Skip to content

Commit

Permalink
[v1] Add equals and hashcode for AST classes
Browse files Browse the repository at this point in the history
  • Loading branch information
alancai98 committed Oct 22, 2024
1 parent 4fa3853 commit 34a0993
Show file tree
Hide file tree
Showing 74 changed files with 468 additions and 4 deletions.
281 changes: 281 additions & 0 deletions partiql-ast/api/partiql-ast.api

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/DataType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.partiql.ast.v1;

import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = false)
public class DataType implements Enum {
public static final int UNKNOWN = 0;
// <absent types>
Expand Down Expand Up @@ -158,6 +161,14 @@ public static DataType DEC() {
return new DataType(DEC);
}

public static DataType DEC(int precision) {
return new DataType(DEC, precision, null, null);
}

public static DataType DEC(int precision, int scale) {
return new DataType(DEC, precision, scale, null);
}

public static DataType NUMERIC() {
return new DataType(NUMERIC);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.partiql.ast.v1;

import lombok.EqualsAndHashCode;

/**
* TODO docs, equals, hashcode
*/
@EqualsAndHashCode(callSuper = false)
public class DatetimeField implements Enum {
public static final int UNKNOWN = 0;
public static final int YEAR = 1;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Exclude.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -11,6 +12,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class Exclude extends AstNode {
@NotNull
public final List<ExcludePath> excludePaths;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/ExcludePath.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.partiql.ast.v1.expr.ExprVarRef;

Expand All @@ -12,6 +13,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class ExcludePath extends AstNode {
@NotNull
public final ExprVarRef root;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Explain.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.partiql.value.PartiQLValue;

Expand All @@ -13,6 +14,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class Explain extends Statement {
// TODO get rid of PartiQLValue once https://github.com/partiql/partiql-lang-kotlin/issues/1589 is resolved
@NotNull
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/From.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -11,6 +12,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class From extends AstNode {
@NotNull
public final List<FromTableRef> tableRefs;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/FromExpr.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.v1.expr.Expr;
Expand All @@ -13,6 +14,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class FromExpr extends FromTableRef {
@NotNull
public final Expr expr;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/FromJoin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.v1.expr.Expr;
Expand All @@ -13,6 +14,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class FromJoin extends FromTableRef {
@NotNull
public final From lhs;
Expand Down
3 changes: 3 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/FromType.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.partiql.ast.v1;

import lombok.EqualsAndHashCode;

/**
* TODO docs, equals, hashcode
*/
@EqualsAndHashCode(callSuper = false)
public class FromType implements Enum {
public static final int UNKNOWN = 0;
public static final int SCAN = 1;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/GroupBy.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.v1.expr.Expr;
Expand All @@ -13,6 +14,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class GroupBy extends AstNode {
@NotNull
public final GroupByStrategy strategy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.partiql.ast.v1;

import lombok.EqualsAndHashCode;

/**
* TODO docs, equals, hashcode
*/
@EqualsAndHashCode(callSuper = false)
public class GroupByStrategy implements Enum {
public static final int UNKNOWN = 0;
public static final int FULL = 1;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Identifier.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -10,6 +11,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class Identifier extends AstNode {
@NotNull
public final String symbol;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -12,6 +13,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class IdentifierChain extends AstNode {
@NotNull
public final Identifier root;
Expand Down
3 changes: 3 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/JoinType.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.partiql.ast.v1;

import lombok.EqualsAndHashCode;

/**
* TODO docs, equals, hashcode
*/
@EqualsAndHashCode(callSuper = false)
public class JoinType implements Enum {
public static final int UNKNOWN = 0;
public static final int INNER = 1;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Let.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.partiql.ast.v1.expr.Expr;

Expand All @@ -12,6 +13,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class Let extends AstNode {
@NotNull
public final List<Binding> bindings;
Expand Down
3 changes: 3 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Nulls.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.partiql.ast.v1;

import lombok.EqualsAndHashCode;

/**
* TODO docs, equals, hashcode
*/
@EqualsAndHashCode(callSuper = false)
public class Nulls implements Enum {
public static final int UNKNOWN = 0;
public static final int FIRST = 1;
Expand Down
3 changes: 3 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Order.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.partiql.ast.v1;

import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = false)
public class Order implements Enum {
public static final int UNKNOWN = 0;
public static final int ASC = 1;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/OrderBy.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -11,6 +12,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class OrderBy extends AstNode {
@NotNull
public final List<Sort> sorts;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/Query.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.partiql.ast.v1.expr.Expr;

Expand All @@ -12,6 +13,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class Query extends Statement {
@NotNull
public final Expr expr;
Expand Down
3 changes: 3 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/QueryBody.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.v1.expr.Expr;
Expand All @@ -11,6 +12,7 @@

public abstract class QueryBody extends AstNode {
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static class SFW extends QueryBody {
@NotNull
public final Select select;
Expand Down Expand Up @@ -65,6 +67,7 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
}

@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static class SetOp extends QueryBody {
@NotNull
public final org.partiql.ast.v1.SetOp type;
Expand Down
3 changes: 3 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/SelectItem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -27,6 +28,7 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static class Star extends SelectItem {
@NotNull
public final org.partiql.ast.v1.expr.Expr expr;
Expand All @@ -53,6 +55,7 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public static class Expr extends SelectItem {
@NotNull
public final org.partiql.ast.v1.expr.Expr expr;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/SelectList.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -12,6 +13,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class SelectList extends Select {
@NotNull
public final List<SelectItem> items;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/SelectPivot.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.partiql.ast.v1.expr.Expr;

Expand All @@ -12,6 +13,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class SelectPivot extends Select {
@NotNull
public final Expr key;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/SelectStar.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -11,6 +12,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class SelectStar extends Select {
@Nullable
public final SetQuantifier setq;
Expand Down
2 changes: 2 additions & 0 deletions partiql-ast/src/main/java/org/partiql/ast/v1/SelectValue.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.partiql.ast.v1;

import lombok.Builder;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.partiql.ast.v1.expr.Expr;
Expand All @@ -13,6 +14,7 @@
* TODO docs, equals, hashcode
*/
@Builder(builderClassName = "Builder")
@EqualsAndHashCode(callSuper = false)
public class SelectValue extends Select {
@NotNull
public final Expr constructor;
Expand Down
Loading

0 comments on commit 34a0993

Please sign in to comment.