Skip to content

Commit

Permalink
[v1][wip] Port SqlDialect to v1 AST
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 committed Nov 2, 2024
1 parent bd7745f commit 91af96d
Show file tree
Hide file tree
Showing 12 changed files with 3,249 additions and 2,907 deletions.
471 changes: 196 additions & 275 deletions partiql-ast/api/partiql-ast.api

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Ast.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import org.partiql.value.PartiQLValue
import org.partiql.value.PartiQLValueExperimental

// TODO docs for all factory methods and move to Kotlin sources
// Also consider defaults for nullable. Need to consider backwards compatibility.
public object Ast {
// Expr
@JvmStatic
Expand Down Expand Up @@ -113,8 +114,8 @@ public object Ast {
}

@JvmStatic
public fun exprLike(value: Expr, Pattern: Expr, escape: Expr?, not: Boolean): ExprLike {
return ExprLike(value, Pattern, escape, not)
public fun exprLike(value: Expr, pattern: Expr, escape: Expr?, not: Boolean): ExprLike {
return ExprLike(value, pattern, escape, not)
}

// This representation will be changed in https://github.com/partiql/partiql-lang-kotlin/issues/1589
Expand Down Expand Up @@ -195,8 +196,8 @@ public object Ast {
}

@JvmStatic
public fun exprTrim(Value: Expr, chars: Expr?, trimSpec: TrimSpec?): ExprTrim {
return ExprTrim(Value, chars, trimSpec)
public fun exprTrim(value: Expr, chars: Expr?, trimSpec: TrimSpec?): ExprTrim {
return ExprTrim(value, chars, trimSpec)
}

@JvmStatic
Expand Down
4 changes: 4 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/AstVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,8 @@ public R visitGraphLabelConj(GraphLabel.Conj node, C ctx) {
public R visitGraphLabelDisj(GraphLabel.Disj node, C ctx) {
return defaultVisit(node, ctx);
}

public R visitDataType(DataType node, C ctx) {
return defaultVisit(node, ctx);
}
}
2 changes: 1 addition & 1 deletion partiql-ast/src/main/java/org/partiql/ast/v1/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,6 @@ public Collection<AstNode> children() {

@Override
public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
return null;
return visitor.visitDataType(this, ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public ExprCast(@NotNull Expr value, @NotNull DataType asType) {
public Collection<AstNode> children() {
List<AstNode> kids = new ArrayList<>();
kids.add(value);
kids.add(asType);
return kids;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public ExprIsType(@NotNull Expr value, @NotNull DataType type, boolean not) {
public Collection<AstNode> children() {
List<AstNode> kids = new ArrayList<>();
kids.add(value);
kids.add(type);
return kids;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.partiql.ast.sql
package org.partiql.ast.v1.sql

import org.partiql.ast.AstNode
import org.partiql.ast.v1.AstNode

/**
* Pretty-print this [AstNode] as SQL text with the given (or standard) [SqlLayout] and [SqlDialect].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* language governing permissions and limitations under the License.
*/

package org.partiql.ast.sql
package org.partiql.ast.v1.sql

/**
* Representation of some textual elements as a token (singly-linked) list.
Expand Down
Loading

0 comments on commit 91af96d

Please sign in to comment.