Skip to content

Conversation

takezoe
Copy link
Member

@takezoe takezoe commented Jan 13, 2023

This will make possible to traverse/transform LogicalPlan in Expression.

Another idea is moving all traverse and transform methods (including mapChildren) to TreeNode with a signature change LogicalPlan -> TreeNode[_]. This will change the ability of those methods that can traverse/transform any nodes in the tree, not only LogicalPlan. Meaning, no need to have methods for LogicalPlan and Expression independently.

I'm not sure which is better. 🤔

@codecov
Copy link

codecov bot commented Jan 13, 2023

Codecov Report

Merging #2698 (62f7734) into master (cc7a46e) will decrease coverage by 0.00%.
The diff coverage is 81.25%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2698      +/-   ##
==========================================
- Coverage   82.20%   82.19%   -0.01%     
==========================================
  Files         337      337              
  Lines       14076    14102      +26     
  Branches     2216     2223       +7     
==========================================
+ Hits        11571    11591      +20     
- Misses       2505     2511       +6     
Impacted Files Coverage Δ
...in/scala/wvlet/airframe/sql/model/Expression.scala 72.56% <72.72%> (+0.01%) ⬆️
...n/scala/wvlet/airframe/sql/model/LogicalPlan.scala 87.15% <100.00%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc7a46e...62f7734. Read the comment docs.

createInstance(newArgs)
}

def traversePlan[U](rule: PartialFunction[LogicalPlan, U]): Unit = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply changing LogicalPlan.traverse() to accept PartialFunction[TreeNode[_], U] works, but if we do so, traverse() will be able to handle Expression, not only LogicalPlan although LogicalPlan already have traverseExpressions().

I think adding traversePlan() is more consistent in terms of API design unless we drop methods for Expression.

@takezoe takezoe force-pushed the sql-in-expression-subquery branch from 06e4b56 to c3fbf07 Compare January 13, 2023 09:58
@takezoe takezoe force-pushed the sql-in-expression-subquery branch from c3fbf07 to 62f7734 Compare January 13, 2023 10:17
@xerial
Copy link
Member

xerial commented Jan 13, 2023

LGTM.

I've checked Spark SQL's code, and it seems it also uses different transform methods for Expression and LogicalPlan. It seems merging two types of traversals will be unnecessary.

@xerial xerial merged commit d575d75 into wvlet:master Jan 13, 2023
@xerial
Copy link
Member

xerial commented Jan 13, 2023

Merged

@takezoe
Copy link
Member Author

takezoe commented Jan 14, 2023

Thank you!

@takezoe takezoe deleted the sql-in-expression-subquery branch January 14, 2023 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants