Skip to content

Commit

Permalink
roll back unintended changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yliuuuu committed Nov 27, 2024
1 parent 565fa71 commit c9f350a
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 6 deletions.
2 changes: 2 additions & 0 deletions partiql-ast/api/partiql-ast.api
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ public class org/partiql/ast/DataType : org/partiql/ast/AstEnum {
protected fun canEqual (Ljava/lang/Object;)Z
public fun children ()Ljava/util/Collection;
public fun code ()I
public static fun codes ()[I
public fun equals (Ljava/lang/Object;)Z
public fun getElementType ()Lorg/partiql/ast/DataType;
public fun getFields ()Ljava/util/List;
Expand All @@ -623,6 +624,7 @@ public class org/partiql/ast/DataType : org/partiql/ast/AstEnum {
public fun getScale ()Ljava/lang/Integer;
public fun hashCode ()I
public fun name ()Ljava/lang/String;
public static fun parse (Ljava/lang/String;)Lorg/partiql/ast/DataType;
}

public class org/partiql/ast/DataType$StructField : org/partiql/ast/AstNode {
Expand Down
113 changes: 112 additions & 1 deletion partiql-ast/src/main/java/org/partiql/ast/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public <R, C> R accept(@NotNull AstVisitor<R, C> visitor, C ctx) {
public static final int TUPLE = 43;
// <collection type>
public static final int LIST = 44;
public static final int ARRAY = 48;
public static final int ARRAY = 48; // TODO: Fix the numbering
public static final int BAG = 45;
public static final int SEXP = 46;
// <user defined type>
Expand Down Expand Up @@ -546,6 +546,117 @@ public String name() {
}
}

@NotNull
private static final int[] codes = {
NULL,
MISSING,
CHARACTER,
CHAR,
CHARACTER_VARYING,
CHAR_VARYING,
VARCHAR,
CHARACTER_LARGE_OBJECT,
CHAR_LARGE_OBJECT,
CLOB,
STRING,
SYMBOL,
BLOB,
BINARY_LARGE_OBJECT,
BIT,
BIT_VARYING,
NUMERIC,
DECIMAL,
DEC,
BIGINT,
INT8,
INTEGER8,
INT4,
INTEGER4,
INTEGER,
INT,
INT2,
INTEGER2,
SMALLINT,
TINYINT,
FLOAT,
REAL,
DOUBLE_PRECISION,
BOOLEAN,
BOOL,
DATE,
TIME,
TIME_WITH_TIME_ZONE,
TIMESTAMP,
TIMESTAMP_WITH_TIME_ZONE,
INTERVAL,
STRUCT,
TUPLE,
LIST,
ARRAY,
BAG,
SEXP,
USER_DEFINED
};

@NotNull
public static DataType parse(@NotNull String value) {
switch (value) {
case "NULL": return NULL();
case "MISSING": return MISSING();
case "BOOL": return BOOL();
case "BOOLEAN": return BOOLEAN();
case "TINYINT": return TINYINT();
case "SMALLINT": return SMALLINT();
case "INTEGER2": return INTEGER2();
case "INT2": return INT2();
case "INTEGER": return INTEGER();
case "INT": return INT();
case "INTEGER4": return INTEGER4();
case "INT4": return INT4();
case "INTEGER8": return INTEGER8();
case "INT8": return INT8();
case "BIGINT": return BIGINT();
case "REAL": return REAL();
case "DOUBLE_PRECISION": return DOUBLE_PRECISION();
case "FLOAT": return FLOAT();
case "DECIMAL": return DECIMAL();
case "DEC": return DEC();
case "NUMERIC": return NUMERIC();
case "BIT": return BIT();
case "BIT_VARYING": return BIT_VARYING();
case "CHAR": return CHAR();
case "CHARACTER": return CHARACTER();
case "VARCHAR": return VARCHAR();
case "CHARACTER_LARGE_OBJECT": return CHARACTER_LARGE_OBJECT();
case "CHAR_LARGE_OBJECT": return CHAR_LARGE_OBJECT();
case "CHAR_VARYING": return CHAR_VARYING();
case "STRING": return STRING();
case "SYMBOL": return SYMBOL();
case "BLOB": return BLOB();
case "BINARY_LARGE_OBJECT": return BINARY_LARGE_OBJECT();
case "CLOB": return CLOB();
case "DATE": return DATE();
case "STRUCT": return STRUCT();
case "TUPLE": return TUPLE();
case "LIST": return LIST();
case "ARRAY": return ARRAY();
case "SEXP": return SEXP();
case "BAG": return BAG();
case "TIME": return TIME();
case "TIME_WITH_TIME_ZONE": return TIME_WITH_TIME_ZONE();
case "TIMESTAMP": return TIMESTAMP();
case "TIMESTAMP_WITH_TIME_ZONE": return TIMESTAMP_WITH_TIME_ZONE();
case "INTERVAL": return INTERVAL();
case "USER_DEFINED": return USER_DEFINED();
default: return UNKNOWN();
}
}

@NotNull
public static int[] codes() {
return codes;
}

/**
* TODO docs
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ internal object NormalizeSelect {
* FROM t AS t
* ```
*
* In order to produce the struct's key in `{ '_1': t }` above, we use [col] to produce the columns name
* In order to produce the struct's key in `{ '_1': t }` above, we use [col] to produce the column name
* given the ordinal.
*/
private val col = { index: Int -> "_${index + 1}" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ internal class PlanTyper(private val env: Env, config: Context) {
* separation is cleaner as the typing of NULLS is subtly different.
*
* SQL-99 6.16 General Rules on <set function specification>
* Let TX be the single-columns table that is the result of applying the <value expression>
* Let TX be the single-column table that is the result of applying the <value expression>
* to each row of T and eliminating null values <--- all NULL values are eliminated as inputs
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4305,7 +4305,7 @@ internal class PlanTyperTestsPorted {
)
),
ErrorTestCase(
name = "Unknown columns",
name = "Unknown column",
catalog = CATALOG_DB,
catalogPath = DB_SCHEMA_MARKETS,
query = "SELECT unknown_col FROM orders WHERE customer_id = 1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import java.util.stream.Stream
*
* TODO: Model handling of Truth Value in typer better.
*/
class NullableIfTest : PartiQLTyperTestBase() {
class NullIfTest : PartiQLTyperTestBase() {

@TestFactory
fun nullIf(): Stream<DynamicContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.util.stream.Stream

// TODO: Finalize the semantics for IS NULL operator when operand is MISSING.
// For now, the IS NULL function can take missing as a operand, and returns TRUE.
class OpIsNullableTest : PartiQLTyperTestBase() {
class OpIsNullTest : PartiQLTyperTestBase() {
@TestFactory
fun isNull(): Stream<DynamicContainer> {
val tests = listOf(
Expand Down

0 comments on commit c9f350a

Please sign in to comment.