-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(optimizer)!: annotate type for databricks REGR_AVGY, REGR_COUNT, REGR_INTERCEPT, REGR_R2, REGR_SLOPE #7820
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,16 @@ class DatabricksParser(SparkParser): | |
| "CURDATE": lambda self: self._parse_curdate(), | ||
| } | ||
|
|
||
| FUNCTION_PARSERS = { | ||
| **SparkParser.FUNCTION_PARSERS, | ||
| "REGR_AVGX": lambda self: self._parse_quantile_function(exp.RegrAvgx), | ||
| "REGR_AVGY": lambda self: self._parse_quantile_function(exp.RegrAvgy), | ||
| "REGR_COUNT": lambda self: self._parse_regr_count(), | ||
| "REGR_INTERCEPT": lambda self: self._parse_quantile_function(exp.RegrIntercept), | ||
| "REGR_R2": lambda self: self._parse_quantile_function(exp.RegrR2), | ||
| "REGR_SLOPE": lambda self: self._parse_quantile_function(exp.RegrSlope), | ||
|
Comment on lines
+39
to
+41
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you check for these 3 functions for databricks where the As it seems, databricks deduplicates based on the pair of (y, x), which is different from Let's verify for the rest of the |
||
| } | ||
|
|
||
| FACTOR = { | ||
| **SparkParser.FACTOR, | ||
| TokenType.COLON: exp.JSONExtract, | ||
|
|
@@ -55,6 +65,13 @@ def _parse_curdate(self) -> exp.CurrentDate: | |
| self._match_r_paren() | ||
| return self.expression(exp.CurrentDate()) | ||
|
|
||
| def _parse_regr_count(self) -> exp.RegrCount: | ||
| if self._match(TokenType.DISTINCT): | ||
| return exp.RegrCount(this=exp.Distinct(expressions=self._parse_function_args())) | ||
| self._match(TokenType.ALL) | ||
| args = self._parse_function_args() | ||
| return self.expression(exp.RegrCount(this=seq_get(args, 0), expression=seq_get(args, 1))) | ||
|
Comment on lines
+68
to
+73
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can make the |
||
|
|
||
| def _parse_cluster_property(self): | ||
| if self._match_texts(("AUTO", "NONE")): | ||
| return self.expression(exp.ClusterProperty(this=self._prev.text.upper())) | ||
|
|
||
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.
Did you verify where the
DISTINCTis applied to? The default_parse_quantile_functionalways applies it to the first arg, but here we also have the second arg (x) as a candidate, right?