forked from partiql/partiql-lang-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
532 additions
and
40 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
82 changes: 82 additions & 0 deletions
82
partiql-ast/src/main/java/org/partiql/ast/WindowFunctionNullTreatment.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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package org.partiql.ast; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
@EqualsAndHashCode(callSuper = false) | ||
public final class WindowFunctionNullTreatment extends AstEnum { | ||
/** | ||
* TODO | ||
*/ | ||
public static final int RESPECT_NULLS = 0; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
public static final int IGNORE_NULLS = 1; | ||
|
||
/** | ||
* TODO | ||
* @return TODO | ||
*/ | ||
public static WindowFunctionNullTreatment RESPECT_NULLS() { | ||
return new WindowFunctionNullTreatment(RESPECT_NULLS); | ||
} | ||
|
||
/** | ||
* TODO | ||
* @return TODO | ||
*/ | ||
public static WindowFunctionNullTreatment IGNORE_NULLS() { | ||
return new WindowFunctionNullTreatment(IGNORE_NULLS); | ||
} | ||
|
||
private final int code; | ||
|
||
private WindowFunctionNullTreatment(int code) { | ||
this.code = code; | ||
} | ||
|
||
@Override | ||
public int code() { | ||
return code; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String name() { | ||
switch (code) { | ||
case RESPECT_NULLS: return "RESPECT_NULLS"; | ||
case IGNORE_NULLS: return "DISTINCT"; | ||
default: throw new IllegalStateException("Invalid code: " + code); | ||
} | ||
} | ||
|
||
@NotNull | ||
private static final int[] codes = { | ||
RESPECT_NULLS, | ||
IGNORE_NULLS | ||
}; | ||
|
||
@NotNull | ||
public static int[] codes() { | ||
return codes; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public List<AstNode> getChildren() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) { | ||
return null; | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
partiql-ast/src/main/java/org/partiql/ast/WindowFunctionSimpleName.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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package org.partiql.ast; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
@EqualsAndHashCode(callSuper = false) | ||
public final class WindowFunctionSimpleName extends AstEnum { | ||
/** | ||
* TODO | ||
*/ | ||
public static final int RANK = 0; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
public static final int DENSE_RANK = 1; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
public static final int PERCENT_RANK = 2; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
public static final int CUME_DIST = 3; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
public static final int ROW_NUMBER = 4; | ||
|
||
/** | ||
* TODO | ||
* @return TODO | ||
*/ | ||
public static WindowFunctionSimpleName RANK() { | ||
return new WindowFunctionSimpleName(RANK); | ||
} | ||
|
||
/** | ||
* TODO | ||
* @return TODO | ||
*/ | ||
public static WindowFunctionSimpleName DENSE_RANK() { | ||
return new WindowFunctionSimpleName(DENSE_RANK); | ||
} | ||
|
||
private final int code; | ||
|
||
private WindowFunctionSimpleName(int code) { | ||
this.code = code; | ||
} | ||
|
||
@Override | ||
public int code() { | ||
return code; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String name() { | ||
switch (code) { | ||
case RANK: return "RANK"; | ||
case DENSE_RANK: return "DENSE_RANK"; | ||
case PERCENT_RANK: return "PERCENT_RANK"; | ||
case CUME_DIST: return "CUME_DIST"; | ||
case ROW_NUMBER: return "ROW_NUMBER"; | ||
default: throw new IllegalStateException("Invalid code: " + code); | ||
} | ||
} | ||
|
||
@NotNull | ||
private static final int[] codes = { | ||
RANK, | ||
DENSE_RANK, | ||
PERCENT_RANK, | ||
CUME_DIST, | ||
ROW_NUMBER | ||
}; | ||
|
||
@NotNull | ||
public static int[] codes() { | ||
return codes; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public List<AstNode> getChildren() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) { | ||
return null; | ||
} | ||
} |
Oops, something went wrong.