[SPARK-41666][PYTHON] Support parameterized SQL by sql()#39183
Closed
MaxGekk wants to merge 8 commits into
Closed
Conversation
MaxGekk
commented
Dec 22, 2022
| "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." |
Member
Author
There was a problem hiding this comment.
I have changed this to address the review comment at #38864 (comment)
sql()sql()
HyukjinKwon
approved these changes
Dec 22, 2022
Member
HyukjinKwon
left a comment
There was a problem hiding this comment.
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
Member
Author
|
Merging to master. Thank you, @HyukjinKwon for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 -argsof 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: