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!: Have Spark put CTE at front of insert #2086

Merged
merged 2 commits into from
Aug 17, 2023

Conversation

eakmanrq
Copy link
Collaborator

This syntax is what I have used in the past (with Spark 2.4) and confirmed that this works with Spark 3.2 and latest Databricks release. Newer releases of Databricks (and likely Spark) do support having the CTE after the INSERT but this format is more universally supported.

@eakmanrq eakmanrq force-pushed the eakmanrq/fix_spark_ctes_insert branch from 3832deb to 27d1a99 Compare August 17, 2023 22:01
@eakmanrq eakmanrq requested a review from georgesittas August 17, 2023 22:01
Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

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

I'd first check whether there's a CTE in Insert's expression before copying the whole thing, but otherwise LGTM 👍

This should probably also be marked as breaking.

@eakmanrq eakmanrq requested a review from georgesittas August 17, 2023 22:09
@eakmanrq eakmanrq changed the title Fix: Have Spark put CTE at front of insert Fix!: Have Spark put CTE at front of insert Aug 17, 2023
sqlglot/dialects/spark2.py Outdated Show resolved Hide resolved
@eakmanrq eakmanrq force-pushed the eakmanrq/fix_spark_ctes_insert branch from 407001e to fedada1 Compare August 17, 2023 22:30
@eakmanrq eakmanrq requested a review from georgesittas August 17, 2023 22:31
@eakmanrq eakmanrq merged commit 1da653f into main Aug 17, 2023
@eakmanrq eakmanrq deleted the eakmanrq/fix_spark_ctes_insert branch August 17, 2023 22:50
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