Skip to content

Commit 80f2724

Browse files
committed
Initial
1 parent ba81cac commit 80f2724

File tree

9 files changed

+94
-6
lines changed

9 files changed

+94
-6
lines changed

cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc

+10-2
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,16 @@ bool SubstraitToVeloxPlanValidator::isAllowedCast(const TypePtr& fromType, const
263263

264264
// Limited support for X to Timestamp.
265265
if (toType->isTimestamp() && !fromType->isDate()) {
266-
LOG_VALIDATION_MSG("Casting from " + fromType->toString() + " to TIMESTAMP is not supported.");
267-
return false;
266+
switch (fromType->kind()) {
267+
case TypeKind::TINYINT:
268+
case TypeKind::SMALLINT:
269+
case TypeKind::INTEGER:
270+
case TypeKind::BIGINT:
271+
break;
272+
default:
273+
LOG_VALIDATION_MSG("Casting from " + fromType->toString() + " to TIMESTAMP is not supported.");
274+
return false;
275+
}
268276
}
269277

270278
// Limited support for Complex types.

gluten-ut/spark32/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala

+2
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,8 @@ class VeloxTestSettings extends BackendTestSettings {
870870
enableSuite[GlutenParquetColumnIndexSuite]
871871
// Rewrite by just removing test timestamp.
872872
.exclude("test reading unaligned pages - test all types")
873+
// Rewrite by converting smaller integral value to timestamp.
874+
.exclude("test reading unaligned pages - test all types (dict encode)")
873875
enableSuite[GlutenParquetCompressionCodecPrecedenceSuite]
874876
enableSuite[GlutenParquetEncodingSuite]
875877
enableSuite[GlutenParquetFileFormatV1Suite]

gluten-ut/spark32/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/GlutenParquetColumnIndexSuite.scala

+19-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,25 @@ class GlutenParquetColumnIndexSuite extends ParquetColumnIndexSuite with GlutenS
3838
"cast(id as float) as _5",
3939
"cast(id as double) as _6",
4040
"cast(id as decimal(20,0)) as _7",
41-
"cast(cast(1618161925000 + id * 1000 * 60 * 60 * 24 as timestamp) as date) as _9"
41+
"cast(cast(1618161925 + id * 60 * 60 * 24 as timestamp) as date) as _9"
42+
)
43+
checkUnalignedPages(df)(actions: _*)
44+
}
45+
46+
testGluten("test reading unaligned pages - test all types (dict encode)") {
47+
val df = spark
48+
.range(0, 2000)
49+
.selectExpr(
50+
"id as _1",
51+
"cast(id % 10 as byte) as _2",
52+
"cast(id % 10 as short) as _3",
53+
"cast(id % 10 as int) as _4",
54+
"cast(id % 10 as float) as _5",
55+
"cast(id % 10 as double) as _6",
56+
"cast(id % 10 as decimal(20,0)) as _7",
57+
"cast(id % 2 as boolean) as _8",
58+
"cast(cast(1618161925 + (id % 10) * 60 * 60 * 24 as timestamp) as date) as _9",
59+
"cast(1618161925 + (id % 10) as timestamp) as _10"
4260
)
4361
checkUnalignedPages(df)(actions: _*)
4462
}

gluten-ut/spark33/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala

+2
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ class VeloxTestSettings extends BackendTestSettings {
664664
enableSuite[GlutenParquetColumnIndexSuite]
665665
// Rewrite by just removing test timestamp.
666666
.exclude("test reading unaligned pages - test all types")
667+
// Rewrite by converting smaller integral value to timestamp.
668+
.exclude("test reading unaligned pages - test all types (dict encode)")
667669
enableSuite[GlutenParquetCompressionCodecPrecedenceSuite]
668670
enableSuite[GlutenParquetDeltaByteArrayEncodingSuite]
669671
enableSuite[GlutenParquetDeltaEncodingInteger]

gluten-ut/spark33/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/GlutenParquetColumnIndexSuite.scala

+19-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,25 @@ class GlutenParquetColumnIndexSuite extends ParquetColumnIndexSuite with GlutenS
3838
"cast(id as float) as _5",
3939
"cast(id as double) as _6",
4040
"cast(id as decimal(20,0)) as _7",
41-
"cast(cast(1618161925000 + id * 1000 * 60 * 60 * 24 as timestamp) as date) as _9"
41+
"cast(cast(1618161925 + id * 60 * 60 * 24 as timestamp) as date) as _9"
42+
)
43+
checkUnalignedPages(df)(actions: _*)
44+
}
45+
46+
testGluten("test reading unaligned pages - test all types (dict encode)") {
47+
val df = spark
48+
.range(0, 2000)
49+
.selectExpr(
50+
"id as _1",
51+
"cast(id % 10 as byte) as _2",
52+
"cast(id % 10 as short) as _3",
53+
"cast(id % 10 as int) as _4",
54+
"cast(id % 10 as float) as _5",
55+
"cast(id % 10 as double) as _6",
56+
"cast(id % 10 as decimal(20,0)) as _7",
57+
"cast(id % 2 as boolean) as _8",
58+
"cast(cast(1618161925 + (id % 10) * 60 * 60 * 24 as timestamp) as date) as _9",
59+
"cast(1618161925 + (id % 10) as timestamp) as _10"
4260
)
4361
checkUnalignedPages(df)(actions: _*)
4462
}

gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala

+2
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,8 @@ class VeloxTestSettings extends BackendTestSettings {
660660
enableSuite[GlutenParquetColumnIndexSuite]
661661
// Rewrite by just removing test timestamp.
662662
.exclude("test reading unaligned pages - test all types")
663+
// Rewrite by converting smaller integral value to timestamp.
664+
.exclude("test reading unaligned pages - test all types (dict encode)")
663665
enableSuite[GlutenParquetCompressionCodecPrecedenceSuite]
664666
enableSuite[GlutenParquetDeltaByteArrayEncodingSuite]
665667
enableSuite[GlutenParquetDeltaEncodingInteger]

gluten-ut/spark34/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/GlutenParquetColumnIndexSuite.scala

+19-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,25 @@ class GlutenParquetColumnIndexSuite extends ParquetColumnIndexSuite with GlutenS
3838
"cast(id as float) as _5",
3939
"cast(id as double) as _6",
4040
"cast(id as decimal(20,0)) as _7",
41-
"cast(cast(1618161925000 + id * 1000 * 60 * 60 * 24 as timestamp) as date) as _9"
41+
"cast(cast(1618161925 + id * 60 * 60 * 24 as timestamp) as date) as _9"
42+
)
43+
checkUnalignedPages(df)(actions: _*)
44+
}
45+
46+
testGluten("test reading unaligned pages - test all types (dict encode)") {
47+
val df = spark
48+
.range(0, 2000)
49+
.selectExpr(
50+
"id as _1",
51+
"cast(id % 10 as byte) as _2",
52+
"cast(id % 10 as short) as _3",
53+
"cast(id % 10 as int) as _4",
54+
"cast(id % 10 as float) as _5",
55+
"cast(id % 10 as double) as _6",
56+
"cast(id % 10 as decimal(20,0)) as _7",
57+
"cast(id % 2 as boolean) as _8",
58+
"cast(cast(1618161925 + (id % 10) * 60 * 60 * 24 as timestamp) as date) as _9",
59+
"cast(1618161925 + (id % 10) as timestamp) as _10"
4260
)
4361
checkUnalignedPages(df)(actions: _*)
4462
}

gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala

+2
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ class VeloxTestSettings extends BackendTestSettings {
671671
enableSuite[GlutenParquetColumnIndexSuite]
672672
// Rewrite by just removing test timestamp.
673673
.exclude("test reading unaligned pages - test all types")
674+
// Rewrite by converting smaller integral value to timestamp.
675+
.exclude("test reading unaligned pages - test all types (dict encode)")
674676
enableSuite[GlutenParquetCompressionCodecPrecedenceSuite]
675677
enableSuite[GlutenParquetDeltaByteArrayEncodingSuite]
676678
enableSuite[GlutenParquetDeltaEncodingInteger]

gluten-ut/spark35/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/GlutenParquetColumnIndexSuite.scala

+19-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,25 @@ class GlutenParquetColumnIndexSuite extends ParquetColumnIndexSuite with GlutenS
3838
"cast(id as float) as _5",
3939
"cast(id as double) as _6",
4040
"cast(id as decimal(20,0)) as _7",
41-
"cast(cast(1618161925000 + id * 1000 * 60 * 60 * 24 as timestamp) as date) as _9"
41+
"cast(cast(1618161925 + id * 60 * 60 * 24 as timestamp) as date) as _9"
42+
)
43+
checkUnalignedPages(df)(actions: _*)
44+
}
45+
46+
testGluten("test reading unaligned pages - test all types (dict encode)") {
47+
val df = spark
48+
.range(0, 2000)
49+
.selectExpr(
50+
"id as _1",
51+
"cast(id % 10 as byte) as _2",
52+
"cast(id % 10 as short) as _3",
53+
"cast(id % 10 as int) as _4",
54+
"cast(id % 10 as float) as _5",
55+
"cast(id % 10 as double) as _6",
56+
"cast(id % 10 as decimal(20,0)) as _7",
57+
"cast(id % 2 as boolean) as _8",
58+
"cast(cast(1618161925 + (id % 10) * 60 * 60 * 24 as timestamp) as date) as _9",
59+
"cast(1618161925 + (id % 10) as timestamp) as _10"
4260
)
4361
checkUnalignedPages(df)(actions: _*)
4462
}

0 commit comments

Comments
 (0)