-
Notifications
You must be signed in to change notification settings - Fork 969
Update(Snowflake): Update tests for concat string function #5809
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
Update(Snowflake): Update tests for concat string function #5809
Conversation
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.
Pull Request Overview
This PR adds test coverage for Snowflake's string concatenation functions (CONCAT
and CONCAT_WS
) to verify their return type annotations in the optimizer.
Key Changes
- Added 5 new test cases for
CONCAT
andCONCAT_WS
functions in Snowflake dialect - Tests verify that both functions return
VARCHAR
type regardless of input parameters
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Given Snowflake's docs say:
The input expressions must all be strings, or all be binary values.
Let's make sure we test the binary values as well.
The base |
@fivetran-amrutabhimsenayachit have you created a virtual environment for Python? Seems like there may be a mismatch between the ruff version SQLGlot installs vs what you have locally. Try the following:
This should fix any formatting issues.
Overriding makes sense, but with a quick look I feel like the current implementations are quite complicated. What about using |
|
03186d9
to
48b4417
Compare
# dialect: snowflake | ||
REVERSE(NULL); | ||
NULL; |
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.
I think this was added by mistake– I got rid of it in main. Let's git rebase off of it.
sqlglot/dialects/snowflake.py
Outdated
@@ -502,6 +502,7 @@ class Snowflake(Dialect): | |||
expr_type: lambda self, e: self._annotate_by_args(e, "this") | |||
for expr_type in (exp.Reverse,) | |||
}, | |||
exp.ConcatWs: lambda self, e: self._annotate_concat_ws(e), |
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.
I believe we can simply do:
exp.ConcatWs: lambda self, e: self._annotate_by_args(e, "expressions")
Don't think that we need _annotate_concat_ws
. Lemme know if I missed something.
* Resolved Conflicts * Handle Binary and Null cases * Fixed ruff formatting * Revert "Fixed ruff formatting" This reverts commit bd5c102. * Addressed review comments * Addressed comments
* feat(singlestore): Added handling of exp.JSONArray * Update(Snowflake): Update tests for concat string function (#5809) * Resolved Conflicts * Handle Binary and Null cases * Fixed ruff formatting * Revert "Fixed ruff formatting" This reverts commit bd5c102. * Addressed review comments * Addressed comments * Fixed merge issues --------- Co-authored-by: fivetran-amrutaayachit <[email protected]>
…MP (#5808) * feat(singlestore): Added support of UTC_TIMESTAMP and CURRENT_TIMESTAMP * Fixed BigQuery * Fixed tests * Updated test as per comments * Update(Snowflake): Update tests for concat string function (#5809) * Resolved Conflicts * Handle Binary and Null cases * Fixed ruff formatting * Revert "Fixed ruff formatting" This reverts commit bd5c102. * Addressed review comments * Addressed comments * Removed unexisting UTC_TIMESTAMP and UTC_TIME functions from bigquery and added them to Oracle/MySQL * Removed bigquery changes --------- Co-authored-by: fivetran-amrutaayachit <[email protected]>
Added tests string function: concat
Refer:
https://docs.snowflake.com/en/sql-reference/functions/concat
https://docs.snowflake.com/en/sql-reference/functions/concat_ws