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

[SPARK-43357][SQL] Filter date type quote date #41035

Closed

Conversation

stijndehaes
Copy link
Contributor

What changes were proposed in this pull request?

In this PR the date value is quoted before being sent to the hive metastore

Why are the changes needed?

Glue for example expects the dates to be quoted, without quotes we get errors.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Changed the result of unit tests, also tested by running the fix against glue

@github-actions github-actions bot added the SQL label May 3, 2023
@Hisoka-X
Copy link
Member

Hisoka-X commented May 7, 2023

This change is not backward compatible, I'm not sure if this change is necessary, if necessary, also need parameters to control whether to open.

@wangyum
Copy link
Member

wangyum commented May 7, 2023

@stijndehaes Do you have the error message if do not quote date?

@stijndehaes
Copy link
Contributor Author

@wangyum @Hisoka-X

There is more info in the issue on JIRA: https://issues.apache.org/jira/browse/SPARK-43357

So basically when integrating we glue we are getting issues:

org.apache.hadoop.hive.metastore.api.InvalidObjectException: Unsupported expression '2023 - 05 - 03' (Service: AWSGlue; Status Code: 400; Error Code: InvalidInputException; Request ID: beed68c6-b228-442e-8783-52c25b9d2243; Proxy: null)

Now this issue might be on the side of glue, but glue is supposed to be hive compatible. So I think this should also work with a hive catalog. However I do not have access to one, and would net to se one up.
So maybe someone with more experience with that could help me to test compatibility.

Copy link
Member

@wangyum wangyum left a comment

Choose a reason for hiding this comment

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

@cloud-fan Hive MetaStore also support quoted string date. I'm not sure if it should be fixed on Spark side or Glue side: https://github.com/apache/hive/blob/5106bf1c8671740099fca8e1a7d4b37afe97137f/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java#L776-L786

@@ -66,17 +66,17 @@ class FiltersSuite extends SparkFunSuite with PlanTest {

filterTest("date filter",
(a("datecol", DateType) === Literal(Date.valueOf("2019-01-01"))) :: Nil,
"datecol = 2019-01-01")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised hive supports this SQL syntax... datecol = 2019-01-01

Copy link
Member

Choose a reason for hiding this comment

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

@cloud-fan
Copy link
Contributor

@wangyum does all hive versions support it?

@wangyum
Copy link
Member

wangyum commented May 9, 2023

@wangyum does all hive versions support it?

Hive 0.13.0 and later support it: https://issues.apache.org/jira/browse/HIVE-5679.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM. Thank you all.

LuciferYang pushed a commit to LuciferYang/spark that referenced this pull request May 10, 2023
### What changes were proposed in this pull request?

In this PR the date value is quoted before being sent to the hive metastore

### Why are the changes needed?

Glue for example expects the dates to be quoted, without quotes we get errors.

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Changed the result of unit tests, also tested by running the fix against glue

Closes apache#41035 from stijndehaes/bugfix/hive-date-partition.

Authored-by: stijndehaes <stijndehaes@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@stijndehaes stijndehaes deleted the bugfix/hive-date-partition branch May 24, 2023 08:39
@stijndehaes stijndehaes restored the bugfix/hive-date-partition branch May 24, 2023 08:39
@stijndehaes stijndehaes deleted the bugfix/hive-date-partition branch May 24, 2023 08:39
@stijndehaes stijndehaes restored the bugfix/hive-date-partition branch May 24, 2023 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants