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

Fix: control whether quotes are generated for extract's date part #1981

Merged
merged 1 commit into from
Jul 30, 2023

Conversation

georgesittas
Copy link
Collaborator

@georgesittas georgesittas commented Jul 30, 2023

write={
"hive": "SELECT EXTRACT(year FROM CAST('2020-01-01' AS TIMESTAMP))",
"snowflake": "SELECT DATE_PART('year', CAST('2020-01-01' AS TIMESTAMPNTZ))",
"spark": "SELECT EXTRACT(year FROM CAST('2020-01-01' AS TIMESTAMP))",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without this fix, year would be generated as a string which is invalid Hive / Spark SQL:

spark-sql (default)> SELECT EXTRACT('year' FROM CAST('2020-01-01' AS TIMESTAMP));

[PARSE_SYNTAX_ERROR] Syntax error at or near 'FROM'.(line 1, pos 22)

== SQL ==
SELECT EXTRACT('year' FROM CAST('2020-01-01' AS TIMESTAMP))
----------------------^^^
spark-sql (default)> SELECT EXTRACT(year FROM CAST('2020-01-01' AS TIMESTAMP));
2020
Time taken: 4.236 seconds, Fetched 1 row(s)

@tobymao tobymao merged commit be7d4e6 into main Jul 30, 2023
@tobymao tobymao deleted the jo/extract_fix branch July 30, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants