Skip to content
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-46337][SQL][CONNECT][PYTHON] Make CTESubstitution retain the PLAN_ID_TAG #44268

Closed
wants to merge 2 commits into from

Conversation

zhengruifeng
Copy link
Contributor

What changes were proposed in this pull request?

Make CTESubstitution retain the PLAN_ID_TAG

Why are the changes needed?

before this PR:

df1 = spark.range(10)
df2 = spark.sql("with dt as (select 1 as ida) select ida as id from dt")
df1.join(df2, df1.id == df2.id)

AnalysisException: When resolving 'id, fail to find subplan with plan_id=2 in 'Join Inner, '`==`('id, 'id)
:- Range (0, 10, step=1, splits=Some(12))
+- WithCTE
   :- CTERelationDef 4, false
   :  +- SubqueryAlias dt
   :     +- Project [1 AS ida#22]
   :        +- OneRowRelation
   +- Project [ida#22 AS id#21]
      +- SubqueryAlias dt
         +- CTERelationRef 4, true, [ida#22], false

Does this PR introduce any user-facing change?

yes

How was this patch tested?

added ut

Was this patch authored or co-authored using generative AI tooling?

no

init

init
@zhengruifeng
Copy link
Contributor Author

cc @hvanhovell @cloud-fan

@HyukjinKwon
Copy link
Member

Merged to master.

@zhengruifeng zhengruifeng deleted the connect_plan_id_cte branch December 9, 2023 10:18
dbatomic pushed a commit to dbatomic/spark that referenced this pull request Dec 11, 2023
… `PLAN_ID_TAG`

### What changes were proposed in this pull request?
Make `CTESubstitution` retain the `PLAN_ID_TAG`

### Why are the changes needed?
before this PR:
```
df1 = spark.range(10)
df2 = spark.sql("with dt as (select 1 as ida) select ida as id from dt")
df1.join(df2, df1.id == df2.id)

AnalysisException: When resolving 'id, fail to find subplan with plan_id=2 in 'Join Inner, '`==`('id, 'id)
:- Range (0, 10, step=1, splits=Some(12))
+- WithCTE
   :- CTERelationDef 4, false
   :  +- SubqueryAlias dt
   :     +- Project [1 AS ida#22]
   :        +- OneRowRelation
   +- Project [ida#22 AS id#21]
      +- SubqueryAlias dt
         +- CTERelationRef 4, true, [ida#22], false
```

### Does this PR introduce _any_ user-facing change?
yes

### How was this patch tested?
added ut

### Was this patch authored or co-authored using generative AI tooling?
no

Closes apache#44268 from zhengruifeng/connect_plan_id_cte.

Authored-by: Ruifeng Zheng <ruifengz@apache.org>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants