[SPARK-47251][PYTHON] Block invalid types from the args argument for sql command#45361
Closed
ueshin wants to merge 1 commit into
Closed
[SPARK-47251][PYTHON] Block invalid types from the args argument for sql command#45361ueshin wants to merge 1 commit into
args argument for sql command#45361ueshin wants to merge 1 commit into
Conversation
MaxGekk
approved these changes
Mar 1, 2024
srielau
approved these changes
Mar 2, 2024
HyukjinKwon
approved these changes
Mar 2, 2024
Member
|
Merged to master. |
TakawaAkirayo
pushed a commit
to TakawaAkirayo/spark
that referenced
this pull request
Mar 4, 2024
…r `sql` command
### What changes were proposed in this pull request?
Blocks invalid types from the `args` argument for `sql` command.
Additionally, uses a `PySparkValueError` instead of assertions in Spark Connect.
### Why are the changes needed?
Currently the vanilla PySpark accepts any value, even `set`, which could cause unexpected results because `set` won't guarantee the item order.
```py
>>> spark.sql("select ?, ?, ?", args={2,1,3}).show()
+---+---+---+
| 1| 2| 3|
+---+---+---+
| 1| 2| 3|
+---+---+---+
```
whereas with list:
```py
>>> spark.sql("select ?, ?, ?", args=[2,1,3]).show()
+---+---+---+
| 2| 1| 3|
+---+---+---+
| 2| 1| 3|
+---+---+---+
```
### Does this PR introduce _any_ user-facing change?
Yes, the `args` argument for `sql` command will only accept `None`, `dict`, or `list`.
### How was this patch tested?
Added the related tests.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes apache#45361 from ueshin/issues/SPARK-47251/args.
Authored-by: Takuya UESHIN <ueshin@databricks.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
ericm-db
pushed a commit
to ericm-db/spark
that referenced
this pull request
Mar 5, 2024
…r `sql` command
### What changes were proposed in this pull request?
Blocks invalid types from the `args` argument for `sql` command.
Additionally, uses a `PySparkValueError` instead of assertions in Spark Connect.
### Why are the changes needed?
Currently the vanilla PySpark accepts any value, even `set`, which could cause unexpected results because `set` won't guarantee the item order.
```py
>>> spark.sql("select ?, ?, ?", args={2,1,3}).show()
+---+---+---+
| 1| 2| 3|
+---+---+---+
| 1| 2| 3|
+---+---+---+
```
whereas with list:
```py
>>> spark.sql("select ?, ?, ?", args=[2,1,3]).show()
+---+---+---+
| 2| 1| 3|
+---+---+---+
| 2| 1| 3|
+---+---+---+
```
### Does this PR introduce _any_ user-facing change?
Yes, the `args` argument for `sql` command will only accept `None`, `dict`, or `list`.
### How was this patch tested?
Added the related tests.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes apache#45361 from ueshin/issues/SPARK-47251/args.
Authored-by: Takuya UESHIN <ueshin@databricks.com>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
HyukjinKwon
pushed a commit
that referenced
this pull request
Mar 5, 2024
…entation ### What changes were proposed in this pull request? This is a follow-up of #45361. Use `__name__` instead of string representation for the error parameter. ### Why are the changes needed? To be consistent with other places. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Updated the related tests. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #45393 from ueshin/issues/SPARK-47251/fup. Authored-by: Takuya UESHIN <ueshin@databricks.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
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?
Blocks invalid types from the
argsargument forsqlcommand.Additionally, uses a
PySparkValueErrorinstead of assertions in Spark Connect.Why are the changes needed?
Currently the vanilla PySpark accepts any value, even
set, which could cause unexpected results becausesetwon't guarantee the item order.whereas with list:
Does this PR introduce any user-facing change?
Yes, the
argsargument forsqlcommand will only acceptNone,dict, orlist.How was this patch tested?
Added the related tests.
Was this patch authored or co-authored using generative AI tooling?
No.