Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DateType support for AST expressions #4431

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions docs/supported_ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ are limited.
<td>S</td>
<td>S</td>
<td>S</td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand All @@ -1795,7 +1795,7 @@ are limited.
<td>S</td>
<td>S</td>
<td>S</td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand Down Expand Up @@ -2664,7 +2664,7 @@ are limited.
<td>S</td>
<td>S</td>
<td>S</td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand Down Expand Up @@ -5183,7 +5183,7 @@ are limited.
<td>S</td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand All @@ -5204,7 +5204,7 @@ are limited.
<td>S</td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand Down Expand Up @@ -6028,7 +6028,7 @@ are limited.
<td>S</td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand All @@ -6049,7 +6049,7 @@ are limited.
<td>S</td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand Down Expand Up @@ -6186,7 +6186,7 @@ are limited.
<td>S</td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand All @@ -6207,7 +6207,7 @@ are limited.
<td>S</td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand Down Expand Up @@ -7509,7 +7509,7 @@ are limited.
<td>S</td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand All @@ -7530,7 +7530,7 @@ are limited.
<td>S</td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand Down Expand Up @@ -7641,7 +7641,7 @@ are limited.
<td>S</td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand All @@ -7662,7 +7662,7 @@ are limited.
<td>S</td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand Down Expand Up @@ -7825,7 +7825,7 @@ are limited.
<td>S</td>
<td>S</td>
<td>S</td>
<td><b>NS</b></td>
<td>S</td>
<td><em>PS<br/>UTC is only supported TZ for TIMESTAMP</em></td>
<td><b>NS</b></td>
<td><b>NS</b></td>
Expand Down
5 changes: 3 additions & 2 deletions integration_tests/src/main/python/ast_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
(float_gen, False),
(double_gen, False),
(timestamp_gen, True),
(date_gen, True),
(string_gen, False)
]

Expand Down Expand Up @@ -69,7 +70,7 @@ def assert_binary_ast(data_descr, func, conf={}):
(data_gen, is_supported) = data_descr
assert_gpu_ast(is_supported, lambda spark: func(binary_op_df(spark, data_gen)), conf=conf)

@pytest.mark.parametrize('data_gen', [boolean_gen, byte_gen, short_gen, int_gen, long_gen, float_gen, double_gen, timestamp_gen], ids=idfn)
@pytest.mark.parametrize('data_gen', [boolean_gen, byte_gen, short_gen, int_gen, long_gen, float_gen, double_gen, timestamp_gen, date_gen], ids=idfn)
def test_literal(spark_tmp_path, data_gen):
# Write data to Parquet so Spark generates a plan using just the count of the data.
data_path = spark_tmp_path + '/AST_TEST_DATA'
Expand All @@ -78,7 +79,7 @@ def test_literal(spark_tmp_path, data_gen):
assert_gpu_ast(is_supported=True,
func=lambda spark: spark.read.parquet(data_path).select(scalar))

@pytest.mark.parametrize('data_gen', [boolean_gen, byte_gen, short_gen, int_gen, long_gen, float_gen, double_gen, timestamp_gen], ids=idfn)
@pytest.mark.parametrize('data_gen', [boolean_gen, byte_gen, short_gen, int_gen, long_gen, float_gen, double_gen, timestamp_gen, date_gen], ids=idfn)
def test_null_literal(spark_tmp_path, data_gen):
# Write data to Parquet so Spark generates a plan using just the count of the data.
data_path = spark_tmp_path + '/AST_TEST_DATA'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ object TypeSig {
(commonCudfTypes + BINARY + DECIMAL_64 + NULL + ARRAY + MAP).nested() + STRUCT

/** All types that can appear in AST expressions */
val astTypes: TypeSig = BOOLEAN + integral + fp + TIMESTAMP
val astTypes: TypeSig = BOOLEAN + integral + fp + TIMESTAMP + DATE

/** All AST types that work for comparisons */
val comparisonAstTypes: TypeSig = astTypes - fp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ case class GpuLiteral (value: Any, dataType: DataType) extends GpuLeafExpression
case TimestampType =>
ast.Literal.ofTimestampFromLong(DType.TIMESTAMP_MICROSECONDS,
value.asInstanceOf[java.lang.Long])
case DateType => ast.Literal.ofTimestampDaysFromInt(value.asInstanceOf[java.lang.Integer])
case _ => throw new IllegalStateException(s"$dataType is an unsupported literal type")
}
}
Expand Down