Skip to content

fix(spark): parse SQL scripting compound blocks#7840

Open
judahrand wants to merge 1 commit into
tobymao:mainfrom
judahrand:spark-scripting
Open

fix(spark): parse SQL scripting compound blocks#7840
judahrand wants to merge 1 commit into
tobymao:mainfrom
judahrand:spark-scripting

Conversation

@judahrand

Copy link
Copy Markdown
Contributor

This is a proposed fix to #7838. I appreciate that this does not fundamentally fix the underlying lack of mature support for imperative SQL. However, it does allow SQL script blocks to roundtrip. I can also understand that this doesn't really solve the issue for transpiling between dialects which is a core sqlglot functionality. So based on that please feel free to close - I figured the approach might spark some idea in someone else.

@georgesittas

Copy link
Copy Markdown
Collaborator

I don't think this is the right approach:

  • What does "wrapped" represent and why does it need to be an AST argument? It'd seem more reasonable to me to abstract the BEGIN, END delimiters away (i.e., remove from the AST) and only emit them at generation time if a dialect requires them to be present.
  • Overriding the parsing for TokenType.BEGIN in Spark may have side-effects in Databricks, which supports BEGIN {TRANSACTION | WORK}.

Based on Spark's grammar, I think we should override the statement parser for Spark and map it to _parse_block, making sure Databricks pops it, or that it overrides it further to ensure its own statements starting with BEGIN can still be parsed.

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