Compatibility Guide

Comet aims to provide consistent results with the version of Apache Spark that is being used.

This guide offers information about areas of functionality where there are known differences.

Parquet Scans

Comet currently has three distinct implementations of the Parquet scan operator. The configuration property spark.comet.scan.impl is used to select an implementation.

ImplementationDescription
native_cometThis is the default implementation. It provides strong compatibility with Spark but does not support complex types.
native_datafusionThis implementation delegates to DataFusion's ParquetExec.
native_iceberg_compatThis implementation also delegates to DataFusion's ParquetExec but uses a hybrid approach of JVM and native code. This scan is designed to be integrated with Iceberg in the future.

The new (and currently experimental) native_datafusion and native_iceberg_compat scans are being added to provide the following benefits over the native_comet implementation:

  • Leverage the DataFusion community's ongoing improvements to ParquetExec
  • Provide support for reading complex types (structs, arrays, and maps)
  • Remove the use of reusable mutable-buffers in Comet, which is complex to maintain

These new implementations are not fully implemented. Some of the current limitations are:

  • Scanning Parquet files containing unsigned 8 or 16-bit integers can produce results that don't match Spark. By default, Comet will fall back to Spark when using these scan implementations to read Parquet files containing 8 or 16-bit integers. This behavior can be disabled by setting spark.comet.scan.allowIncompatible=true.
  • These implementations do not yet fully support timestamps, decimals, or complex types.

ANSI mode

Comet currently ignores ANSI mode in most cases, and therefore can produce different results than Spark. By default, Comet will fall back to Spark if ANSI mode is enabled. To enable Comet to accelerate queries when ANSI mode is enabled, specify spark.comet.ansi.enabled=true in the Spark configuration. Comet's ANSI support is experimental and should not be used in production.

There is an epic where we are tracking the work to fully implement ANSI support.

Floating number comparison

Spark normalizes NaN and zero for floating point numbers for several cases. See NormalizeFloatingNumbers optimization rule in Spark. However, one exception is comparison. Spark does not normalize NaN and zero when comparing values because they are handled well in Spark (e.g., SQLOrderingUtil.compareFloats). But the comparison functions of arrow-rs used by DataFusion do not normalize NaN and zero (e.g., arrow::compute::kernels::cmp::eq). So Comet will add additional normalization expression of NaN and zero for comparison.

Incompatible Expressions

Some Comet native expressions are not 100% compatible with Spark and are disabled by default. These expressions will fall back to Spark but can be enabled by setting spark.comet.expression.allowIncompatible=true.

Array Expressions

Comet has experimental support for a number of array expressions. These are experimental and currently marked as incompatible and can be enabled by setting spark.comet.expression.allowIncompatible=true.

Regular Expressions

Comet uses the Rust regexp crate for evaluating regular expressions, and this has different behavior from Java's regular expression engine. Comet will fall back to Spark for patterns that are known to produce different results, but this can be overridden by setting spark.comet.regexp.allowIncompatible=true.

Cast

Cast operations in Comet fall into three levels of support:

  • Compatible: The results match Apache Spark
  • Incompatible: The results may match Apache Spark for some inputs, but there are known issues where some inputs will result in incorrect results or exceptions. The query stage will fall back to Spark by default. Setting spark.comet.cast.allowIncompatible=true will allow all incompatible casts to run natively in Comet, but this is not recommended for production use.
  • Unsupported: Comet does not provide a native version of this cast expression and the query stage will fall back to Spark.

Compatible Casts

The following cast operations are generally compatible with Spark except for the differences noted here.

From TypeTo TypeNotes
booleanbyte
booleanshort
booleaninteger
booleanlong
booleanfloat
booleandouble
booleanstring
byteboolean
byteshort
byteinteger
bytelong
bytefloat
bytedouble
bytedecimal
bytestring
shortboolean
shortbyte
shortinteger
shortlong
shortfloat
shortdouble
shortdecimal
shortstring
integerboolean
integerbyte
integershort
integerlong
integerfloat
integerdouble
integerstring
longboolean
longbyte
longshort
longinteger
longfloat
longdouble
longstring
floatboolean
floatbyte
floatshort
floatinteger
floatlong
floatdouble
floatstringThere can be differences in precision. For example, the input “1.4E-45” will produce 1.0E-45 instead of 1.4E-45
doubleboolean
doublebyte
doubleshort
doubleinteger
doublelong
doublefloat
doublestringThere can be differences in precision. For example, the input “1.4E-45” will produce 1.0E-45 instead of 1.4E-45
decimalbyte
decimalshort
decimalinteger
decimallong
decimalfloat
decimaldouble
decimalstringThere can be formatting differences in some case due to Spark using scientific notation where Comet does not
stringboolean
stringbyte
stringshort
stringinteger
stringlong
stringbinary
stringdateOnly supports years between 262143 BC and 262142 AD
datestring
timestamplong
timestampstring
timestampdate

Incompatible Casts

The following cast operations are not compatible with Spark for all inputs and are disabled by default.

From TypeTo TypeNotes
integerdecimalNo overflow check
longdecimalNo overflow check
floatdecimalThere can be rounding differences
doubledecimalThere can be rounding differences
stringfloatDoes not support inputs ending with ‘d’ or ‘f’. Does not support ‘inf’. Does not support ANSI mode.
stringdoubleDoes not support inputs ending with ‘d’ or ‘f’. Does not support ‘inf’. Does not support ANSI mode.
stringdecimalDoes not support inputs ending with ‘d’ or ‘f’. Does not support ‘inf’. Does not support ANSI mode. Returns 0.0 instead of null if input contains no digits
stringtimestampNot all valid formats are supported
binarystringOnly works for binary data representing valid UTF-8 strings

Unsupported Casts

Any cast not listed in the previous tables is currently unsupported. We are working on adding more. See the tracking issue for more details.