-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-41666][PYTHON] Support parameterized SQL by sql()
#39183
Conversation
@@ -813,7 +813,7 @@ | |||
}, | |||
"INVALID_SQL_ARG" : { | |||
"message" : [ | |||
"The argument <name> of `sql()` is invalid. Consider to replace it by a SQL literal statement." | |||
"The argument <name> of `sql()` is invalid. Consider to replace it by a SQL literal." |
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 have changed this to address the review comment at #38864 (comment)
sql()
sql()
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.
Shall we add one line here https://github.com/apache/spark/blob/master/python/docs/source/migration_guide/pyspark_3.3_to_3.4.rst#upgrading-from-pyspark-33-to-34?
LGTM otherwise
Merging to master. Thank you, @HyukjinKwon for review. |
What changes were proposed in this pull request?
In the PR, I propose to extend the
sql()
method in PySpark to support parameterized SQL queries, see #38864, and add new parameter -args
of the typeDict[str, str]
. This parameter maps named parameters that can occur in the input SQL query to SQL literals like 1, INTERVAL '1-1' YEAR TO MONTH, DATE'2022-12-22' (see the doc of supported literals).For example:
Closes #39159
Why are the changes needed?
To achieve feature parity with Scala/Java API, and provide PySpark users the same feature.
Does this PR introduce any user-facing change?
No, it shouldn't.
How was this patch tested?
Checked the examples locally, and running the tests: