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] use cachedRelation.output to build OutputMap in MergePaimonScalarSubqueriers #3148

Merged
merged 2 commits into from
Apr 2, 2024

Conversation

Zouxxyy
Copy link
Contributor

@Zouxxyy Zouxxyy commented Apr 2, 2024

Purpose

use cachedRelation.output to build OutputMap in MergePaimonScalarSubqueriers

before

=== Applying Rule org.apache.paimon.spark.catalyst.optimizer.MergePaimonScalarSubqueriers ===
!Project [CASE WHEN (scalar-subquery#0 [] > 74129) THEN scalar-subquery#1 [] ELSE scalar-subquery#2 [] END AS bucket1#3, CASE WHEN (scalar-subquery#4 [] > 122840) THEN scalar-subquery#5 [] ELSE scalar-subquery#6 [] END AS bucket2#7, CASE WHEN (scalar-subquery#8 [] > 56580) THEN scalar-subquery#9 [] ELSE scalar-subquery#10 [] END AS bucket3#11, CASE WHEN (scalar-subquery#12 [] > 10097) THEN scalar-subquery#13 [] ELSE scalar-subquery#14 [] END AS bucket4#15, CASE WHEN (scalar-subquery#16 [] > 165306) THEN scalar-subquery#17 [] ELSE scalar-subquery#18 [] END AS bucket5#19]   WithCTE
!:  :- Aggregate [count(1) AS count(1)#47L]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        :- CTERelationDef 0, true
!:  :  +- Project                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  :  +- Project [named_struct(count(1), count(1)#47L, avg(ss_ext_discount_amt), avg(ss_ext_discount_amt)#72, avg(ss_net_paid), avg(ss_net_paid)#97) AS mergedValue#521]
!:  :     +- Filter ((isnotnull(ss_quantity#33) AND (ss_quantity#33 >= 1)) AND (ss_quantity#33 <= 20))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             :     +- Aggregate [count(1) AS count(1)#47L, cast((avg(UnscaledValue(ss_ext_discount_amt#457)) / 100.0) as decimal(11,6)) AS avg(ss_ext_discount_amt)#72, cast((avg(UnscaledValue(ss_net_paid#464)) / 100.0) as decimal(11,6)) AS avg(ss_net_paid)#97]
!:  :        +- RelationV2[ss_quantity#33] store_sales                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             :        +- Project [ss_ext_discount_amt#457, ss_net_paid#464]
!:  :  +- Project [ss_ext_discount_amt#62]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         :              +- RelationV2[ss_quantity#33, ss_ext_discount_amt#457, ss_net_paid#464] store_sales

after

=== Applying Rule org.apache.paimon.spark.catalyst.optimizer.MergePaimonScalarSubqueriers ===
!Project [CASE WHEN (scalar-subquery#0 [] > 74129) THEN scalar-subquery#1 [] ELSE scalar-subquery#2 [] END AS bucket1#3, CASE WHEN (scalar-subquery#4 [] > 122840) THEN scalar-subquery#5 [] ELSE scalar-subquery#6 [] END AS bucket2#7, CASE WHEN (scalar-subquery#8 [] > 56580) THEN scalar-subquery#9 [] ELSE scalar-subquery#10 [] END AS bucket3#11, CASE WHEN (scalar-subquery#12 [] > 10097) THEN scalar-subquery#13 [] ELSE scalar-subquery#14 [] END AS bucket4#15, CASE WHEN (scalar-subquery#16 [] > 165306) THEN scalar-subquery#17 [] ELSE scalar-subquery#18 [] END AS bucket5#19]   WithCTE
!:  :- Aggregate [count(1) AS count(1)#47L]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        :- CTERelationDef 0, true
!:  :  +- Project                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  :  +- Project [named_struct(count(1), count(1)#47L, avg(ss_ext_discount_amt), avg(ss_ext_discount_amt)#72, avg(ss_net_paid), avg(ss_net_paid)#97) AS mergedValue#521]
!:  :     +- Filter ((isnotnull(ss_quantity#33) AND (ss_quantity#33 >= 1)) AND (ss_quantity#33 <= 20))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             :     +- Aggregate [count(1) AS count(1)#47L, cast((avg(UnscaledValue(ss_ext_discount_amt#37)) / 100.0) as decimal(11,6)) AS avg(ss_ext_discount_amt)#72, cast((avg(UnscaledValue(ss_net_paid#43)) / 100.0) as decimal(11,6)) AS avg(ss_net_paid)#97]
!:  :        +- RelationV2[ss_quantity#33] store_sales                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             :        +- Project [ss_ext_discount_amt#37, ss_net_paid#43]
!:  :- Aggregate [cast((avg(UnscaledValue(ss_ext_discount_amt#62)) / 100.0) as decimal(11,6)) AS avg(ss_ext_discount_amt)#72]                                                                                                                                                                                                                                                                                                                                                                                                                                                                      :           +- Filter ((isnotnull(ss_quantity#33) AND (ss_quantity#33 >= 1)) AND (ss_quantity#33 <= 20))
!:  :  +- Project [ss_ext_discount_amt#62]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         :              +- RelationV2[ss_quantity#33, ss_ext_discount_amt#37, ss_net_paid#43] store_sales

Tests

API and Format

Documentation

@Zouxxyy Zouxxyy requested a review from YannByron April 2, 2024 08:43
@apache apache locked and limited conversation to collaborators Apr 2, 2024
@apache apache unlocked this conversation Apr 2, 2024
@YannByron YannByron merged commit b8884f8 into apache:master Apr 2, 2024
9 checks passed
@Zouxxyy Zouxxyy deleted the dev/fix-cte branch April 2, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants