You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "JiaqiWang18 (via GitHub)" <gi...@apache.org> on 2025/08/25 20:03:06 UTC
[PR] [SPARK-53377][SDP] Tests for groupby and rollup [spark]
JiaqiWang18 opened a new pull request, #52121:
URL: https://github.com/apache/spark/pull/52121
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
Tests for group by and roll up to ensure they work with Spark Connect
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
Spark Connect had behavior change to now lazily analyze these two functions, so they should work now in SDP
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
Tests
### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "JiaqiWang18 (via GitHub)" <gi...@apache.org>.
JiaqiWang18 commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2308670138
##########
sql/connect/server/src/test/scala/org/apache/spark/sql/connect/pipelines/PythonPipelineSuite.scala:
##########
@@ -434,6 +434,66 @@ class PythonPipelineSuite
.map(_.identifier) == Seq(graphIdentifier("a"), graphIdentifier("something")))
}
+ test("groupby and rollup works with internal datasets (col, str, index)") {
Review Comment:
referencing index is still doing eager analysis, and we disallow this behavior in query functions
```
@dp.materialized_view
def groupby_with_index_result():
return spark.read.table("src").groupBy(1).agg(
sum(col(id_col)).alias("sum_id"),
count("*").alias("cnt")
)
```
will reachout to spark connect and check with them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #52121:
URL: https://github.com/apache/spark/pull/52121#issuecomment-3240742596
thanks, merging to master!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "JiaqiWang18 (via GitHub)" <gi...@apache.org>.
JiaqiWang18 commented on PR #52121:
URL: https://github.com/apache/spark/pull/52121#issuecomment-3235344773
cc @cloud-fan
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "JiaqiWang18 (via GitHub)" <gi...@apache.org>.
JiaqiWang18 commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2308673826
##########
sql/connect/server/src/test/scala/org/apache/spark/sql/connect/pipelines/PythonPipelineSuite.scala:
##########
@@ -434,6 +434,66 @@ class PythonPipelineSuite
.map(_.identifier) == Seq(graphIdentifier("a"), graphIdentifier("something")))
}
+ test("groupby and rollup works with internal datasets (col, str, index)") {
+ val graph = buildGraph("""
+ from pyspark.sql.functions import col, sum, count
+
+ @dp.materialized_view
+ def src():
+ return spark.range(3)
+
+ @dp.materialized_view
+ def groupby_with_col_result():
+ return spark.read.table("src").groupBy(col("id")).agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+
+ @dp.materialized_view
+ def groupby_with_str_result():
+ return spark.read.table("src").groupBy("id").agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+
+ @dp.materialized_view
+ def rollup_with_col_result():
+ return spark.read.table("src").rollup(col("id")).agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+
+ @dp.materialized_view
+ def rollup_with_str_result():
+ return spark.read.table("src").rollup("id").agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+ """)
+
+ val updateContext = new PipelineUpdateContextImpl(graph, _ => ())
+ updateContext.pipelineExecution.runPipeline()
+ updateContext.pipelineExecution.awaitCompletion()
+
+ val groupbyDfs =
+ Seq(spark.table("groupby_with_col_result"), spark.table("groupby_with_str_result"))
+
+ val rollupDfs =
+ Seq(spark.table("rollup_with_col_result"), spark.table("rollup_with_str_result"))
+
+ // groupBy: each variant should have exactly one row per id [0,1,2]
+ groupbyDfs.foreach { df =>
+ assert(df.select("id").collect().map(_.getLong(0)).toSet == Set(0L, 1L, 2L))
Review Comment:
I just realized we actually don't extend `PipelineTest` in any of the child of `SparkDeclarativePipelinesServerTest`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "AnishMahto (via GitHub)" <gi...@apache.org>.
AnishMahto commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2308622852
##########
sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/FlowAnalysis.scala:
##########
@@ -112,23 +112,33 @@ object FlowAnalysis {
// - SELECT ... FROM STREAM(t1)
// - SELECT ... FROM STREAM t1
case u: UnresolvedRelation if u.isStreaming =>
- readStreamInput(
+ val resolved = readStreamInput(
context,
name = IdentifierHelper.toQuotedString(u.multipartIdentifier),
spark.readStream,
streamingReadOptions = StreamingReadOptions()
).queryExecution.analyzed
-
+ // Spark Connect requires the PLAN_ID_TAG to be propagated to the resolved plan
+ // to allow correct analysis of the parent plan that contains this subquery
+ u.getTagValue(LogicalPlan.PLAN_ID_TAG).foreach(
+ id => resolved.setTagValue(LogicalPlan.PLAN_ID_TAG, id)
Review Comment:
+1, will wait for someone else to chime in
##########
sql/connect/server/src/test/scala/org/apache/spark/sql/connect/pipelines/PythonPipelineSuite.scala:
##########
@@ -434,6 +434,66 @@ class PythonPipelineSuite
.map(_.identifier) == Seq(graphIdentifier("a"), graphIdentifier("something")))
}
+ test("groupby and rollup works with internal datasets (col, str, index)") {
Review Comment:
does the test actually try index?
##########
sql/connect/server/src/test/scala/org/apache/spark/sql/connect/pipelines/PythonPipelineSuite.scala:
##########
@@ -434,6 +434,66 @@ class PythonPipelineSuite
.map(_.identifier) == Seq(graphIdentifier("a"), graphIdentifier("something")))
}
+ test("groupby and rollup works with internal datasets (col, str, index)") {
+ val graph = buildGraph("""
+ from pyspark.sql.functions import col, sum, count
+
+ @dp.materialized_view
+ def src():
+ return spark.range(3)
+
+ @dp.materialized_view
+ def groupby_with_col_result():
+ return spark.read.table("src").groupBy(col("id")).agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+
+ @dp.materialized_view
+ def groupby_with_str_result():
+ return spark.read.table("src").groupBy("id").agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+
+ @dp.materialized_view
+ def rollup_with_col_result():
+ return spark.read.table("src").rollup(col("id")).agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+
+ @dp.materialized_view
+ def rollup_with_str_result():
+ return spark.read.table("src").rollup("id").agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+ """)
+
+ val updateContext = new PipelineUpdateContextImpl(graph, _ => ())
+ updateContext.pipelineExecution.runPipeline()
+ updateContext.pipelineExecution.awaitCompletion()
+
+ val groupbyDfs =
+ Seq(spark.table("groupby_with_col_result"), spark.table("groupby_with_str_result"))
+
+ val rollupDfs =
+ Seq(spark.table("rollup_with_col_result"), spark.table("rollup_with_str_result"))
+
+ // groupBy: each variant should have exactly one row per id [0,1,2]
+ groupbyDfs.foreach { df =>
+ assert(df.select("id").collect().map(_.getLong(0)).toSet == Set(0L, 1L, 2L))
Review Comment:
nit: use `PipelineTest.checkAnswer` in all the tests instead of directly calling df.collect
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53377][SDP] Tests for groupby and rollup [spark]
Posted by "JiaqiWang18 (via GitHub)" <gi...@apache.org>.
JiaqiWang18 commented on PR #52121:
URL: https://github.com/apache/spark/pull/52121#issuecomment-3221848302
@anishm-db @gengliangwang
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2309004638
##########
sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/FlowAnalysis.scala:
##########
@@ -112,23 +112,33 @@ object FlowAnalysis {
// - SELECT ... FROM STREAM(t1)
// - SELECT ... FROM STREAM t1
case u: UnresolvedRelation if u.isStreaming =>
- readStreamInput(
+ val resolved = readStreamInput(
context,
name = IdentifierHelper.toQuotedString(u.multipartIdentifier),
spark.readStream,
streamingReadOptions = StreamingReadOptions()
).queryExecution.analyzed
-
+ // Spark Connect requires the PLAN_ID_TAG to be propagated to the resolved plan
+ // to allow correct analysis of the parent plan that contains this subquery
+ u.getTagValue(LogicalPlan.PLAN_ID_TAG).foreach(
+ id => resolved.setTagValue(LogicalPlan.PLAN_ID_TAG, id)
Review Comment:
the plan id tag is only needed to be in the root plan of a DataFrame
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #52121: [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis
URL: https://github.com/apache/spark/pull/52121
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "JiaqiWang18 (via GitHub)" <gi...@apache.org>.
JiaqiWang18 commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2308844223
##########
sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/FlowAnalysis.scala:
##########
@@ -112,23 +112,33 @@ object FlowAnalysis {
// - SELECT ... FROM STREAM(t1)
// - SELECT ... FROM STREAM t1
case u: UnresolvedRelation if u.isStreaming =>
- readStreamInput(
+ val resolved = readStreamInput(
context,
name = IdentifierHelper.toQuotedString(u.multipartIdentifier),
spark.readStream,
streamingReadOptions = StreamingReadOptions()
).queryExecution.analyzed
-
+ // Spark Connect requires the PLAN_ID_TAG to be propagated to the resolved plan
+ // to allow correct analysis of the parent plan that contains this subquery
+ u.getTagValue(LogicalPlan.PLAN_ID_TAG).foreach(
+ id => resolved.setTagValue(LogicalPlan.PLAN_ID_TAG, id)
+ )
+ resolved
// Batch read on another dataset in the pipeline
case u: UnresolvedRelation =>
- readBatchInput(
+ val resolved = readBatchInput(
context,
name = IdentifierHelper.toQuotedString(u.multipartIdentifier),
batchReadOptions = BatchReadOptions()
).queryExecution.analyzed
+ // Spark Connect requires the PLAN_ID_TAG to be propagated to the resolved plan
+ // to allow correct analysis of the parent plan that contains this subquery
+ u.getTagValue(LogicalPlan.PLAN_ID_TAG).foreach(
+ id => resolved.setTagValue(LogicalPlan.PLAN_ID_TAG, id)
+ )
Review Comment:
Also, we are directly using `setTagValue(LogicalPlan.PLAN_ID_TAG ..)` instead of using `copyTagsFrom` because the `reslved` plan contains a `dataset_id` tag and `copyTagsFrom` expects the destination to not contain any tags ([src](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala#L179)).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53377][SDP] Tests for groupby and rollup [spark]
Posted by "AnishMahto (via GitHub)" <gi...@apache.org>.
AnishMahto commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2299868527
##########
sql/connect/server/src/test/scala/org/apache/spark/sql/connect/pipelines/PythonPipelineSuite.scala:
##########
@@ -434,6 +434,47 @@ class PythonPipelineSuite
.map(_.identifier) == Seq(graphIdentifier("a"), graphIdentifier("something")))
}
+ test("groupby and rollup works with internal datasets") {
+ val graph = buildGraph("""
+ from pyspark.sql.functions import col, sum, count
+
+ @dp.materialized_view
+ def src():
+ return spark.range(3)
+
+ @dp.materialized_view
+ def groupby_result():
+ return spark.read.table("src").groupBy(col("id")).agg(
Review Comment:
For both groupby and rollup can you just reference the column directly by string?
We already knew `col("id")` is lazy and will work, can you try `groupBy("id")`? This was previously eager
##########
sql/connect/server/src/test/scala/org/apache/spark/sql/connect/pipelines/PythonPipelineSuite.scala:
##########
@@ -434,6 +434,47 @@ class PythonPipelineSuite
.map(_.identifier) == Seq(graphIdentifier("a"), graphIdentifier("something")))
}
+ test("groupby and rollup works with internal datasets") {
Review Comment:
There's 3 ways to reference a column in both groupby/rollup IIRC:
1. by name, ex. "id"
2. as a col, ex. col("id")
3. by index, ex. 1
Can you test all 3 ways? Last I checked 1/3 were eager and 2 was lazy. I'd expect 1 to be lazy now, maybe not 3.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "AnishMahto (via GitHub)" <gi...@apache.org>.
AnishMahto commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2311632138
##########
sql/connect/server/src/test/scala/org/apache/spark/sql/connect/pipelines/PythonPipelineSuite.scala:
##########
@@ -434,6 +434,66 @@ class PythonPipelineSuite
.map(_.identifier) == Seq(graphIdentifier("a"), graphIdentifier("something")))
}
+ test("groupby and rollup works with internal datasets (col, str, index)") {
+ val graph = buildGraph("""
+ from pyspark.sql.functions import col, sum, count
+
+ @dp.materialized_view
+ def src():
+ return spark.range(3)
+
+ @dp.materialized_view
+ def groupby_with_col_result():
+ return spark.read.table("src").groupBy(col("id")).agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+
+ @dp.materialized_view
+ def groupby_with_str_result():
+ return spark.read.table("src").groupBy("id").agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+
+ @dp.materialized_view
+ def rollup_with_col_result():
+ return spark.read.table("src").rollup(col("id")).agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+
+ @dp.materialized_view
+ def rollup_with_str_result():
+ return spark.read.table("src").rollup("id").agg(
+ sum("id").alias("sum_id"),
+ count("*").alias("cnt")
+ )
+ """)
+
+ val updateContext = new PipelineUpdateContextImpl(graph, _ => ())
+ updateContext.pipelineExecution.runPipeline()
+ updateContext.pipelineExecution.awaitCompletion()
+
+ val groupbyDfs =
+ Seq(spark.table("groupby_with_col_result"), spark.table("groupby_with_str_result"))
+
+ val rollupDfs =
+ Seq(spark.table("rollup_with_col_result"), spark.table("rollup_with_str_result"))
+
+ // groupBy: each variant should have exactly one row per id [0,1,2]
+ groupbyDfs.foreach { df =>
+ assert(df.select("id").collect().map(_.getLong(0)).toSet == Set(0L, 1L, 2L))
Review Comment:
Ah didn't realize either. That's fine then, not worth refactoring or changing inheritance just for it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "JiaqiWang18 (via GitHub)" <gi...@apache.org>.
JiaqiWang18 commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2309149657
##########
sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/FlowAnalysis.scala:
##########
@@ -112,23 +112,33 @@ object FlowAnalysis {
// - SELECT ... FROM STREAM(t1)
// - SELECT ... FROM STREAM t1
case u: UnresolvedRelation if u.isStreaming =>
- readStreamInput(
+ val resolved = readStreamInput(
context,
name = IdentifierHelper.toQuotedString(u.multipartIdentifier),
spark.readStream,
streamingReadOptions = StreamingReadOptions()
).queryExecution.analyzed
-
+ // Spark Connect requires the PLAN_ID_TAG to be propagated to the resolved plan
+ // to allow correct analysis of the parent plan that contains this subquery
+ u.getTagValue(LogicalPlan.PLAN_ID_TAG).foreach(
+ id => resolved.setTagValue(LogicalPlan.PLAN_ID_TAG, id)
Review Comment:
@cloud-fan We were directly using `setTagValue(LogicalPlan.PLAN_ID_TAG ..)` instead of using `copyTagsFrom` because the `reslved` plan contains a `dataset_id` tag and `copyTagsFrom` expects the destination to not contain any tags ([src](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala#L179)).
I think it make sense to also copy over other tags, so I introduced a new `mergeTagsFrom` [method](https://github.com/apache/spark/pull/52121/commits/0b3b26e663dcde3a029262920d83196f68d7fc71). I don't expect there will be tags that are defined in both and have conflicting values.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2309009170
##########
sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/FlowAnalysis.scala:
##########
@@ -112,23 +112,33 @@ object FlowAnalysis {
// - SELECT ... FROM STREAM(t1)
// - SELECT ... FROM STREAM t1
case u: UnresolvedRelation if u.isStreaming =>
- readStreamInput(
+ val resolved = readStreamInput(
context,
name = IdentifierHelper.toQuotedString(u.multipartIdentifier),
spark.readStream,
streamingReadOptions = StreamingReadOptions()
).queryExecution.analyzed
-
+ // Spark Connect requires the PLAN_ID_TAG to be propagated to the resolved plan
+ // to allow correct analysis of the parent plan that contains this subquery
+ u.getTagValue(LogicalPlan.PLAN_ID_TAG).foreach(
+ id => resolved.setTagValue(LogicalPlan.PLAN_ID_TAG, id)
Review Comment:
for normal queries, if the DataFrame is `spark.table("view_name")`, the analyzer also copies all the tags from `UnresolvedRelation` to the root node of the resolved view query plan,.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2309005041
##########
sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/FlowAnalysis.scala:
##########
@@ -112,23 +112,33 @@ object FlowAnalysis {
// - SELECT ... FROM STREAM(t1)
// - SELECT ... FROM STREAM t1
case u: UnresolvedRelation if u.isStreaming =>
- readStreamInput(
+ val resolved = readStreamInput(
context,
name = IdentifierHelper.toQuotedString(u.multipartIdentifier),
spark.readStream,
streamingReadOptions = StreamingReadOptions()
).queryExecution.analyzed
-
+ // Spark Connect requires the PLAN_ID_TAG to be propagated to the resolved plan
+ // to allow correct analysis of the parent plan that contains this subquery
+ u.getTagValue(LogicalPlan.PLAN_ID_TAG).foreach(
+ id => resolved.setTagValue(LogicalPlan.PLAN_ID_TAG, id)
Review Comment:
to avoid other potential issues, can we copy all tree node tags from the original plan?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "JiaqiWang18 (via GitHub)" <gi...@apache.org>.
JiaqiWang18 commented on PR #52121:
URL: https://github.com/apache/spark/pull/52121#issuecomment-3235757970
[reason](https://github.com/apache/spark/pull/52121#discussion_r2309149657) for adding mergeTagsFrom
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-53421][SPARK-53377][SDP] Propagate Logical Plan ID in SDP Analysis [spark]
Posted by "JiaqiWang18 (via GitHub)" <gi...@apache.org>.
JiaqiWang18 commented on code in PR #52121:
URL: https://github.com/apache/spark/pull/52121#discussion_r2308595218
##########
sql/pipelines/src/main/scala/org/apache/spark/sql/pipelines/graph/FlowAnalysis.scala:
##########
@@ -112,23 +112,33 @@ object FlowAnalysis {
// - SELECT ... FROM STREAM(t1)
// - SELECT ... FROM STREAM t1
case u: UnresolvedRelation if u.isStreaming =>
- readStreamInput(
+ val resolved = readStreamInput(
context,
name = IdentifierHelper.toQuotedString(u.multipartIdentifier),
spark.readStream,
streamingReadOptions = StreamingReadOptions()
).queryExecution.analyzed
-
+ // Spark Connect requires the PLAN_ID_TAG to be propagated to the resolved plan
+ // to allow correct analysis of the parent plan that contains this subquery
+ u.getTagValue(LogicalPlan.PLAN_ID_TAG).foreach(
+ id => resolved.setTagValue(LogicalPlan.PLAN_ID_TAG, id)
Review Comment:
we only attach the plan id to the top level `resolved` logical plan. I am wondering if this is sufficient, do we need to also attach it to the children of `resolved`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org