-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(snowflake)!: annotate type for MODE function snowflake #6447
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
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 |
|---|---|---|
|
|
@@ -14,7 +14,9 @@ def test_ddl(self): | |
| self.validate_identity("DAYOFMONTH(TO_DATE(x))") | ||
| self.validate_identity("DAYOFYEAR(TO_DATE(x))") | ||
| self.validate_identity("WEEKOFYEAR(TO_DATE(x))") | ||
|
|
||
| self.validate_identity("SELECT MODE(category)") | ||
| self.validate_identity("SELECT MODE(price, TRUE) AS deterministic_mode FROM products") | ||
|
Comment on lines
+17
to
+18
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. Ditto. Also, instead of repeating tests in each file we can also put the common ones in
Collaborator
Author
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. the problem is that Postgres only seems to support semantics like "SELECT MODE() WITHIN GROUP (ORDER BY category) FROM table1", not "SELECT MODE(x)" |
||
| self.validate_identity("SELECT MODE() WITHIN GROUP (ORDER BY status) FROM orders") | ||
| self.validate_identity("DROP NAMESPACE my_catalog.my_namespace") | ||
| self.validate_identity("CREATE NAMESPACE my_catalog.my_namespace") | ||
| self.validate_identity("INSERT OVERWRITE TABLE db1.tb1 TABLE db2.tb2") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
This function is supported by other dialects.
For example: Databricks mode supports up to 2 arguments:
mode(expr [, deterministic ])We should verify if other databases support this function (from their docs online), and find a common representation for all of them. Then add parsing tests for each of them
validate_identityorvalidate_all.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.
Updated to support 3 patterns:
Pattern 1: Simple Aggregate
Mode(this=category, deterministic=None)
-> Snowflake: MODE(category)
Pattern 2: With Deterministic Parameter
Mode(this=category, deterministic=TRUE/FALSE)
-> Databricks/Spark: mode(category, true)
Pattern 3: Empty Function with WITHIN GROUP
WithinGroup(
this=Mode(this=None, deterministic=None),
expression=Order(expressions=[Ordered(this=category)])
)
-> PostgreSQL: mode() WITHIN GROUP (ORDER BY category)