Skip to content

Commit

Permalink
build: Enable spark-4.0 Spark tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuyukitanimura committed Jun 8, 2024
1 parent 69f9cb2 commit 1a386bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 8 additions & 1 deletion common/src/main/java/org/apache/comet/parquet/TypeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.parquet.schema.PrimitiveType;
import org.apache.parquet.schema.Type;
import org.apache.parquet.schema.Types;
import org.apache.spark.package$;
import org.apache.spark.sql.execution.datasources.SchemaColumnConvertNotSupportedException;
import org.apache.spark.sql.types.*;

Expand Down Expand Up @@ -169,6 +170,7 @@ && isUnsignedIntTypeMatched(logicalTypeAnnotation, 64)) {
break;
case INT96:
if (sparkType == TimestampNTZType$.MODULE$) {
if (isSpark40Plus()) return;
convertErrorForTimestampNTZ(typeName.name());
} else if (sparkType == DataTypes.TimestampType) {
return;
Expand Down Expand Up @@ -218,7 +220,8 @@ private static void validateTimestampType(
// Throw an exception if the Parquet type is TimestampLTZ and the Catalyst type is TimestampNTZ.
// This is to avoid mistakes in reading the timestamp values.
if (((TimestampLogicalTypeAnnotation) logicalTypeAnnotation).isAdjustedToUTC()
&& sparkType == TimestampNTZType$.MODULE$) {
&& sparkType == TimestampNTZType$.MODULE$
&& !isSpark40Plus()) {
convertErrorForTimestampNTZ("int64 time(" + logicalTypeAnnotation + ")");
}
}
Expand Down Expand Up @@ -278,4 +281,8 @@ private static boolean isUnsignedIntTypeMatched(
&& !((IntLogicalTypeAnnotation) logicalTypeAnnotation).isSigned()
&& ((IntLogicalTypeAnnotation) logicalTypeAnnotation).getBitWidth() == bitWidth;
}

private static boolean isSpark40Plus() {
return package$.MODULE$.SPARK_VERSION().compareTo("4.0") >= 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim
_: DoubleType | _: StringType | _: BinaryType | _: TimestampType | _: DecimalType |
_: DateType | _: BooleanType | _: NullType =>
true
// `TimestampNTZType` is private in Spark 3.2.
case dt if isTimestampNTZType(dt) => true
case dt =>
emitWarning(s"unsupported Spark data type: $dt")
Expand Down Expand Up @@ -2246,7 +2245,6 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim
case _: ByteType | _: ShortType | _: IntegerType | _: LongType | _: FloatType |
_: DoubleType | _: StringType | _: DateType | _: DecimalType | _: BooleanType =>
true
// `TimestampNTZType` is private in Spark 3.2/3.3.
case dt if isTimestampNTZType(dt) => true
case _ => false
}
Expand Down

0 comments on commit 1a386bc

Please sign in to comment.