Skip to content

Commit

Permalink
Removes sexp and symbol from PType and Datum
Browse files Browse the repository at this point in the history
  • Loading branch information
johnedquinn committed Oct 28, 2024
1 parent 246b63c commit c8a186b
Show file tree
Hide file tree
Showing 90 changed files with 732 additions and 2,984 deletions.
1 change: 0 additions & 1 deletion partiql-ast/api/partiql-ast.api
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ public final class org/partiql/ast/Expr$Collection$Type : java/lang/Enum {
public static final field ARRAY Lorg/partiql/ast/Expr$Collection$Type;
public static final field BAG Lorg/partiql/ast/Expr$Collection$Type;
public static final field LIST Lorg/partiql/ast/Expr$Collection$Type;
public static final field SEXP Lorg/partiql/ast/Expr$Collection$Type;
public static final field VALUES Lorg/partiql/ast/Expr$Collection$Type;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lorg/partiql/ast/Expr$Collection$Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ public abstract class SqlDialect : AstBaseVisitor<SqlBlock, SqlBlock>() {
Expr.Collection.Type.ARRAY -> "[" to "]"
Expr.Collection.Type.VALUES -> "VALUES (" to ")"
Expr.Collection.Type.LIST -> "(" to ")"
Expr.Collection.Type.SEXP -> "SEXP (" to ")"
}
return tail concat list(start, end) { node.values }
}
Expand Down
1 change: 0 additions & 1 deletion partiql-ast/src/main/resources/partiql_ast.ion
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ expr::[
ARRAY, // [ ... ]
VALUES, // ( ... )
LIST, // LIST ( ... )
SEXP, // SEXP ( ... )
],
values: list::[expr],
},
Expand Down
13 changes: 0 additions & 13 deletions partiql-ast/src/test/kotlin/org/partiql/ast/sql/SqlDialectTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -739,19 +739,6 @@ class SqlDialectTest {
values += exprLit(int32Value(3))
}
},
expect("SEXP ()") {
exprCollection {
type = Expr.Collection.Type.SEXP
}
},
expect("SEXP (1, 2, 3)") {
exprCollection {
type = Expr.Collection.Type.SEXP
values += exprLit(int32Value(1))
values += exprLit(int32Value(2))
values += exprLit(int32Value(3))
}
},
)

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ internal class StandardCompiler : PartiQLCompiler {
// Compile the candidates
val candidates = Array(functions.size) {
val fn = functions[it]
val fnArity = fn.parameters.size
val fnArity = fn.getParameters().size
if (arity == -1) {
// set first
arity = fnArity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ internal object ValueUtility {
*/
fun Datum.getText(): String {
return when (this.type.kind) {
PType.Kind.STRING, PType.Kind.SYMBOL, PType.Kind.CHAR -> this.string
PType.Kind.STRING, PType.Kind.CHAR -> this.string
else -> throw TypeCheckException("Expected text, but received ${this.type}.")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal class RelOpExclude(
*/
private fun Datum.exclude(exclusions: List<Exclusion.Item>): Datum = when (this.type.kind) {
PType.Kind.ROW, PType.Kind.STRUCT -> this.structExclude(exclusions)
PType.Kind.BAG, PType.Kind.ARRAY, PType.Kind.SEXP -> this.collExclude(exclusions)
PType.Kind.BAG, PType.Kind.ARRAY -> this.collExclude(exclusions)
else -> this
}

Expand Down Expand Up @@ -140,7 +140,6 @@ internal class RelOpExclude(
return when (type.kind) {
PType.Kind.ARRAY -> Datum.list(coll)
PType.Kind.BAG -> Datum.bag(coll)
PType.Kind.SEXP -> Datum.sexp(coll)
else -> error("Collection type required")
}
}
Expand Down Expand Up @@ -173,7 +172,7 @@ internal class RelOpExclude(
// apply exclusions to subtree
var value = element
// apply collection index exclusions at deeper levels for lists and sexps
if (type.kind == PType.Kind.ARRAY || type.kind == PType.Kind.SEXP) {
if (type.kind == PType.Kind.ARRAY) {
branches.getCollIndex(i)?.let {
value = value.exclude(it.getItems())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class RelOpIterate(
close()
throw TypeCheckException()
}
PType.Kind.ARRAY, PType.Kind.SEXP -> r.iterator()
PType.Kind.ARRAY -> r.iterator()
else -> {
close()
throw TypeCheckException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class RelOpIteratePermissive(
isIndexable = false
r.iterator()
}
PType.Kind.ARRAY, PType.Kind.SEXP -> r.iterator()
PType.Kind.ARRAY -> r.iterator()
else -> {
isIndexable = false
iterator { yield(r) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class RelOpScan(
override fun open(env: Environment) {
val r = expr.eval(env.push(Row()))
records = when (r.type.kind) {
PType.Kind.ARRAY, PType.Kind.BAG, PType.Kind.SEXP -> RecordValueIterator(r.iterator())
PType.Kind.ARRAY, PType.Kind.BAG -> RecordValueIterator(r.iterator())
else -> {
close()
throw TypeCheckException("Unexpected type for scan: ${r.type}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class RelOpScanPermissive(
override fun open(env: Environment) {
val r = expr.eval(env.push(Row()))
records = when (r.type.kind) {
PType.Kind.BAG, PType.Kind.ARRAY, PType.Kind.SEXP -> RecordValueIterator(r.iterator())
PType.Kind.BAG, PType.Kind.ARRAY -> RecordValueIterator(r.iterator())
else -> iterator { yield(Row(arrayOf(r))) }
}
}
Expand Down
Loading

0 comments on commit c8a186b

Please sign in to comment.