-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(databricks)!: support comma-separated syntax for OVERLAY function #6497
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
base: main
Are you sure you want to change the base?
feat(databricks)!: support comma-separated syntax for OVERLAY function #6497
Conversation
VaggelisD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution @AbhishekASLK! Two minor comments to consider and its fine to merge
| from_=self._match_text_seq("FROM") and self._parse_bitwise(), | ||
| for_=self._match_text_seq("FOR") and self._parse_bitwise(), | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably simplify this as:
def _parse_overlay(self) -> exp.Overlay:
def _parse_overlay_arg(text: str) -> t.Optional[exp.Expression]:
return (self._match(TokenType.COMMA) or self._match_text_seq(text)) and self._parse_bitwise()
return self.expression(
exp.Overlay,
this=self._parse_bitwise(),
expression=_parse_overlay_arg("PLACING"),
from_=_parse_overlay_arg("FROM"),
for_=_parse_overlay_arg("FOR"),
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to simplify this, will modify it as suggested.
| self.validate_all( | ||
| "SELECT OVERLAY('Spark SQL', 'ANSI ', 7, 0)", | ||
| write={ | ||
| "databricks": "SELECT OVERLAY('Spark SQL' PLACING 'ANSI ' FROM 7 FOR 0)", | ||
| }, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate_all should be used when we also want to check transpilations between other dialects; When testing the same dialect with expected changes we should still use validate_identity:
| self.validate_all( | |
| "SELECT OVERLAY('Spark SQL', 'ANSI ', 7, 0)", | |
| write={ | |
| "databricks": "SELECT OVERLAY('Spark SQL' PLACING 'ANSI ' FROM 7 FOR 0)", | |
| }, | |
| ) | |
| self.validate_identity( | |
| "SELECT OVERLAY('Spark SQL', 'ANSI ', 7, 0)", | |
| "SELECT OVERLAY('Spark SQL' PLACING 'ANSI ' FROM 7 FOR 0)" | |
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, got it!
Previously, the parser defaulted to the strict ANSI implementation, causing a ParseError when encountering the
comma-separated variant.
SQL:
Databricks Docs