-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-42705][CONNECT] Fix spark.sql to return values from the command #40323
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
Conversation
|
Is there a similar case on Scala connect client ? |
I haven't tried Scala client, but yes, it would happen, and this will fix both. |
|
Is there a chance to add a similar case in |
LuciferYang
left a comment
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.
+1, LGTM
|
@LuciferYang This PR fix it in the connect planner, so should also works for the Scala Client. |
OK, got it |
### What changes were proposed in this pull request?
Fixes `spark.sql` to return values from the command.
### Why are the changes needed?
Currently `spark.sql` doesn't return the result from the commands.
```py
>>> spark.sql("show functions").show()
+--------+
|function|
+--------+
+--------+
```
### Does this PR introduce _any_ user-facing change?
`spark.sql` with commands will return the values.
### How was this patch tested?
Added a test.
Closes #40323 from ueshin/issues/SPARK-42705/sql.
Authored-by: Takuya UESHIN <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
(cherry picked from commit 1507a52)
Signed-off-by: Ruifeng Zheng <[email protected]>
|
thank you all, merged into master/branch-3.4 |
| timeZoneId) | ||
| assert(batches.size == 1) | ||
| batches.next() | ||
| assert(batches.hasNext) |
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.
Sorry for the late reply but how is this code different to the existing one?
val bytes = batches.next()
bytes
Is the same as
batches.next()
The asserts in between don't count as they don't have side effects.
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.
The batches is an iterator, so batches.size consumes all the data in the iterator to calculate the size.
Then batches.next() would return an empty data? Usually it should throw an Exception, though.
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 see thank you. My understanding with iterators was that non rewindable iterators simply do not have a size method.
But something new learned.
### What changes were proposed in this pull request?
Fixes `spark.sql` to return values from the command.
### Why are the changes needed?
Currently `spark.sql` doesn't return the result from the commands.
```py
>>> spark.sql("show functions").show()
+--------+
|function|
+--------+
+--------+
```
### Does this PR introduce _any_ user-facing change?
`spark.sql` with commands will return the values.
### How was this patch tested?
Added a test.
Closes apache#40323 from ueshin/issues/SPARK-42705/sql.
Authored-by: Takuya UESHIN <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
(cherry picked from commit 1507a52)
Signed-off-by: Ruifeng Zheng <[email protected]>
What changes were proposed in this pull request?
Fixes
spark.sqlto return values from the command.Why are the changes needed?
Currently
spark.sqldoesn't return the result from the commands.Does this PR introduce any user-facing change?
spark.sqlwith commands will return the values.How was this patch tested?
Added a test.