Skip to content

[SPARK-45387][SQL]Optimize hive patition filter when the comparision dataType not match#46073

Closed
lastbus wants to merge 2 commits intoapache:branch-3.5from
lastbus:branch-3.5-hive-partition-filter-pushdown-optimize
Closed

[SPARK-45387][SQL]Optimize hive patition filter when the comparision dataType not match#46073
lastbus wants to merge 2 commits intoapache:branch-3.5from
lastbus:branch-3.5-hive-partition-filter-pushdown-optimize

Conversation

@lastbus
Copy link
Copy Markdown

@lastbus lastbus commented Apr 16, 2024

What changes were proposed in this pull request?

During the PruneFileSourcePartitions process, we can optimize by casting the dataType of the constant to match the dataType of the corresponding partition key.

Why are the changes needed?

Suppose we have a partitioned table table_pt with partition colum dt which is StringType and the table metadata is managed by Hive Metastore, if we filter partition by dt = '123', this filter can be pushed down to data source directly, but if the filter condition is number, e.g. dt = 123, Spark will not known which partition should be pushed down. Thus in the process of physical plan optimization, Spark will pull all of that table's partition meta data to client side, to decide which partition filter should be push down to the data source. This is poor of performance if the table has thousands of partitions and increasing the risk of hive metastore oom. In our production env, we encounter this problem.

Does this PR introduce any user-facing change?

No

How was this patch tested?

in our production env, this fix is OK

Was this patch authored or co-authored using generative AI tooling?

No

@github-actions github-actions bot added the SQL label Apr 16, 2024
…dataType not match

Suppose we have a partitioned table `table_pt` with partition colum `dt` which is StringType and the table metadata is managed by Hive Metastore, if we filter partition by dt = '123', this filter can be pushed down to data source directly, but if the filter condition is number, e.g. dt = 123, Spark will not known which partition should be pushed down. Thus in the process of physical plan optimization, Spark will pull all of that table's partition meta data to client side, to decide which partition filter should be push down to the data source. This is poor of performance if the table has thousands of partitions and increasing the risk of hive metastore oom.
@lastbus lastbus force-pushed the branch-3.5-hive-partition-filter-pushdown-optimize branch from fe7cf2c to d2bdb78 Compare April 16, 2024 07:30
…dataType not match

What changes were proposed in this pull request?
During the PruneFileSourcePartitions process, we can optimize by casting the dataType of the constant to match the dataType of the corresponding partition key.

Why are the changes needed?
Suppose we have a partitioned table table_pt with partition colum dt which is StringType and the table metadata is managed by Hive Metastore, if we filter partition by dt = '123', this filter can be pushed down to data source directly, but if the filter condition is number, e.g. dt = 123, Spark will not known which partition should be pushed down. Thus in the process of physical plan optimization, Spark will pull all of that table's partition meta data to client side, to decide which partition filter should be push down to the data source. This is poor of performance if the table has thousands of partitions and increasing the risk of hive metastore oom. In our production env, we encounter this problem.

Does this PR introduce any user-facing change?
No

How was this patch tested?
in our production env, this fix is OK

Was this patch authored or co-authored using generative AI tooling?
No
@lastbus lastbus force-pushed the branch-3.5-hive-partition-filter-pushdown-optimize branch from 85d5385 to c28b6fa Compare April 24, 2024 10:50
@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 3, 2024

We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!

@github-actions github-actions bot added the Stale label Aug 3, 2024
@github-actions github-actions bot closed this Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant