This repository has been archived by the owner on Jan 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: implement new API for node transformation
Instead of having TransformUp and TransformExpressionsUp in each node, which was really error prone, now we have a different API. Each node will have a WithChildren method that will receive the children from which a new node of the same type will be created. These nodes must come in the same number and order as the ones returned by the Children method. Expressioner nodes will also have WithExpressions method, which is the same, except it will create a new node with its expressions changed, instead of the children nodes. The plan package will expose 3 new helpers: - TransformUp: which transforms a node from the bottom-up. - TransformExpressionsUp: which transforms expressions of a node from the bottom up. - TransformExpressions: which transforms the expressions of just the given node. Just like with nodes, expressions will also have a new WithChildren method that does the exact same thing as it does in the nodes. The expression package will expose a new helper: - TransformUp: which transforms an expression from the bottom up. Caveats and limitations: One thing that may seem odd is the limitation that WithChildren and WithExpressions must receive the children in the exact same order and number as they were returned from Expressions or Children. This is because without this limitation there is no way to build certain nodes. If we force this limitation on one, it would feel odd not to have it elsewhere. For example, take Case expression into account. It may or may not have Expr, it has a list of branches (each having 2 expressions) and it may or may not have an Else expression. If WithChildren receives N children, how do we know where to put all these expressions? This limitation allows us to build the node beacause we know the shape of children must match the current shape. Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
- Loading branch information
1 parent
8702d43
commit 2c7cd89
Showing
125 changed files
with
1,088 additions
and
1,817 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.