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

HybridParquetScan: Fix velox runtime error in hybrid scan when filter timestamp #12112

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 16 additions & 0 deletions integration_tests/src/main/python/hybrid_parquet_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,19 @@ def udf_fallback(s):
assert_gpu_and_cpu_are_equal_collect(
lambda spark: spark.read.parquet(data_path).filter("ascii(a) >= 50 and udf_fallback(a) = 'udf_100'"),
conf=filter_split_conf)

@allow_non_gpu(*non_utc_allow)
def test_hybrid_parquet_filter_pushdown_timestamp(spark_tmp_path):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be marked as a hybrid test?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch, thanks

data_path = spark_tmp_path + '/PARQUET_DATA'
with_cpu_session(
lambda spark: gen_df(spark, [('a', TimestampGen(start=datetime(1900, 1, 1, tzinfo=timezone.utc)))]).write.parquet(data_path),
conf=rebase_write_corrected_conf)

# Timestamp is not fully supported in Hybrid Filter, so it should remain on the GPU
plan = with_gpu_session(
lambda spark: spark.read.parquet(data_path).filter(f.col("a") > f.lit(datetime(2024, 1, 1, tzinfo=timezone.utc)))._jdf.queryExecution().executedPlan(),
conf=filter_split_conf)
check_filter_pushdown(plan, pushed_exprs=[], not_pushed_exprs=['isnotnull', '>'])
assert_gpu_and_cpu_are_equal_collect(
lambda spark: spark.read.parquet(data_path).filter(f.col("a") > f.lit(datetime(2024, 1, 1, tzinfo=timezone.utc))),
conf=filter_split_conf)
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,13 @@ object HybridExecutionUtils extends PredicateHelper {
}
}

def isTimestampCondition(expr: Expression): Boolean = {
expr.references.exists(attr => attr.dataType == TimestampType)
}

def isExprSupportedByHybridScan(condition: Expression, whitelistExprsName: String): Boolean = {
condition match {
case filter if isTimestampCondition(filter) => false // Timestamp is not fully supported in Hybrid Filter
case filter if HybridExecutionUtils.supportedByHybridFilters(whitelistExprsName)
.exists(_.isInstance(filter)) =>
val childrenSupported = filter.children.forall(
Expand Down