-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v1] Add AstVisitor and AstRewriter; port partiql-ast normalization p…
…asses to partiql-planner
- Loading branch information
Showing
25 changed files
with
2,345 additions
and
540 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
752 changes: 752 additions & 0 deletions
752
partiql-ast/src/main/java/org/partiql/ast/v1/AstRewriter.kt
Large diffs are not rendered by default.
Oops, something went wrong.
742 changes: 546 additions & 196 deletions
742
partiql-ast/src/main/java/org/partiql/ast/v1/AstVisitor.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
15 changes: 1 addition & 14 deletions
15
partiql-ast/src/main/java/org/partiql/ast/v1/FromTableRef.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,6 @@ | ||
package org.partiql.ast.v1; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* TODO docs, equals, hashcode | ||
*/ | ||
public abstract class FromTableRef extends AstNode { | ||
@Override | ||
public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) { | ||
if (this instanceof FromExpr) { | ||
return visitor.visitFromExpr((FromExpr) this, ctx); | ||
} else if (this instanceof FromJoin) { | ||
return visitor.visitFromJoin((FromJoin) this, ctx); | ||
} else { | ||
throw new IllegalStateException("Unexpected value: " + this); | ||
} | ||
} | ||
} | ||
public abstract class FromTableRef extends AstNode {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,6 @@ | ||
package org.partiql.ast.v1; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* TODO docs, equals, hashcode | ||
*/ | ||
public abstract class Select extends AstNode { | ||
@Override | ||
public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) { | ||
if (this instanceof SelectStar) { | ||
return visitor.visitSelectStar((SelectStar) this, ctx); | ||
} else if (this instanceof SelectList) { | ||
return visitor.visitSelectList((SelectList) this, ctx); | ||
} else if (this instanceof SelectPivot) { | ||
return visitor.visitSelectPivot((SelectPivot) this, ctx); | ||
} else if (this instanceof SelectValue) { | ||
return visitor.visitSelectValue((SelectValue) this, ctx); | ||
} else { | ||
throw new IllegalStateException("Unexpected value: " + this); | ||
} | ||
} | ||
} | ||
public abstract class Select extends AstNode {} |
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
15 changes: 1 addition & 14 deletions
15
partiql-ast/src/main/java/org/partiql/ast/v1/Statement.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,6 @@ | ||
package org.partiql.ast.v1; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* TODO docs, equals, hashcode | ||
*/ | ||
public abstract class Statement extends AstNode { | ||
@Override | ||
public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) { | ||
if (this instanceof Query) { | ||
return visitor.visitQuery((Query) this, ctx); | ||
} else if (this instanceof Explain) { | ||
return visitor.visitExplain((Explain) this, ctx); | ||
} else { | ||
throw new IllegalStateException("Unexpected value: " + this); | ||
} | ||
} | ||
} | ||
public abstract class Statement extends AstNode {} |
73 changes: 1 addition & 72 deletions
73
partiql-ast/src/main/java/org/partiql/ast/v1/expr/Expr.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,8 @@ | ||
package org.partiql.ast.v1.expr; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.partiql.ast.v1.AstNode; | ||
import org.partiql.ast.v1.AstVisitor; | ||
|
||
/** | ||
* TODO docs, equals, hashcode | ||
*/ | ||
public abstract class Expr extends AstNode { | ||
@Override | ||
public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) { | ||
if (this instanceof ExprLit) { | ||
return visitor.visitExprLit((ExprLit) this, ctx); | ||
} else if (this instanceof ExprVariant) { | ||
return visitor.visitExprVariant((ExprVariant) this, ctx); | ||
} else if (this instanceof ExprVarRef) { | ||
return visitor.visitExprVarRef((ExprVarRef) this, ctx); | ||
} else if (this instanceof ExprSessionAttribute) { | ||
return visitor.visitExprSessionAttribute((ExprSessionAttribute) this, ctx); | ||
} else if (this instanceof ExprPath) { | ||
return visitor.visitExprPath((ExprPath) this, ctx); | ||
} else if (this instanceof ExprCall) { | ||
return visitor.visitExprCall((ExprCall) this, ctx); | ||
} else if (this instanceof ExprParameter) { | ||
return visitor.visitExprParameter((ExprParameter) this, ctx); | ||
} else if (this instanceof ExprOperator) { | ||
return visitor.visitExprOperator((ExprOperator) this, ctx); | ||
} else if (this instanceof ExprNot) { | ||
return visitor.visitExprNot((ExprNot) this, ctx); | ||
} else if (this instanceof ExprAnd) { | ||
return visitor.visitExprAnd((ExprAnd) this, ctx); | ||
} else if (this instanceof ExprOr) { | ||
return visitor.visitExprOr((ExprOr) this, ctx); | ||
} else if (this instanceof ExprValues) { | ||
return visitor.visitExprValues((ExprValues) this, ctx); | ||
} else if (this instanceof ExprArray) { | ||
return visitor.visitExprArray((ExprArray) this, ctx); | ||
} else if (this instanceof ExprBag) { | ||
return visitor.visitExprBag((ExprBag) this, ctx); | ||
} else if (this instanceof ExprStruct) { | ||
return visitor.visitExprStruct((ExprStruct) this, ctx); | ||
} else if (this instanceof ExprLike) { | ||
return visitor.visitExprLike((ExprLike) this, ctx); | ||
} else if (this instanceof ExprBetween) { | ||
return visitor.visitExprBetween((ExprBetween) this, ctx); | ||
} else if (this instanceof ExprInCollection) { | ||
return visitor.visitExprInCollection((ExprInCollection) this, ctx); | ||
} else if (this instanceof ExprIsType) { | ||
return visitor.visitExprIsType((ExprIsType) this, ctx); | ||
} else if (this instanceof ExprCase) { | ||
return visitor.visitExprCase((ExprCase) this, ctx); | ||
} else if (this instanceof ExprCoalesce) { | ||
return visitor.visitExprCoalesce((ExprCoalesce) this, ctx); | ||
} else if (this instanceof ExprNullIf) { | ||
return visitor.visitExprNullIf((ExprNullIf) this, ctx); | ||
} else if (this instanceof ExprSubstring) { | ||
return visitor.visitExprSubstring((ExprSubstring) this, ctx); | ||
} else if (this instanceof ExprPosition) { | ||
return visitor.visitExprPosition((ExprPosition) this, ctx); | ||
} else if (this instanceof ExprTrim) { | ||
return visitor.visitExprTrim((ExprTrim) this, ctx); | ||
} else if (this instanceof ExprOverlay) { | ||
return visitor.visitExprOverlay((ExprOverlay) this, ctx); | ||
} else if (this instanceof ExprExtract) { | ||
return visitor.visitExprExtract((ExprExtract) this, ctx); | ||
} else if (this instanceof ExprCast) { | ||
return visitor.visitExprCast((ExprCast) this, ctx); | ||
} else if (this instanceof ExprQuerySet) { | ||
return visitor.visitExprQuerySet((ExprQuerySet) this, ctx); | ||
} else if (this instanceof ExprMatch) { | ||
return visitor.visitExprMatch((ExprMatch) this, ctx); | ||
} else if (this instanceof ExprWindow) { | ||
return visitor.visitExprWindow((ExprWindow) this, ctx); | ||
} else { | ||
throw new IllegalStateException("Unexpected value: " + this); | ||
} | ||
} | ||
} | ||
public abstract class Expr extends AstNode {} |
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.