From 1e1a71f7ee06fce56f88f437a20d47b775635332 Mon Sep 17 00:00:00 2001 From: "R. C. Howell" Date: Tue, 16 Jan 2024 09:44:36 -0800 Subject: [PATCH 1/4] Adds qualifiers to function call expressions (#1337) --- .../lang/syntax/impl/PartiQLPigVisitor.kt | 87 ++++++----- partiql-parser/src/main/antlr/PartiQL.g4 | 12 +- .../org/partiql/parser/PartiQLParser.kt | 2 +- .../partiql/parser/PartiQLParserBuilder.kt | 2 +- .../PartiQLParserDefault.kt | 35 +++-- .../{impl => internal}/util/DateTimeUtils.kt | 2 +- .../PartiQLParserFunctionCallTests.kt | 136 ++++++++++++++++++ .../PartiQLParserSessionAttributeTests.kt | 2 +- 8 files changed, 226 insertions(+), 52 deletions(-) rename partiql-parser/src/main/kotlin/org/partiql/parser/{impl => internal}/PartiQLParserDefault.kt (98%) rename partiql-parser/src/main/kotlin/org/partiql/parser/{impl => internal}/util/DateTimeUtils.kt (98%) create mode 100644 partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserFunctionCallTests.kt rename partiql-parser/src/test/kotlin/org/partiql/parser/{impl => internal}/PartiQLParserSessionAttributeTests.kt (98%) diff --git a/partiql-lang/src/main/kotlin/org/partiql/lang/syntax/impl/PartiQLPigVisitor.kt b/partiql-lang/src/main/kotlin/org/partiql/lang/syntax/impl/PartiQLPigVisitor.kt index ee93af85ee..1d10d5ce49 100644 --- a/partiql-lang/src/main/kotlin/org/partiql/lang/syntax/impl/PartiQLPigVisitor.kt +++ b/partiql-lang/src/main/kotlin/org/partiql/lang/syntax/impl/PartiQLPigVisitor.kt @@ -36,7 +36,6 @@ import com.amazon.ionelement.api.loadSingleElement import org.antlr.v4.runtime.ParserRuleContext import org.antlr.v4.runtime.Token import org.antlr.v4.runtime.tree.TerminalNode -import org.partiql.ast.Identifier import org.partiql.errors.ErrorCode import org.partiql.errors.Property import org.partiql.errors.PropertyValueMap @@ -118,7 +117,7 @@ import java.time.format.DateTimeParseException */ internal class PartiQLPigVisitor( val customTypes: List = listOf(), - private val parameterIndexes: Map = mapOf() + private val parameterIndexes: Map = mapOf(), ) : PartiQLBaseVisitor() { @@ -648,19 +647,22 @@ internal class PartiQLPigVisitor( excludeTupleAttr(identifier(attr, caseSensitivity)) } - override fun visitExcludeExprCollectionIndex(ctx: PartiQLParser.ExcludeExprCollectionIndexContext) = PartiqlAst.build { - val index = ctx.index.text.toInteger().toLong() - excludeCollectionIndex(index) - } + override fun visitExcludeExprCollectionIndex(ctx: PartiQLParser.ExcludeExprCollectionIndexContext) = + PartiqlAst.build { + val index = ctx.index.text.toInteger().toLong() + excludeCollectionIndex(index) + } - override fun visitExcludeExprCollectionAttr(ctx: PartiQLParser.ExcludeExprCollectionAttrContext) = PartiqlAst.build { - val attr = ctx.attr.getStringValue() - excludeTupleAttr(identifier(attr, caseSensitive())) - } + override fun visitExcludeExprCollectionAttr(ctx: PartiQLParser.ExcludeExprCollectionAttrContext) = + PartiqlAst.build { + val attr = ctx.attr.getStringValue() + excludeTupleAttr(identifier(attr, caseSensitive())) + } - override fun visitExcludeExprCollectionWildcard(ctx: PartiQLParser.ExcludeExprCollectionWildcardContext) = PartiqlAst.build { - excludeCollectionWildcard() - } + override fun visitExcludeExprCollectionWildcard(ctx: PartiQLParser.ExcludeExprCollectionWildcardContext) = + PartiqlAst.build { + excludeCollectionWildcard() + } override fun visitExcludeExprTupleWildcard(ctx: PartiQLParser.ExcludeExprTupleWildcardContext) = PartiqlAst.build { excludeTupleWildcard() @@ -1292,17 +1294,20 @@ internal class PartiQLPigVisitor( canLosslessCast(expr, type, metas) } - override fun visitFunctionCallIdent(ctx: PartiQLParser.FunctionCallIdentContext) = PartiqlAst.build { - val name = ctx.name.getString().lowercase() - val args = ctx.expr().map { visitExpr(it) } - val metas = ctx.name.getSourceMetaContainer() - call(name, args = args, metas = metas) - } - - override fun visitFunctionCallReserved(ctx: PartiQLParser.FunctionCallReservedContext) = PartiqlAst.build { - val name = ctx.name.text.lowercase() + override fun visitFunctionCall(ctx: PartiQLParser.FunctionCallContext) = PartiqlAst.build { + val name = when (val nameCtx = ctx.functionName()) { + is PartiQLParser.FunctionNameReservedContext -> { + if (nameCtx.qualifier.isNotEmpty()) error("Legacy AST does not support qualified function names") + nameCtx.name.text.lowercase() + } + is PartiQLParser.FunctionNameSymbolContext -> { + if (nameCtx.qualifier.isNotEmpty()) error("Legacy AST does not support qualified function names") + nameCtx.name.getString().lowercase() + } + else -> error("Expected context FunctionNameReserved or FunctionNameSymbol") + } val args = ctx.expr().map { visitExpr(it) } - val metas = ctx.name.getSourceMetaContainer() + val metas = ctx.start.getSourceMetaContainer() call(name, args = args, metas = metas) } @@ -1693,7 +1698,7 @@ internal class PartiQLPigVisitor( lhs: ParserRuleContext?, rhs: ParserRuleContext?, op: Token?, - parent: ParserRuleContext? = null + parent: ParserRuleContext? = null, ) = PartiqlAst.build { if (parent != null) return@build visit(parent) as PartiqlAst.Expr val args = listOf(lhs!!, rhs!!).map { visit(it) as PartiqlAst.Expr } @@ -1847,7 +1852,7 @@ internal class PartiQLPigVisitor( withTimeZone: Boolean, precision: Long, stringNode: TerminalNode, - timeNode: TerminalNode + timeNode: TerminalNode, ) = PartiqlAst.build { val time: LocalTime val formatter = when (withTimeZone) { @@ -1871,7 +1876,7 @@ internal class PartiQLPigVisitor( private fun getTimestampStringAndPrecision( stringNode: TerminalNode, - integerNode: TerminalNode? + integerNode: TerminalNode?, ): Pair { val timestampString = stringNode.getStringValue() val precision = when (integerNode) { @@ -1890,7 +1895,7 @@ internal class PartiQLPigVisitor( private fun getTimestampDynamic( timestampString: String, precision: Long?, - node: TerminalNode + node: TerminalNode, ) = PartiqlAst.build { val timestamp = try { @@ -1901,9 +1906,14 @@ internal class PartiQLPigVisitor( val timeZone = timestamp.timeZone?.let { getTimeZone(it) } timestamp( timestampValue( - timestamp.year.toLong(), timestamp.month.toLong(), timestamp.day.toLong(), - timestamp.hour.toLong(), timestamp.minute.toLong(), ionDecimal(Decimal.valueOf(timestamp.decimalSecond)), - timeZone, precision + timestamp.year.toLong(), + timestamp.month.toLong(), + timestamp.day.toLong(), + timestamp.hour.toLong(), + timestamp.minute.toLong(), + ionDecimal(Decimal.valueOf(timestamp.decimalSecond)), + timeZone, + precision ) ) } @@ -1911,7 +1921,7 @@ internal class PartiQLPigVisitor( private fun getTimestampWithTimezone( timestampString: String, precision: Long?, - node: TerminalNode + node: TerminalNode, ) = PartiqlAst.build { val timestamp = try { DateTimeUtils.parseTimestamp(timestampString) @@ -1926,9 +1936,14 @@ internal class PartiQLPigVisitor( val timeZone = timestamp.timeZone?.let { getTimeZone(it) } timestamp( timestampValue( - timestamp.year.toLong(), timestamp.month.toLong(), timestamp.day.toLong(), - timestamp.hour.toLong(), timestamp.minute.toLong(), ionDecimal(Decimal.valueOf(timestamp.decimalSecond)), - timeZone, precision + timestamp.year.toLong(), + timestamp.month.toLong(), + timestamp.day.toLong(), + timestamp.hour.toLong(), + timestamp.minute.toLong(), + ionDecimal(Decimal.valueOf(timestamp.decimalSecond)), + timeZone, + precision ) ) } @@ -2124,13 +2139,13 @@ internal class PartiQLPigVisitor( msg: String, code: ErrorCode, ctx: PropertyValueMap = PropertyValueMap(), - cause: Throwable? = null + cause: Throwable? = null, ) = this.error(msg, code, ctx, cause) private fun Token?.err( msg: String, code: ErrorCode, ctx: PropertyValueMap = PropertyValueMap(), - cause: Throwable? = null + cause: Throwable? = null, ) = this.error(msg, code, ctx, cause) } diff --git a/partiql-parser/src/main/antlr/PartiQL.g4 b/partiql-parser/src/main/antlr/PartiQL.g4 index 3567e022ef..748d038366 100644 --- a/partiql-parser/src/main/antlr/PartiQL.g4 +++ b/partiql-parser/src/main/antlr/PartiQL.g4 @@ -709,11 +709,15 @@ trimFunction dateFunction : func=(DATE_ADD|DATE_DIFF) PAREN_LEFT dt=IDENTIFIER COMMA expr COMMA expr PAREN_RIGHT; +// SQL-99 10.4 — ::= functionCall - : name=( CHAR_LENGTH | CHARACTER_LENGTH | OCTET_LENGTH | - BIT_LENGTH | UPPER | LOWER | SIZE | EXISTS | COUNT ) - PAREN_LEFT ( expr ( COMMA expr )* )? PAREN_RIGHT # FunctionCallReserved - | name=symbolPrimitive PAREN_LEFT ( expr ( COMMA expr )* )? PAREN_RIGHT # FunctionCallIdent + : functionName PAREN_LEFT ( expr ( COMMA expr )* )? PAREN_RIGHT + ; + +// SQL-99 10.4 — ::= [ ] +functionName + : (qualifier+=symbolPrimitive PERIOD)* name=( CHAR_LENGTH | CHARACTER_LENGTH | OCTET_LENGTH | BIT_LENGTH | UPPER | LOWER | SIZE | EXISTS | COUNT ) # FunctionNameReserved + | (qualifier+=symbolPrimitive PERIOD)* name=symbolPrimitive # FunctionNameSymbol ; pathStep diff --git a/partiql-parser/src/main/kotlin/org/partiql/parser/PartiQLParser.kt b/partiql-parser/src/main/kotlin/org/partiql/parser/PartiQLParser.kt index 8cbf60dd6b..fe8efc2949 100644 --- a/partiql-parser/src/main/kotlin/org/partiql/parser/PartiQLParser.kt +++ b/partiql-parser/src/main/kotlin/org/partiql/parser/PartiQLParser.kt @@ -15,7 +15,7 @@ package org.partiql.parser import org.partiql.ast.Statement -import org.partiql.parser.impl.PartiQLParserDefault +import org.partiql.parser.internal.PartiQLParserDefault public interface PartiQLParser { diff --git a/partiql-parser/src/main/kotlin/org/partiql/parser/PartiQLParserBuilder.kt b/partiql-parser/src/main/kotlin/org/partiql/parser/PartiQLParserBuilder.kt index b985ed7b04..1a918b0094 100644 --- a/partiql-parser/src/main/kotlin/org/partiql/parser/PartiQLParserBuilder.kt +++ b/partiql-parser/src/main/kotlin/org/partiql/parser/PartiQLParserBuilder.kt @@ -14,7 +14,7 @@ package org.partiql.parser -import org.partiql.parser.impl.PartiQLParserDefault +import org.partiql.parser.internal.PartiQLParserDefault /** * A builder class to instantiate a [PartiQLParser]. diff --git a/partiql-parser/src/main/kotlin/org/partiql/parser/impl/PartiQLParserDefault.kt b/partiql-parser/src/main/kotlin/org/partiql/parser/internal/PartiQLParserDefault.kt similarity index 98% rename from partiql-parser/src/main/kotlin/org/partiql/parser/impl/PartiQLParserDefault.kt rename to partiql-parser/src/main/kotlin/org/partiql/parser/internal/PartiQLParserDefault.kt index 870f427420..73a029b6e9 100644 --- a/partiql-parser/src/main/kotlin/org/partiql/parser/impl/PartiQLParserDefault.kt +++ b/partiql-parser/src/main/kotlin/org/partiql/parser/internal/PartiQLParserDefault.kt @@ -12,7 +12,7 @@ * language governing permissions and limitations under the License. */ -package org.partiql.parser.impl +package org.partiql.parser.internal import com.amazon.ionelement.api.IntElement import com.amazon.ionelement.api.IntElementSize @@ -118,6 +118,7 @@ import org.partiql.ast.graphMatchSelectorShortestK import org.partiql.ast.graphMatchSelectorShortestKGroup import org.partiql.ast.groupBy import org.partiql.ast.groupByKey +import org.partiql.ast.identifierQualified import org.partiql.ast.identifierSymbol import org.partiql.ast.let import org.partiql.ast.letBinding @@ -208,7 +209,7 @@ import org.partiql.parser.PartiQLSyntaxException import org.partiql.parser.SourceLocation import org.partiql.parser.SourceLocations import org.partiql.parser.antlr.PartiQLBaseVisitor -import org.partiql.parser.impl.util.DateTimeUtils +import org.partiql.parser.internal.util.DateTimeUtils import org.partiql.value.NumericValue import org.partiql.value.PartiQLValueExperimental import org.partiql.value.StringValue @@ -1723,16 +1724,34 @@ internal class PartiQLParserDefault : PartiQLParser { exprCanLosslessCast(expr, type) } - override fun visitFunctionCallIdent(ctx: GeneratedParser.FunctionCallIdentContext) = translate(ctx) { - val function = visitSymbolPrimitive(ctx.name) + override fun visitFunctionCall(ctx: GeneratedParser.FunctionCallContext) = translate(ctx) { + val function = visit(ctx.functionName()) as Identifier val args = visitOrEmpty(ctx.expr()) exprCall(function, args) } - override fun visitFunctionCallReserved(ctx: GeneratedParser.FunctionCallReservedContext) = translate(ctx) { - val function = ctx.name.text.toIdentifier() - val args = visitOrEmpty(ctx.expr()) - exprCall(function, args) + override fun visitFunctionNameReserved(ctx: GeneratedParser.FunctionNameReservedContext): Identifier { + val path = ctx.qualifier.map { visitSymbolPrimitive(it) } + val name = identifierSymbol(ctx.name.text, Identifier.CaseSensitivity.INSENSITIVE) + return if (path.isEmpty()) { + name + } else { + val root = path.first() + val steps = path.drop(1) + listOf(name) + identifierQualified(root, steps) + } + } + + override fun visitFunctionNameSymbol(ctx: GeneratedParser.FunctionNameSymbolContext): Identifier { + val path = ctx.qualifier.map { visitSymbolPrimitive(it) } + val name = visitSymbolPrimitive(ctx.name) + return if (path.isEmpty()) { + name + } else { + val root = path.first() + val steps = path.drop(1) + listOf(name) + identifierQualified(root, steps) + } } /** diff --git a/partiql-parser/src/main/kotlin/org/partiql/parser/impl/util/DateTimeUtils.kt b/partiql-parser/src/main/kotlin/org/partiql/parser/internal/util/DateTimeUtils.kt similarity index 98% rename from partiql-parser/src/main/kotlin/org/partiql/parser/impl/util/DateTimeUtils.kt rename to partiql-parser/src/main/kotlin/org/partiql/parser/internal/util/DateTimeUtils.kt index ea4b9a1a70..02fa77c482 100644 --- a/partiql-parser/src/main/kotlin/org/partiql/parser/impl/util/DateTimeUtils.kt +++ b/partiql-parser/src/main/kotlin/org/partiql/parser/internal/util/DateTimeUtils.kt @@ -1,4 +1,4 @@ -package org.partiql.parser.impl.util +package org.partiql.parser.internal.util import org.partiql.value.datetime.Date import org.partiql.value.datetime.DateTimeException diff --git a/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserFunctionCallTests.kt b/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserFunctionCallTests.kt new file mode 100644 index 0000000000..a562805895 --- /dev/null +++ b/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserFunctionCallTests.kt @@ -0,0 +1,136 @@ +package org.partiql.parser.internal + +import org.junit.jupiter.api.Test +import org.partiql.ast.AstNode +import org.partiql.ast.Expr +import org.partiql.ast.Identifier +import org.partiql.ast.exprCall +import org.partiql.ast.identifierQualified +import org.partiql.ast.identifierSymbol +import org.partiql.ast.statementQuery +import kotlin.test.assertEquals + +class PartiQLParserFunctionCallTests { + + private val parser = PartiQLParserDefault() + + private inline fun query(body: () -> Expr) = statementQuery(body()) + + @Test + fun callUnqualifiedNonReservedInsensitive() = assertExpression( + "foo()", + query { + exprCall( + function = identifierSymbol("foo", Identifier.CaseSensitivity.INSENSITIVE), + args = emptyList() + ) + } + ) + + @Test + fun callUnqualifiedNonReservedSensitive() = assertExpression( + "\"foo\"()", + query { + exprCall( + function = identifierSymbol("foo", Identifier.CaseSensitivity.SENSITIVE), + args = emptyList() + ) + } + ) + + @Test + fun callUnqualifiedReservedInsensitive() = assertExpression( + "upper()", + query { + exprCall( + function = identifierSymbol("upper", Identifier.CaseSensitivity.INSENSITIVE), + args = emptyList() + ) + } + ) + + @Test + fun callUnqualifiedReservedSensitive() = assertExpression( + "\"upper\"()", + query { + exprCall( + function = identifierSymbol("upper", Identifier.CaseSensitivity.SENSITIVE), + args = emptyList() + ) + } + ) + + @Test + fun callQualifiedNonReservedInsensitive() = assertExpression( + "my_catalog.my_schema.foo()", + query { + exprCall( + function = identifierQualified( + root = identifierSymbol("my_catalog", Identifier.CaseSensitivity.INSENSITIVE), + steps = listOf( + identifierSymbol("my_schema", Identifier.CaseSensitivity.INSENSITIVE), + identifierSymbol("foo", Identifier.CaseSensitivity.INSENSITIVE), + ) + ), + args = emptyList() + ) + } + ) + + @Test + fun callQualifiedNonReservedSensitive() = assertExpression( + "my_catalog.my_schema.\"foo\"()", + query { + exprCall( + function = identifierQualified( + root = identifierSymbol("my_catalog", Identifier.CaseSensitivity.INSENSITIVE), + steps = listOf( + identifierSymbol("my_schema", Identifier.CaseSensitivity.INSENSITIVE), + identifierSymbol("foo", Identifier.CaseSensitivity.SENSITIVE), + ) + ), + args = emptyList() + ) + } + ) + + @Test + fun callQualifiedReservedInsensitive() = assertExpression( + "my_catalog.my_schema.upper()", + query { + exprCall( + function = identifierQualified( + root = identifierSymbol("my_catalog", Identifier.CaseSensitivity.INSENSITIVE), + steps = listOf( + identifierSymbol("my_schema", Identifier.CaseSensitivity.INSENSITIVE), + identifierSymbol("upper", Identifier.CaseSensitivity.INSENSITIVE), + ) + ), + args = emptyList() + ) + } + ) + + @Test + fun callQualifiedReservedSensitive() = assertExpression( + "my_catalog.my_schema.\"upper\"()", + query { + exprCall( + function = identifierQualified( + root = identifierSymbol("my_catalog", Identifier.CaseSensitivity.INSENSITIVE), + steps = listOf( + identifierSymbol("my_schema", Identifier.CaseSensitivity.INSENSITIVE), + identifierSymbol("upper", Identifier.CaseSensitivity.SENSITIVE), + ) + ), + args = emptyList() + ) + } + ) + + private fun assertExpression(input: String, expected: AstNode) { + val result = parser.parse(input) + val actual = result.root + assertEquals(expected, actual) + } +} diff --git a/partiql-parser/src/test/kotlin/org/partiql/parser/impl/PartiQLParserSessionAttributeTests.kt b/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserSessionAttributeTests.kt similarity index 98% rename from partiql-parser/src/test/kotlin/org/partiql/parser/impl/PartiQLParserSessionAttributeTests.kt rename to partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserSessionAttributeTests.kt index 1748db55fb..7d02f659ff 100644 --- a/partiql-parser/src/test/kotlin/org/partiql/parser/impl/PartiQLParserSessionAttributeTests.kt +++ b/partiql-parser/src/test/kotlin/org/partiql/parser/internal/PartiQLParserSessionAttributeTests.kt @@ -1,4 +1,4 @@ -package org.partiql.parser.impl +package org.partiql.parser.internal import org.junit.jupiter.api.Test import org.partiql.ast.AstNode From 05c591ce80e88598a10faa4434e42d70f33000fe Mon Sep 17 00:00:00 2001 From: "R. C. Howell" Date: Fri, 19 Jan 2024 09:36:32 -0800 Subject: [PATCH 2/4] Adds the explicit decimal to integer downcasts (#1342) --- .../planner/internal/typer/TypeLattice.kt | 42 +++++++++++------ .../internal/typer/PlanTyperTestsPorted.kt | 46 +++++++++++++++++++ .../catalogs/default/pql/numbers.ion | 5 ++ .../inputs/schema_inferencer/casts.sql | 17 +++++++ 4 files changed, 97 insertions(+), 13 deletions(-) create mode 100644 partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/casts.sql diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeLattice.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeLattice.kt index bdf0222697..767dd91922 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeLattice.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeLattice.kt @@ -266,41 +266,57 @@ internal class TypeLattice private constructor( SYMBOL to explicit(), ) graph[DECIMAL] = relationships( + BOOL to explicit(), INT8 to explicit(), INT16 to explicit(), INT32 to explicit(), INT64 to explicit(), - BOOL to explicit(), - DECIMAL to explicit(), - DECIMAL_ARBITRARY to explicit(), + INT to explicit(), + DECIMAL to coercion(), + DECIMAL_ARBITRARY to coercion(), FLOAT32 to explicit(), FLOAT64 to explicit(), STRING to explicit(), SYMBOL to explicit(), ) - graph[FLOAT32] = relationships( + graph[DECIMAL_ARBITRARY] = relationships( BOOL to explicit(), - DECIMAL to explicit(), + INT8 to explicit(), + INT16 to explicit(), + INT32 to explicit(), + INT64 to explicit(), + INT to explicit(), + DECIMAL to coercion(), DECIMAL_ARBITRARY to coercion(), - FLOAT32 to coercion(), - FLOAT64 to coercion(), + FLOAT32 to explicit(), + FLOAT64 to explicit(), STRING to explicit(), SYMBOL to explicit(), ) - graph[FLOAT64] = relationships( + graph[FLOAT32] = relationships( BOOL to explicit(), - DECIMAL to explicit(), + INT8 to unsafe(), + INT16 to unsafe(), + INT32 to unsafe(), + INT64 to unsafe(), + INT to unsafe(), + DECIMAL to unsafe(), DECIMAL_ARBITRARY to coercion(), + FLOAT32 to coercion(), FLOAT64 to coercion(), STRING to explicit(), SYMBOL to explicit(), ) - graph[DECIMAL_ARBITRARY] = relationships( + graph[FLOAT64] = relationships( BOOL to explicit(), - DECIMAL to explicit(), + INT8 to unsafe(), + INT16 to unsafe(), + INT32 to unsafe(), + INT64 to unsafe(), + INT to unsafe(), + DECIMAL to unsafe(), DECIMAL_ARBITRARY to coercion(), - FLOAT32 to explicit(), - FLOAT64 to explicit(), + FLOAT64 to coercion(), STRING to explicit(), SYMBOL to explicit(), ) diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt index 0f7b548c92..ad8114067c 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt @@ -33,6 +33,7 @@ import org.partiql.types.BagType import org.partiql.types.ListType import org.partiql.types.SexpType import org.partiql.types.StaticType +import org.partiql.types.StaticType.Companion.unionOf import org.partiql.types.StructType import org.partiql.types.TupleConstraint import java.util.stream.Stream @@ -448,6 +449,46 @@ class PlanTyperTestsPorted { ), ) + @JvmStatic + fun castCases() = listOf( + SuccessTestCase( + name = "DECIMAL AS INT2", + key = key("cast-00"), + catalog = "pql", + expected = StaticType.INT2, + ), + SuccessTestCase( + name = "DECIMAL AS INT4", + key = key("cast-01"), + catalog = "pql", + expected = StaticType.INT4, + ), + SuccessTestCase( + name = "DECIMAL AS INT8", + key = key("cast-02"), + catalog = "pql", + expected = StaticType.INT8, + ), + SuccessTestCase( + name = "DECIMAL AS INT", + key = key("cast-03"), + catalog = "pql", + expected = StaticType.INT, + ), + SuccessTestCase( + name = "DECIMAL AS BIGINT", + key = key("cast-04"), + catalog = "pql", + expected = StaticType.INT8, + ), + SuccessTestCase( + name = "DECIMAL_ARBITRARY AS DECIMAL", + key = key("cast-05"), + catalog = "pql", + expected = StaticType.DECIMAL, + ), + ) + @JvmStatic fun sessionVariables() = listOf( SuccessTestCase( @@ -3040,6 +3081,11 @@ class PlanTyperTestsPorted { @Execution(ExecutionMode.CONCURRENT) fun testIsType(tc: TestCase) = runTest(tc) + @ParameterizedTest + @MethodSource("castCases") + @Execution(ExecutionMode.CONCURRENT) + fun testCasts(tc: TestCase) = runTest(tc) + // --------- Finish Parameterized Tests ------ // diff --git a/partiql-planner/src/testFixtures/resources/catalogs/default/pql/numbers.ion b/partiql-planner/src/testFixtures/resources/catalogs/default/pql/numbers.ion index 14c03f7135..311e5a474d 100644 --- a/partiql-planner/src/testFixtures/resources/catalogs/default/pql/numbers.ion +++ b/partiql-planner/src/testFixtures/resources/catalogs/default/pql/numbers.ion @@ -1,5 +1,6 @@ { type: "struct", + constraints: [closed], fields: [ { name: "nullable_int16s", @@ -69,6 +70,10 @@ items: "int", }, }, + { + name: "d", + type: "decimal", + }, { name: "decimals", type: { diff --git a/partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/casts.sql b/partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/casts.sql new file mode 100644 index 0000000000..c1416bad80 --- /dev/null +++ b/partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/casts.sql @@ -0,0 +1,17 @@ +--#[cast-00] +CAST(numbers.d AS INT2); + +--#[cast-01] +CAST(numbers.d AS INT4); + +--#[cast-02] +CAST(numbers.d AS INT8); + +--#[cast-03] +CAST(numbers.d AS INT); + +--#[cast-04] +CAST(numbers.d AS BIGINT); + +--#[cast-05] +CAST(numbers.d AS DECIMAL); From d37369e8e81a7456b99545455882812332938740 Mon Sep 17 00:00:00 2001 From: "R. C. Howell" Date: Fri, 19 Jan 2024 10:37:01 -0800 Subject: [PATCH 3/4] Generate internalized planning IR (#1339) --- partiql-planner/build.gradle.kts | 51 + .../partiql/planner/PartiQLPlannerDefault.kt | 2 - .../org/partiql/planner/internal/ir/Nodes.kt | 647 ++---- .../org/partiql/planner/internal/ir/Plan.kt | 182 -- .../internal/ir/builder/PlanBuilder.kt | 568 ----- .../internal/ir/builder/PlanBuilders.kt | 846 ------- .../planner/internal/ir/util/PlanRewriter.kt | 606 ----- .../internal/ir/visitor/PlanBaseVisitor.kt | 273 --- .../internal/ir/visitor/PlanVisitor.kt | 153 -- .../src/main/resources/builtins.sql | 1681 -------------- partiql-planner/src/main/resources/casts.sql | 1982 ---------------- .../src/main/resources/operators.sql | 2031 ----------------- .../main/resources/partiql_plan_internal.ion | 342 +++ 13 files changed, 639 insertions(+), 8725 deletions(-) delete mode 100644 partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Plan.kt delete mode 100644 partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/builder/PlanBuilder.kt delete mode 100644 partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/builder/PlanBuilders.kt delete mode 100644 partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/util/PlanRewriter.kt delete mode 100644 partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/visitor/PlanBaseVisitor.kt delete mode 100644 partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/visitor/PlanVisitor.kt delete mode 100644 partiql-planner/src/main/resources/builtins.sql delete mode 100644 partiql-planner/src/main/resources/casts.sql delete mode 100644 partiql-planner/src/main/resources/operators.sql create mode 100644 partiql-planner/src/main/resources/partiql_plan_internal.ion diff --git a/partiql-planner/build.gradle.kts b/partiql-planner/build.gradle.kts index aca57c6517..f43b9a660f 100644 --- a/partiql-planner/build.gradle.kts +++ b/partiql-planner/build.gradle.kts @@ -77,3 +77,54 @@ publish { name = "PartiQL Planner" description = "PartiQL's Experimental Planner." } + +// Generate internal IR +tasks.register("codegen") { + dependsOn(":lib:sprout:install") + workingDir(projectDir) + commandLine( + "../lib/sprout/build/install/sprout/bin/sprout", + "generate", + "kotlin", + "-o", "$buildDir/tmp", + "-p", "org.partiql.planner.internal.ir", + "-u", "Plan", + "--poems", "factory", + "--poems", "visitor", + "--poems", "builder", + "--poems", "util", + "--opt-in", "org.partiql.value.PartiQLValueExperimental", + "./src/main/resources/partiql_plan_internal.ion" + ) +} + +// Copy generated utilities to generated-src +tasks.register("copyUtils") { + includeEmptyDirs = false + dependsOn("codegen") + filter { it.replace(Regex("public (?!(override|(fun visit)))"), "internal ") } + from("$buildDir/tmp") + exclude("**/Nodes.kt") + into("$buildDir/generated-src") +} + +// Copy generated Nodes.kt to src +// +// !! IMPORTANT !! — only run manually, as this will overwrite the existing ir/Nodes.kt. +// +tasks.register("copyNodes") { + includeEmptyDirs = false + dependsOn("codegen") + filter { it.replace(Regex("public (?!(override|(fun visit)))"), "internal ") } + from("$buildDir/tmp") + include("**/Nodes.kt") + into("src/main/kotlin") +} + +tasks.register("generate") { + dependsOn("codegen", "copyUtils") +} + +tasks.compileKotlin { + dependsOn("generate") +} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlannerDefault.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlannerDefault.kt index 19c728f06d..3b8314e7f8 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlannerDefault.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlannerDefault.kt @@ -4,7 +4,6 @@ import org.partiql.ast.Statement import org.partiql.ast.normalize.normalize import org.partiql.errors.ProblemCallback import org.partiql.planner.internal.Env -import org.partiql.planner.internal.ir.PartiQLVersion import org.partiql.planner.internal.transforms.AstToPlan import org.partiql.planner.internal.transforms.PlanTransform import org.partiql.planner.internal.typer.PlanTyper @@ -34,7 +33,6 @@ internal class PartiQLPlannerDefault( // 3. Resolve variables val typer = PlanTyper(env, onProblem) val internal = org.partiql.planner.internal.ir.PartiQLPlan( - version = PartiQLVersion.VERSION_0_1, catalogs = env.catalogs, statement = typer.resolve(root), ) diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Nodes.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Nodes.kt index 0d23c2a5ca..0d444cb340 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Nodes.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Nodes.kt @@ -1,6 +1,13 @@ +/** + * !! IMPORTANT !! + * + * This file is generated by `./gradlew :partiql-planner:copyNodes`. The command will overwrite this file, so any + * further modifications should be restored. We copy this file from build/tmp to src/main in order to manually + * override certain node implementations for equals and hashcode. + */ @file:OptIn(PartiQLValueExperimental::class) -package org.partiql.planner.internal.ir +package org.partiql.planner.`internal`.ir import org.partiql.planner.internal.ir.builder.AggResolvedBuilder import org.partiql.planner.internal.ir.builder.AggUnresolvedBuilder @@ -77,22 +84,17 @@ internal abstract class PlanNode { } internal data class PartiQLPlan( - @JvmField - internal val version: PartiQLVersion, - @JvmField - internal val catalogs: List, - @JvmField - internal val statement: Statement, + @JvmField internal val catalogs: List, + @JvmField internal val statement: Statement, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.addAll(catalogs) kids.add(statement) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitPartiQLPlan(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitPartiQLPlan(this, ctx) internal companion object { @JvmStatic @@ -101,41 +103,32 @@ internal data class PartiQLPlan( } internal data class Catalog( - @JvmField - internal val name: String, - @JvmField - internal val symbols: List, + @JvmField internal val name: String, + @JvmField internal val symbols: List, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.addAll(symbols) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitCatalog(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitCatalog(this, ctx) internal data class Symbol( - @JvmField - internal val path: List, - @JvmField - internal val type: StaticType, + @JvmField internal val path: List, + @JvmField internal val type: StaticType, ) : PlanNode() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitCatalogSymbol(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitCatalogSymbol(this, ctx) internal data class Ref( - @JvmField - internal val catalog: Int, - @JvmField - internal val symbol: Int, + @JvmField internal val catalog: Int, + @JvmField internal val symbol: Int, ) : PlanNode() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitCatalogSymbolRef(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitCatalogSymbolRef(this, ctx) internal companion object { @JvmStatic @@ -156,19 +149,17 @@ internal data class Catalog( } internal sealed class Fn : PlanNode() { - internal override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Resolved -> visitor.visitFnResolved(this, ctx) is Unresolved -> visitor.visitFnUnresolved(this, ctx) } internal data class Resolved( - @JvmField - internal val signature: FunctionSignature.Scalar, + @JvmField internal val signature: FunctionSignature.Scalar, ) : Fn() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitFnResolved(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitFnResolved(this, ctx) internal companion object { @JvmStatic @@ -177,19 +168,16 @@ internal sealed class Fn : PlanNode() { } internal data class Unresolved( - @JvmField - internal val identifier: Identifier, - @JvmField - internal val isHidden: Boolean, + @JvmField internal val identifier: Identifier, + @JvmField internal val isHidden: Boolean, ) : Fn() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(identifier) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitFnUnresolved(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitFnUnresolved(this, ctx) internal companion object { @JvmStatic @@ -199,19 +187,17 @@ internal sealed class Fn : PlanNode() { } internal sealed class Agg : PlanNode() { - internal override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Resolved -> visitor.visitAggResolved(this, ctx) is Unresolved -> visitor.visitAggUnresolved(this, ctx) } internal data class Resolved( - @JvmField - internal val signature: FunctionSignature.Aggregation, + @JvmField internal val signature: FunctionSignature.Aggregation, ) : Agg() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitAggResolved(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitAggResolved(this, ctx) internal companion object { @JvmStatic @@ -220,17 +206,15 @@ internal sealed class Agg : PlanNode() { } internal data class Unresolved( - @JvmField - internal val identifier: Identifier, + @JvmField internal val identifier: Identifier, ) : Agg() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(identifier) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitAggUnresolved(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitAggUnresolved(this, ctx) internal companion object { @JvmStatic @@ -240,22 +224,20 @@ internal sealed class Agg : PlanNode() { } internal sealed class Statement : PlanNode() { - internal override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Query -> visitor.visitStatementQuery(this, ctx) } internal data class Query( - @JvmField - internal val root: Rex, + @JvmField internal val root: Rex, ) : Statement() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitStatementQuery(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitStatementQuery(this, ctx) internal companion object { @JvmStatic @@ -265,26 +247,22 @@ internal sealed class Statement : PlanNode() { } internal sealed class Identifier : PlanNode() { - internal override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Symbol -> visitor.visitIdentifierSymbol(this, ctx) is Qualified -> visitor.visitIdentifierQualified(this, ctx) } internal enum class CaseSensitivity { - SENSITIVE, - INSENSITIVE, + SENSITIVE, INSENSITIVE, } internal data class Symbol( - @JvmField - internal val symbol: String, - @JvmField - internal val caseSensitivity: CaseSensitivity, + @JvmField internal val symbol: String, + @JvmField internal val caseSensitivity: CaseSensitivity, ) : Identifier() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitIdentifierSymbol(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitIdentifierSymbol(this, ctx) internal companion object { @JvmStatic @@ -293,20 +271,17 @@ internal sealed class Identifier : PlanNode() { } internal data class Qualified( - @JvmField - internal val root: Symbol, - @JvmField - internal val steps: List, + @JvmField internal val root: Symbol, + @JvmField internal val steps: List, ) : Identifier() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.addAll(steps) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitIdentifierQualified(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitIdentifierQualified(this, ctx) internal companion object { @JvmStatic @@ -316,24 +291,21 @@ internal sealed class Identifier : PlanNode() { } internal data class Rex( - @JvmField - internal val type: StaticType, - @JvmField - internal val op: Op, + @JvmField internal val type: StaticType, + @JvmField internal val op: Op, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(op) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRex( - this, - ctx + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRex( + this, ctx ) internal sealed class Op : PlanNode() { - internal override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Lit -> visitor.visitRexOpLit(this, ctx) is Var -> visitor.visitRexOpVar(this, ctx) is Global -> visitor.visitRexOpGlobal(this, ctx) @@ -350,13 +322,11 @@ internal data class Rex( } internal data class Lit( - @JvmField - internal val `value`: PartiQLValue, + @JvmField internal val `value`: PartiQLValue, ) : Op() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpLit(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpLit(this, ctx) internal companion object { @JvmStatic @@ -365,23 +335,21 @@ internal data class Rex( } internal sealed class Var : Op() { - internal override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Resolved -> visitor.visitRexOpVarResolved(this, ctx) is Unresolved -> visitor.visitRexOpVarUnresolved(this, ctx) } internal enum class Scope { - DEFAULT, - LOCAL, + DEFAULT, LOCAL, } internal data class Resolved( - @JvmField - internal val ref: Int, + @JvmField internal val ref: Int, ) : Var() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpVarResolved(this, ctx) internal companion object { @@ -391,18 +359,16 @@ internal data class Rex( } internal data class Unresolved( - @JvmField - internal val identifier: Identifier, - @JvmField - internal val scope: Scope, + @JvmField internal val identifier: Identifier, + @JvmField internal val scope: Scope, ) : Var() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(identifier) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpVarUnresolved(this, ctx) internal companion object { @@ -413,17 +379,15 @@ internal data class Rex( } internal data class Global( - @JvmField - internal val ref: Catalog.Symbol.Ref, + @JvmField internal val ref: Catalog.Symbol.Ref, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(ref) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpGlobal(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpGlobal(this, ctx) internal companion object { @JvmStatic @@ -432,26 +396,24 @@ internal data class Rex( } internal sealed class Path : Op() { - internal override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Index -> visitor.visitRexOpPathIndex(this, ctx) is Key -> visitor.visitRexOpPathKey(this, ctx) is Symbol -> visitor.visitRexOpPathSymbol(this, ctx) } internal data class Index( - @JvmField - internal val root: Rex, - @JvmField - internal val key: Rex, + @JvmField internal val root: Rex, + @JvmField internal val key: Rex, ) : Path() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.add(key) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpPathIndex(this, ctx) internal companion object { @@ -461,40 +423,35 @@ internal data class Rex( } internal data class Key( - @JvmField - internal val root: Rex, - @JvmField - internal val key: Rex, + @JvmField internal val root: Rex, + @JvmField internal val key: Rex, ) : Path() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.add(key) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpPathKey(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpPathKey(this, ctx) internal companion object { @JvmStatic - fun builder(): RexOpPathKeyBuilder = RexOpPathKeyBuilder() + internal fun builder(): RexOpPathKeyBuilder = RexOpPathKeyBuilder() } } internal data class Symbol( - @JvmField - internal val root: Rex, - @JvmField - internal val key: String, + @JvmField internal val root: Rex, + @JvmField internal val key: String, ) : Path() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpPathSymbol(this, ctx) internal companion object { @@ -505,25 +462,23 @@ internal data class Rex( } internal sealed class Call : Op() { - internal override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Static -> visitor.visitRexOpCallStatic(this, ctx) is Dynamic -> visitor.visitRexOpCallDynamic(this, ctx) } internal data class Static( - @JvmField - internal val fn: Fn, - @JvmField - internal val args: List, + @JvmField internal val fn: Fn, + @JvmField internal val args: List, ) : Call() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(fn) kids.addAll(args) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCallStatic(this, ctx) internal companion object { @@ -533,41 +488,36 @@ internal data class Rex( } internal data class Dynamic( - @JvmField - internal val args: List, - @JvmField - internal val candidates: List, + @JvmField internal val args: List, + @JvmField internal val candidates: List, ) : Call() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.addAll(args) kids.addAll(candidates) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCallDynamic(this, ctx) internal data class Candidate( - @JvmField - internal val fn: Fn.Resolved, - @JvmField - internal val coercions: List, + @JvmField internal val fn: Fn, + @JvmField internal val coercions: List, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(fn) kids.addAll(coercions) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCallDynamicCandidate(this, ctx) internal companion object { @JvmStatic - internal fun builder(): RexOpCallDynamicCandidateBuilder = - RexOpCallDynamicCandidateBuilder() + internal fun builder(): RexOpCallDynamicCandidateBuilder = RexOpCallDynamicCandidateBuilder() } } @@ -579,35 +529,30 @@ internal data class Rex( } internal data class Case( - @JvmField - internal val branches: List, - @JvmField - internal val default: Rex, + @JvmField internal val branches: List, + @JvmField internal val default: Rex, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.addAll(branches) kids.add(default) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpCase(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCase(this, ctx) internal data class Branch( - @JvmField - internal val condition: Rex, - @JvmField - internal val rex: Rex, + @JvmField internal val condition: Rex, + @JvmField internal val rex: Rex, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(condition) kids.add(rex) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCaseBranch(this, ctx) internal companion object { @@ -623,17 +568,15 @@ internal data class Rex( } internal data class Collection( - @JvmField - internal val values: List, + @JvmField internal val values: List, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.addAll(values) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpCollection(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCollection(this, ctx) internal companion object { @JvmStatic @@ -642,32 +585,28 @@ internal data class Rex( } internal data class Struct( - @JvmField - internal val fields: List, + @JvmField internal val fields: List, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.addAll(fields) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpStruct(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpStruct(this, ctx) internal data class Field( - @JvmField - internal val k: Rex, - @JvmField - internal val v: Rex, + @JvmField internal val k: Rex, + @JvmField internal val v: Rex, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(k) kids.add(v) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpStructField(this, ctx) internal companion object { @@ -683,14 +622,11 @@ internal data class Rex( } internal data class Pivot( - @JvmField - internal val key: Rex, - @JvmField - internal val `value`: Rex, - @JvmField - internal val rel: Rel, + @JvmField internal val key: Rex, + @JvmField internal val `value`: Rex, + @JvmField internal val rel: Rel, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(key) kids.add(value) @@ -698,8 +634,7 @@ internal data class Rex( kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpPivot(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpPivot(this, ctx) internal companion object { @JvmStatic @@ -708,23 +643,19 @@ internal data class Rex( } internal data class Subquery( - @JvmField - internal val select: Select, - @JvmField - internal val coercion: Coercion, + @JvmField internal val select: Select, + @JvmField internal val coercion: Coercion, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(select) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpSubquery(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpSubquery(this, ctx) internal enum class Coercion { - SCALAR, - ROW, + SCALAR, ROW, } internal companion object { @@ -734,20 +665,17 @@ internal data class Rex( } internal data class Select( - @JvmField - internal val `constructor`: Rex, - @JvmField - internal val rel: Rel, + @JvmField internal val `constructor`: Rex, + @JvmField internal val rel: Rel, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(constructor) kids.add(rel) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpSelect(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpSelect(this, ctx) internal companion object { @JvmStatic @@ -756,17 +684,15 @@ internal data class Rex( } internal data class TupleUnion( - @JvmField - internal val args: List, + @JvmField internal val args: List, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.addAll(args) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpTupleUnion(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpTupleUnion(this, ctx) internal companion object { @JvmStatic @@ -775,13 +701,11 @@ internal data class Rex( } internal data class Err( - @JvmField - internal val message: String, + @JvmField internal val message: String, ) : Op() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRexOpErr(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpErr(this, ctx) internal companion object { @JvmStatic @@ -797,21 +721,18 @@ internal data class Rex( } internal data class Rel( - @JvmField - internal val type: Type, - @JvmField - internal val op: Op, + @JvmField internal val type: Type, + @JvmField internal val op: Op, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(type) kids.add(op) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRel( - this, - ctx + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRel( + this, ctx ) internal enum class Prop { @@ -819,19 +740,16 @@ internal data class Rel( } internal data class Type( - @JvmField - internal val schema: List, - @JvmField - internal val props: Set, + @JvmField internal val schema: List, + @JvmField internal val props: Set, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.addAll(schema) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelType(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelType(this, ctx) internal companion object { @JvmStatic @@ -840,7 +758,7 @@ internal data class Rel( } internal sealed class Op : PlanNode() { - internal override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Scan -> visitor.visitRelOpScan(this, ctx) is ScanIndexed -> visitor.visitRelOpScanIndexed(this, ctx) is Unpivot -> visitor.visitRelOpUnpivot(this, ctx) @@ -860,17 +778,15 @@ internal data class Rel( } internal data class Scan( - @JvmField - internal val rex: Rex, + @JvmField internal val rex: Rex, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(rex) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpScan(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpScan(this, ctx) internal companion object { @JvmStatic @@ -879,17 +795,15 @@ internal data class Rel( } internal data class ScanIndexed( - @JvmField - internal val rex: Rex, + @JvmField internal val rex: Rex, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(rex) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpScanIndexed(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpScanIndexed(this, ctx) internal companion object { @JvmStatic @@ -898,17 +812,15 @@ internal data class Rel( } internal data class Unpivot( - @JvmField - internal val rex: Rex, + @JvmField internal val rex: Rex, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(rex) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpUnpivot(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpUnpivot(this, ctx) internal companion object { @JvmStatic @@ -917,17 +829,15 @@ internal data class Rel( } internal data class Distinct( - @JvmField - internal val input: Rel, + @JvmField internal val input: Rel, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpDistinct(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpDistinct(this, ctx) internal companion object { @JvmStatic @@ -936,20 +846,17 @@ internal data class Rel( } internal data class Filter( - @JvmField - internal val input: Rel, - @JvmField - internal val predicate: Rex, + @JvmField internal val input: Rel, + @JvmField internal val predicate: Rex, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.add(predicate) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpFilter(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpFilter(this, ctx) internal companion object { @JvmStatic @@ -958,41 +865,33 @@ internal data class Rel( } internal data class Sort( - @JvmField - internal val input: Rel, - @JvmField - internal val specs: List, + @JvmField internal val input: Rel, + @JvmField internal val specs: List, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.addAll(specs) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpSort(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpSort(this, ctx) internal enum class Order { - ASC_NULLS_LAST, - ASC_NULLS_FIRST, - DESC_NULLS_LAST, - DESC_NULLS_FIRST, + ASC_NULLS_LAST, ASC_NULLS_FIRST, DESC_NULLS_LAST, DESC_NULLS_FIRST, } internal data class Spec( - @JvmField - internal val rex: Rex, - @JvmField - internal val order: Order, + @JvmField internal val rex: Rex, + @JvmField internal val order: Order, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(rex) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpSortSpec(this, ctx) internal companion object { @@ -1008,20 +907,17 @@ internal data class Rel( } internal data class Union( - @JvmField - internal val lhs: Rel, - @JvmField - internal val rhs: Rel, + @JvmField internal val lhs: Rel, + @JvmField internal val rhs: Rel, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(lhs) kids.add(rhs) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpUnion(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpUnion(this, ctx) internal companion object { @JvmStatic @@ -1030,20 +926,17 @@ internal data class Rel( } internal data class Intersect( - @JvmField - internal val lhs: Rel, - @JvmField - internal val rhs: Rel, + @JvmField internal val lhs: Rel, + @JvmField internal val rhs: Rel, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(lhs) kids.add(rhs) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpIntersect(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpIntersect(this, ctx) internal companion object { @JvmStatic @@ -1052,20 +945,17 @@ internal data class Rel( } internal data class Except( - @JvmField - internal val lhs: Rel, - @JvmField - internal val rhs: Rel, + @JvmField internal val lhs: Rel, + @JvmField internal val rhs: Rel, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(lhs) kids.add(rhs) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpExcept(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcept(this, ctx) internal companion object { @JvmStatic @@ -1074,20 +964,17 @@ internal data class Rel( } internal data class Limit( - @JvmField - internal val input: Rel, - @JvmField - internal val limit: Rex, + @JvmField internal val input: Rel, + @JvmField internal val limit: Rex, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.add(limit) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpLimit(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpLimit(this, ctx) internal companion object { @JvmStatic @@ -1096,20 +983,17 @@ internal data class Rel( } internal data class Offset( - @JvmField - internal val input: Rel, - @JvmField - internal val offset: Rex, + @JvmField internal val input: Rel, + @JvmField internal val offset: Rex, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.add(offset) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpOffset(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpOffset(this, ctx) internal companion object { @JvmStatic @@ -1118,20 +1002,17 @@ internal data class Rel( } internal data class Project( - @JvmField - internal val input: Rel, - @JvmField - internal val projections: List, + @JvmField internal val input: Rel, + @JvmField internal val projections: List, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.addAll(projections) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpProject(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpProject(this, ctx) internal companion object { @JvmStatic @@ -1140,16 +1021,12 @@ internal data class Rel( } internal data class Join( - @JvmField - internal val lhs: Rel, - @JvmField - internal val rhs: Rel, - @JvmField - internal val rex: Rex, - @JvmField - internal val type: Type, + @JvmField internal val lhs: Rel, + @JvmField internal val rhs: Rel, + @JvmField internal val rex: Rex, + @JvmField internal val type: Type, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(lhs) kids.add(rhs) @@ -1157,14 +1034,10 @@ internal data class Rel( kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpJoin(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpJoin(this, ctx) internal enum class Type { - INNER, - LEFT, - RIGHT, - FULL, + INNER, LEFT, RIGHT, FULL, } internal companion object { @@ -1174,16 +1047,12 @@ internal data class Rel( } internal data class Aggregate( - @JvmField - internal val input: Rel, - @JvmField - internal val strategy: Strategy, - @JvmField - internal val calls: List, - @JvmField - internal val groups: List, + @JvmField internal val input: Rel, + @JvmField internal val strategy: Strategy, + @JvmField internal val calls: List, + @JvmField internal val groups: List, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.addAll(calls) @@ -1191,28 +1060,24 @@ internal data class Rel( kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpAggregate(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpAggregate(this, ctx) internal enum class Strategy { - FULL, - PARTIAL, + FULL, PARTIAL, } internal data class Call( - @JvmField - internal val agg: Agg, - @JvmField - internal val args: List, + @JvmField internal val agg: Agg, + @JvmField internal val args: List, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(agg) kids.addAll(args) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpAggregateCall(this, ctx) internal companion object { @@ -1228,35 +1093,30 @@ internal data class Rel( } internal data class Exclude( - @JvmField - internal val input: Rel, - @JvmField - internal val items: List, + @JvmField internal val input: Rel, + @JvmField internal val items: List, ) : Op() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.addAll(items) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpExclude(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExclude(this, ctx) internal data class Item( - @JvmField - internal val root: Rex.Op.Var, - @JvmField - internal val steps: List, + @JvmField internal val root: Rex.Op.Var, + @JvmField internal val steps: List, ) : PlanNode() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.addAll(steps) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcludeItem(this, ctx) internal companion object { @@ -1266,7 +1126,7 @@ internal data class Rel( } internal sealed class Step : PlanNode() { - internal override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is StructField -> visitor.visitRelOpExcludeStepStructField(this, ctx) is CollIndex -> visitor.visitRelOpExcludeStepCollIndex(this, ctx) is StructWildcard -> visitor.visitRelOpExcludeStepStructWildcard(this, ctx) @@ -1274,16 +1134,15 @@ internal data class Rel( } internal data class StructField( - @JvmField - internal val symbol: Identifier.Symbol, + @JvmField internal val symbol: Identifier.Symbol, ) : Step() { - internal override val children: List by lazy { + override val children: List by lazy { val kids = mutableListOf() kids.add(symbol) kids.filterNotNull() } - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcludeStepStructField(this, ctx) internal companion object { @@ -1294,28 +1153,25 @@ internal data class Rel( } internal data class CollIndex( - @JvmField - internal val index: Int, + @JvmField internal val index: Int, ) : Step() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcludeStepCollIndex(this, ctx) internal companion object { @JvmStatic - internal fun builder(): RelOpExcludeStepCollIndexBuilder = - RelOpExcludeStepCollIndexBuilder() + internal fun builder(): RelOpExcludeStepCollIndexBuilder = RelOpExcludeStepCollIndexBuilder() } } internal data class StructWildcard( - @JvmField - internal val ` `: Char = ' ', + @JvmField internal val ` `: Char = ' ', ) : Step() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcludeStepStructWildcard(this, ctx) internal companion object { @@ -1326,12 +1182,11 @@ internal data class Rel( } internal data class CollWildcard( - @JvmField - internal val ` `: Char = ' ', + @JvmField internal val ` `: Char = ' ', ) : Step() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcludeStepCollWildcard(this, ctx) internal companion object { @@ -1349,13 +1204,11 @@ internal data class Rel( } internal data class Err( - @JvmField - internal val message: String, + @JvmField internal val message: String, ) : Op() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpErr(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpErr(this, ctx) internal companion object { @JvmStatic @@ -1365,15 +1218,12 @@ internal data class Rel( } internal data class Binding( - @JvmField - internal val name: String, - @JvmField - internal val type: StaticType, + @JvmField internal val name: String, + @JvmField internal val type: StaticType, ) : PlanNode() { - internal override val children: List = emptyList() + override val children: List = emptyList() - internal override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelBinding(this, ctx) + override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelBinding(this, ctx) internal companion object { @JvmStatic @@ -1386,8 +1236,3 @@ internal data class Rel( internal fun builder(): RelBuilder = RelBuilder() } } - -internal enum class PartiQLVersion { - VERSION_0_0, - VERSION_0_1, -} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Plan.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Plan.kt deleted file mode 100644 index e7516fba9f..0000000000 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/Plan.kt +++ /dev/null @@ -1,182 +0,0 @@ -@file:JvmName("Plan") -@file:OptIn(PartiQLValueExperimental::class) - -package org.partiql.planner.internal.ir - -import org.partiql.types.StaticType -import org.partiql.types.function.FunctionSignature -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental - -internal fun partiQLPlan( - version: PartiQLVersion, - catalogs: List, - statement: Statement, -): PartiQLPlan = PartiQLPlan(version, catalogs, statement) - -internal fun catalog(name: String, symbols: List): Catalog = Catalog(name, symbols) - -internal fun catalogSymbol(path: List, type: StaticType): Catalog.Symbol = - Catalog.Symbol(path, type) - -internal fun catalogSymbolRef(catalog: Int, symbol: Int): Catalog.Symbol.Ref = - Catalog.Symbol.Ref(catalog, symbol) - -internal fun fnResolved(signature: FunctionSignature.Scalar): Fn.Resolved = Fn.Resolved(signature) - -internal fun fnUnresolved(identifier: Identifier, isHidden: Boolean): Fn.Unresolved = - Fn.Unresolved(identifier, isHidden) - -internal fun aggResolved(signature: FunctionSignature.Aggregation): Agg.Resolved = - Agg.Resolved(signature) - -internal fun aggUnresolved(identifier: Identifier): Agg.Unresolved = Agg.Unresolved(identifier) - -internal fun statementQuery(root: Rex): Statement.Query = Statement.Query(root) - -internal fun identifierSymbol(symbol: String, caseSensitivity: Identifier.CaseSensitivity): - Identifier.Symbol = Identifier.Symbol(symbol, caseSensitivity) - -internal fun identifierQualified(root: Identifier.Symbol, steps: List): - Identifier.Qualified = Identifier.Qualified(root, steps) - -internal fun rex(type: StaticType, op: Rex.Op): Rex = Rex(type, op) - -@OptIn(PartiQLValueExperimental::class) -internal fun rexOpLit(`value`: PartiQLValue): Rex.Op.Lit = Rex.Op.Lit(value) - -internal fun rexOpVarResolved(ref: Int): Rex.Op.Var.Resolved = Rex.Op.Var.Resolved(ref) - -internal fun rexOpVarUnresolved(identifier: Identifier, scope: Rex.Op.Var.Scope): - Rex.Op.Var.Unresolved = Rex.Op.Var.Unresolved(identifier, scope) - -internal fun rexOpGlobal(ref: Catalog.Symbol.Ref): Rex.Op.Global = Rex.Op.Global(ref) - -internal fun rexOpPathIndex(root: Rex, key: Rex): Rex.Op.Path.Index = Rex.Op.Path.Index(root, key) - -internal fun rexOpPathKey(root: Rex, key: Rex): Rex.Op.Path.Key = Rex.Op.Path.Key(root, key) - -internal fun rexOpPathSymbol(root: Rex, key: String): Rex.Op.Path.Symbol = Rex.Op.Path.Symbol( - root, - key -) - -internal fun rexOpCallStatic(fn: Fn, args: List): Rex.Op.Call.Static = Rex.Op.Call.Static( - fn, - args -) - -internal fun rexOpCallDynamic(args: List, candidates: List): - Rex.Op.Call.Dynamic = Rex.Op.Call.Dynamic(args, candidates) - -internal fun rexOpCallDynamicCandidate(fn: Fn.Resolved, coercions: List): - Rex.Op.Call.Dynamic.Candidate = Rex.Op.Call.Dynamic.Candidate(fn, coercions) - -internal fun rexOpCase(branches: List, default: Rex): Rex.Op.Case = - Rex.Op.Case(branches, default) - -internal fun rexOpCaseBranch(condition: Rex, rex: Rex): Rex.Op.Case.Branch = - Rex.Op.Case.Branch(condition, rex) - -internal fun rexOpCollection(values: List): Rex.Op.Collection = Rex.Op.Collection(values) - -internal fun rexOpStruct(fields: List): Rex.Op.Struct = Rex.Op.Struct(fields) - -internal fun rexOpStructField(k: Rex, v: Rex): Rex.Op.Struct.Field = Rex.Op.Struct.Field(k, v) - -internal fun rexOpPivot( - key: Rex, - `value`: Rex, - rel: Rel, -): Rex.Op.Pivot = Rex.Op.Pivot(key, value, rel) - -internal fun rexOpSubquery(select: Rex.Op.Select, coercion: Rex.Op.Subquery.Coercion): Rex.Op.Subquery = - Rex.Op.Subquery(select, coercion) - -internal fun rexOpSelect(`constructor`: Rex, rel: Rel): Rex.Op.Select = Rex.Op.Select( - constructor, - rel -) - -internal fun rexOpTupleUnion(args: List): Rex.Op.TupleUnion = Rex.Op.TupleUnion(args) - -internal fun rexOpErr(message: String): Rex.Op.Err = Rex.Op.Err(message) - -internal fun rel(type: Rel.Type, op: Rel.Op): Rel = Rel(type, op) - -internal fun relType(schema: List, props: Set): Rel.Type = Rel.Type( - schema, - props -) - -internal fun relOpScan(rex: Rex): Rel.Op.Scan = Rel.Op.Scan(rex) - -internal fun relOpScanIndexed(rex: Rex): Rel.Op.ScanIndexed = Rel.Op.ScanIndexed(rex) - -internal fun relOpUnpivot(rex: Rex): Rel.Op.Unpivot = Rel.Op.Unpivot(rex) - -internal fun relOpDistinct(input: Rel): Rel.Op.Distinct = Rel.Op.Distinct(input) - -internal fun relOpFilter(input: Rel, predicate: Rex): Rel.Op.Filter = Rel.Op.Filter(input, predicate) - -internal fun relOpSort(input: Rel, specs: List): Rel.Op.Sort = Rel.Op.Sort( - input, - specs -) - -internal fun relOpSortSpec(rex: Rex, order: Rel.Op.Sort.Order): Rel.Op.Sort.Spec = - Rel.Op.Sort.Spec(rex, order) - -internal fun relOpUnion(lhs: Rel, rhs: Rel): Rel.Op.Union = Rel.Op.Union(lhs, rhs) - -internal fun relOpIntersect(lhs: Rel, rhs: Rel): Rel.Op.Intersect = Rel.Op.Intersect(lhs, rhs) - -internal fun relOpExcept(lhs: Rel, rhs: Rel): Rel.Op.Except = Rel.Op.Except(lhs, rhs) - -internal fun relOpLimit(input: Rel, limit: Rex): Rel.Op.Limit = Rel.Op.Limit(input, limit) - -internal fun relOpOffset(input: Rel, offset: Rex): Rel.Op.Offset = Rel.Op.Offset(input, offset) - -internal fun relOpProject(input: Rel, projections: List): Rel.Op.Project = Rel.Op.Project( - input, - projections -) - -internal fun relOpJoin( - lhs: Rel, - rhs: Rel, - rex: Rex, - type: Rel.Op.Join.Type, -): Rel.Op.Join = Rel.Op.Join(lhs, rhs, rex, type) - -internal fun relOpAggregate( - input: Rel, - strategy: Rel.Op.Aggregate.Strategy, - calls: List, - groups: List, -): Rel.Op.Aggregate = Rel.Op.Aggregate(input, strategy, calls, groups) - -internal fun relOpAggregateCall(agg: Agg, args: List): Rel.Op.Aggregate.Call = - Rel.Op.Aggregate.Call(agg, args) - -internal fun relOpExclude(input: Rel, items: List): Rel.Op.Exclude = - Rel.Op.Exclude(input, items) - -internal fun relOpExcludeItem(root: Rex.Op.Var, steps: List): Rel.Op.Exclude.Item = - Rel.Op.Exclude.Item(root, steps) - -internal fun relOpExcludeStepStructField(symbol: Identifier.Symbol): Rel.Op.Exclude.Step.StructField = - Rel.Op.Exclude.Step.StructField(symbol) - -internal fun relOpExcludeStepCollIndex(index: Int): Rel.Op.Exclude.Step.CollIndex = - Rel.Op.Exclude.Step.CollIndex(index) - -internal fun relOpExcludeStepStructWildcard(): Rel.Op.Exclude.Step.StructWildcard = - Rel.Op.Exclude.Step.StructWildcard() - -internal fun relOpExcludeStepCollWildcard(): Rel.Op.Exclude.Step.CollWildcard = - Rel.Op.Exclude.Step.CollWildcard() - -internal fun relOpErr(message: String): Rel.Op.Err = Rel.Op.Err(message) - -internal fun relBinding(name: String, type: StaticType): Rel.Binding = Rel.Binding(name, type) diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/builder/PlanBuilder.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/builder/PlanBuilder.kt deleted file mode 100644 index bbfd68e420..0000000000 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/builder/PlanBuilder.kt +++ /dev/null @@ -1,568 +0,0 @@ -@file:Suppress("UNUSED_PARAMETER") @file:OptIn(PartiQLValueExperimental::class) - -package org.partiql.planner.internal.ir.builder - -import org.partiql.planner.internal.ir.Agg -import org.partiql.planner.internal.ir.Catalog -import org.partiql.planner.internal.ir.Fn -import org.partiql.planner.internal.ir.Identifier -import org.partiql.planner.internal.ir.PartiQLPlan -import org.partiql.planner.internal.ir.PartiQLVersion -import org.partiql.planner.internal.ir.PlanNode -import org.partiql.planner.internal.ir.Rel -import org.partiql.planner.internal.ir.Rex -import org.partiql.planner.internal.ir.Statement -import org.partiql.types.StaticType -import org.partiql.types.function.FunctionSignature -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental - -internal fun plan(block: PlanBuilder.() -> T) = PlanBuilder().block() - -internal class PlanBuilder { - internal fun partiQLPlan( - version: PartiQLVersion? = null, - catalogs: MutableList = mutableListOf(), - statement: Statement? = null, - block: PartiQlPlanBuilder.() -> Unit = {}, - ): PartiQLPlan { - val builder = PartiQlPlanBuilder(version, catalogs, statement) - builder.block() - return builder.build() - } - - internal fun catalog( - name: String? = null, - symbols: MutableList = mutableListOf(), - block: CatalogBuilder.() -> Unit = {}, - ): Catalog { - val builder = CatalogBuilder(name, symbols) - builder.block() - return builder.build() - } - - internal fun catalogSymbol( - path: MutableList = mutableListOf(), - type: StaticType? = null, - block: CatalogSymbolBuilder.() -> Unit = {}, - ): Catalog.Symbol { - val builder = CatalogSymbolBuilder(path, type) - builder.block() - return builder.build() - } - - internal fun catalogSymbolRef( - catalog: Int? = null, - symbol: Int? = null, - block: CatalogSymbolRefBuilder.() -> Unit = {}, - ): Catalog.Symbol.Ref { - val builder = CatalogSymbolRefBuilder(catalog, symbol) - builder.block() - return builder.build() - } - - internal fun fnResolved( - signature: FunctionSignature.Scalar? = null, - block: FnResolvedBuilder.() -> Unit = {}, - ): Fn.Resolved { - val builder = FnResolvedBuilder(signature) - builder.block() - return builder.build() - } - - internal fun fnUnresolved( - identifier: Identifier? = null, - isHidden: Boolean? = null, - block: FnUnresolvedBuilder.() -> Unit = {}, - ): Fn.Unresolved { - val builder = FnUnresolvedBuilder(identifier, isHidden) - builder.block() - return builder.build() - } - - internal fun aggResolved( - signature: FunctionSignature.Aggregation? = null, - block: AggResolvedBuilder.() -> Unit = {}, - ): Agg.Resolved { - val builder = AggResolvedBuilder(signature) - builder.block() - return builder.build() - } - - internal fun aggUnresolved( - identifier: Identifier? = null, - block: AggUnresolvedBuilder.() -> Unit = {}, - ): Agg.Unresolved { - val builder = AggUnresolvedBuilder(identifier) - builder.block() - return builder.build() - } - - internal fun statementQuery(root: Rex? = null, block: StatementQueryBuilder.() -> Unit = {}): Statement.Query { - val builder = StatementQueryBuilder(root) - builder.block() - return builder.build() - } - - internal fun identifierSymbol( - symbol: String? = null, - caseSensitivity: Identifier.CaseSensitivity? = null, - block: IdentifierSymbolBuilder.() -> Unit = {}, - ): Identifier.Symbol { - val builder = IdentifierSymbolBuilder(symbol, caseSensitivity) - builder.block() - return builder.build() - } - - internal fun identifierQualified( - root: Identifier.Symbol? = null, - steps: MutableList = mutableListOf(), - block: IdentifierQualifiedBuilder.() -> Unit = {}, - ): Identifier.Qualified { - val builder = IdentifierQualifiedBuilder(root, steps) - builder.block() - return builder.build() - } - - internal fun rex( - type: StaticType? = null, - op: Rex.Op? = null, - block: RexBuilder.() -> Unit = {}, - ): Rex { - val builder = RexBuilder(type, op) - builder.block() - return builder.build() - } - - @OptIn(PartiQLValueExperimental::class) - internal fun rexOpLit(`value`: PartiQLValue? = null, block: RexOpLitBuilder.() -> Unit = {}): Rex.Op.Lit { - val builder = RexOpLitBuilder(value) - builder.block() - return builder.build() - } - - internal fun rexOpVarResolved( - ref: Int? = null, - block: RexOpVarResolvedBuilder.() -> Unit = {}, - ): Rex.Op.Var.Resolved { - val builder = RexOpVarResolvedBuilder(ref) - builder.block() - return builder.build() - } - - internal fun rexOpVarUnresolved( - identifier: Identifier? = null, - scope: Rex.Op.Var.Scope? = null, - block: RexOpVarUnresolvedBuilder.() -> Unit = {}, - ): Rex.Op.Var.Unresolved { - val builder = RexOpVarUnresolvedBuilder(identifier, scope) - builder.block() - return builder.build() - } - - internal fun rexOpGlobal( - ref: Catalog.Symbol.Ref? = null, - block: RexOpGlobalBuilder.() -> Unit = {} - ): Rex.Op.Global { - val builder = RexOpGlobalBuilder(ref) - builder.block() - return builder.build() - } - - internal fun rexOpPathIndex( - root: Rex? = null, - key: Rex? = null, - block: RexOpPathIndexBuilder.() -> Unit = {}, - ): Rex.Op.Path.Index { - val builder = RexOpPathIndexBuilder(root, key) - builder.block() - return builder.build() - } - - internal fun rexOpPathKey( - root: Rex? = null, - key: Rex? = null, - block: RexOpPathKeyBuilder.() -> Unit = {}, - ): Rex.Op.Path.Key { - val builder = RexOpPathKeyBuilder(root, key) - builder.block() - return builder.build() - } - - internal fun rexOpPathSymbol( - root: Rex? = null, - key: String? = null, - block: RexOpPathSymbolBuilder.() -> Unit = {}, - ): Rex.Op.Path.Symbol { - val builder = RexOpPathSymbolBuilder(root, key) - builder.block() - return builder.build() - } - - internal fun rexOpCallStatic( - fn: Fn? = null, - args: MutableList = mutableListOf(), - block: RexOpCallStaticBuilder.() -> Unit = {}, - ): Rex.Op.Call.Static { - val builder = RexOpCallStaticBuilder(fn, args) - builder.block() - return builder.build() - } - - internal fun rexOpCallDynamic( - args: MutableList = mutableListOf(), - candidates: MutableList = mutableListOf(), - block: RexOpCallDynamicBuilder.() -> Unit = {}, - ): Rex.Op.Call.Dynamic { - val builder = RexOpCallDynamicBuilder(args, candidates) - builder.block() - return builder.build() - } - - internal fun rexOpCallDynamicCandidate( - fn: Fn.Resolved? = null, - coercions: MutableList = mutableListOf(), - block: RexOpCallDynamicCandidateBuilder.() -> Unit = {}, - ): Rex.Op.Call.Dynamic.Candidate { - val builder = RexOpCallDynamicCandidateBuilder(fn, coercions) - builder.block() - return builder.build() - } - - internal fun rexOpCase( - branches: MutableList = mutableListOf(), - default: Rex? = null, - block: RexOpCaseBuilder.() -> Unit = {}, - ): Rex.Op.Case { - val builder = RexOpCaseBuilder(branches, default) - builder.block() - return builder.build() - } - - internal fun rexOpCaseBranch( - condition: Rex? = null, - rex: Rex? = null, - block: RexOpCaseBranchBuilder.() -> Unit = {}, - ): Rex.Op.Case.Branch { - val builder = RexOpCaseBranchBuilder(condition, rex) - builder.block() - return builder.build() - } - - internal fun rexOpCollection( - values: MutableList = mutableListOf(), - block: RexOpCollectionBuilder.() -> Unit = {}, - ): Rex.Op.Collection { - val builder = RexOpCollectionBuilder(values) - builder.block() - return builder.build() - } - - internal fun rexOpStruct( - fields: MutableList = mutableListOf(), - block: RexOpStructBuilder.() -> Unit = {}, - ): Rex.Op.Struct { - val builder = RexOpStructBuilder(fields) - builder.block() - return builder.build() - } - - internal fun rexOpStructField( - k: Rex? = null, - v: Rex? = null, - block: RexOpStructFieldBuilder.() -> Unit = {}, - ): Rex.Op.Struct.Field { - val builder = RexOpStructFieldBuilder(k, v) - builder.block() - return builder.build() - } - - internal fun rexOpPivot( - key: Rex? = null, - `value`: Rex? = null, - rel: Rel? = null, - block: RexOpPivotBuilder.() -> Unit = {}, - ): Rex.Op.Pivot { - val builder = RexOpPivotBuilder(key, value, rel) - builder.block() - return builder.build() - } - - internal fun rexOpSubquery( - select: Rex.Op.Select? = null, - coercion: Rex.Op.Subquery.Coercion? = null, - block: RexOpSubqueryBuilder.() -> Unit = {}, - ): Rex.Op.Subquery { - val builder = RexOpSubqueryBuilder(select, coercion) - builder.block() - return builder.build() - } - - internal fun rexOpSelect( - `constructor`: Rex? = null, - rel: Rel? = null, - block: RexOpSelectBuilder.() -> Unit = {}, - ): Rex.Op.Select { - val builder = RexOpSelectBuilder(constructor, rel) - builder.block() - return builder.build() - } - - internal fun rexOpTupleUnion( - args: MutableList = mutableListOf(), - block: RexOpTupleUnionBuilder.() -> Unit = {}, - ): Rex.Op.TupleUnion { - val builder = RexOpTupleUnionBuilder(args) - builder.block() - return builder.build() - } - - internal fun rexOpErr(message: String? = null, block: RexOpErrBuilder.() -> Unit = {}): Rex.Op.Err { - val builder = RexOpErrBuilder(message) - builder.block() - return builder.build() - } - - internal fun rel( - type: Rel.Type? = null, - op: Rel.Op? = null, - block: RelBuilder.() -> Unit = {}, - ): Rel { - val builder = RelBuilder(type, op) - builder.block() - return builder.build() - } - - internal fun relType( - schema: MutableList = mutableListOf(), - props: MutableSet = mutableSetOf(), - block: RelTypeBuilder.() -> Unit = {}, - ): Rel.Type { - val builder = RelTypeBuilder(schema, props) - builder.block() - return builder.build() - } - - internal fun relOpScan(rex: Rex? = null, block: RelOpScanBuilder.() -> Unit = {}): Rel.Op.Scan { - val builder = RelOpScanBuilder(rex) - builder.block() - return builder.build() - } - - internal fun relOpScanIndexed( - rex: Rex? = null, - block: RelOpScanIndexedBuilder.() -> Unit = {}, - ): Rel.Op.ScanIndexed { - val builder = RelOpScanIndexedBuilder(rex) - builder.block() - return builder.build() - } - - internal fun relOpUnpivot(rex: Rex? = null, block: RelOpUnpivotBuilder.() -> Unit = {}): Rel.Op.Unpivot { - val builder = RelOpUnpivotBuilder(rex) - builder.block() - return builder.build() - } - - internal fun relOpDistinct(input: Rel? = null, block: RelOpDistinctBuilder.() -> Unit = {}): Rel.Op.Distinct { - val builder = RelOpDistinctBuilder(input) - builder.block() - return builder.build() - } - - internal fun relOpFilter( - input: Rel? = null, - predicate: Rex? = null, - block: RelOpFilterBuilder.() -> Unit = {}, - ): Rel.Op.Filter { - val builder = RelOpFilterBuilder(input, predicate) - builder.block() - return builder.build() - } - - internal fun relOpSort( - input: Rel? = null, - specs: MutableList = mutableListOf(), - block: RelOpSortBuilder.() -> Unit = {}, - ): Rel.Op.Sort { - val builder = RelOpSortBuilder(input, specs) - builder.block() - return builder.build() - } - - internal fun relOpSortSpec( - rex: Rex? = null, - order: Rel.Op.Sort.Order? = null, - block: RelOpSortSpecBuilder.() -> Unit = {}, - ): Rel.Op.Sort.Spec { - val builder = RelOpSortSpecBuilder(rex, order) - builder.block() - return builder.build() - } - - internal fun relOpUnion( - lhs: Rel? = null, - rhs: Rel? = null, - block: RelOpUnionBuilder.() -> Unit = {}, - ): Rel.Op.Union { - val builder = RelOpUnionBuilder(lhs, rhs) - builder.block() - return builder.build() - } - - internal fun relOpIntersect( - lhs: Rel? = null, - rhs: Rel? = null, - block: RelOpIntersectBuilder.() -> Unit = {}, - ): Rel.Op.Intersect { - val builder = RelOpIntersectBuilder(lhs, rhs) - builder.block() - return builder.build() - } - - internal fun relOpExcept( - lhs: Rel? = null, - rhs: Rel? = null, - block: RelOpExceptBuilder.() -> Unit = {}, - ): Rel.Op.Except { - val builder = RelOpExceptBuilder(lhs, rhs) - builder.block() - return builder.build() - } - - internal fun relOpLimit( - input: Rel? = null, - limit: Rex? = null, - block: RelOpLimitBuilder.() -> Unit = {}, - ): Rel.Op.Limit { - val builder = RelOpLimitBuilder(input, limit) - builder.block() - return builder.build() - } - - internal fun relOpOffset( - input: Rel? = null, - offset: Rex? = null, - block: RelOpOffsetBuilder.() -> Unit = {}, - ): Rel.Op.Offset { - val builder = RelOpOffsetBuilder(input, offset) - builder.block() - return builder.build() - } - - internal fun relOpProject( - input: Rel? = null, - projections: MutableList = mutableListOf(), - block: RelOpProjectBuilder.() -> Unit = {}, - ): Rel.Op.Project { - val builder = RelOpProjectBuilder(input, projections) - builder.block() - return builder.build() - } - - internal fun relOpJoin( - lhs: Rel? = null, - rhs: Rel? = null, - rex: Rex? = null, - type: Rel.Op.Join.Type? = null, - block: RelOpJoinBuilder.() -> Unit = {}, - ): Rel.Op.Join { - val builder = RelOpJoinBuilder(lhs, rhs, rex, type) - builder.block() - return builder.build() - } - - internal fun relOpAggregate( - input: Rel? = null, - strategy: Rel.Op.Aggregate.Strategy? = null, - calls: MutableList = mutableListOf(), - groups: MutableList = mutableListOf(), - block: RelOpAggregateBuilder.() -> Unit = {}, - ): Rel.Op.Aggregate { - val builder = RelOpAggregateBuilder(input, strategy, calls, groups) - builder.block() - return builder.build() - } - - internal fun relOpAggregateCall( - agg: Agg? = null, - args: MutableList = mutableListOf(), - block: RelOpAggregateCallBuilder.() -> Unit = {}, - ): Rel.Op.Aggregate.Call { - val builder = RelOpAggregateCallBuilder(agg, args) - builder.block() - return builder.build() - } - - internal fun relOpExclude( - input: Rel? = null, - items: MutableList = mutableListOf(), - block: RelOpExcludeBuilder.() -> Unit = {}, - ): Rel.Op.Exclude { - val builder = RelOpExcludeBuilder(input, items) - builder.block() - return builder.build() - } - - internal fun relOpExcludeItem( - root: Rex.Op.Var? = null, - steps: MutableList = mutableListOf(), - block: RelOpExcludeItemBuilder.() -> Unit = {}, - ): Rel.Op.Exclude.Item { - val builder = RelOpExcludeItemBuilder(root, steps) - builder.block() - return builder.build() - } - - internal fun relOpExcludeStepStructField( - symbol: Identifier.Symbol? = null, - block: RelOpExcludeStepStructFieldBuilder.() -> Unit = {} - ): Rel.Op.Exclude.Step.StructField { - val builder = RelOpExcludeStepStructFieldBuilder(symbol) - builder.block() - return builder.build() - } - - internal fun relOpExcludeStepCollIndex( - index: Int? = null, - block: RelOpExcludeStepCollIndexBuilder.() -> Unit = {} - ): Rel.Op.Exclude.Step.CollIndex { - val builder = RelOpExcludeStepCollIndexBuilder(index) - builder.block() - return builder.build() - } - - internal fun relOpExcludeStepStructWildcard( - block: RelOpExcludeStepStructWildcardBuilder.() -> Unit = - {} - ): Rel.Op.Exclude.Step.StructWildcard { - val builder = RelOpExcludeStepStructWildcardBuilder() - builder.block() - return builder.build() - } - - internal fun relOpExcludeStepCollWildcard( - block: RelOpExcludeStepCollWildcardBuilder.() -> Unit = - {} - ): Rel.Op.Exclude.Step.CollWildcard { - val builder = RelOpExcludeStepCollWildcardBuilder() - builder.block() - return builder.build() - } - - internal fun relOpErr(message: String? = null, block: RelOpErrBuilder.() -> Unit = {}): Rel.Op.Err { - val builder = RelOpErrBuilder(message) - builder.block() - return builder.build() - } - - internal fun relBinding( - name: String? = null, - type: StaticType? = null, - block: RelBindingBuilder.() -> Unit = {}, - ): Rel.Binding { - val builder = RelBindingBuilder(name, type) - builder.block() - return builder.build() - } -} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/builder/PlanBuilders.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/builder/PlanBuilders.kt deleted file mode 100644 index be428c8c75..0000000000 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/builder/PlanBuilders.kt +++ /dev/null @@ -1,846 +0,0 @@ -@file:OptIn(PartiQLValueExperimental::class) - -package org.partiql.planner.internal.ir.builder - -import org.partiql.planner.internal.ir.Agg -import org.partiql.planner.internal.ir.Catalog -import org.partiql.planner.internal.ir.Fn -import org.partiql.planner.internal.ir.Identifier -import org.partiql.planner.internal.ir.PartiQLPlan -import org.partiql.planner.internal.ir.PartiQLVersion -import org.partiql.planner.internal.ir.Rel -import org.partiql.planner.internal.ir.Rex -import org.partiql.planner.internal.ir.Statement -import org.partiql.types.StaticType -import org.partiql.types.function.FunctionSignature -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental - -internal class PartiQlPlanBuilder( - internal var version: PartiQLVersion? = null, - internal var catalogs: MutableList = mutableListOf(), - internal var statement: Statement? = null, -) { - internal fun version(version: PartiQLVersion?): PartiQlPlanBuilder = this.apply { - this.version = version - } - - internal fun catalogs(catalogs: MutableList): PartiQlPlanBuilder = this.apply { - this.catalogs = catalogs - } - - internal fun statement(statement: Statement?): PartiQlPlanBuilder = this.apply { - this.statement = statement - } - - internal fun build(): PartiQLPlan = PartiQLPlan( - version = version!!, catalogs = catalogs, - statement = - statement!! - ) -} - -internal class CatalogBuilder( - internal var name: String? = null, - internal var symbols: MutableList = mutableListOf(), -) { - internal fun name(name: String?): CatalogBuilder = this.apply { - this.name = name - } - - internal fun symbols(symbols: MutableList): CatalogBuilder = this.apply { - this.symbols = symbols - } - - internal fun build(): Catalog = Catalog(name = name!!, symbols = symbols) -} - -internal class CatalogSymbolBuilder( - internal var path: MutableList = mutableListOf(), - internal var type: StaticType? = null, -) { - internal fun path(path: MutableList): CatalogSymbolBuilder = this.apply { - this.path = path - } - - internal fun type(type: StaticType?): CatalogSymbolBuilder = this.apply { - this.type = type - } - - internal fun build(): Catalog.Symbol = Catalog.Symbol(path = path, type = type!!) -} - -internal class CatalogSymbolRefBuilder( - internal var catalog: Int? = null, - internal var symbol: Int? = null, -) { - internal fun catalog(catalog: Int?): CatalogSymbolRefBuilder = this.apply { - this.catalog = catalog - } - - internal fun symbol(symbol: Int?): CatalogSymbolRefBuilder = this.apply { - this.symbol = symbol - } - - internal fun build(): Catalog.Symbol.Ref = Catalog.Symbol.Ref( - catalog = catalog!!, - symbol = - symbol!! - ) -} - -internal class FnResolvedBuilder( - internal var signature: FunctionSignature.Scalar? = null, -) { - internal fun signature(signature: FunctionSignature.Scalar?): FnResolvedBuilder = this.apply { - this.signature = signature - } - - internal fun build(): Fn.Resolved = Fn.Resolved(signature = signature!!) -} - -internal class FnUnresolvedBuilder( - internal var identifier: Identifier? = null, - internal var isHidden: Boolean? = null, -) { - internal fun identifier(identifier: Identifier?): FnUnresolvedBuilder = this.apply { - this.identifier = identifier - } - - internal fun isHidden(isHidden: Boolean?): FnUnresolvedBuilder = this.apply { - this.isHidden = isHidden - } - - internal fun build(): Fn.Unresolved = Fn.Unresolved( - identifier = identifier!!, - isHidden = - isHidden!! - ) -} - -internal class AggResolvedBuilder( - internal var signature: FunctionSignature.Aggregation? = null, -) { - internal fun signature(signature: FunctionSignature.Aggregation?): AggResolvedBuilder = this.apply { - this.signature = signature - } - - internal fun build(): Agg.Resolved = Agg.Resolved(signature = signature!!) -} - -internal class AggUnresolvedBuilder( - internal var identifier: Identifier? = null, -) { - internal fun identifier(identifier: Identifier?): AggUnresolvedBuilder = this.apply { - this.identifier = identifier - } - - internal fun build(): Agg.Unresolved = Agg.Unresolved(identifier = identifier!!) -} - -internal class StatementQueryBuilder( - internal var root: Rex? = null, -) { - internal fun root(root: Rex?): StatementQueryBuilder = this.apply { - this.root = root - } - - internal fun build(): Statement.Query = Statement.Query(root = root!!) -} - -internal class IdentifierSymbolBuilder( - internal var symbol: String? = null, - internal var caseSensitivity: Identifier.CaseSensitivity? = null, -) { - internal fun symbol(symbol: String?): IdentifierSymbolBuilder = this.apply { - this.symbol = symbol - } - - internal fun caseSensitivity(caseSensitivity: Identifier.CaseSensitivity?): IdentifierSymbolBuilder = this.apply { - this.caseSensitivity = caseSensitivity - } - - internal fun build(): Identifier.Symbol = Identifier.Symbol( - symbol = symbol!!, - caseSensitivity = - caseSensitivity!! - ) -} - -internal class IdentifierQualifiedBuilder( - internal var root: Identifier.Symbol? = null, - internal var steps: MutableList = mutableListOf(), -) { - internal fun root(root: Identifier.Symbol?): IdentifierQualifiedBuilder = this.apply { - this.root = root - } - - internal fun steps(steps: MutableList): IdentifierQualifiedBuilder = this.apply { - this.steps = steps - } - - internal fun build(): Identifier.Qualified = Identifier.Qualified(root = root!!, steps = steps) -} - -internal class RexBuilder( - internal var type: StaticType? = null, - internal var op: Rex.Op? = null, -) { - internal fun type(type: StaticType?): RexBuilder = this.apply { - this.type = type - } - - internal fun op(op: Rex.Op?): RexBuilder = this.apply { - this.op = op - } - - internal fun build(): Rex = Rex(type = type!!, op = op!!) -} - -internal class RexOpLitBuilder( - internal var `value`: PartiQLValue? = null, -) { - @OptIn(PartiQLValueExperimental::class) - internal fun `value`(`value`: PartiQLValue?): RexOpLitBuilder = this.apply { - this.`value` = `value` - } - - @OptIn(PartiQLValueExperimental::class) - internal fun build(): Rex.Op.Lit = Rex.Op.Lit(value = value!!) -} - -internal class RexOpVarResolvedBuilder( - internal var ref: Int? = null, -) { - internal fun ref(ref: Int?): RexOpVarResolvedBuilder = this.apply { - this.ref = ref - } - - internal fun build(): Rex.Op.Var.Resolved = Rex.Op.Var.Resolved(ref = ref!!) -} - -internal class RexOpVarUnresolvedBuilder( - internal var identifier: Identifier? = null, - internal var scope: Rex.Op.Var.Scope? = null, -) { - internal fun identifier(identifier: Identifier?): RexOpVarUnresolvedBuilder = this.apply { - this.identifier = identifier - } - - internal fun scope(scope: Rex.Op.Var.Scope?): RexOpVarUnresolvedBuilder = this.apply { - this.scope = scope - } - - internal fun build(): Rex.Op.Var.Unresolved = Rex.Op.Var.Unresolved( - identifier = identifier!!, - scope = - scope!! - ) -} - -internal class RexOpGlobalBuilder( - internal var ref: Catalog.Symbol.Ref? = null, -) { - internal fun ref(ref: Catalog.Symbol.Ref?): RexOpGlobalBuilder = this.apply { - this.ref = ref - } - - internal fun build(): Rex.Op.Global = Rex.Op.Global(ref = ref!!) -} - -internal class RexOpPathIndexBuilder( - internal var root: Rex? = null, - internal var key: Rex? = null, -) { - internal fun root(root: Rex?): RexOpPathIndexBuilder = this.apply { - this.root = root - } - - internal fun key(key: Rex?): RexOpPathIndexBuilder = this.apply { - this.key = key - } - - internal fun build(): Rex.Op.Path.Index = Rex.Op.Path.Index(root = root!!, key = key!!) -} - -internal class RexOpPathKeyBuilder( - internal var root: Rex? = null, - internal var key: Rex? = null, -) { - internal fun root(root: Rex?): RexOpPathKeyBuilder = this.apply { - this.root = root - } - - internal fun key(key: Rex?): RexOpPathKeyBuilder = this.apply { - this.key = key - } - - internal fun build(): Rex.Op.Path.Key = Rex.Op.Path.Key(root = root!!, key = key!!) -} - -internal class RexOpPathSymbolBuilder( - internal var root: Rex? = null, - internal var key: String? = null, -) { - internal fun root(root: Rex?): RexOpPathSymbolBuilder = this.apply { - this.root = root - } - - internal fun key(key: String?): RexOpPathSymbolBuilder = this.apply { - this.key = key - } - - internal fun build(): Rex.Op.Path.Symbol = Rex.Op.Path.Symbol(root = root!!, key = key!!) -} - -internal class RexOpCallStaticBuilder( - internal var fn: Fn? = null, - internal var args: MutableList = mutableListOf(), -) { - internal fun fn(fn: Fn?): RexOpCallStaticBuilder = this.apply { - this.fn = fn - } - - internal fun args(args: MutableList): RexOpCallStaticBuilder = this.apply { - this.args = args - } - - internal fun build(): Rex.Op.Call.Static = Rex.Op.Call.Static(fn = fn!!, args = args) -} - -internal class RexOpCallDynamicBuilder( - internal var args: MutableList = mutableListOf(), - internal var candidates: MutableList = mutableListOf(), -) { - internal fun args(args: MutableList): RexOpCallDynamicBuilder = this.apply { - this.args = args - } - - internal fun candidates(candidates: MutableList): - RexOpCallDynamicBuilder = this.apply { - this.candidates = candidates - } - - internal fun build(): Rex.Op.Call.Dynamic = Rex.Op.Call.Dynamic( - args = args, - candidates = - candidates - ) -} - -internal class RexOpCallDynamicCandidateBuilder( - internal var fn: Fn.Resolved? = null, - internal var coercions: MutableList = mutableListOf(), -) { - internal fun fn(fn: Fn.Resolved?): RexOpCallDynamicCandidateBuilder = this.apply { - this.fn = fn - } - - internal fun coercions(coercions: MutableList): RexOpCallDynamicCandidateBuilder = - this.apply { - this.coercions = coercions - } - - internal fun build(): Rex.Op.Call.Dynamic.Candidate = Rex.Op.Call.Dynamic.Candidate( - fn = fn!!, - coercions = coercions - ) -} - -internal class RexOpCaseBuilder( - internal var branches: MutableList = mutableListOf(), - internal var default: Rex? = null, -) { - internal fun branches(branches: MutableList): RexOpCaseBuilder = this.apply { - this.branches = branches - } - - internal fun default(default: Rex?): RexOpCaseBuilder = this.apply { - this.default = default - } - - internal fun build(): Rex.Op.Case = Rex.Op.Case(branches = branches, default = default!!) -} - -internal class RexOpCaseBranchBuilder( - internal var condition: Rex? = null, - internal var rex: Rex? = null, -) { - internal fun condition(condition: Rex?): RexOpCaseBranchBuilder = this.apply { - this.condition = condition - } - - internal fun rex(rex: Rex?): RexOpCaseBranchBuilder = this.apply { - this.rex = rex - } - - internal fun build(): Rex.Op.Case.Branch = Rex.Op.Case.Branch(condition = condition!!, rex = rex!!) -} - -internal class RexOpCollectionBuilder( - internal var values: MutableList = mutableListOf(), -) { - internal fun values(values: MutableList): RexOpCollectionBuilder = this.apply { - this.values = values - } - - internal fun build(): Rex.Op.Collection = Rex.Op.Collection(values = values) -} - -internal class RexOpStructBuilder( - internal var fields: MutableList = mutableListOf(), -) { - internal fun fields(fields: MutableList): RexOpStructBuilder = this.apply { - this.fields = fields - } - - internal fun build(): Rex.Op.Struct = Rex.Op.Struct(fields = fields) -} - -internal class RexOpStructFieldBuilder( - internal var k: Rex? = null, - internal var v: Rex? = null, -) { - internal fun k(k: Rex?): RexOpStructFieldBuilder = this.apply { - this.k = k - } - - internal fun v(v: Rex?): RexOpStructFieldBuilder = this.apply { - this.v = v - } - - internal fun build(): Rex.Op.Struct.Field = Rex.Op.Struct.Field(k = k!!, v = v!!) -} - -internal class RexOpPivotBuilder( - internal var key: Rex? = null, - internal var `value`: Rex? = null, - internal var rel: Rel? = null, -) { - internal fun key(key: Rex?): RexOpPivotBuilder = this.apply { - this.key = key - } - - internal fun `value`(`value`: Rex?): RexOpPivotBuilder = this.apply { - this.`value` = `value` - } - - internal fun rel(rel: Rel?): RexOpPivotBuilder = this.apply { - this.rel = rel - } - - internal fun build(): Rex.Op.Pivot = Rex.Op.Pivot(key = key!!, value = value!!, rel = rel!!) -} - -internal class RexOpSubqueryBuilder( - internal var select: Rex.Op.Select? = null, - internal var coercion: Rex.Op.Subquery.Coercion? = null, -) { - internal fun select(select: Rex.Op.Select?): RexOpSubqueryBuilder = this.apply { - this.select = select - } - - internal fun coercion(coercion: Rex.Op.Subquery.Coercion?): RexOpSubqueryBuilder = this.apply { - this.coercion = coercion - } - - internal fun build(): Rex.Op.Subquery = Rex.Op.Subquery(select = select!!, coercion = coercion!!) -} - -internal class RexOpSelectBuilder( - internal var `constructor`: Rex? = null, - internal var rel: Rel? = null, -) { - internal fun `constructor`(`constructor`: Rex?): RexOpSelectBuilder = this.apply { - this.`constructor` = `constructor` - } - - internal fun rel(rel: Rel?): RexOpSelectBuilder = this.apply { - this.rel = rel - } - - internal fun build(): Rex.Op.Select = Rex.Op.Select(constructor = constructor!!, rel = rel!!) -} - -internal class RexOpTupleUnionBuilder( - internal var args: MutableList = mutableListOf(), -) { - internal fun args(args: MutableList): RexOpTupleUnionBuilder = this.apply { - this.args = args - } - - internal fun build(): Rex.Op.TupleUnion = Rex.Op.TupleUnion(args = args) -} - -internal class RexOpErrBuilder( - internal var message: String? = null, -) { - internal fun message(message: String?): RexOpErrBuilder = this.apply { - this.message = message - } - - internal fun build(): Rex.Op.Err = Rex.Op.Err(message = message!!) -} - -internal class RelBuilder( - internal var type: Rel.Type? = null, - internal var op: Rel.Op? = null, -) { - internal fun type(type: Rel.Type?): RelBuilder = this.apply { - this.type = type - } - - internal fun op(op: Rel.Op?): RelBuilder = this.apply { - this.op = op - } - - internal fun build(): Rel = Rel(type = type!!, op = op!!) -} - -internal class RelTypeBuilder( - internal var schema: MutableList = mutableListOf(), - internal var props: MutableSet = mutableSetOf(), -) { - internal fun schema(schema: MutableList): RelTypeBuilder = this.apply { - this.schema = schema - } - - internal fun props(props: MutableSet): RelTypeBuilder = this.apply { - this.props = props - } - - internal fun build(): Rel.Type = Rel.Type(schema = schema, props = props) -} - -internal class RelOpScanBuilder( - internal var rex: Rex? = null, -) { - internal fun rex(rex: Rex?): RelOpScanBuilder = this.apply { - this.rex = rex - } - - internal fun build(): Rel.Op.Scan = Rel.Op.Scan(rex = rex!!) -} - -internal class RelOpScanIndexedBuilder( - internal var rex: Rex? = null, -) { - internal fun rex(rex: Rex?): RelOpScanIndexedBuilder = this.apply { - this.rex = rex - } - - internal fun build(): Rel.Op.ScanIndexed = Rel.Op.ScanIndexed(rex = rex!!) -} - -internal class RelOpUnpivotBuilder( - internal var rex: Rex? = null, -) { - internal fun rex(rex: Rex?): RelOpUnpivotBuilder = this.apply { - this.rex = rex - } - - internal fun build(): Rel.Op.Unpivot = Rel.Op.Unpivot(rex = rex!!) -} - -internal class RelOpDistinctBuilder( - internal var input: Rel? = null, -) { - internal fun input(input: Rel?): RelOpDistinctBuilder = this.apply { - this.input = input - } - - internal fun build(): Rel.Op.Distinct = Rel.Op.Distinct(input = input!!) -} - -internal class RelOpFilterBuilder( - internal var input: Rel? = null, - internal var predicate: Rex? = null, -) { - internal fun input(input: Rel?): RelOpFilterBuilder = this.apply { - this.input = input - } - - internal fun predicate(predicate: Rex?): RelOpFilterBuilder = this.apply { - this.predicate = predicate - } - - internal fun build(): Rel.Op.Filter = Rel.Op.Filter(input = input!!, predicate = predicate!!) -} - -internal class RelOpSortBuilder( - internal var input: Rel? = null, - internal var specs: MutableList = mutableListOf(), -) { - internal fun input(input: Rel?): RelOpSortBuilder = this.apply { - this.input = input - } - - internal fun specs(specs: MutableList): RelOpSortBuilder = this.apply { - this.specs = specs - } - - internal fun build(): Rel.Op.Sort = Rel.Op.Sort(input = input!!, specs = specs) -} - -internal class RelOpSortSpecBuilder( - internal var rex: Rex? = null, - internal var order: Rel.Op.Sort.Order? = null, -) { - internal fun rex(rex: Rex?): RelOpSortSpecBuilder = this.apply { - this.rex = rex - } - - internal fun order(order: Rel.Op.Sort.Order?): RelOpSortSpecBuilder = this.apply { - this.order = order - } - - internal fun build(): Rel.Op.Sort.Spec = Rel.Op.Sort.Spec(rex = rex!!, order = order!!) -} - -internal class RelOpUnionBuilder( - internal var lhs: Rel? = null, - internal var rhs: Rel? = null, -) { - internal fun lhs(lhs: Rel?): RelOpUnionBuilder = this.apply { - this.lhs = lhs - } - - internal fun rhs(rhs: Rel?): RelOpUnionBuilder = this.apply { - this.rhs = rhs - } - - internal fun build(): Rel.Op.Union = Rel.Op.Union(lhs = lhs!!, rhs = rhs!!) -} - -internal class RelOpIntersectBuilder( - internal var lhs: Rel? = null, - internal var rhs: Rel? = null, -) { - internal fun lhs(lhs: Rel?): RelOpIntersectBuilder = this.apply { - this.lhs = lhs - } - - internal fun rhs(rhs: Rel?): RelOpIntersectBuilder = this.apply { - this.rhs = rhs - } - - internal fun build(): Rel.Op.Intersect = Rel.Op.Intersect(lhs = lhs!!, rhs = rhs!!) -} - -internal class RelOpExceptBuilder( - internal var lhs: Rel? = null, - internal var rhs: Rel? = null, -) { - internal fun lhs(lhs: Rel?): RelOpExceptBuilder = this.apply { - this.lhs = lhs - } - - internal fun rhs(rhs: Rel?): RelOpExceptBuilder = this.apply { - this.rhs = rhs - } - - internal fun build(): Rel.Op.Except = Rel.Op.Except(lhs = lhs!!, rhs = rhs!!) -} - -internal class RelOpLimitBuilder( - internal var input: Rel? = null, - internal var limit: Rex? = null, -) { - internal fun input(input: Rel?): RelOpLimitBuilder = this.apply { - this.input = input - } - - internal fun limit(limit: Rex?): RelOpLimitBuilder = this.apply { - this.limit = limit - } - - internal fun build(): Rel.Op.Limit = Rel.Op.Limit(input = input!!, limit = limit!!) -} - -internal class RelOpOffsetBuilder( - internal var input: Rel? = null, - internal var offset: Rex? = null, -) { - internal fun input(input: Rel?): RelOpOffsetBuilder = this.apply { - this.input = input - } - - internal fun offset(offset: Rex?): RelOpOffsetBuilder = this.apply { - this.offset = offset - } - - internal fun build(): Rel.Op.Offset = Rel.Op.Offset(input = input!!, offset = offset!!) -} - -internal class RelOpProjectBuilder( - internal var input: Rel? = null, - internal var projections: MutableList = mutableListOf(), -) { - internal fun input(input: Rel?): RelOpProjectBuilder = this.apply { - this.input = input - } - - internal fun projections(projections: MutableList): RelOpProjectBuilder = this.apply { - this.projections = projections - } - - internal fun build(): Rel.Op.Project = Rel.Op.Project(input = input!!, projections = projections) -} - -internal class RelOpJoinBuilder( - internal var lhs: Rel? = null, - internal var rhs: Rel? = null, - internal var rex: Rex? = null, - internal var type: Rel.Op.Join.Type? = null, -) { - internal fun lhs(lhs: Rel?): RelOpJoinBuilder = this.apply { - this.lhs = lhs - } - - internal fun rhs(rhs: Rel?): RelOpJoinBuilder = this.apply { - this.rhs = rhs - } - - internal fun rex(rex: Rex?): RelOpJoinBuilder = this.apply { - this.rex = rex - } - - internal fun type(type: Rel.Op.Join.Type?): RelOpJoinBuilder = this.apply { - this.type = type - } - - internal fun build(): Rel.Op.Join = Rel.Op.Join( - lhs = lhs!!, rhs = rhs!!, rex = rex!!, - type = - type!! - ) -} - -internal class RelOpAggregateBuilder( - internal var input: Rel? = null, - internal var strategy: Rel.Op.Aggregate.Strategy? = null, - internal var calls: MutableList = mutableListOf(), - internal var groups: MutableList = mutableListOf(), -) { - internal fun input(input: Rel?): RelOpAggregateBuilder = this.apply { - this.input = input - } - - internal fun strategy(strategy: Rel.Op.Aggregate.Strategy?): RelOpAggregateBuilder = this.apply { - this.strategy = strategy - } - - internal fun calls(calls: MutableList): RelOpAggregateBuilder = this.apply { - this.calls = calls - } - - internal fun groups(groups: MutableList): RelOpAggregateBuilder = this.apply { - this.groups = groups - } - - internal fun build(): Rel.Op.Aggregate = Rel.Op.Aggregate( - input = input!!, strategy = strategy!!, - calls = calls, groups = groups - ) -} - -internal class RelOpAggregateCallBuilder( - internal var agg: Agg? = null, - internal var args: MutableList = mutableListOf(), -) { - internal fun agg(agg: Agg?): RelOpAggregateCallBuilder = this.apply { - this.agg = agg - } - - internal fun args(args: MutableList): RelOpAggregateCallBuilder = this.apply { - this.args = args - } - - internal fun build(): Rel.Op.Aggregate.Call = Rel.Op.Aggregate.Call(agg = agg!!, args = args) -} - -internal class RelOpExcludeBuilder( - internal var input: Rel? = null, - internal var items: MutableList = mutableListOf(), -) { - internal fun input(input: Rel?): RelOpExcludeBuilder = this.apply { - this.input = input - } - - internal fun items(items: MutableList): RelOpExcludeBuilder = this.apply { - this.items = items - } - - internal fun build(): Rel.Op.Exclude = Rel.Op.Exclude(input = input!!, items = items) -} - -internal class RelOpExcludeItemBuilder( - internal var root: Rex.Op.Var? = null, - internal var steps: MutableList = mutableListOf(), -) { - internal fun root(root: Rex.Op.Var?): RelOpExcludeItemBuilder = this.apply { - this.root = root - } - - internal fun steps(steps: MutableList): RelOpExcludeItemBuilder = this.apply { - this.steps = steps - } - - internal fun build(): Rel.Op.Exclude.Item = Rel.Op.Exclude.Item(root = root!!, steps = steps) -} - -internal class RelOpExcludeStepStructFieldBuilder( - internal var symbol: Identifier.Symbol? = null, -) { - internal fun symbol(symbol: Identifier.Symbol?): RelOpExcludeStepStructFieldBuilder = this.apply { - this.symbol = symbol - } - - internal fun build(): Rel.Op.Exclude.Step.StructField = Rel.Op.Exclude.Step.StructField( - symbol = - symbol!! - ) -} - -internal class RelOpExcludeStepCollIndexBuilder( - internal var index: Int? = null, -) { - internal fun index(index: Int?): RelOpExcludeStepCollIndexBuilder = this.apply { - this.index = index - } - - internal fun build(): Rel.Op.Exclude.Step.CollIndex = Rel.Op.Exclude.Step.CollIndex(index = index!!) -} - -internal class RelOpExcludeStepStructWildcardBuilder() { - internal fun build(): Rel.Op.Exclude.Step.StructWildcard = Rel.Op.Exclude.Step.StructWildcard() -} - -internal class RelOpExcludeStepCollWildcardBuilder() { - internal fun build(): Rel.Op.Exclude.Step.CollWildcard = Rel.Op.Exclude.Step.CollWildcard() -} - -internal class RelOpErrBuilder( - internal var message: String? = null, -) { - internal fun message(message: String?): RelOpErrBuilder = this.apply { - this.message = message - } - - internal fun build(): Rel.Op.Err = Rel.Op.Err(message = message!!) -} - -internal class RelBindingBuilder( - internal var name: String? = null, - internal var type: StaticType? = null, -) { - internal fun name(name: String?): RelBindingBuilder = this.apply { - this.name = name - } - - internal fun type(type: StaticType?): RelBindingBuilder = this.apply { - this.type = type - } - - internal fun build(): Rel.Binding = Rel.Binding(name = name!!, type = type!!) -} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/util/PlanRewriter.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/util/PlanRewriter.kt deleted file mode 100644 index a9e807160a..0000000000 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/util/PlanRewriter.kt +++ /dev/null @@ -1,606 +0,0 @@ -@file:Suppress( - "UNUSED_PARAMETER", - "UNUSED_VARIABLE", -) @file:OptIn(PartiQLValueExperimental::class) - -package org.partiql.planner.internal.ir.util - -import org.partiql.planner.internal.ir.Agg -import org.partiql.planner.internal.ir.Catalog -import org.partiql.planner.internal.ir.Fn -import org.partiql.planner.internal.ir.Identifier -import org.partiql.planner.internal.ir.PartiQLPlan -import org.partiql.planner.internal.ir.PlanNode -import org.partiql.planner.internal.ir.Rel -import org.partiql.planner.internal.ir.Rex -import org.partiql.planner.internal.ir.Statement -import org.partiql.planner.internal.ir.visitor.PlanBaseVisitor -import org.partiql.value.PartiQLValueExperimental - -internal abstract class PlanRewriter : PlanBaseVisitor() { - - override fun defaultReturn(node: PlanNode, ctx: C): PlanNode = node - - private inline fun _visitList( - nodes: List, - ctx: C, - method: (node: T, ctx: C) -> PlanNode, - ): List { - if (nodes.isEmpty()) return nodes - var diff = false - val transformed = ArrayList(nodes.size) - nodes.forEach { - val n = method(it, ctx) as T - if (it !== n) diff = true - transformed.add(n) - } - return if (diff) transformed else nodes - } - - private inline fun _visitListNull( - nodes: List, - ctx: C, - method: (node: T, ctx: C) -> PlanNode, - ): List { - if (nodes.isEmpty()) return nodes - var diff = false - val transformed = ArrayList(nodes.size) - nodes.forEach { - val n = if (it == null) null else method(it, ctx) as T - if (it !== n) diff = true - transformed.add(n) - } - return if (diff) transformed else nodes - } - - private inline fun _visitSet( - nodes: Set, - ctx: C, - method: (node: T, ctx: C) -> PlanNode, - ): Set { - if (nodes.isEmpty()) return nodes - var diff = false - val transformed = HashSet(nodes.size) - nodes.forEach { - val n = method(it, ctx) as T - if (it !== n) diff = true - transformed.add(n) - } - return if (diff) transformed else nodes - } - - private inline fun _visitSetNull( - nodes: Set, - ctx: C, - method: (node: T, ctx: C) -> PlanNode, - ): Set { - if (nodes.isEmpty()) return nodes - var diff = false - val transformed = HashSet(nodes.size) - nodes.forEach { - val n = if (it == null) null else method(it, ctx) as T - if (it !== n) diff = true - transformed.add(n) - } - return if (diff) transformed else nodes - } - - override fun visitPartiQLPlan(node: PartiQLPlan, ctx: C): PlanNode { - val version = node.version - val globals = _visitList(node.catalogs, ctx, ::visitCatalog) - val statement = visitStatement(node.statement, ctx) as Statement - return if (version !== node.version || globals !== node.catalogs || statement !== node.statement) { - PartiQLPlan(version, globals, statement) - } else { - node - } - } - - override fun visitCatalog(node: Catalog, ctx: C): PlanNode { - val name = node.name - val symbols = _visitList(node.symbols, ctx, ::visitCatalogSymbol) - return if (name !== node.name || symbols !== node.symbols) { - Catalog(name, symbols) - } else { - node - } - } - - override fun visitCatalogSymbol(node: Catalog.Symbol, ctx: C): PlanNode { - val path = node.path - val type = node.type - return node - } - - override fun visitCatalogSymbolRef(node: Catalog.Symbol.Ref, ctx: C): PlanNode { - val catalog = node.catalog - val symbol = node.symbol - return node - } - - override fun visitFnResolved(node: Fn.Resolved, ctx: C): PlanNode { - val signature = node.signature - return node - } - - override fun visitFnUnresolved(node: Fn.Unresolved, ctx: C): PlanNode { - val identifier = visitIdentifier(node.identifier, ctx) as Identifier - val isHidden = node.isHidden - return if (identifier !== node.identifier || isHidden !== node.isHidden) { - Fn.Unresolved(identifier, isHidden) - } else { - node - } - } - - override fun visitAggResolved(node: Agg.Resolved, ctx: C): PlanNode { - val signature = node.signature - return node - } - - override fun visitAggUnresolved(node: Agg.Unresolved, ctx: C): PlanNode { - val identifier = visitIdentifier(node.identifier, ctx) as Identifier - return if (identifier !== node.identifier) { - Agg.Unresolved(identifier) - } else { - node - } - } - - override fun visitStatementQuery(node: Statement.Query, ctx: C): PlanNode { - val root = visitRex(node.root, ctx) as Rex - return if (root !== node.root) { - Statement.Query(root) - } else { - node - } - } - - override fun visitIdentifierSymbol(node: Identifier.Symbol, ctx: C): PlanNode { - val symbol = node.symbol - val caseSensitivity = node.caseSensitivity - return node - } - - override fun visitIdentifierQualified(node: Identifier.Qualified, ctx: C): PlanNode { - val root = visitIdentifierSymbol(node.root, ctx) as Identifier.Symbol - val steps = _visitList(node.steps, ctx, ::visitIdentifierSymbol) - return if (root !== node.root || steps !== node.steps) { - Identifier.Qualified(root, steps) - } else { - node - } - } - - override fun visitRex(node: Rex, ctx: C): PlanNode { - val type = node.type - val op = visitRexOp(node.op, ctx) as Rex.Op - return if (type !== node.type || op !== node.op) { - Rex(type, op) - } else { - node - } - } - - @OptIn(PartiQLValueExperimental::class) - override fun visitRexOpLit(node: Rex.Op.Lit, ctx: C): PlanNode { - val value = node.value - return node - } - - override fun visitRexOpVarResolved(node: Rex.Op.Var.Resolved, ctx: C): PlanNode { - val ref = node.ref - return node - } - - override fun visitRexOpVarUnresolved(node: Rex.Op.Var.Unresolved, ctx: C): PlanNode { - val identifier = visitIdentifier(node.identifier, ctx) as Identifier - val scope = node.scope - return if (identifier !== node.identifier || scope !== node.scope) { - Rex.Op.Var.Unresolved(identifier, scope) - } else { - node - } - } - - override fun visitRexOpGlobal(node: Rex.Op.Global, ctx: C): PlanNode { - val ref = visitCatalogSymbolRef(node.ref, ctx) as Catalog.Symbol.Ref - return if (ref !== node.ref) { - Rex.Op.Global(ref) - } else { - node - } - } - - override fun visitRexOpPathIndex(node: Rex.Op.Path.Index, ctx: C): PlanNode { - val root = visitRex(node.root, ctx) as Rex - val key = visitRex(node.key, ctx) as Rex - return if (root !== node.root || key !== node.key) { - Rex.Op.Path.Index(root, key) - } else { - node - } - } - - override fun visitRexOpPathKey(node: Rex.Op.Path.Key, ctx: C): PlanNode { - val root = visitRex(node.root, ctx) as Rex - val key = visitRex(node.key, ctx) as Rex - return if (root !== node.root || key !== node.key) { - Rex.Op.Path.Key(root, key) - } else { - node - } - } - - override fun visitRexOpPathSymbol(node: Rex.Op.Path.Symbol, ctx: C): PlanNode { - val root = visitRex(node.root, ctx) as Rex - val key = node.key - return if (root !== node.root || key !== node.key) { - Rex.Op.Path.Symbol(root, key) - } else { - node - } - } - - override fun visitRexOpCallStatic(node: Rex.Op.Call.Static, ctx: C): PlanNode { - val fn = visitFn(node.fn, ctx) as Fn - val args = _visitList(node.args, ctx, ::visitRex) - return if (fn !== node.fn || args !== node.args) { - Rex.Op.Call.Static(fn, args) - } else { - node - } - } - - override fun visitRexOpCallDynamic(node: Rex.Op.Call.Dynamic, ctx: C): PlanNode { - val args = _visitList(node.args, ctx, ::visitRex) - val candidates = _visitList(node.candidates, ctx, ::visitRexOpCallDynamicCandidate) - return if (args !== node.args || candidates !== node.candidates) { - Rex.Op.Call.Dynamic(args, candidates) - } else { - node - } - } - - override fun visitRexOpCallDynamicCandidate(node: Rex.Op.Call.Dynamic.Candidate, ctx: C): PlanNode { - val fn = visitFnResolved(node.fn, ctx) as Fn.Resolved - val coercions = _visitListNull(node.coercions, ctx, ::visitFnResolved) - return if (fn !== node.fn || coercions !== node.coercions) { - Rex.Op.Call.Dynamic.Candidate(fn, coercions) - } else { - node - } - } - - override fun visitRexOpCase(node: Rex.Op.Case, ctx: C): PlanNode { - val branches = _visitList(node.branches, ctx, ::visitRexOpCaseBranch) - val default = visitRex(node.default, ctx) as Rex - return if (branches !== node.branches || default !== node.default) { - Rex.Op.Case(branches, default) - } else { - node - } - } - - override fun visitRexOpCaseBranch(node: Rex.Op.Case.Branch, ctx: C): PlanNode { - val condition = visitRex(node.condition, ctx) as Rex - val rex = visitRex(node.rex, ctx) as Rex - return if (condition !== node.condition || rex !== node.rex) { - Rex.Op.Case.Branch(condition, rex) - } else { - node - } - } - - override fun visitRexOpCollection(node: Rex.Op.Collection, ctx: C): PlanNode { - val values = _visitList(node.values, ctx, ::visitRex) - return if (values !== node.values) { - Rex.Op.Collection(values) - } else { - node - } - } - - override fun visitRexOpStruct(node: Rex.Op.Struct, ctx: C): PlanNode { - val fields = _visitList(node.fields, ctx, ::visitRexOpStructField) - return if (fields !== node.fields) { - Rex.Op.Struct(fields) - } else { - node - } - } - - override fun visitRexOpStructField(node: Rex.Op.Struct.Field, ctx: C): PlanNode { - val k = visitRex(node.k, ctx) as Rex - val v = visitRex(node.v, ctx) as Rex - return if (k !== node.k || v !== node.v) { - Rex.Op.Struct.Field(k, v) - } else { - node - } - } - - override fun visitRexOpPivot(node: Rex.Op.Pivot, ctx: C): PlanNode { - val key = visitRex(node.key, ctx) as Rex - val value = visitRex(node.value, ctx) as Rex - val rel = visitRel(node.rel, ctx) as Rel - return if (key !== node.key || value !== node.value || rel !== node.rel) { - Rex.Op.Pivot(key, value, rel) - } else { - node - } - } - - override fun visitRexOpSubquery(node: Rex.Op.Subquery, ctx: C): PlanNode { - val select = visitRexOpSelect(node.select, ctx) as Rex.Op.Select - val coercion = node.coercion - return if (select !== node.select || coercion !== node.coercion) { - Rex.Op.Subquery(select, coercion) - } else { - node - } - } - - override fun visitRexOpSelect(node: Rex.Op.Select, ctx: C): PlanNode { - val constructor = visitRex(node.constructor, ctx) as Rex - val rel = visitRel(node.rel, ctx) as Rel - return if (constructor !== node.constructor || rel !== node.rel) { - Rex.Op.Select(constructor, rel) - } else { - node - } - } - - override fun visitRexOpTupleUnion(node: Rex.Op.TupleUnion, ctx: C): PlanNode { - val args = _visitList(node.args, ctx, ::visitRex) - return if (args !== node.args) { - Rex.Op.TupleUnion(args) - } else { - node - } - } - - override fun visitRexOpErr(node: Rex.Op.Err, ctx: C): PlanNode { - val message = node.message - return node - } - - override fun visitRel(node: Rel, ctx: C): PlanNode { - val type = visitRelType(node.type, ctx) as Rel.Type - val op = visitRelOp(node.op, ctx) as Rel.Op - return if (type !== node.type || op !== node.op) { - Rel(type, op) - } else { - node - } - } - - override fun visitRelType(node: Rel.Type, ctx: C): PlanNode { - val schema = _visitList(node.schema, ctx, ::visitRelBinding) - val props = node.props - return if (schema !== node.schema || props !== node.props) { - Rel.Type(schema, props) - } else { - node - } - } - - override fun visitRelOpScan(node: Rel.Op.Scan, ctx: C): PlanNode { - val rex = visitRex(node.rex, ctx) as Rex - return if (rex !== node.rex) { - Rel.Op.Scan(rex) - } else { - node - } - } - - override fun visitRelOpScanIndexed(node: Rel.Op.ScanIndexed, ctx: C): PlanNode { - val rex = visitRex(node.rex, ctx) as Rex - return if (rex !== node.rex) { - Rel.Op.ScanIndexed(rex) - } else { - node - } - } - - override fun visitRelOpUnpivot(node: Rel.Op.Unpivot, ctx: C): PlanNode { - val rex = visitRex(node.rex, ctx) as Rex - return if (rex !== node.rex) { - Rel.Op.Unpivot(rex) - } else { - node - } - } - - override fun visitRelOpDistinct(node: Rel.Op.Distinct, ctx: C): PlanNode { - val input = visitRel(node.input, ctx) as Rel - return if (input !== node.input) { - Rel.Op.Distinct(input) - } else { - node - } - } - - override fun visitRelOpFilter(node: Rel.Op.Filter, ctx: C): PlanNode { - val input = visitRel(node.input, ctx) as Rel - val predicate = visitRex(node.predicate, ctx) as Rex - return if (input !== node.input || predicate !== node.predicate) { - Rel.Op.Filter(input, predicate) - } else { - node - } - } - - override fun visitRelOpSort(node: Rel.Op.Sort, ctx: C): PlanNode { - val input = visitRel(node.input, ctx) as Rel - val specs = _visitList(node.specs, ctx, ::visitRelOpSortSpec) - return if (input !== node.input || specs !== node.specs) { - Rel.Op.Sort(input, specs) - } else { - node - } - } - - override fun visitRelOpSortSpec(node: Rel.Op.Sort.Spec, ctx: C): PlanNode { - val rex = visitRex(node.rex, ctx) as Rex - val order = node.order - return if (rex !== node.rex || order !== node.order) { - Rel.Op.Sort.Spec(rex, order) - } else { - node - } - } - - override fun visitRelOpUnion(node: Rel.Op.Union, ctx: C): PlanNode { - val lhs = visitRel(node.lhs, ctx) as Rel - val rhs = visitRel(node.rhs, ctx) as Rel - return if (lhs !== node.lhs || rhs !== node.rhs) { - Rel.Op.Union(lhs, rhs) - } else { - node - } - } - - override fun visitRelOpIntersect(node: Rel.Op.Intersect, ctx: C): PlanNode { - val lhs = visitRel(node.lhs, ctx) as Rel - val rhs = visitRel(node.rhs, ctx) as Rel - return if (lhs !== node.lhs || rhs !== node.rhs) { - Rel.Op.Intersect(lhs, rhs) - } else { - node - } - } - - override fun visitRelOpExcept(node: Rel.Op.Except, ctx: C): PlanNode { - val lhs = visitRel(node.lhs, ctx) as Rel - val rhs = visitRel(node.rhs, ctx) as Rel - return if (lhs !== node.lhs || rhs !== node.rhs) { - Rel.Op.Except(lhs, rhs) - } else { - node - } - } - - override fun visitRelOpLimit(node: Rel.Op.Limit, ctx: C): PlanNode { - val input = visitRel(node.input, ctx) as Rel - val limit = visitRex(node.limit, ctx) as Rex - return if (input !== node.input || limit !== node.limit) { - Rel.Op.Limit(input, limit) - } else { - node - } - } - - override fun visitRelOpOffset(node: Rel.Op.Offset, ctx: C): PlanNode { - val input = visitRel(node.input, ctx) as Rel - val offset = visitRex(node.offset, ctx) as Rex - return if (input !== node.input || offset !== node.offset) { - Rel.Op.Offset(input, offset) - } else { - node - } - } - - override fun visitRelOpProject(node: Rel.Op.Project, ctx: C): PlanNode { - val input = visitRel(node.input, ctx) as Rel - val projections = _visitList(node.projections, ctx, ::visitRex) - return if (input !== node.input || projections !== node.projections) { - Rel.Op.Project(input, projections) - } else { - node - } - } - - override fun visitRelOpJoin(node: Rel.Op.Join, ctx: C): PlanNode { - val lhs = visitRel(node.lhs, ctx) as Rel - val rhs = visitRel(node.rhs, ctx) as Rel - val rex = visitRex(node.rex, ctx) as Rex - val type = node.type - return if (lhs !== node.lhs || rhs !== node.rhs || rex !== node.rex || type !== node.type) { - Rel.Op.Join(lhs, rhs, rex, type) - } else { - node - } - } - - override fun visitRelOpAggregate(node: Rel.Op.Aggregate, ctx: C): PlanNode { - val input = visitRel(node.input, ctx) as Rel - val strategy = node.strategy - val calls = _visitList(node.calls, ctx, ::visitRelOpAggregateCall) - val groups = _visitList(node.groups, ctx, ::visitRex) - return if (input !== node.input || strategy !== node.strategy || calls !== node.calls || groups !== node.groups) { - Rel.Op.Aggregate(input, strategy, calls, groups) - } else { - node - } - } - - override fun visitRelOpAggregateCall(node: Rel.Op.Aggregate.Call, ctx: C): PlanNode { - val agg = visitAgg(node.agg, ctx) as Agg - val args = _visitList(node.args, ctx, ::visitRex) - return if (agg !== node.agg || args !== node.args) { - Rel.Op.Aggregate.Call(agg, args) - } else { - node - } - } - - override fun visitRelOpExclude(node: Rel.Op.Exclude, ctx: C): PlanNode { - val input = visitRel(node.input, ctx) as Rel - val items = _visitList(node.items, ctx, ::visitRelOpExcludeItem) - return if (input !== node.input || items !== node.items) { - Rel.Op.Exclude(input, items) - } else { - node - } - } - - override fun visitRelOpExcludeItem(node: Rel.Op.Exclude.Item, ctx: C): PlanNode { - val root = visitRexOpVar(node.root, ctx) as Rex.Op.Var - val steps = _visitList(node.steps, ctx, ::visitRelOpExcludeStep) - return if (root !== node.root || steps !== node.steps) { - Rel.Op.Exclude.Item(root, steps) - } else { - node - } - } - - override fun visitRelOpExcludeStepStructField( - node: Rel.Op.Exclude.Step.StructField, - ctx: C - ): PlanNode { - val symbol = visitIdentifierSymbol(node.symbol, ctx) as Identifier.Symbol - return if (symbol !== node.symbol) { - Rel.Op.Exclude.Step.StructField(symbol) - } else { - node - } - } - - override fun visitRelOpExcludeStepCollIndex(node: Rel.Op.Exclude.Step.CollIndex, ctx: C): - PlanNode { - val index = node.index - return node - } - - override fun visitRelOpExcludeStepStructWildcard( - node: Rel.Op.Exclude.Step.StructWildcard, - ctx: C - ): PlanNode = node - - override fun visitRelOpExcludeStepCollWildcard( - node: Rel.Op.Exclude.Step.CollWildcard, - ctx: C - ): PlanNode = node - - override fun visitRelOpErr(node: Rel.Op.Err, ctx: C): PlanNode { - val message = node.message - return node - } - - override fun visitRelBinding(node: Rel.Binding, ctx: C): PlanNode { - val name = node.name - val type = node.type - return node - } -} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/visitor/PlanBaseVisitor.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/visitor/PlanBaseVisitor.kt deleted file mode 100644 index 901d17895a..0000000000 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/visitor/PlanBaseVisitor.kt +++ /dev/null @@ -1,273 +0,0 @@ -@file:OptIn(PartiQLValueExperimental::class) - -package org.partiql.planner.internal.ir.visitor - -import org.partiql.planner.internal.ir.Agg -import org.partiql.planner.internal.ir.Catalog -import org.partiql.planner.internal.ir.Fn -import org.partiql.planner.internal.ir.Identifier -import org.partiql.planner.internal.ir.PartiQLPlan -import org.partiql.planner.internal.ir.PlanNode -import org.partiql.planner.internal.ir.Rel -import org.partiql.planner.internal.ir.Rex -import org.partiql.planner.internal.ir.Statement -import org.partiql.value.PartiQLValueExperimental - -internal abstract class PlanBaseVisitor : PlanVisitor { - override fun visit(node: PlanNode, ctx: C): R = node.accept(this, ctx) - - override fun visitPartiQLPlan(node: PartiQLPlan, ctx: C): R = defaultVisit(node, ctx) - - public override fun visitCatalog(node: Catalog, ctx: C): R = defaultVisit(node, ctx) - - public override fun visitCatalogSymbol(node: Catalog.Symbol, ctx: C): R = defaultVisit(node, ctx) - - public override fun visitCatalogSymbolRef(node: Catalog.Symbol.Ref, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitFn(node: Fn, ctx: C): R = when (node) { - is Fn.Resolved -> visitFnResolved(node, ctx) - is Fn.Unresolved -> visitFnUnresolved(node, ctx) - } - - override fun visitFnResolved(node: Fn.Resolved, ctx: C): R = defaultVisit(node, ctx) - - override fun visitFnUnresolved(node: Fn.Unresolved, ctx: C): R = defaultVisit(node, ctx) - - override fun visitAgg(node: Agg, ctx: C): R = when (node) { - is Agg.Resolved -> visitAggResolved(node, ctx) - is Agg.Unresolved -> visitAggUnresolved(node, ctx) - } - - override fun visitAggResolved(node: Agg.Resolved, ctx: C): R = defaultVisit(node, ctx) - - override fun visitAggUnresolved(node: Agg.Unresolved, ctx: C): R = defaultVisit(node, ctx) - - override fun visitStatement(node: Statement, ctx: C): R = when (node) { - is Statement.Query -> visitStatementQuery(node, ctx) - } - - override fun visitStatementQuery(node: Statement.Query, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitIdentifier(node: Identifier, ctx: C): R = when (node) { - is Identifier.Symbol -> visitIdentifierSymbol(node, ctx) - is Identifier.Qualified -> visitIdentifierQualified(node, ctx) - } - - override fun visitIdentifierSymbol(node: Identifier.Symbol, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitIdentifierQualified(node: Identifier.Qualified, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitRex(node: Rex, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRexOp(node: Rex.Op, ctx: C): R = when (node) { - is Rex.Op.Lit -> visitRexOpLit(node, ctx) - is Rex.Op.Var -> visitRexOpVar(node, ctx) - is Rex.Op.Global -> visitRexOpGlobal(node, ctx) - is Rex.Op.Path -> visitRexOpPath(node, ctx) - is Rex.Op.Call -> visitRexOpCall(node, ctx) - is Rex.Op.Case -> visitRexOpCase(node, ctx) - is Rex.Op.Collection -> visitRexOpCollection(node, ctx) - is Rex.Op.Struct -> visitRexOpStruct(node, ctx) - is Rex.Op.Pivot -> visitRexOpPivot(node, ctx) - is Rex.Op.Subquery -> visitRexOpSubquery(node, ctx) - is Rex.Op.Select -> visitRexOpSelect(node, ctx) - is Rex.Op.TupleUnion -> visitRexOpTupleUnion(node, ctx) - is Rex.Op.Err -> visitRexOpErr(node, ctx) - } - - override fun visitRexOpLit(node: Rex.Op.Lit, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRexOpVar(node: Rex.Op.Var, ctx: C): R = when (node) { - is Rex.Op.Var.Resolved -> visitRexOpVarResolved(node, ctx) - is Rex.Op.Var.Unresolved -> visitRexOpVarUnresolved(node, ctx) - } - - override fun visitRexOpVarResolved(node: Rex.Op.Var.Resolved, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitRexOpVarUnresolved(node: Rex.Op.Var.Unresolved, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitRexOpGlobal(node: Rex.Op.Global, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRexOpPath(node: Rex.Op.Path, ctx: C): R = when (node) { - is Rex.Op.Path.Index -> visitRexOpPathIndex(node, ctx) - is Rex.Op.Path.Key -> visitRexOpPathKey(node, ctx) - is Rex.Op.Path.Symbol -> visitRexOpPathSymbol(node, ctx) - } - - override fun visitRexOpPathIndex(node: Rex.Op.Path.Index, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitRexOpPathKey(node: Rex.Op.Path.Key, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRexOpPathSymbol(node: Rex.Op.Path.Symbol, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitRexOpCall(node: Rex.Op.Call, ctx: C): R = when (node) { - is Rex.Op.Call.Static -> visitRexOpCallStatic(node, ctx) - is Rex.Op.Call.Dynamic -> visitRexOpCallDynamic(node, ctx) - } - - override fun visitRexOpCallStatic(node: Rex.Op.Call.Static, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitRexOpCallDynamic(node: Rex.Op.Call.Dynamic, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitRexOpCallDynamicCandidate(node: Rex.Op.Call.Dynamic.Candidate, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitRexOpCase(node: Rex.Op.Case, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRexOpCaseBranch(node: Rex.Op.Case.Branch, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitRexOpCollection(node: Rex.Op.Collection, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitRexOpStruct(node: Rex.Op.Struct, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRexOpStructField(node: Rex.Op.Struct.Field, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitRexOpPivot(node: Rex.Op.Pivot, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRexOpSubquery(node: Rex.Op.Subquery, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRexOpSelect(node: Rex.Op.Select, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRexOpTupleUnion(node: Rex.Op.TupleUnion, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitRexOpErr(node: Rex.Op.Err, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRel(node: Rel, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelType(node: Rel.Type, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOp(node: Rel.Op, ctx: C): R = when (node) { - is Rel.Op.Scan -> visitRelOpScan(node, ctx) - is Rel.Op.ScanIndexed -> visitRelOpScanIndexed(node, ctx) - is Rel.Op.Unpivot -> visitRelOpUnpivot(node, ctx) - is Rel.Op.Distinct -> visitRelOpDistinct(node, ctx) - is Rel.Op.Filter -> visitRelOpFilter(node, ctx) - is Rel.Op.Sort -> visitRelOpSort(node, ctx) - is Rel.Op.Union -> visitRelOpUnion(node, ctx) - is Rel.Op.Intersect -> visitRelOpIntersect(node, ctx) - is Rel.Op.Except -> visitRelOpExcept(node, ctx) - is Rel.Op.Limit -> visitRelOpLimit(node, ctx) - is Rel.Op.Offset -> visitRelOpOffset(node, ctx) - is Rel.Op.Project -> visitRelOpProject(node, ctx) - is Rel.Op.Join -> visitRelOpJoin(node, ctx) - is Rel.Op.Aggregate -> visitRelOpAggregate(node, ctx) - is Rel.Op.Exclude -> visitRelOpExclude(node, ctx) - is Rel.Op.Err -> visitRelOpErr(node, ctx) - } - - override fun visitRelOpScan(node: Rel.Op.Scan, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpScanIndexed(node: Rel.Op.ScanIndexed, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitRelOpUnpivot(node: Rel.Op.Unpivot, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpDistinct(node: Rel.Op.Distinct, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpFilter(node: Rel.Op.Filter, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpSort(node: Rel.Op.Sort, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpSortSpec(node: Rel.Op.Sort.Spec, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitRelOpUnion(node: Rel.Op.Union, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpIntersect(node: Rel.Op.Intersect, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitRelOpExcept(node: Rel.Op.Except, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpLimit(node: Rel.Op.Limit, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpOffset(node: Rel.Op.Offset, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpProject(node: Rel.Op.Project, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpJoin(node: Rel.Op.Join, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpAggregate(node: Rel.Op.Aggregate, ctx: C): R = defaultVisit( - node, - ctx - ) - - override fun visitRelOpAggregateCall(node: Rel.Op.Aggregate.Call, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitRelOpExclude(node: Rel.Op.Exclude, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelOpExcludeItem(node: Rel.Op.Exclude.Item, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitRelOpExcludeStep(node: Rel.Op.Exclude.Step, ctx: C): R = when (node) { - is Rel.Op.Exclude.Step.StructField -> visitRelOpExcludeStepStructField(node, ctx) - is Rel.Op.Exclude.Step.CollIndex -> visitRelOpExcludeStepCollIndex(node, ctx) - is Rel.Op.Exclude.Step.StructWildcard -> visitRelOpExcludeStepStructWildcard(node, ctx) - is Rel.Op.Exclude.Step.CollWildcard -> visitRelOpExcludeStepCollWildcard(node, ctx) - } - - override fun visitRelOpExcludeStepStructField( - node: Rel.Op.Exclude.Step.StructField, - ctx: C - ): R = defaultVisit(node, ctx) - - override fun visitRelOpExcludeStepCollIndex(node: Rel.Op.Exclude.Step.CollIndex, ctx: C): R = - defaultVisit(node, ctx) - - override fun visitRelOpExcludeStepStructWildcard( - node: Rel.Op.Exclude.Step.StructWildcard, - ctx: C - ): R = defaultVisit(node, ctx) - - override fun visitRelOpExcludeStepCollWildcard( - node: Rel.Op.Exclude.Step.CollWildcard, - ctx: C - ): R = defaultVisit(node, ctx) - - override fun visitRelOpErr(node: Rel.Op.Err, ctx: C): R = defaultVisit(node, ctx) - - override fun visitRelBinding(node: Rel.Binding, ctx: C): R = defaultVisit(node, ctx) - - internal open fun defaultVisit(node: PlanNode, ctx: C): R { - for (child in node.children) { - child.accept(this, ctx) - } - return defaultReturn(node, ctx) - } - - internal abstract fun defaultReturn(node: PlanNode, ctx: C): R -} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/visitor/PlanVisitor.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/visitor/PlanVisitor.kt deleted file mode 100644 index c2fd04e7b0..0000000000 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/ir/visitor/PlanVisitor.kt +++ /dev/null @@ -1,153 +0,0 @@ -@file:OptIn(PartiQLValueExperimental::class) - -package org.partiql.planner.internal.ir.visitor - -import org.partiql.planner.internal.ir.Agg -import org.partiql.planner.internal.ir.Catalog -import org.partiql.planner.internal.ir.Fn -import org.partiql.planner.internal.ir.Identifier -import org.partiql.planner.internal.ir.PartiQLPlan -import org.partiql.planner.internal.ir.PlanNode -import org.partiql.planner.internal.ir.Rel -import org.partiql.planner.internal.ir.Rex -import org.partiql.planner.internal.ir.Statement -import org.partiql.value.PartiQLValueExperimental - -internal interface PlanVisitor { - fun visit(node: PlanNode, ctx: C): R - - fun visitPartiQLPlan(node: PartiQLPlan, ctx: C): R - - public fun visitCatalog(node: Catalog, ctx: C): R - - public fun visitCatalogSymbol(node: Catalog.Symbol, ctx: C): R - - public fun visitCatalogSymbolRef(node: Catalog.Symbol.Ref, ctx: C): R - - fun visitFn(node: Fn, ctx: C): R - - fun visitFnResolved(node: Fn.Resolved, ctx: C): R - - fun visitFnUnresolved(node: Fn.Unresolved, ctx: C): R - - fun visitAgg(node: Agg, ctx: C): R - - fun visitAggResolved(node: Agg.Resolved, ctx: C): R - - fun visitAggUnresolved(node: Agg.Unresolved, ctx: C): R - - fun visitStatement(node: Statement, ctx: C): R - - fun visitStatementQuery(node: Statement.Query, ctx: C): R - - fun visitIdentifier(node: Identifier, ctx: C): R - - fun visitIdentifierSymbol(node: Identifier.Symbol, ctx: C): R - - fun visitIdentifierQualified(node: Identifier.Qualified, ctx: C): R - - fun visitRex(node: Rex, ctx: C): R - - fun visitRexOp(node: Rex.Op, ctx: C): R - - fun visitRexOpLit(node: Rex.Op.Lit, ctx: C): R - - fun visitRexOpVar(node: Rex.Op.Var, ctx: C): R - - fun visitRexOpVarResolved(node: Rex.Op.Var.Resolved, ctx: C): R - - fun visitRexOpVarUnresolved(node: Rex.Op.Var.Unresolved, ctx: C): R - - fun visitRexOpGlobal(node: Rex.Op.Global, ctx: C): R - - fun visitRexOpPath(node: Rex.Op.Path, ctx: C): R - - fun visitRexOpPathIndex(node: Rex.Op.Path.Index, ctx: C): R - - fun visitRexOpPathKey(node: Rex.Op.Path.Key, ctx: C): R - - fun visitRexOpPathSymbol(node: Rex.Op.Path.Symbol, ctx: C): R - - fun visitRexOpCall(node: Rex.Op.Call, ctx: C): R - - fun visitRexOpCallStatic(node: Rex.Op.Call.Static, ctx: C): R - - fun visitRexOpCallDynamic(node: Rex.Op.Call.Dynamic, ctx: C): R - - fun visitRexOpCallDynamicCandidate(node: Rex.Op.Call.Dynamic.Candidate, ctx: C): R - - fun visitRexOpCase(node: Rex.Op.Case, ctx: C): R - - fun visitRexOpCaseBranch(node: Rex.Op.Case.Branch, ctx: C): R - - fun visitRexOpCollection(node: Rex.Op.Collection, ctx: C): R - - fun visitRexOpStruct(node: Rex.Op.Struct, ctx: C): R - - fun visitRexOpStructField(node: Rex.Op.Struct.Field, ctx: C): R - - fun visitRexOpPivot(node: Rex.Op.Pivot, ctx: C): R - - fun visitRexOpSubquery(node: Rex.Op.Subquery, ctx: C): R - - fun visitRexOpSelect(node: Rex.Op.Select, ctx: C): R - - fun visitRexOpTupleUnion(node: Rex.Op.TupleUnion, ctx: C): R - - fun visitRexOpErr(node: Rex.Op.Err, ctx: C): R - - fun visitRel(node: Rel, ctx: C): R - - fun visitRelType(node: Rel.Type, ctx: C): R - - fun visitRelOp(node: Rel.Op, ctx: C): R - - fun visitRelOpScan(node: Rel.Op.Scan, ctx: C): R - - fun visitRelOpScanIndexed(node: Rel.Op.ScanIndexed, ctx: C): R - - fun visitRelOpUnpivot(node: Rel.Op.Unpivot, ctx: C): R - - fun visitRelOpDistinct(node: Rel.Op.Distinct, ctx: C): R - - fun visitRelOpFilter(node: Rel.Op.Filter, ctx: C): R - - fun visitRelOpSort(node: Rel.Op.Sort, ctx: C): R - - fun visitRelOpSortSpec(node: Rel.Op.Sort.Spec, ctx: C): R - - fun visitRelOpUnion(node: Rel.Op.Union, ctx: C): R - - fun visitRelOpIntersect(node: Rel.Op.Intersect, ctx: C): R - - fun visitRelOpExcept(node: Rel.Op.Except, ctx: C): R - - fun visitRelOpLimit(node: Rel.Op.Limit, ctx: C): R - - fun visitRelOpOffset(node: Rel.Op.Offset, ctx: C): R - - fun visitRelOpProject(node: Rel.Op.Project, ctx: C): R - - fun visitRelOpJoin(node: Rel.Op.Join, ctx: C): R - - fun visitRelOpAggregate(node: Rel.Op.Aggregate, ctx: C): R - - fun visitRelOpAggregateCall(node: Rel.Op.Aggregate.Call, ctx: C): R - - fun visitRelOpExclude(node: Rel.Op.Exclude, ctx: C): R - - fun visitRelOpExcludeItem(node: Rel.Op.Exclude.Item, ctx: C): R - - fun visitRelOpExcludeStep(node: Rel.Op.Exclude.Step, ctx: C): R - - fun visitRelOpExcludeStepStructField(node: Rel.Op.Exclude.Step.StructField, ctx: C): R - - fun visitRelOpExcludeStepCollIndex(node: Rel.Op.Exclude.Step.CollIndex, ctx: C): R - - fun visitRelOpExcludeStepStructWildcard(node: Rel.Op.Exclude.Step.StructWildcard, ctx: C): - R - - fun visitRelOpExcludeStepCollWildcard(node: Rel.Op.Exclude.Step.CollWildcard, ctx: C): R fun visitRelOpErr(node: Rel.Op.Err, ctx: C): R - - fun visitRelBinding(node: Rel.Binding, ctx: C): R -} diff --git a/partiql-planner/src/main/resources/builtins.sql b/partiql-planner/src/main/resources/builtins.sql deleted file mode 100644 index a15ead3f63..0000000000 --- a/partiql-planner/src/main/resources/builtins.sql +++ /dev/null @@ -1,1681 +0,0 @@ --- [trim] --------- - -CREATE FUNCTION "TRIM"( - VALUE STRING) - RETURNS STRING - SPECIFIC - - RETURN TRIM ( VALUE ); - -CREATE FUNCTION "TRIM"( - VALUE NULLABLE_STRING) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN TRIM ( VALUE ); - -CREATE FUNCTION "TRIM"( - VALUE SYMBOL) - RETURNS SYMBOL - SPECIFIC - - RETURN TRIM ( VALUE ); - -CREATE FUNCTION "TRIM"( - VALUE NULLABLE_SYMBOL) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN TRIM ( VALUE ); - - --- [trim_leading] --------- - -CREATE FUNCTION "TRIM_LEADING"( - VALUE STRING) - RETURNS STRING - SPECIFIC - - RETURN TRIM_LEADING ( VALUE ); - -CREATE FUNCTION "TRIM_LEADING"( - VALUE NULLABLE_STRING) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN TRIM_LEADING ( VALUE ); - -CREATE FUNCTION "TRIM_LEADING"( - VALUE SYMBOL) - RETURNS SYMBOL - SPECIFIC - - RETURN TRIM_LEADING ( VALUE ); - -CREATE FUNCTION "TRIM_LEADING"( - VALUE NULLABLE_SYMBOL) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN TRIM_LEADING ( VALUE ); - - --- [trim_trailing] --------- - -CREATE FUNCTION "TRIM_TRAILING"( - VALUE STRING) - RETURNS STRING - SPECIFIC - - RETURN TRIM_TRAILING ( VALUE ); - -CREATE FUNCTION "TRIM_TRAILING"( - VALUE NULLABLE_STRING) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN TRIM_TRAILING ( VALUE ); - -CREATE FUNCTION "TRIM_TRAILING"( - VALUE SYMBOL) - RETURNS SYMBOL - SPECIFIC - - RETURN TRIM_TRAILING ( VALUE ); - -CREATE FUNCTION "TRIM_TRAILING"( - VALUE NULLABLE_SYMBOL) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN TRIM_TRAILING ( VALUE ); - - --- [null_if] --------- - -CREATE FUNCTION "NULL_IF"( - VALUE NULL - NULLIFIER BOOL) - RETURNS NULL - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE MISSING - NULLIFIER BOOL) - RETURNS MISSING - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_BOOL - NULLIFIER BOOL) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_INT8 - NULLIFIER BOOL) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_INT16 - NULLIFIER BOOL) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_INT32 - NULLIFIER BOOL) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_INT64 - NULLIFIER BOOL) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_INT - NULLIFIER BOOL) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_DECIMAL - NULLIFIER BOOL) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_FLOAT32 - NULLIFIER BOOL) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_FLOAT64 - NULLIFIER BOOL) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_CHAR - NULLIFIER BOOL) - RETURNS NULLABLE_CHAR - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_STRING - NULLIFIER BOOL) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_SYMBOL - NULLIFIER BOOL) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_CLOB - NULLIFIER BOOL) - RETURNS NULLABLE_CLOB - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_BINARY - NULLIFIER BOOL) - RETURNS NULLABLE_BINARY - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_BYTE - NULLIFIER BOOL) - RETURNS NULLABLE_BYTE - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_BLOB - NULLIFIER BOOL) - RETURNS NULLABLE_BLOB - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_DATE - NULLIFIER BOOL) - RETURNS NULLABLE_DATE - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_TIME - NULLIFIER BOOL) - RETURNS NULLABLE_TIME - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_TIMESTAMP - NULLIFIER BOOL) - RETURNS NULLABLE_TIMESTAMP - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_INTERVAL - NULLIFIER BOOL) - RETURNS NULLABLE_INTERVAL - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_LIST - NULLIFIER BOOL) - RETURNS NULLABLE_LIST - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_BAG - NULLIFIER BOOL) - RETURNS NULLABLE_BAG - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_SEXP - NULLIFIER BOOL) - RETURNS NULLABLE_SEXP - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - -CREATE FUNCTION "NULL_IF"( - VALUE NULLABLE_STRUCT - NULLIFIER BOOL) - RETURNS NULLABLE_STRUCT - SPECIFIC - - RETURN NULL_IF ( VALUE, NULLIFIER ); - - --- [in_collection] --------- - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULL - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE MISSING - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULL - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE MISSING - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULL - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE MISSING - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BOOL - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BOOL - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BOOL - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BOOL - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BOOL - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BOOL - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT8 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT8 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT8 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT8 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT8 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT8 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT16 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT16 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT16 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT16 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT16 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT16 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT32 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT32 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT32 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT32 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT32 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT32 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT64 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT64 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT64 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT64 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT64 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT64 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INT - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INT - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE DECIMAL - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE DECIMAL - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE DECIMAL - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_DECIMAL - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_DECIMAL - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_DECIMAL - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE FLOAT32 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE FLOAT32 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE FLOAT32 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_FLOAT32 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_FLOAT32 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_FLOAT32 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE FLOAT64 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE FLOAT64 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE FLOAT64 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_FLOAT64 - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_FLOAT64 - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_FLOAT64 - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE CHAR - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE CHAR - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE CHAR - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_CHAR - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_CHAR - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_CHAR - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE STRING - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE STRING - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE STRING - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_STRING - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_STRING - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_STRING - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE SYMBOL - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE SYMBOL - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE SYMBOL - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_SYMBOL - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_SYMBOL - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_SYMBOL - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE CLOB - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE CLOB - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE CLOB - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_CLOB - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_CLOB - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_CLOB - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BINARY - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BINARY - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BINARY - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BINARY - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BINARY - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BINARY - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BYTE - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BYTE - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BYTE - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BYTE - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BYTE - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BYTE - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BLOB - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BLOB - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BLOB - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BLOB - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BLOB - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BLOB - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE DATE - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE DATE - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE DATE - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_DATE - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_DATE - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_DATE - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE TIME - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE TIME - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE TIME - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_TIME - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_TIME - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_TIME - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE TIMESTAMP - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE TIMESTAMP - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE TIMESTAMP - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_TIMESTAMP - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_TIMESTAMP - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_TIMESTAMP - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INTERVAL - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INTERVAL - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE INTERVAL - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INTERVAL - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INTERVAL - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_INTERVAL - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE LIST - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE LIST - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE LIST - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_LIST - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_LIST - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_LIST - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BAG - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BAG - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE BAG - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BAG - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BAG - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_BAG - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE SEXP - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE SEXP - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE SEXP - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_SEXP - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_SEXP - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_SEXP - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE STRUCT - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE STRUCT - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE STRUCT - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_STRUCT - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_STRUCT - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE NULLABLE_STRUCT - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE GRAPH - COLLECTION LIST) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE GRAPH - COLLECTION BAG) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - -CREATE FUNCTION "IN_COLLECTION"( - VALUE GRAPH - COLLECTION SEXP) - RETURNS BOOL - SPECIFIC - - RETURN IN_COLLECTION ( VALUE, COLLECTION ); - - --- [substring] --------- - -CREATE FUNCTION "SUBSTRING"( - VALUE STRING - START INT64) - RETURNS STRING - SPECIFIC - - RETURN SUBSTRING ( VALUE, START ); - -CREATE FUNCTION "SUBSTRING"( - VALUE NULLABLE_STRING - START INT64) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN SUBSTRING ( VALUE, START ); - -CREATE FUNCTION "SUBSTRING"( - VALUE SYMBOL - START INT64) - RETURNS SYMBOL - SPECIFIC - - RETURN SUBSTRING ( VALUE, START ); - -CREATE FUNCTION "SUBSTRING"( - VALUE NULLABLE_SYMBOL - START INT64) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN SUBSTRING ( VALUE, START ); - - --- [like] --------- - -CREATE FUNCTION "LIKE"( - VALUE STRING - PATTERN STRING) - RETURNS BOOL - SPECIFIC - - RETURN LIKE ( VALUE, PATTERN ); - - --- [position] --------- - -CREATE FUNCTION "POSITION"( - PROBE STRING - VALUE STRING) - RETURNS INT64 - SPECIFIC - - RETURN POSITION ( PROBE, VALUE ); - -CREATE FUNCTION "POSITION"( - PROBE NULLABLE_STRING - VALUE NULLABLE_STRING) - RETURNS INT64 - SPECIFIC - - RETURN POSITION ( PROBE, VALUE ); - -CREATE FUNCTION "POSITION"( - PROBE SYMBOL - VALUE SYMBOL) - RETURNS INT64 - SPECIFIC - - RETURN POSITION ( PROBE, VALUE ); - -CREATE FUNCTION "POSITION"( - PROBE NULLABLE_SYMBOL - VALUE NULLABLE_SYMBOL) - RETURNS INT64 - SPECIFIC - - RETURN POSITION ( PROBE, VALUE ); - - --- [trim_chars] --------- - -CREATE FUNCTION "TRIM_CHARS"( - VALUE STRING - CHARS STRING) - RETURNS STRING - SPECIFIC - - RETURN TRIM_CHARS ( VALUE, CHARS ); - -CREATE FUNCTION "TRIM_CHARS"( - VALUE NULLABLE_STRING - CHARS NULLABLE_STRING) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN TRIM_CHARS ( VALUE, CHARS ); - -CREATE FUNCTION "TRIM_CHARS"( - VALUE SYMBOL - CHARS SYMBOL) - RETURNS SYMBOL - SPECIFIC - - RETURN TRIM_CHARS ( VALUE, CHARS ); - -CREATE FUNCTION "TRIM_CHARS"( - VALUE NULLABLE_SYMBOL - CHARS NULLABLE_SYMBOL) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN TRIM_CHARS ( VALUE, CHARS ); - - --- [trim_leading_chars] --------- - -CREATE FUNCTION "TRIM_LEADING_CHARS"( - VALUE STRING - CHARS STRING) - RETURNS STRING - SPECIFIC - - RETURN TRIM_LEADING_CHARS ( VALUE, CHARS ); - -CREATE FUNCTION "TRIM_LEADING_CHARS"( - VALUE NULLABLE_STRING - CHARS NULLABLE_STRING) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN TRIM_LEADING_CHARS ( VALUE, CHARS ); - -CREATE FUNCTION "TRIM_LEADING_CHARS"( - VALUE SYMBOL - CHARS SYMBOL) - RETURNS SYMBOL - SPECIFIC - - RETURN TRIM_LEADING_CHARS ( VALUE, CHARS ); - -CREATE FUNCTION "TRIM_LEADING_CHARS"( - VALUE NULLABLE_SYMBOL - CHARS NULLABLE_SYMBOL) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN TRIM_LEADING_CHARS ( VALUE, CHARS ); - - --- [trim_trailing_chars] --------- - -CREATE FUNCTION "TRIM_TRAILING_CHARS"( - VALUE STRING - CHARS STRING) - RETURNS STRING - SPECIFIC - - RETURN TRIM_TRAILING_CHARS ( VALUE, CHARS ); - -CREATE FUNCTION "TRIM_TRAILING_CHARS"( - VALUE NULLABLE_STRING - CHARS NULLABLE_STRING) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN TRIM_TRAILING_CHARS ( VALUE, CHARS ); - -CREATE FUNCTION "TRIM_TRAILING_CHARS"( - VALUE SYMBOL - CHARS SYMBOL) - RETURNS SYMBOL - SPECIFIC - - RETURN TRIM_TRAILING_CHARS ( VALUE, CHARS ); - -CREATE FUNCTION "TRIM_TRAILING_CHARS"( - VALUE NULLABLE_SYMBOL - CHARS NULLABLE_SYMBOL) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN TRIM_TRAILING_CHARS ( VALUE, CHARS ); - - --- [between] --------- - -CREATE FUNCTION "BETWEEN"( - VALUE INT8 - LOWER INT8 - UPPER INT8) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE NULLABLE_INT8 - LOWER NULLABLE_INT8 - UPPER NULLABLE_INT8) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE INT16 - LOWER INT16 - UPPER INT16) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE NULLABLE_INT16 - LOWER NULLABLE_INT16 - UPPER NULLABLE_INT16) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE INT32 - LOWER INT32 - UPPER INT32) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE NULLABLE_INT32 - LOWER NULLABLE_INT32 - UPPER NULLABLE_INT32) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE INT64 - LOWER INT64 - UPPER INT64) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE NULLABLE_INT64 - LOWER NULLABLE_INT64 - UPPER NULLABLE_INT64) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE INT - LOWER INT - UPPER INT) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE NULLABLE_INT - LOWER NULLABLE_INT - UPPER NULLABLE_INT) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE DECIMAL - LOWER DECIMAL - UPPER DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE NULLABLE_DECIMAL - LOWER NULLABLE_DECIMAL - UPPER NULLABLE_DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE FLOAT32 - LOWER FLOAT32 - UPPER FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE NULLABLE_FLOAT32 - LOWER NULLABLE_FLOAT32 - UPPER NULLABLE_FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE FLOAT64 - LOWER FLOAT64 - UPPER FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - -CREATE FUNCTION "BETWEEN"( - VALUE NULLABLE_FLOAT64 - LOWER NULLABLE_FLOAT64 - UPPER NULLABLE_FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN BETWEEN ( VALUE, LOWER, UPPER ); - - --- [substring_length] --------- - -CREATE FUNCTION "SUBSTRING_LENGTH"( - VALUE STRING - START INT64 - END INT64) - RETURNS STRING - SPECIFIC - - RETURN SUBSTRING_LENGTH ( VALUE, START, END ); - -CREATE FUNCTION "SUBSTRING_LENGTH"( - VALUE NULLABLE_STRING - START INT64 - END INT64) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN SUBSTRING_LENGTH ( VALUE, START, END ); - -CREATE FUNCTION "SUBSTRING_LENGTH"( - VALUE SYMBOL - START INT64 - END INT64) - RETURNS SYMBOL - SPECIFIC - - RETURN SUBSTRING_LENGTH ( VALUE, START, END ); - -CREATE FUNCTION "SUBSTRING_LENGTH"( - VALUE NULLABLE_SYMBOL - START INT64 - END INT64) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN SUBSTRING_LENGTH ( VALUE, START, END ); - - --- [like_escape] --------- - -CREATE FUNCTION "LIKE_ESCAPE"( - VALUE STRING - PATTERN STRING - ESCAPE STRING) - RETURNS BOOL - SPECIFIC - - RETURN LIKE_ESCAPE ( VALUE, PATTERN, ESCAPE ); - diff --git a/partiql-planner/src/main/resources/casts.sql b/partiql-planner/src/main/resources/casts.sql deleted file mode 100644 index d985ddc242..0000000000 --- a/partiql-planner/src/main/resources/casts.sql +++ /dev/null @@ -1,1982 +0,0 @@ --- [cast] --------- - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (INT8)) - RETURNS INT8 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (INT16)) - RETURNS INT16 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (INT32)) - RETURNS INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (INT64)) - RETURNS INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (INT)) - RETURNS INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (DECIMAL)) - RETURNS DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (FLOAT32)) - RETURNS FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (FLOAT64)) - RETURNS FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (CHAR)) - RETURNS CHAR - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_INT8)) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_INT16)) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_INT32)) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_INT64)) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_CHAR)) - RETURNS NULLABLE_CHAR - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BOOL - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_INT8)) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_INT16)) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_INT32)) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_INT64)) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_CHAR)) - RETURNS NULLABLE_CHAR - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BOOL - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (INT8)) - RETURNS INT8 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (INT16)) - RETURNS INT16 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (INT32)) - RETURNS INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (INT64)) - RETURNS INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (INT)) - RETURNS INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (DECIMAL)) - RETURNS DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (FLOAT32)) - RETURNS FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (FLOAT64)) - RETURNS FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_INT8)) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_INT16)) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_INT32)) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_INT64)) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT8 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_INT8)) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_INT16)) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_INT32)) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_INT64)) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT8 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (INT16)) - RETURNS INT16 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (INT32)) - RETURNS INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (INT64)) - RETURNS INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (INT)) - RETURNS INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (DECIMAL)) - RETURNS DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (FLOAT32)) - RETURNS FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (FLOAT64)) - RETURNS FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (NULLABLE_INT16)) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (NULLABLE_INT32)) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (NULLABLE_INT64)) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT16 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT16 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT16 - TYPE TYPE (NULLABLE_INT16)) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT16 - TYPE TYPE (NULLABLE_INT32)) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT16 - TYPE TYPE (NULLABLE_INT64)) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT16 - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT16 - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT16 - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT16 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT16 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT16 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (INT32)) - RETURNS INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (INT64)) - RETURNS INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (INT)) - RETURNS INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (DECIMAL)) - RETURNS DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (FLOAT32)) - RETURNS FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (FLOAT64)) - RETURNS FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (NULLABLE_INT32)) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (NULLABLE_INT64)) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT32 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT32 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT32 - TYPE TYPE (NULLABLE_INT32)) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT32 - TYPE TYPE (NULLABLE_INT64)) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT32 - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT32 - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT32 - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT32 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT32 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT32 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (INT64)) - RETURNS INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (INT)) - RETURNS INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (DECIMAL)) - RETURNS DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (FLOAT32)) - RETURNS FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (FLOAT64)) - RETURNS FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (NULLABLE_INT64)) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT64 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT64 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT64 - TYPE TYPE (NULLABLE_INT64)) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT64 - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT64 - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT64 - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT64 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT64 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT64 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (INT)) - RETURNS INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (DECIMAL)) - RETURNS DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (FLOAT32)) - RETURNS FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (FLOAT64)) - RETURNS FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE INT - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT - TYPE TYPE (NULLABLE_INT)) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_INT - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (DECIMAL)) - RETURNS DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (FLOAT32)) - RETURNS FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (FLOAT64)) - RETURNS FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE DECIMAL - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_DECIMAL - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_DECIMAL - TYPE TYPE (NULLABLE_DECIMAL)) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_DECIMAL - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_DECIMAL - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_DECIMAL - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_DECIMAL - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT32 - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT32 - TYPE TYPE (FLOAT32)) - RETURNS FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT32 - TYPE TYPE (FLOAT64)) - RETURNS FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT32 - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT32 - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT32 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT32 - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT32 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT32 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT32 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_FLOAT32 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_FLOAT32 - TYPE TYPE (NULLABLE_FLOAT32)) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_FLOAT32 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_FLOAT32 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_FLOAT32 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT64 - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT64 - TYPE TYPE (FLOAT64)) - RETURNS FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT64 - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT64 - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT64 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT64 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT64 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE FLOAT64 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_FLOAT64 - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_FLOAT64 - TYPE TYPE (NULLABLE_FLOAT64)) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_FLOAT64 - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_FLOAT64 - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE CHAR - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE CHAR - TYPE TYPE (CHAR)) - RETURNS CHAR - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE CHAR - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE CHAR - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE CHAR - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE CHAR - TYPE TYPE (NULLABLE_CHAR)) - RETURNS NULLABLE_CHAR - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE CHAR - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE CHAR - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_CHAR - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_CHAR - TYPE TYPE (NULLABLE_CHAR)) - RETURNS NULLABLE_CHAR - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_CHAR - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_CHAR - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE STRING - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE STRING - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE STRING - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE STRING - TYPE TYPE (CLOB)) - RETURNS CLOB - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE STRING - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE STRING - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE STRING - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE STRING - TYPE TYPE (NULLABLE_CLOB)) - RETURNS NULLABLE_CLOB - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_STRING - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_STRING - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_STRING - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_STRING - TYPE TYPE (CLOB)) - RETURNS CLOB - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_STRING - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_STRING - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_STRING - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_STRING - TYPE TYPE (NULLABLE_CLOB)) - RETURNS NULLABLE_CLOB - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SYMBOL - TYPE TYPE (BOOL)) - RETURNS BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SYMBOL - TYPE TYPE (STRING)) - RETURNS STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SYMBOL - TYPE TYPE (SYMBOL)) - RETURNS SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SYMBOL - TYPE TYPE (CLOB)) - RETURNS CLOB - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SYMBOL - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SYMBOL - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SYMBOL - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SYMBOL - TYPE TYPE (NULLABLE_CLOB)) - RETURNS NULLABLE_CLOB - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_SYMBOL - TYPE TYPE (NULLABLE_BOOL)) - RETURNS NULLABLE_BOOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_SYMBOL - TYPE TYPE (NULLABLE_STRING)) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_SYMBOL - TYPE TYPE (NULLABLE_SYMBOL)) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_SYMBOL - TYPE TYPE (NULLABLE_CLOB)) - RETURNS NULLABLE_CLOB - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE CLOB - TYPE TYPE (CLOB)) - RETURNS CLOB - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE CLOB - TYPE TYPE (NULLABLE_CLOB)) - RETURNS NULLABLE_CLOB - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_CLOB - TYPE TYPE (NULLABLE_CLOB)) - RETURNS NULLABLE_CLOB - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE LIST - TYPE TYPE (BAG)) - RETURNS BAG - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE LIST - TYPE TYPE (LIST)) - RETURNS LIST - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE LIST - TYPE TYPE (SEXP)) - RETURNS SEXP - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE LIST - TYPE TYPE (NULLABLE_BAG)) - RETURNS NULLABLE_BAG - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE LIST - TYPE TYPE (NULLABLE_LIST)) - RETURNS NULLABLE_LIST - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE LIST - TYPE TYPE (NULLABLE_SEXP)) - RETURNS NULLABLE_SEXP - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_LIST - TYPE TYPE (NULLABLE_BAG)) - RETURNS NULLABLE_BAG - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_LIST - TYPE TYPE (NULLABLE_LIST)) - RETURNS NULLABLE_LIST - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_LIST - TYPE TYPE (NULLABLE_SEXP)) - RETURNS NULLABLE_SEXP - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BAG - TYPE TYPE (BAG)) - RETURNS BAG - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE BAG - TYPE TYPE (NULLABLE_BAG)) - RETURNS NULLABLE_BAG - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_BAG - TYPE TYPE (NULLABLE_BAG)) - RETURNS NULLABLE_BAG - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SEXP - TYPE TYPE (BAG)) - RETURNS BAG - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SEXP - TYPE TYPE (LIST)) - RETURNS LIST - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SEXP - TYPE TYPE (SEXP)) - RETURNS SEXP - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SEXP - TYPE TYPE (NULLABLE_BAG)) - RETURNS NULLABLE_BAG - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SEXP - TYPE TYPE (NULLABLE_LIST)) - RETURNS NULLABLE_LIST - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE SEXP - TYPE TYPE (NULLABLE_SEXP)) - RETURNS NULLABLE_SEXP - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_SEXP - TYPE TYPE (NULLABLE_BAG)) - RETURNS NULLABLE_BAG - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_SEXP - TYPE TYPE (NULLABLE_LIST)) - RETURNS NULLABLE_LIST - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_SEXP - TYPE TYPE (NULLABLE_SEXP)) - RETURNS NULLABLE_SEXP - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE STRUCT - TYPE TYPE (STRUCT)) - RETURNS STRUCT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE STRUCT - TYPE TYPE (NULLABLE_STRUCT)) - RETURNS NULLABLE_STRUCT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); - -CREATE FUNCTION "CAST"( - VALUE NULLABLE_STRUCT - TYPE TYPE (NULLABLE_STRUCT)) - RETURNS NULLABLE_STRUCT - SPECIFIC - - RETURN CAST ( VALUE, TYPE ); diff --git a/partiql-planner/src/main/resources/operators.sql b/partiql-planner/src/main/resources/operators.sql deleted file mode 100644 index a4e17f8558..0000000000 --- a/partiql-planner/src/main/resources/operators.sql +++ /dev/null @@ -1,2031 +0,0 @@ ---- [not] --------- - -CREATE FUNCTION "NOT"( - VALUE BOOL) - RETURNS BOOL - SPECIFIC - - RETURN NOT ( VALUE ); - -CREATE FUNCTION "NOT"( - VALUE BOOL) - RETURNS BOOL - SPECIFIC - - RETURN NOT ( VALUE ); - - ---- [pos] --------- - -CREATE FUNCTION "POS"( - VALUE INT8) - RETURNS INT8 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE NULLABLE_INT8) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE INT16) - RETURNS INT16 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE NULLABLE_INT16) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE INT32) - RETURNS INT32 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE NULLABLE_INT32) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE INT64) - RETURNS INT64 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE NULLABLE_INT64) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE INT) - RETURNS INT - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE NULLABLE_INT) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE DECIMAL) - RETURNS DECIMAL - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE NULLABLE_DECIMAL) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE FLOAT32) - RETURNS FLOAT32 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE NULLABLE_FLOAT32) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE FLOAT64) - RETURNS FLOAT64 - SPECIFIC - - RETURN POS ( VALUE ); - -CREATE FUNCTION "POS"( - VALUE NULLABLE_FLOAT64) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN POS ( VALUE ); - - ---- [neg] --------- - -CREATE FUNCTION "NEG"( - VALUE INT8) - RETURNS INT8 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE NULLABLE_INT8) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE INT16) - RETURNS INT16 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE NULLABLE_INT16) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE INT32) - RETURNS INT32 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE NULLABLE_INT32) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE INT64) - RETURNS INT64 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE NULLABLE_INT64) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE INT) - RETURNS INT - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE NULLABLE_INT) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE DECIMAL) - RETURNS DECIMAL - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE NULLABLE_DECIMAL) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE FLOAT32) - RETURNS FLOAT32 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE NULLABLE_FLOAT32) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE FLOAT64) - RETURNS FLOAT64 - SPECIFIC - - RETURN NEG ( VALUE ); - -CREATE FUNCTION "NEG"( - VALUE NULLABLE_FLOAT64) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN NEG ( VALUE ); - - ---- [eq] --------- - -CREATE FUNCTION "EQ"( - LHS NULL - RHS NULL) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS MISSING - RHS MISSING) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS BOOL - RHS BOOL) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_BOOL - RHS NULLABLE_BOOL) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS INT8 - RHS INT8) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS INT16 - RHS INT16) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS INT32 - RHS INT32) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS INT64 - RHS INT64) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS INT - RHS INT) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS DECIMAL - RHS DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS CHAR - RHS CHAR) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_CHAR - RHS NULLABLE_CHAR) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS SYMBOL - RHS SYMBOL) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_SYMBOL - RHS NULLABLE_SYMBOL) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS STRING - RHS STRING) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_STRING - RHS NULLABLE_STRING) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS CLOB - RHS CLOB) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_CLOB - RHS NULLABLE_CLOB) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS BINARY - RHS BINARY) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_BINARY - RHS NULLABLE_BINARY) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS BYTE - RHS BYTE) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_BYTE - RHS NULLABLE_BYTE) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS BLOB - RHS BLOB) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_BLOB - RHS NULLABLE_BLOB) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS DATE - RHS DATE) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_DATE - RHS NULLABLE_DATE) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS TIME - RHS TIME) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_TIME - RHS NULLABLE_TIME) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS TIMESTAMP - RHS TIMESTAMP) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_TIMESTAMP - RHS NULLABLE_TIMESTAMP) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS INTERVAL - RHS INTERVAL) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_INTERVAL - RHS NULLABLE_INTERVAL) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS LIST - RHS LIST) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_LIST - RHS NULLABLE_LIST) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS BAG - RHS BAG) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_BAG - RHS NULLABLE_BAG) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS SEXP - RHS SEXP) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_SEXP - RHS NULLABLE_SEXP) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS STRUCT - RHS STRUCT) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS NULLABLE_STRUCT - RHS NULLABLE_STRUCT) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - -CREATE FUNCTION "EQ"( - LHS GRAPH - RHS GRAPH) - RETURNS BOOL - SPECIFIC - - RETURN EQ ( LHS, RHS ); - - ---- [neq] --------- - -CREATE FUNCTION "NEQ"( - LHS NULL - RHS NULL) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS MISSING - RHS MISSING) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS BOOL - RHS BOOL) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_BOOL - RHS NULLABLE_BOOL) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS INT8 - RHS INT8) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS INT16 - RHS INT16) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS INT32 - RHS INT32) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS INT64 - RHS INT64) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS INT - RHS INT) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS DECIMAL - RHS DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS CHAR - RHS CHAR) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_CHAR - RHS NULLABLE_CHAR) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS SYMBOL - RHS SYMBOL) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_SYMBOL - RHS NULLABLE_SYMBOL) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS STRING - RHS STRING) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_STRING - RHS NULLABLE_STRING) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS CLOB - RHS CLOB) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_CLOB - RHS NULLABLE_CLOB) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS BINARY - RHS BINARY) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_BINARY - RHS NULLABLE_BINARY) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS BYTE - RHS BYTE) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_BYTE - RHS NULLABLE_BYTE) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS BLOB - RHS BLOB) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_BLOB - RHS NULLABLE_BLOB) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS DATE - RHS DATE) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_DATE - RHS NULLABLE_DATE) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS TIME - RHS TIME) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_TIME - RHS NULLABLE_TIME) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS TIMESTAMP - RHS TIMESTAMP) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_TIMESTAMP - RHS NULLABLE_TIMESTAMP) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS INTERVAL - RHS INTERVAL) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_INTERVAL - RHS NULLABLE_INTERVAL) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS LIST - RHS LIST) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_LIST - RHS NULLABLE_LIST) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS BAG - RHS BAG) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_BAG - RHS NULLABLE_BAG) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS SEXP - RHS SEXP) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_SEXP - RHS NULLABLE_SEXP) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS STRUCT - RHS STRUCT) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS NULLABLE_STRUCT - RHS NULLABLE_STRUCT) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - -CREATE FUNCTION "NEQ"( - LHS GRAPH - RHS GRAPH) - RETURNS BOOL - SPECIFIC - - RETURN NEQ ( LHS, RHS ); - - ---- [and] --------- - -CREATE FUNCTION "AND"( - LHS BOOL - RHS BOOL) - RETURNS BOOL - SPECIFIC - - RETURN AND ( LHS, RHS ); - -CREATE FUNCTION "AND"( - LHS NULLABLE_BOOL - RHS NULLABLE_BOOL) - RETURNS BOOL - SPECIFIC - - RETURN AND ( LHS, RHS ); - - ---- [or] --------- - -CREATE FUNCTION "OR"( - LHS BOOL - RHS BOOL) - RETURNS BOOL - SPECIFIC - - RETURN OR ( LHS, RHS ); - -CREATE FUNCTION "OR"( - LHS NULLABLE_BOOL - RHS NULLABLE_BOOL) - RETURNS BOOL - SPECIFIC - - RETURN OR ( LHS, RHS ); - - ---- [lt] --------- - -CREATE FUNCTION "LT"( - LHS INT8 - RHS INT8) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS INT16 - RHS INT16) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS INT32 - RHS INT32) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS INT64 - RHS INT64) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS INT - RHS INT) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS DECIMAL - RHS DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - -CREATE FUNCTION "LT"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN LT ( LHS, RHS ); - - ---- [lte] --------- - -CREATE FUNCTION "LTE"( - LHS INT8 - RHS INT8) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS INT16 - RHS INT16) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS INT32 - RHS INT32) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS INT64 - RHS INT64) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS INT - RHS INT) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS DECIMAL - RHS DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - -CREATE FUNCTION "LTE"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN LTE ( LHS, RHS ); - - ---- [gt] --------- - -CREATE FUNCTION "GT"( - LHS INT8 - RHS INT8) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS INT16 - RHS INT16) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS INT32 - RHS INT32) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS INT64 - RHS INT64) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS INT - RHS INT) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS DECIMAL - RHS DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - -CREATE FUNCTION "GT"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN GT ( LHS, RHS ); - - ---- [gte] --------- - -CREATE FUNCTION "GTE"( - LHS INT8 - RHS INT8) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS INT16 - RHS INT16) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS INT32 - RHS INT32) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS INT64 - RHS INT64) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS INT - RHS INT) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS DECIMAL - RHS DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - -CREATE FUNCTION "GTE"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS BOOL - SPECIFIC - - RETURN GTE ( LHS, RHS ); - - ---- [plus] --------- - -CREATE FUNCTION "PLUS"( - LHS INT8 - RHS INT8) - RETURNS INT8 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS INT16 - RHS INT16) - RETURNS INT16 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS INT32 - RHS INT32) - RETURNS INT32 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS INT64 - RHS INT64) - RETURNS INT64 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS INT - RHS INT) - RETURNS INT - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS DECIMAL - RHS DECIMAL) - RETURNS DECIMAL - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS FLOAT32 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS FLOAT64 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - -CREATE FUNCTION "PLUS"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN PLUS ( LHS, RHS ); - - ---- [minus] --------- - -CREATE FUNCTION "MINUS"( - LHS INT8 - RHS INT8) - RETURNS INT8 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS INT16 - RHS INT16) - RETURNS INT16 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS INT32 - RHS INT32) - RETURNS INT32 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS INT64 - RHS INT64) - RETURNS INT64 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS INT - RHS INT) - RETURNS INT - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS DECIMAL - RHS DECIMAL) - RETURNS DECIMAL - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS FLOAT32 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS FLOAT64 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - -CREATE FUNCTION "MINUS"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN MINUS ( LHS, RHS ); - - ---- [times] --------- - -CREATE FUNCTION "TIMES"( - LHS INT8 - RHS INT8) - RETURNS INT8 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS INT16 - RHS INT16) - RETURNS INT16 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS INT32 - RHS INT32) - RETURNS INT32 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS INT64 - RHS INT64) - RETURNS INT64 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS INT - RHS INT) - RETURNS INT - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS DECIMAL - RHS DECIMAL) - RETURNS DECIMAL - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS FLOAT32 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS FLOAT64 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - -CREATE FUNCTION "TIMES"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN TIMES ( LHS, RHS ); - - ---- [div] --------- - -CREATE FUNCTION "DIV"( - LHS INT8 - RHS INT8) - RETURNS INT8 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS INT16 - RHS INT16) - RETURNS INT16 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS INT32 - RHS INT32) - RETURNS INT32 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS INT64 - RHS INT64) - RETURNS INT64 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS INT - RHS INT) - RETURNS INT - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS DECIMAL - RHS DECIMAL) - RETURNS DECIMAL - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS FLOAT32 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS FLOAT64 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - -CREATE FUNCTION "DIV"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN DIV ( LHS, RHS ); - - ---- [mod] --------- - -CREATE FUNCTION "MOD"( - LHS INT8 - RHS INT8) - RETURNS INT8 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS NULLABLE_INT8 - RHS NULLABLE_INT8) - RETURNS NULLABLE_INT8 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS INT16 - RHS INT16) - RETURNS INT16 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS NULLABLE_INT16 - RHS NULLABLE_INT16) - RETURNS NULLABLE_INT16 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS INT32 - RHS INT32) - RETURNS INT32 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS NULLABLE_INT32 - RHS NULLABLE_INT32) - RETURNS NULLABLE_INT32 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS INT64 - RHS INT64) - RETURNS INT64 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS NULLABLE_INT64 - RHS NULLABLE_INT64) - RETURNS NULLABLE_INT64 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS INT - RHS INT) - RETURNS INT - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS NULLABLE_INT - RHS NULLABLE_INT) - RETURNS NULLABLE_INT - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS DECIMAL - RHS DECIMAL) - RETURNS DECIMAL - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS NULLABLE_DECIMAL - RHS NULLABLE_DECIMAL) - RETURNS NULLABLE_DECIMAL - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS FLOAT32 - RHS FLOAT32) - RETURNS FLOAT32 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS NULLABLE_FLOAT32 - RHS NULLABLE_FLOAT32) - RETURNS NULLABLE_FLOAT32 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS FLOAT64 - RHS FLOAT64) - RETURNS FLOAT64 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - -CREATE FUNCTION "MOD"( - LHS NULLABLE_FLOAT64 - RHS NULLABLE_FLOAT64) - RETURNS NULLABLE_FLOAT64 - SPECIFIC - - RETURN MOD ( LHS, RHS ); - - ---- [concat] --------- - -CREATE FUNCTION "CONCAT"( - LHS SYMBOL - RHS SYMBOL) - RETURNS SYMBOL - SPECIFIC - - RETURN CONCAT ( LHS, RHS ); - -CREATE FUNCTION "CONCAT"( - LHS NULLABLE_SYMBOL - RHS NULLABLE_SYMBOL) - RETURNS NULLABLE_SYMBOL - SPECIFIC - - RETURN CONCAT ( LHS, RHS ); - -CREATE FUNCTION "CONCAT"( - LHS STRING - RHS STRING) - RETURNS STRING - SPECIFIC - - RETURN CONCAT ( LHS, RHS ); - -CREATE FUNCTION "CONCAT"( - LHS NULLABLE_STRING - RHS NULLABLE_STRING) - RETURNS NULLABLE_STRING - SPECIFIC - - RETURN CONCAT ( LHS, RHS ); diff --git a/partiql-planner/src/main/resources/partiql_plan_internal.ion b/partiql-planner/src/main/resources/partiql_plan_internal.ion new file mode 100644 index 0000000000..d2cf418e67 --- /dev/null +++ b/partiql-planner/src/main/resources/partiql_plan_internal.ion @@ -0,0 +1,342 @@ +imports::{ + kotlin: [ + partiql_value::'org.partiql.value.PartiQLValue', + static_type::'org.partiql.types.StaticType', + scalar_signature::'org.partiql.types.function.FunctionSignature$Scalar', + aggregation_signature::'org.partiql.types.function.FunctionSignature$Aggregation', + ], +} + +parti_q_l_plan::{ + catalogs: list::[catalog], // (catalogs ...) + statement: statement, // (statement ...) +} + +// Represent an instance of a database. +// - Currently, `symbols` represents all values from this catalog to be used in this plan. +// - Eventually, TODO functions may be resolved to a specific namespace within a catalog. +catalog::{ + name: string, + symbols: list::[symbol], + _: [ + // A reference to a value contained within a catalog. + symbol::{ + // The path to a value WITHIN a catalog. Note: This should not start with the catalog's name. Also, this + // should not be empty + path: list::[string], + type: static_type, + _: [ + // A reference to a symbol + ref::{ + catalog: int, + symbol: int + } + ] + } + ] +} + +// Functions + +fn::[ + resolved::{ + signature: scalar_signature, + }, + unresolved::{ + identifier: identifier, + isHidden: bool, + }, +] + +agg::[ + resolved::{ + signature: aggregation_signature, + }, + unresolved::{ + identifier: identifier, + }, +] + +// Statements + +statement::[ + query::{ + root: rex, + }, +] + +// Identifiers + +identifier::[ + symbol::{ + symbol: string, + case_sensitivity: case_sensitivity, + }, + qualified::{ + root: symbol, + steps: list::[symbol], + }, + _::[ + case_sensitivity::[ + SENSITIVE, + INSENSITIVE, + ], + ], +] + +// Rex +rex::{ + type: static_type, + op:[ + + lit::{ + value: partiql_value, + }, + + var::[ + resolved::{ + ref: int, + }, + unresolved::{ + identifier: identifier, + scope: scope, + }, + _::[ + scope::[ + DEFAULT, // x.y.z + LOCAL, // @x.y.z + ], + ], + ], + + global::{ + ref: '.catalog.symbol.ref' + }, + + path::[ + // The key MUST be an integer expression. Ex: a[0], a[1 + 1] + index::{ root: rex, key: rex }, + + // Case-sensitive lookup. The key MUST be a string expression. Ex: a["b"], a."b", a[CAST(b AS STRING)] + key::{ root: rex, key: rex }, + + // Case-insensitive lookup. The key MUST be a literal string. Ex: a.b + symbol::{ root: rex, key: string }, + ], + + call::[ + static::{ + fn: fn, + args: list::[rex] + }, + + // Represents a dynamic function call. If all candidates are exhausted, dynamic calls will return MISSING. + // + // args: represent the original typed arguments. These will eventually be wrapped by coercions from [candidates]. + // candidates: represent the potentially applicable resolved functions with coercions. Each of these candidates + // should be overloaded functions of the same name and number of arguments. + dynamic::{ + args: list::[rex], + candidates: list::[candidate], + _: [ + candidate::{ + fn: fn, + coercions: list::[optional::fn] + } + ] + } + ], + + case::{ + branches: list::[branch], + default: rex, + _: [ + branch::{ + condition: rex, + rex: rex, + }, + ], + }, + + collection::{ + values: list::[rex], + }, + + struct::{ + fields: list::[field], + _: [ + field::{ + k: rex, + v: rex, + }, + ], + }, + + pivot::{ + key: rex, + value: rex, + rel: rel, + }, + + subquery::{ + select: select, + coercion: [ SCALAR, ROW ], + }, + + select::{ + constructor: rex, + rel: rel, + }, + + // SELECT v1.*, e2 AS a, v3.* + // + // SELECT VALUE TUPLEUNION( + // CASE WHEN v1 IS TUPLE THEN v1 ELSE {'_1': v1} END, + // {'a':e2 }, + // CASE WHEN v3 IS TUPLE THEN v3 ELSE {'_2': v3} END + // ) + // + // Tuple Union Function Signature: (Array) -> Struct + tuple_union::{ + args: list::[rex], + }, + + err::{ + message: string, + }, + ], +} + +// Rel + +rel::{ + type: { + schema: list::[binding], + props: set::[prop], + }, + op: [ + + scan::{ + rex: rex, + }, + + scan_indexed::{ + rex: rex, + }, + + unpivot::{ + rex: rex, + }, + + distinct::{ + input: rel, + }, + + filter::{ + input: rel, + predicate: rex, + }, + + sort::{ + input: rel, + specs: list::[spec], + _: [ + spec::{ + rex: rex, + order: order, + }, + order::[ + ASC_NULLS_LAST, + ASC_NULLS_FIRST, + DESC_NULLS_LAST, + DESC_NULLS_FIRST, + ], + ], + }, + + union::{ + lhs: rel, + rhs: rel, + }, + + intersect::{ + lhs: rel, + rhs: rel, + }, + + except::{ + lhs: rel, + rhs: rel, + }, + + limit::{ + input: rel, + limit: rex, + }, + + offset::{ + input: rel, + offset: rex, + }, + + project::{ + input: rel, + projections: list::[rex], + }, + + join::{ + lhs: rel, + rhs: rel, + rex: rex, // The Join Expression (required) (can be set to TRUE) + type: [ + INNER, // Inner Join + LEFT, // Left Outer Join + RIGHT, // Right Outer Join + FULL // Full Outer Join + ], + }, + + aggregate::{ + input: rel, + strategy: [ FULL, PARTIAL ], + calls: list::[call], + groups: list::[rex], + _: [ + call::{ + agg: agg, + args: list::[rex], + }, + ], + }, + + exclude::{ + input: rel, + items: list::[item], + _: [ + item::{ + root: '.rex.op.var', + steps: list::[step], + }, + step::[ + struct_field::{ symbol: '.identifier.symbol' }, + coll_index::{ index: int }, + struct_wildcard::{}, + coll_wildcard::{}, + ], + ], + }, + + err::{ + message: string, + }, + ], + _: [ + prop::[ + ORDERED, + ], + binding::{ + name: string, + type: static_type, + }, + ] +} From 89d38df7116fa3ae1eb1db91262a7a8ab87a763c Mon Sep 17 00:00:00 2001 From: "R. C. Howell" Date: Tue, 23 Jan 2024 14:23:52 -0800 Subject: [PATCH 4/4] Isolates local variable resolution logic (#1344) --- .../org/partiql/planner/internal/Env.kt | 264 +++--------------- .../planner/internal/typer/PlanTyper.kt | 131 ++++----- .../partiql/planner/internal/typer/TypeEnv.kt | 155 ++++++++++ .../org/partiql/planner/internal/EnvTest.kt | 12 +- .../planner/internal/typer/TypeEnvTest.kt | 114 ++++++++ 5 files changed, 362 insertions(+), 314 deletions(-) create mode 100644 partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeEnv.kt create mode 100644 partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/TypeEnvTest.kt diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Env.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Env.kt index 0f87fc5890..5f22fd3f6f 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Env.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Env.kt @@ -4,11 +4,15 @@ import org.partiql.planner.PartiQLPlanner import org.partiql.planner.internal.ir.Agg import org.partiql.planner.internal.ir.Catalog import org.partiql.planner.internal.ir.Fn -import org.partiql.planner.internal.ir.Identifier -import org.partiql.planner.internal.ir.Rel import org.partiql.planner.internal.ir.Rex -import org.partiql.planner.internal.ir.identifierSymbol +import org.partiql.planner.internal.ir.catalogSymbolRef +import org.partiql.planner.internal.ir.rex +import org.partiql.planner.internal.ir.rexOpGlobal +import org.partiql.planner.internal.ir.rexOpLit +import org.partiql.planner.internal.ir.rexOpPathKey +import org.partiql.planner.internal.ir.rexOpPathSymbol import org.partiql.planner.internal.typer.FnResolver +import org.partiql.planner.internal.typer.TypeEnv import org.partiql.spi.BindingCase import org.partiql.spi.BindingName import org.partiql.spi.BindingPath @@ -17,9 +21,9 @@ import org.partiql.spi.connector.ConnectorObjectHandle import org.partiql.spi.connector.ConnectorObjectPath import org.partiql.spi.connector.ConnectorSession import org.partiql.types.StaticType -import org.partiql.types.StructType -import org.partiql.types.TupleConstraint import org.partiql.types.function.FunctionSignature +import org.partiql.value.PartiQLValueExperimental +import org.partiql.value.stringValue /** * Handle for associating a catalog name with catalog related metadata objects. @@ -27,84 +31,19 @@ import org.partiql.types.function.FunctionSignature internal typealias Handle = Pair /** - * TypeEnv represents the environment in which we type expressions and resolve variables while planning. + * Metadata for a resolved global variable * - * TODO TypeEnv should be a stack of locals; also the strategy has been kept here because it's easier to - * pass through the traversal like this, but is conceptually odd to associate with the TypeEnv. - * @property schema - * @property strategy - */ -internal class TypeEnv( - val schema: List, - val strategy: ResolutionStrategy, -) { - - /** - * Return a copy with GLOBAL lookup strategy - */ - fun global() = TypeEnv(schema, ResolutionStrategy.GLOBAL) - - /** - * Return a copy with LOCAL lookup strategy - */ - fun local() = TypeEnv(schema, ResolutionStrategy.LOCAL) - - /** - * Debug string - */ - override fun toString() = buildString { - append("(") - append("strategy=$strategy") - append(", ") - val bindings = "< " + schema.joinToString { "${it.name}: ${it.type}" } + " >" - append("bindings=$bindings") - append(")") - } -} - -/** - * Metadata regarding a resolved variable. + * @property type Resolved StaticType + * @property ordinal The relevant catalog's index offset in the [Env.catalogs] list * @property depth The depth/level of the path match. + * @property position The relevant value's index offset in the [Catalog.values] list */ -internal sealed interface ResolvedVar { - - public val type: StaticType - public val ordinal: Int - public val depth: Int - - /** - * Metadata for a resolved local variable. - * - * @property type Resolved StaticType - * @property ordinal Index offset in [TypeEnv] - * @property resolvedSteps The fully resolved path steps.s - */ - class Local( - override val type: StaticType, - override val ordinal: Int, - val rootType: StaticType, - val resolvedSteps: List, - ) : ResolvedVar { - // the depth are always going to be 1 because this is local variable. - // the global path, however the path length maybe, going to be replaced by a binding name. - override val depth: Int = 1 - } - - /** - * Metadata for a resolved global variable - * - * @property type Resolved StaticType - * @property ordinal The relevant catalog's index offset in the [Env.catalogs] list - * @property depth The depth/level of the path match. - * @property position The relevant value's index offset in the [Catalog.values] list - */ - class Global( - override val type: StaticType, - override val ordinal: Int, - override val depth: Int, - val position: Int, - ) : ResolvedVar -} +internal class ResolvedVar( + val type: StaticType, + val ordinal: Int, + val depth: Int, + val position: Int, +) /** * Variable resolution strategies — https://partiql.org/assets/PartiQL-Specification.pdf#page=35 @@ -235,7 +174,7 @@ internal class Env( type ) // Return resolution metadata - ResolvedVar.Global(type, catalogIndex, depth, valueIndex) + ResolvedVar(type, catalogIndex, depth, valueIndex) } } } @@ -282,31 +221,13 @@ internal class Env( } } - private fun BindingPath.toCaseSensitive(): BindingPath { - return this.copy(steps = this.steps.map { it.copy(bindingCase = BindingCase.SENSITIVE) }) - } - /** * Attempt to resolve a [BindingPath] in the global + local type environments. */ - fun resolve(path: BindingPath, locals: TypeEnv, scope: Rex.Op.Var.Scope): ResolvedVar? { - val strategy = when (scope) { - Rex.Op.Var.Scope.DEFAULT -> locals.strategy - Rex.Op.Var.Scope.LOCAL -> ResolutionStrategy.LOCAL - } + fun resolve(path: BindingPath, locals: TypeEnv, strategy: ResolutionStrategy): Rex? { return when (strategy) { - ResolutionStrategy.LOCAL -> { - var type: ResolvedVar? = null - type = type ?: resolveLocalBind(path, locals.schema) - type = type ?: resolveGlobalBind(path) - type - } - ResolutionStrategy.GLOBAL -> { - var type: ResolvedVar? = null - type = type ?: resolveGlobalBind(path) - type = type ?: resolveLocalBind(path, locals.schema) - type - } + ResolutionStrategy.LOCAL -> locals.resolve(path) ?: resolveGlobalBind(path) + ResolutionStrategy.GLOBAL -> resolveGlobalBind(path) ?: locals.resolve(path) } } @@ -320,7 +241,7 @@ internal class Env( * TODO: Add global bindings * TODO: Replace paths with global variable references if found */ - private fun resolveGlobalBind(path: BindingPath): ResolvedVar? { + private fun resolveGlobalBind(path: BindingPath): Rex? { val currentCatalog = session.currentCatalog?.let { BindingName(it, BindingCase.SENSITIVE) } val currentCatalogPath = BindingPath(session.currentDirectory.map { BindingName(it, BindingCase.SENSITIVE) }) val absoluteCatalogPath = BindingPath(currentCatalogPath.steps + path.steps) @@ -335,122 +256,13 @@ internal class Env( ?: getGlobalType(currentCatalog, path, path) ?: getGlobalType(currentCatalog, path, absoluteCatalogPath) } - } - return resolvedVar + } ?: return null + // rewrite as path expression for any remaining steps. + val root = rex(resolvedVar.type, rexOpGlobal(catalogSymbolRef(resolvedVar.ordinal, resolvedVar.position))) + val tail = path.steps.drop(resolvedVar.depth) + return if (tail.isEmpty()) root else root.toPath(tail) } - /** - * Check locals, else search structs. - */ - internal fun resolveLocalBind(path: BindingPath, locals: List): ResolvedVar? { - if (path.steps.isEmpty()) { - return null - } - - // 1. Check locals for root - locals.forEachIndexed { ordinal, binding -> - val root = path.steps[0] - if (root.isEquivalentTo(binding.name)) { - return ResolvedVar.Local(binding.type, ordinal, binding.type, path.steps) - } - } - - // 2. Check if this variable is referencing a struct field, carrying ordinals - val matches = mutableListOf() - for (ordinal in locals.indices) { - val rootType = locals[ordinal].type - val pathPrefix = BindingName(locals[ordinal].name, BindingCase.SENSITIVE) - if (rootType is StructType) { - val varType = inferStructLookup(rootType, path) - if (varType != null) { - // we found this path within a struct! - val match = ResolvedVar.Local( - varType.resolvedType, - ordinal, - rootType, - listOf(pathPrefix) + varType.replacementPath.steps, - ) - matches.add(match) - } - } - } - - // 0 -> no match - // 1 -> resolved - // N -> ambiguous - return when (matches.size) { - 0 -> null - 1 -> matches.single() - else -> null // TODO emit ambiguous error - } - } - - /** - * Searches for the path within the given struct, returning null if not found. - * - * @return a [ResolvedPath] that contains the disambiguated [ResolvedPath.replacementPath] and the path's - * [StaticType]. Returns NULL if unable to find the [path] given the [struct]. - */ - private fun inferStructLookup(struct: StructType, path: BindingPath): ResolvedPath? { - var curr: StaticType = struct - val replacementSteps = path.steps.map { step -> - // Assume ORDERED for now - val currentStruct = curr as? StructType ?: return null - val (replacement, stepType) = inferStructLookup(currentStruct, step) ?: return null - curr = stepType - replacement - } - // Lookup final field - return ResolvedPath( - BindingPath(replacementSteps), - curr - ) - } - - /** - * Represents a disambiguated [BindingPath] and its inferred [StaticType]. - */ - private class ResolvedPath( - val replacementPath: BindingPath, - val resolvedType: StaticType, - ) - - /** - * @return a disambiguated [key] and the resulting [StaticType]. - */ - private fun inferStructLookup(struct: StructType, key: BindingName): Pair? { - val isClosed = struct.constraints.contains(TupleConstraint.Open(false)) - val isOrdered = struct.constraints.contains(TupleConstraint.Ordered) - return when { - // 1. Struct is closed and ordered - isClosed && isOrdered -> { - struct.fields.firstOrNull { entry -> key.isEquivalentTo(entry.key) }?.let { - (sensitive(it.key) to it.value) - } - } - // 2. Struct is closed - isClosed -> { - val matches = struct.fields.filter { entry -> key.isEquivalentTo(entry.key) } - when (matches.size) { - 0 -> null - 1 -> matches.first().let { (sensitive(it.key) to it.value) } - else -> { - val firstKey = matches.first().key - val sharedKey = when (matches.all { it.key == firstKey }) { - true -> sensitive(firstKey) - false -> key - } - sharedKey to StaticType.unionOf(matches.map { it.value }.toSet()).flatten() - } - } - } - // 3. Struct is open - else -> key to StaticType.ANY - } - } - - private fun sensitive(str: String): BindingName = BindingName(str, BindingCase.SENSITIVE) - /** * Logic for determining how many BindingNames were “matched” by the ConnectorMetadata * 1. Matched = RelativePath - Not Found @@ -466,16 +278,12 @@ internal class Env( return originalPath.steps.size + outputCatalogPath.steps.size - inputCatalogPath.steps.size } - private fun String.toIdentifier() = identifierSymbol( - symbol = this, - caseSensitivity = Identifier.CaseSensitivity.SENSITIVE - ) - - private fun BindingName.toIdentifier() = identifierSymbol( - symbol = name, - caseSensitivity = when (bindingCase) { - BindingCase.SENSITIVE -> Identifier.CaseSensitivity.SENSITIVE - BindingCase.INSENSITIVE -> Identifier.CaseSensitivity.INSENSITIVE + @OptIn(PartiQLValueExperimental::class) + private fun Rex.toPath(steps: List): Rex = steps.fold(this) { curr, step -> + val op = when (step.bindingCase) { + BindingCase.SENSITIVE -> rexOpPathKey(curr, rex(StaticType.STRING, rexOpLit(stringValue(step.name)))) + BindingCase.INSENSITIVE -> rexOpPathSymbol(curr, step.name) } - ) + rex(StaticType.ANY, op) + } } diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt index f2d9ca5662..1c15078553 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/PlanTyper.kt @@ -22,8 +22,6 @@ import org.partiql.errors.UNKNOWN_PROBLEM_LOCATION import org.partiql.planner.PlanningProblemDetails import org.partiql.planner.internal.Env import org.partiql.planner.internal.ResolutionStrategy -import org.partiql.planner.internal.ResolvedVar -import org.partiql.planner.internal.TypeEnv import org.partiql.planner.internal.ir.Agg import org.partiql.planner.internal.ir.Fn import org.partiql.planner.internal.ir.Identifier @@ -32,7 +30,6 @@ import org.partiql.planner.internal.ir.Rel import org.partiql.planner.internal.ir.Rex import org.partiql.planner.internal.ir.Statement import org.partiql.planner.internal.ir.aggResolved -import org.partiql.planner.internal.ir.catalogSymbolRef import org.partiql.planner.internal.ir.fnResolved import org.partiql.planner.internal.ir.identifierSymbol import org.partiql.planner.internal.ir.rel @@ -60,7 +57,6 @@ import org.partiql.planner.internal.ir.rexOpCallStatic import org.partiql.planner.internal.ir.rexOpCaseBranch import org.partiql.planner.internal.ir.rexOpCollection import org.partiql.planner.internal.ir.rexOpErr -import org.partiql.planner.internal.ir.rexOpGlobal import org.partiql.planner.internal.ir.rexOpLit import org.partiql.planner.internal.ir.rexOpPathIndex import org.partiql.planner.internal.ir.rexOpPathKey @@ -70,7 +66,6 @@ import org.partiql.planner.internal.ir.rexOpSelect import org.partiql.planner.internal.ir.rexOpStruct import org.partiql.planner.internal.ir.rexOpStructField import org.partiql.planner.internal.ir.rexOpTupleUnion -import org.partiql.planner.internal.ir.rexOpVarResolved import org.partiql.planner.internal.ir.statementQuery import org.partiql.planner.internal.ir.util.PlanRewriter import org.partiql.spi.BindingCase @@ -124,10 +119,7 @@ internal class PlanTyper( throw IllegalArgumentException("PartiQLPlanner only supports Query statements") } // root TypeEnv has no bindings - val typeEnv = TypeEnv( - schema = emptyList(), - strategy = ResolutionStrategy.GLOBAL, - ) + val typeEnv = TypeEnv(schema = emptyList()) val root = statement.root.type(typeEnv) return statementQuery(root) } @@ -136,8 +128,12 @@ internal class PlanTyper( * Types the relational operators of a query expression. * * @property outer represents the outer TypeEnv of a query expression — only used by scan variable resolution. + * @property strategy */ - private inner class RelTyper(private val outer: TypeEnv) : PlanRewriter() { + private inner class RelTyper( + private val outer: TypeEnv, + private val strategy: ResolutionStrategy, + ) : PlanRewriter() { override fun visitRel(node: Rel, ctx: Rel.Type?) = visitRelOp(node.op, node.type) as Rel @@ -146,7 +142,7 @@ internal class PlanTyper( */ override fun visitRelOpScan(node: Rel.Op.Scan, ctx: Rel.Type?): Rel { // descend, with GLOBAL resolution strategy - val rex = node.rex.type(outer.global()) + val rex = node.rex.type(outer, ResolutionStrategy.GLOBAL) // compute rel type val valueT = getElementTypeForFromSource(rex.type) val type = ctx!!.copyWithSchema(listOf(valueT)) @@ -165,7 +161,7 @@ internal class PlanTyper( */ override fun visitRelOpScanIndexed(node: Rel.Op.ScanIndexed, ctx: Rel.Type?): Rel { // descend, with GLOBAL resolution strategy - val rex = node.rex.type(outer.global()) + val rex = node.rex.type(outer, ResolutionStrategy.GLOBAL) // compute rel type val valueT = getElementTypeForFromSource(rex.type) val indexT = StaticType.INT8 @@ -180,7 +176,7 @@ internal class PlanTyper( */ override fun visitRelOpUnpivot(node: Rel.Op.Unpivot, ctx: Rel.Type?): Rel { // descend, with GLOBAL resolution strategy - val rex = node.rex.type(outer.global()) + val rex = node.rex.type(outer, ResolutionStrategy.GLOBAL) // only UNPIVOT a struct if (rex.type !is StructType) { @@ -215,7 +211,7 @@ internal class PlanTyper( // compute input schema val input = visitRel(node.input, ctx) // type sub-nodes - val typeEnv = TypeEnv(input.type.schema, ResolutionStrategy.LOCAL) + val typeEnv = TypeEnv(input.type.schema) val predicate = node.predicate.type(typeEnv) // compute output schema val type = input.type @@ -228,10 +224,10 @@ internal class PlanTyper( // compute input schema val input = visitRel(node.input, ctx) // type sub-nodes - val typeEnv = TypeEnv(input.type.schema, ResolutionStrategy.LOCAL) + val typeEnv = TypeEnv(input.type.schema) val specs = node.specs.map { val rex = it.rex.type(typeEnv) - it.copy(rex) + it.copy(rex = rex) } // output schema of a sort is the same as the input val type = input.type.copy(props = setOf(Rel.Prop.ORDERED)) @@ -256,8 +252,7 @@ internal class PlanTyper( // compute input schema val input = visitRel(node.input, ctx) // type limit expression using outer scope with global resolution - val typeEnv = outer.global() - val limit = node.limit.type(typeEnv) + val limit = node.limit.type(outer, ResolutionStrategy.GLOBAL) // check types assertAsInt(limit.type) // compute output schema @@ -271,8 +266,7 @@ internal class PlanTyper( // compute input schema val input = visitRel(node.input, ctx) // type offset expression using outer scope with global resolution - val typeEnv = outer.global() - val offset = node.offset.type(typeEnv) + val offset = node.offset.type(outer, ResolutionStrategy.GLOBAL) // check types assertAsInt(offset.type) // compute output schema @@ -286,7 +280,7 @@ internal class PlanTyper( // compute input schema val input = visitRel(node.input, ctx) // type sub-nodes - val typeEnv = TypeEnv(input.type.schema, ResolutionStrategy.LOCAL) + val typeEnv = TypeEnv(input.type.schema) val projections = node.projections.map { it.type(typeEnv) } @@ -315,7 +309,7 @@ internal class PlanTyper( val type = relType(schema, ctx!!.props) // Type the condition on the output schema - val condition = node.rex.type(TypeEnv(type.schema, ResolutionStrategy.LOCAL)) + val condition = node.rex.type(TypeEnv(type.schema)) val op = relOpJoin(lhs, rhs, condition, node.type) return rel(type, op) @@ -359,20 +353,22 @@ internal class PlanTyper( val schema = node.items.fold((init)) { bindings, item -> excludeBindings(bindings, item) } // rewrite - val type = ctx!!.copy(schema) + val type = ctx!!.copy(schema = schema) // resolve exclude path roots val newItems = node.items.map { item -> val resolvedRoot = when (val root = item.root) { is Rex.Op.Var.Unresolved -> { // resolve `root` to local binding - val bindingPath = root.identifier.toBindingPath() - when (val resolved = env.resolveLocalBind(bindingPath, init)) { - null -> { - handleUnresolvedExcludeRoot(root.identifier) - root - } - else -> rexOpVarResolved(resolved.ordinal) + val locals = TypeEnv(input.type.schema) + val path = root.identifier.toBindingPath() + val resolved = locals.resolve(path) + if (resolved == null) { + handleUnresolvedExcludeRoot(root.identifier) + root + } else { + // root of exclude is always a symbol + resolved.op as Rex.Op.Var } } is Rex.Op.Var.Resolved -> root @@ -390,7 +386,7 @@ internal class PlanTyper( val input = visitRel(node.input, ctx) // type the calls and groups - val typer = RexTyper(locals = TypeEnv(input.type.schema, ResolutionStrategy.LOCAL)) + val typer = RexTyper(TypeEnv(input.type.schema), ResolutionStrategy.LOCAL) // typing of aggregate calls is slightly more complicated because they are not expressions. val calls = node.calls.mapIndexed { i, call -> @@ -427,7 +423,10 @@ internal class PlanTyper( * @property locals TypeEnv in which this rex tree is evaluated. */ @OptIn(PartiQLValueExperimental::class) - private inner class RexTyper(private val locals: TypeEnv) : PlanRewriter() { + private inner class RexTyper( + private val locals: TypeEnv, + private val strategy: ResolutionStrategy, + ) : PlanRewriter() { override fun visitRex(node: Rex, ctx: StaticType?): Rex = visitRexOp(node.op, node.type) as Rex @@ -444,52 +443,16 @@ internal class PlanTyper( override fun visitRexOpVarUnresolved(node: Rex.Op.Var.Unresolved, ctx: StaticType?): Rex { val path = node.identifier.toBindingPath() - val resolvedVar = env.resolve(path, locals, node.scope) - + val strategy = when (node.scope) { + Rex.Op.Var.Scope.DEFAULT -> strategy + Rex.Op.Var.Scope.LOCAL -> ResolutionStrategy.LOCAL + } + val resolvedVar = env.resolve(path, locals, strategy) if (resolvedVar == null) { handleUndefinedVariable(path.steps.last()) return rex(ANY, rexOpErr("Undefined variable ${node.identifier}")) } - val type = resolvedVar.type - return when (resolvedVar) { - is ResolvedVar.Global -> { - val variable = rex(type, rexOpGlobal(catalogSymbolRef(resolvedVar.ordinal, resolvedVar.position))) - when (resolvedVar.depth) { - path.steps.size -> variable - else -> { - val foldedPath = foldPath(path.steps, resolvedVar.depth, path.steps.size, variable) - visitRex(foldedPath, ctx) - } - } - } - is ResolvedVar.Local -> { - val variable = rex(type, rexOpVarResolved(resolvedVar.ordinal)) - when { - path.isEquivalentTo(resolvedVar.resolvedSteps) && path.steps.size == resolvedVar.depth -> variable - else -> { - val foldedPath = foldPath(resolvedVar.resolvedSteps, resolvedVar.depth, resolvedVar.resolvedSteps.size, variable) - visitRex(foldedPath, ctx) - } - } - } - } - } - - private fun foldPath(path: List, start: Int, end: Int, global: Rex) = - path.subList(start, end).fold(global) { current, step -> - when (step.bindingCase) { - BindingCase.SENSITIVE -> rex(ANY, rexOpPathKey(current, rex(STRING, rexOpLit(stringValue(step.name))))) - BindingCase.INSENSITIVE -> rex(ANY, rexOpPathSymbol(current, step.name)) - } - } - - private fun BindingPath.isEquivalentTo(other: List): Boolean { - this.steps.forEachIndexed { index, bindingName -> - if (bindingName != other[index]) { - return false - } - } - return true + return visitRex(resolvedVar, null) } override fun visitRexOpGlobal(node: Rex.Op.Global, ctx: StaticType?): Rex { @@ -559,10 +522,16 @@ internal class PlanTyper( val paths = root.type.allTypes.map { type -> val struct = type as? StructType ?: return@map rex(MISSING, rexOpLit(missingValue())) - val (pathType, replacementId) = inferStructLookup(struct, identifierSymbol(node.key, Identifier.CaseSensitivity.INSENSITIVE)) + val (pathType, replacementId) = inferStructLookup( + struct, + identifierSymbol(node.key, Identifier.CaseSensitivity.INSENSITIVE) + ) when (replacementId.caseSensitivity) { Identifier.CaseSensitivity.INSENSITIVE -> rex(pathType, rexOpPathSymbol(root, replacementId.symbol)) - Identifier.CaseSensitivity.SENSITIVE -> rex(pathType, rexOpPathKey(root, rexString(replacementId.symbol))) + Identifier.CaseSensitivity.SENSITIVE -> rex( + pathType, + rexOpPathKey(root, rexString(replacementId.symbol)) + ) } } val type = unionOf(paths.map { it.type }.toSet()).flatten() @@ -901,7 +870,7 @@ internal class PlanTyper( override fun visitRexOpPivot(node: Rex.Op.Pivot, ctx: StaticType?): Rex { val rel = node.rel.type(locals) - val typeEnv = TypeEnv(rel.type.schema, ResolutionStrategy.LOCAL) + val typeEnv = TypeEnv(rel.type.schema) val key = node.key.type(typeEnv) val value = node.value.type(typeEnv) val type = StructType( @@ -960,7 +929,7 @@ internal class PlanTyper( override fun visitRexOpSelect(node: Rex.Op.Select, ctx: StaticType?): Rex { val rel = node.rel.type(locals) - val typeEnv = TypeEnv(rel.type.schema, ResolutionStrategy.LOCAL) + val typeEnv = TypeEnv(rel.type.schema) var constructor = node.constructor.type(typeEnv) var constructorType = constructor.type // add the ordered property to the constructor @@ -1243,9 +1212,11 @@ internal class PlanTyper( // HELPERS - private fun Rel.type(typeEnv: TypeEnv): Rel = RelTyper(typeEnv).visitRel(this, null) + private fun Rel.type(locals: TypeEnv, strategy: ResolutionStrategy = ResolutionStrategy.LOCAL): Rel = + RelTyper(locals, strategy).visitRel(this, null) - private fun Rex.type(typeEnv: TypeEnv) = RexTyper(typeEnv).visitRex(this, this.type) + private fun Rex.type(locals: TypeEnv, strategy: ResolutionStrategy = ResolutionStrategy.LOCAL) = + RexTyper(locals, strategy).visitRex(this, this.type) private fun rexErr(message: String) = rex(MISSING, rexOpErr(message)) diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeEnv.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeEnv.kt new file mode 100644 index 0000000000..d413abde04 --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeEnv.kt @@ -0,0 +1,155 @@ +package org.partiql.planner.internal.typer + +import org.partiql.planner.internal.ir.Rel +import org.partiql.planner.internal.ir.Rex +import org.partiql.planner.internal.ir.rex +import org.partiql.planner.internal.ir.rexOpLit +import org.partiql.planner.internal.ir.rexOpPathKey +import org.partiql.planner.internal.ir.rexOpPathSymbol +import org.partiql.planner.internal.ir.rexOpVarResolved +import org.partiql.spi.BindingCase +import org.partiql.spi.BindingName +import org.partiql.spi.BindingPath +import org.partiql.types.StaticType +import org.partiql.types.StructType +import org.partiql.types.TupleConstraint +import org.partiql.value.PartiQLValueExperimental +import org.partiql.value.stringValue + +/** + * TypeEnv represents a variables type environment. + */ +internal class TypeEnv(public val schema: List) { + + /** + * We resolve a local with the following rules. See, PartiQL Specification p.35. + * + * 1) Check if the path root unambiguously matches a local binding name, set as root. + * 2) Check if the path root unambiguously matches a local binding struct value field. + * + * Convert any remaining binding names (tail) to a path expression. + * + * @param path + * @return + */ + fun resolve(path: BindingPath): Rex? { + val head: BindingName = path.steps[0] + var tail: List = path.steps.drop(1) + var r = matchRoot(head) + if (r == null) { + r = matchStruct(head) ?: return null + tail = path.steps + } + // Convert any remaining binding names (tail) to an untyped path expression. + return if (tail.isEmpty()) r else r.toPath(tail) + } + + /** + * Debugging string, ex: < x: int, y: string > + * + * @return + */ + override fun toString(): String = "< " + schema.joinToString { "${it.name}: ${it.type}" } + " >" + + /** + * Check if `name` unambiguously matches a local binding name and return its reference; otherwise return null. + * + * @param name + * @return + */ + private fun matchRoot(name: BindingName): Rex? { + var r: Rex? = null + for (i in schema.indices) { + val local = schema[i] + val type = local.type + if (name.isEquivalentTo(local.name)) { + if (r != null) { + // TODO root was already matched, emit ambiguous error. + return null + } + r = rex(type, rexOpVarResolved(i)) + } + } + return r + } + + /** + * Check if `name` unambiguously matches a field within a struct and return its reference; otherwise return null. + * + * @param name + * @return + */ + private fun matchStruct(name: BindingName): Rex? { + var c: Rex? = null + var known = false + for (i in schema.indices) { + val local = schema[i] + val type = local.type + if (type is StructType) { + when (type.containsKey(name)) { + true -> { + if (c != null && known) { + // TODO root was already definitively matched, emit ambiguous error. + return null + } + c = rex(type, rexOpVarResolved(i)) + known = true + } + null -> { + if (c != null) { + if (known) { + continue + } else { + // TODO we have more than one possible match, emit ambiguous error. + return null + } + } + c = rex(type, rexOpVarResolved(i)) + known = false + } + false -> continue + } + } + } + return c + } + + /** + * Converts a list of [BindingName] to a path expression. + * + * 1) Case SENSITIVE identifiers become string literal key lookups. + * 2) Case INSENSITIVE identifiers become symbol lookups. + * + * @param steps + * @return + */ + @OptIn(PartiQLValueExperimental::class) + private fun Rex.toPath(steps: List): Rex = steps.fold(this) { curr, step -> + val op = when (step.bindingCase) { + BindingCase.SENSITIVE -> rexOpPathKey(curr, rex(StaticType.STRING, rexOpLit(stringValue(step.name)))) + BindingCase.INSENSITIVE -> rexOpPathSymbol(curr, step.name) + } + rex(StaticType.ANY, op) + } + + /** + * Searches for the [BindingName] within the given [StructType]. + * + * Returns + * - true iff known to contain key + * - false iff known to NOT contain key + * - null iff NOT known to contain key + * + * @param name + * @return + */ + private fun StructType.containsKey(name: BindingName): Boolean? { + for (f in fields) { + if (name.isEquivalentTo(f.key)) { + return true + } + } + val closed = constraints.contains(TupleConstraint.Open(false)) + return if (closed) false else null + } +} diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/EnvTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/EnvTest.kt index cbdb3892e0..3f83b5b309 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/EnvTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/EnvTest.kt @@ -5,7 +5,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.partiql.planner.PartiQLPlanner import org.partiql.planner.internal.ir.Catalog -import org.partiql.planner.internal.ir.Rex +import org.partiql.planner.internal.typer.TypeEnv import org.partiql.plugins.local.LocalConnector import org.partiql.spi.BindingCase import org.partiql.spi.BindingName @@ -22,7 +22,7 @@ class EnvTest { private val root = this::class.java.getResource("/catalogs/default/pql")!!.toURI().toPath() - private val EMPTY_TYPE_ENV = TypeEnv(schema = emptyList(), ResolutionStrategy.GLOBAL) + private val EMPTY_TYPE_ENV = TypeEnv(schema = emptyList()) private val GLOBAL_OS = Catalog( name = "pql", @@ -52,7 +52,7 @@ class EnvTest { @Test fun testGlobalMatchingSensitiveName() { val path = BindingPath(listOf(BindingName("os", BindingCase.SENSITIVE))) - assertNotNull(env.resolve(path, EMPTY_TYPE_ENV, Rex.Op.Var.Scope.DEFAULT)) + assertNotNull(env.resolve(path, EMPTY_TYPE_ENV, ResolutionStrategy.GLOBAL)) assertEquals(1, env.catalogs.size) assert(env.catalogs.contains(GLOBAL_OS)) } @@ -60,7 +60,7 @@ class EnvTest { @Test fun testGlobalMatchingInsensitiveName() { val path = BindingPath(listOf(BindingName("oS", BindingCase.INSENSITIVE))) - assertNotNull(env.resolve(path, EMPTY_TYPE_ENV, Rex.Op.Var.Scope.DEFAULT)) + assertNotNull(env.resolve(path, EMPTY_TYPE_ENV, ResolutionStrategy.GLOBAL)) assertEquals(1, env.catalogs.size) assert(env.catalogs.contains(GLOBAL_OS)) } @@ -68,14 +68,14 @@ class EnvTest { @Test fun testGlobalNotMatchingSensitiveName() { val path = BindingPath(listOf(BindingName("oS", BindingCase.SENSITIVE))) - assertNull(env.resolve(path, EMPTY_TYPE_ENV, Rex.Op.Var.Scope.DEFAULT)) + assertNull(env.resolve(path, EMPTY_TYPE_ENV, ResolutionStrategy.GLOBAL)) assert(env.catalogs.isEmpty()) } @Test fun testGlobalNotMatchingInsensitiveName() { val path = BindingPath(listOf(BindingName("nonexistent", BindingCase.INSENSITIVE))) - assertNull(env.resolve(path, EMPTY_TYPE_ENV, Rex.Op.Var.Scope.DEFAULT)) + assertNull(env.resolve(path, EMPTY_TYPE_ENV, ResolutionStrategy.GLOBAL)) assert(env.catalogs.isEmpty()) } } diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/TypeEnvTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/TypeEnvTest.kt new file mode 100644 index 0000000000..67504b0f89 --- /dev/null +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/TypeEnvTest.kt @@ -0,0 +1,114 @@ +package org.partiql.planner.internal.typer + +import org.junit.jupiter.api.parallel.Execution +import org.junit.jupiter.api.parallel.ExecutionMode +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.MethodSource +import org.partiql.planner.internal.ir.Rex +import org.partiql.planner.internal.ir.relBinding +import org.partiql.spi.BindingCase +import org.partiql.spi.BindingName +import org.partiql.spi.BindingPath +import org.partiql.types.BoolType +import org.partiql.types.StaticType +import org.partiql.types.StructType +import org.partiql.types.TupleConstraint +import kotlin.test.assertEquals +import kotlin.test.fail + +internal class TypeEnvTest { + + companion object { + + /** + * < + * A : { B: } }, + * a : { b: } }, + * X : { ... } }, + * x : { y: , ... } }, + * Y : { ... } }, + * T : { x: , x: } }, + * > + */ + @JvmStatic + val locals = TypeEnv( + listOf( + relBinding("A", struct("B" to BoolType())), + relBinding("a", struct("b" to BoolType())), + relBinding("X", struct(open = true)), + relBinding("x", struct("Y" to BoolType(), open = true)), + relBinding("y", struct(open = true)), + relBinding("T", struct("x" to BoolType(), "x" to BoolType())), + ) + ) + + private fun struct(vararg fields: Pair, open: Boolean = false): StructType { + return StructType( + fields = fields.map { StructType.Field(it.first, it.second) }, + constraints = setOf(TupleConstraint.Open(open)), + ) + } + + @JvmStatic + public fun cases() = listOf>( + // root matching + """ A.B """ to null, + """ A."B" """ to null, + """ "A".B """ to 0, + """ "A"."B" """ to 0, + """ "a".B """ to 1, + """ "a"."B" """ to 1, + """ x """ to null, + // """ x.y """ to 3, + """ y """ to 4, + + // struct searching + """ b """ to null, + """ "B" """ to 0, + """ "b" """ to 1, + """ "Y" """ to 3, + + // other + """ T.x """ to 5 + ) + } + + @ParameterizedTest + @MethodSource("cases") + @Execution(ExecutionMode.CONCURRENT) + fun resolve(case: Pair) { + val path = case.first.path() + val expected = case.second + val rex = locals.resolve(path) + if (rex == null) { + if (expected == null) { + return // pass + } else { + fail("could not resolve variable") + } + } + // For now, just traverse to the root + var root = rex.op + while (root !is Rex.Op.Var.Resolved) { + root = when (root) { + is Rex.Op.Path.Symbol -> root.root.op + is Rex.Op.Path.Key -> root.root.op + else -> { + fail("Expected path step of symbol or key, but found $root") + } + } + } + // + assertEquals(expected, root.ref) + } + + private fun String.path(): BindingPath { + val steps = trim().split(".").map { + when (it.startsWith("\"")) { + true -> BindingName(it.drop(1).dropLast(1), BindingCase.SENSITIVE) + else -> BindingName(it, BindingCase.INSENSITIVE) + } + } + return BindingPath(steps) + } +}