refactor: separate expression tree nodes into a separate tree from ast #3126
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This patch moves the nodes in our expression tree into a separate parse
tree. This is a first step towards moving the code that deals with
expressions into ksql-execution (see #3125),
so that the serialized execution plan nodes can refer to expressions (e.g. for a select).
Both AST and Expression node have a common parent Node class, which now
just contains a NodeLocation, and abstract hashcode/equals methods.
The Expression tree now has its own visitor interface, called
ExpressionVisitor. This patch also migrates ExpressionFormatter to
implement this interface.
Note that this is just the first of multiple steps to get these decoupled, with the goal
for this PR being to separate the two trees. I'm deferring the following to later PRs:
- Actually moving the expression classes into ksql-execution (this pollutes the diff).
- We have lots of AstVisitor implementations that only operate on expressions
(e.g. codegen, expression type manager, insert-into analyzer). Migrating these
to implement ExpressionVisitor is deferred to a later PR.
- The current patch has AstVisitor implement ExpressionVisitor. These should be
decoupled into separate visitors (and all made private inner classes (see below)),
and explicitly composed where needed.
- ExpressionVisitor is an interface, which means that all the visit methods are public,
but that's fine since the final implementation should always be a private inner class
so that the interface can be restricted appropriately for the given visitor use case.
Migrating AstVisitor (and cleaning up the weird inheritance hierarchy) to follow a
similar pattern is also deferred.
Testing done
This is purely a refactor, so no new tests have been added.