diff --git a/partiql-cli/src/main/kotlin/org/partiql/cli/Main.kt b/partiql-cli/src/main/kotlin/org/partiql/cli/Main.kt index 61267b6f66..147d335012 100644 --- a/partiql-cli/src/main/kotlin/org/partiql/cli/Main.kt +++ b/partiql-cli/src/main/kotlin/org/partiql/cli/Main.kt @@ -23,7 +23,6 @@ import org.partiql.lang.eval.EvaluationSession import org.partiql.parser.PartiQLParser import org.partiql.plan.debug.PlanPrinter import org.partiql.planner.PartiQLPlanner -import org.partiql.plugins.local.LocalConnector import picocli.CommandLine import java.io.PrintStream import java.nio.file.Paths @@ -72,9 +71,8 @@ object Debug { val sess = PartiQLPlanner.Session( queryId = UUID.randomUUID().toString(), userId = "debug", - catalogs = mapOf( - "local" to LocalConnector.Metadata(root) - ) + currentCatalog = "default", + catalogs = emptyMap(), ) val result = planner.plan(statement, sess).plan out.info("-- Plan ----------") diff --git a/partiql-cli/src/main/kotlin/org/partiql/cli/pipeline/AbstractPipeline.kt b/partiql-cli/src/main/kotlin/org/partiql/cli/pipeline/AbstractPipeline.kt index ac8dcbc6c7..c2fdabe5f4 100644 --- a/partiql-cli/src/main/kotlin/org/partiql/cli/pipeline/AbstractPipeline.kt +++ b/partiql-cli/src/main/kotlin/org/partiql/cli/pipeline/AbstractPipeline.kt @@ -27,7 +27,6 @@ import org.partiql.cli.functions.ReadFile_1 import org.partiql.cli.functions.ReadFile_2 import org.partiql.cli.functions.WriteFile_1 import org.partiql.cli.functions.WriteFile_2 -import org.partiql.cli.utils.ServiceLoaderUtil import org.partiql.lang.CompilerPipeline import org.partiql.lang.compiler.PartiQLCompilerBuilder import org.partiql.lang.compiler.PartiQLCompilerPipeline @@ -84,7 +83,7 @@ internal sealed class AbstractPipeline(open val options: PipelineOptions) { WriteFile_1(ion), WriteFile_2(ion), QueryDDB(ion) - ) + ServiceLoaderUtil.loadFunctions(pluginPath) + ) val parser = PartiQLParserBuilder().build() return PipelineOptions( pipeline, diff --git a/partiql-cli/src/main/kotlin/org/partiql/cli/utils/ServiceLoaderUtil.kt b/partiql-cli/src/main/kotlin/org/partiql/cli/utils/ServiceLoaderUtil.kt deleted file mode 100644 index 0ed38ae35b..0000000000 --- a/partiql-cli/src/main/kotlin/org/partiql/cli/utils/ServiceLoaderUtil.kt +++ /dev/null @@ -1,537 +0,0 @@ -package org.partiql.cli.utils - -import org.partiql.lang.eval.EvaluationSession -import org.partiql.lang.eval.ExprFunction -import org.partiql.lang.eval.ExprValue -import org.partiql.lang.eval.ExprValue.Companion.newBag -import org.partiql.lang.eval.ExprValue.Companion.newBlob -import org.partiql.lang.eval.ExprValue.Companion.newBoolean -import org.partiql.lang.eval.ExprValue.Companion.newClob -import org.partiql.lang.eval.ExprValue.Companion.newDate -import org.partiql.lang.eval.ExprValue.Companion.newDecimal -import org.partiql.lang.eval.ExprValue.Companion.newFloat -import org.partiql.lang.eval.ExprValue.Companion.newInt -import org.partiql.lang.eval.ExprValue.Companion.newList -import org.partiql.lang.eval.ExprValue.Companion.newSexp -import org.partiql.lang.eval.ExprValue.Companion.newString -import org.partiql.lang.eval.ExprValue.Companion.newStruct -import org.partiql.lang.eval.ExprValue.Companion.newSymbol -import org.partiql.lang.eval.ExprValue.Companion.newTime -import org.partiql.lang.eval.ExprValueType -import org.partiql.lang.eval.StructOrdering -import org.partiql.lang.eval.booleanValue -import org.partiql.lang.eval.bytesValue -import org.partiql.lang.eval.dateValue -import org.partiql.lang.eval.name -import org.partiql.lang.eval.namedValue -import org.partiql.lang.eval.numberValue -import org.partiql.lang.eval.stringValue -import org.partiql.lang.eval.time.Time -import org.partiql.lang.eval.timeValue -import org.partiql.lang.types.FunctionSignature -import org.partiql.spi.Plugin -import org.partiql.spi.function.PartiQLFunction -import org.partiql.spi.function.PartiQLFunctionExperimental -import org.partiql.types.StaticType -import org.partiql.value.BagValue -import org.partiql.value.BlobValue -import org.partiql.value.BoolValue -import org.partiql.value.CharValue -import org.partiql.value.ClobValue -import org.partiql.value.DateValue -import org.partiql.value.DecimalValue -import org.partiql.value.Float32Value -import org.partiql.value.Float64Value -import org.partiql.value.Int16Value -import org.partiql.value.Int32Value -import org.partiql.value.Int64Value -import org.partiql.value.Int8Value -import org.partiql.value.IntValue -import org.partiql.value.ListValue -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental -import org.partiql.value.PartiQLValueType -import org.partiql.value.SexpValue -import org.partiql.value.StringValue -import org.partiql.value.StructValue -import org.partiql.value.SymbolValue -import org.partiql.value.TimeValue -import org.partiql.value.bagValue -import org.partiql.value.blobValue -import org.partiql.value.boolValue -import org.partiql.value.charValue -import org.partiql.value.clobValue -import org.partiql.value.dateValue -import org.partiql.value.datetime.DateTimeValue.date -import org.partiql.value.datetime.DateTimeValue.time -import org.partiql.value.datetime.TimeZone -import org.partiql.value.decimalValue -import org.partiql.value.float32Value -import org.partiql.value.float64Value -import org.partiql.value.int16Value -import org.partiql.value.int32Value -import org.partiql.value.int64Value -import org.partiql.value.int8Value -import org.partiql.value.intValue -import org.partiql.value.listValue -import org.partiql.value.missingValue -import org.partiql.value.nullValue -import org.partiql.value.sexpValue -import org.partiql.value.stringValue -import org.partiql.value.structValue -import org.partiql.value.symbolValue -import org.partiql.value.timeValue -import java.math.BigDecimal -import java.math.BigInteger -import java.math.RoundingMode -import java.net.URLClassLoader -import java.nio.file.Path -import java.time.DateTimeException -import java.util.ServiceLoader -import java.util.concurrent.locks.ReentrantLock -import kotlin.concurrent.withLock - -/** - * A util class to load pluggable functions by invoking Java Service Loader. - */ -class ServiceLoaderUtil { - @OptIn(PartiQLValueExperimental::class) - companion object { - private val lock = ReentrantLock() - - @OptIn(PartiQLFunctionExperimental::class) - @JvmStatic - fun loadFunctions(pluginPath: Path): List = lock.withLock { - val pluginsDir = pluginPath.toFile() - val pluginFolders = pluginsDir.listFiles { file -> file.isDirectory }.orEmpty() - val files = pluginFolders.flatMap { folder -> - folder.listFiles { file -> file.isFile && file.extension == "jar" }.orEmpty().toList() - } - val plugins = if (files.isNotEmpty()) { - val classLoader = URLClassLoader.newInstance(files.map { it.toURI().toURL() }.toTypedArray()) - ServiceLoader.load(Plugin::class.java, classLoader) - } else { - listOf() - } - return plugins.flatMap { plugin -> plugin.functions } - .filterIsInstance() - .map { partiqlFunc -> PartiQLtoExprFunction(partiqlFunc) } - } - - @OptIn(PartiQLValueExperimental::class, PartiQLFunctionExperimental::class) - private fun PartiQLtoExprFunction(customFunction: PartiQLFunction.Scalar): ExprFunction { - val name = customFunction.signature.name - val parameters = customFunction.signature.parameters.map { it.type } - val returnType = customFunction.signature.returns - return object : ExprFunction { - override val signature = FunctionSignature( - name = name, - requiredParameters = parameters.map { PartiQLToStaticType(it) }, - returnType = PartiQLToStaticType(returnType), - ) - - override fun callWithRequired(session: EvaluationSession, required: List): ExprValue { - val partiQLArguments = required.mapIndexed { i, expr -> ExprToPartiQLValue(expr, parameters[i]) }.toTypedArray() - val partiQLResult = customFunction.invoke(partiQLArguments) - return PartiQLtoExprValue(partiQLResult) - } - } - } - - /** - * All runtime values are nullable in SQL. - */ - @OptIn(PartiQLValueExperimental::class) - private fun PartiQLToStaticType(partiqlType: PartiQLValueType): StaticType { - return when (partiqlType) { - PartiQLValueType.ANY -> StaticType.ANY.asNullable() - PartiQLValueType.NULL -> StaticType.NULL - PartiQLValueType.MISSING -> StaticType.MISSING - PartiQLValueType.BOOL -> StaticType.BOOL.asNullable() - PartiQLValueType.INT8 -> StaticType.INT.asNullable() - PartiQLValueType.INT16 -> StaticType.INT2.asNullable() - PartiQLValueType.INT32 -> StaticType.INT4.asNullable() - PartiQLValueType.INT64 -> StaticType.INT8.asNullable() - PartiQLValueType.INT -> StaticType.INT.asNullable() - PartiQLValueType.DECIMAL_ARBITRARY -> StaticType.DECIMAL.asNullable() - PartiQLValueType.FLOAT32 -> StaticType.FLOAT.asNullable() - PartiQLValueType.FLOAT64 -> StaticType.FLOAT.asNullable() - PartiQLValueType.CHAR -> StaticType.STRING.asNullable() - PartiQLValueType.STRING -> StaticType.STRING.asNullable() - PartiQLValueType.SYMBOL -> StaticType.SYMBOL.asNullable() - PartiQLValueType.BINARY -> TODO() - PartiQLValueType.BYTE -> TODO() - PartiQLValueType.BLOB -> StaticType.BLOB.asNullable() - PartiQLValueType.CLOB -> StaticType.CLOB.asNullable() - PartiQLValueType.DATE -> StaticType.DATE.asNullable() - PartiQLValueType.TIME -> StaticType.TIME.asNullable() - PartiQLValueType.TIMESTAMP -> StaticType.TIMESTAMP.asNullable() - PartiQLValueType.INTERVAL -> TODO() - PartiQLValueType.BAG -> StaticType.BAG.asNullable() - PartiQLValueType.LIST -> StaticType.LIST.asNullable() - PartiQLValueType.SEXP -> StaticType.SEXP.asNullable() - PartiQLValueType.STRUCT -> StaticType.STRUCT.asNullable() - PartiQLValueType.DECIMAL -> TODO() - } - } - - @Throws(PartiQLtoExprValueTypeMismatchException::class) - @OptIn(PartiQLValueExperimental::class) - private fun PartiQLtoExprValue(partiqlValue: PartiQLValue): ExprValue { - return when (partiqlValue.type) { - PartiQLValueType.ANY -> throw UnsupportedOperationException("PartiQLValue ANY not implemented") - PartiQLValueType.NULL -> ExprValue.nullValue - PartiQLValueType.MISSING -> ExprValue.missingValue - PartiQLValueType.BOOL -> (partiqlValue as? BoolValue)?.value?.let { newBoolean(it) } - ?: ExprValue.nullValue - - PartiQLValueType.INT8 -> (partiqlValue as? Int8Value)?.int?.let { newInt(it) } ?: ExprValue.nullValue - - PartiQLValueType.INT16 -> (partiqlValue as? Int16Value)?.int?.let { newInt(it) } ?: ExprValue.nullValue - - PartiQLValueType.INT32 -> (partiqlValue as? Int32Value)?.int?.let { newInt(it) } ?: ExprValue.nullValue - - PartiQLValueType.INT64 -> (partiqlValue as? Int64Value)?.long?.let { newInt(it) } ?: ExprValue.nullValue - - PartiQLValueType.INT -> (partiqlValue as? IntValue)?.long?.let { newInt(it) } ?: ExprValue.nullValue - - PartiQLValueType.DECIMAL_ARBITRARY -> (partiqlValue as? DecimalValue)?.value?.let { newDecimal(it) } - ?: ExprValue.nullValue - - PartiQLValueType.FLOAT32 -> (partiqlValue as? Float32Value)?.double?.let { newFloat(it) } - ?: ExprValue.nullValue - - PartiQLValueType.FLOAT64 -> (partiqlValue as? Float64Value)?.double?.let { newFloat(it) } - ?: ExprValue.nullValue - - PartiQLValueType.CHAR -> (partiqlValue as? CharValue)?.string?.let { newString(it) } - ?: ExprValue.nullValue - - PartiQLValueType.STRING -> (partiqlValue as? StringValue)?.string?.let { newString(it) } - ?: ExprValue.nullValue - - PartiQLValueType.SYMBOL -> (partiqlValue as? SymbolValue)?.string?.let { newSymbol(it) } - ?: ExprValue.nullValue - - PartiQLValueType.BINARY -> TODO() - - PartiQLValueType.BYTE -> TODO() - - PartiQLValueType.BLOB -> (partiqlValue as? BlobValue)?.value?.let { newBlob(it) } ?: ExprValue.nullValue - - PartiQLValueType.CLOB -> (partiqlValue as? ClobValue)?.value?.let { newClob(it) } ?: ExprValue.nullValue - - PartiQLValueType.DATE -> (partiqlValue as? DateValue)?.value?.let { newDate(it.year, it.month, it.day) } - ?: ExprValue.nullValue - - PartiQLValueType.TIME -> (partiqlValue as? TimeValue)?.value?.let { partiqlTime -> - val fraction = partiqlTime.decimalSecond.remainder(BigDecimal.ONE) - val precision = when { - fraction.scale() > 9 -> throw DateTimeException("Precision greater than nano seconds not supported") - else -> fraction.scale() - } - - val tzMinutes = when (val tz = partiqlTime.timeZone) { - is TimeZone.UnknownTimeZone -> 0 // Treat unknown offset as UTC (+00:00) - is TimeZone.UtcOffset -> tz.totalOffsetMinutes - else -> null - } - - try { - newTime( - Time.of( - partiqlTime.hour, - partiqlTime.minute, - partiqlTime.decimalSecond.setScale(0, RoundingMode.DOWN).toInt(), - fraction.movePointRight(9).setScale(0, RoundingMode.DOWN).toInt(), - precision, - tzMinutes - ) - ) - } catch (e: DateTimeException) { - throw e - } - } ?: ExprValue.nullValue - - PartiQLValueType.TIMESTAMP -> TODO() - // TODO: Implement -// { -// val timestampValue = partiqlValue as? TimestampValue -// timestampValue?.let { tv -> -// val localDateTime = tv.value -// val zoneOffset = tv.offset -// val instant = localDateTime.atOffset(zoneOffset ?: ZoneOffset.UTC).toInstant() -// val timestamp = Timestamp.forMillis(instant.toEpochMilli(), (zoneOffset?.totalSeconds ?: 0) / 60) -// newTimestamp(timestamp) -// } ?: ExprValue.nullValue -// } - - PartiQLValueType.INTERVAL -> TODO() - - PartiQLValueType.BAG -> { - if (partiqlValue.isNull) { - ExprValue.nullValue - } else { - newBag((partiqlValue as? BagValue<*>)!!.map { PartiQLtoExprValue(it) }) - } - } - - PartiQLValueType.LIST -> { - if (partiqlValue.isNull) { - ExprValue.nullValue - } else { - newList((partiqlValue as? ListValue<*>)!!.map { PartiQLtoExprValue(it) }) - } - } - - PartiQLValueType.SEXP -> { - if (partiqlValue.isNull) { - ExprValue.nullValue - } else { - newSexp((partiqlValue as? SexpValue<*>)!!.map { PartiQLtoExprValue(it) }) - } - } - - PartiQLValueType.STRUCT -> { - if (partiqlValue.isNull) { - ExprValue.nullValue - } else { - val entries = (partiqlValue as? StructValue<*>)!!.entries - entries.map { - PartiQLtoExprValue(it.second).namedValue( - newString( - it.first - ) - ) - }.let { newStruct(it, StructOrdering.ORDERED) } - } - } - - PartiQLValueType.DECIMAL -> TODO() - } - } - - @Throws(ExprToPartiQLValueTypeMismatchException::class) - @OptIn(PartiQLValueExperimental::class) - private fun ExprToPartiQLValue(exprValue: ExprValue, partiqlType: PartiQLValueType): PartiQLValue { - fun checkType(exprType: ExprValueType) { - if (exprValue.type != exprType) { - throw ExprToPartiQLValueTypeMismatchException(partiqlType, ExprToPartiQLValueType(exprValue)) - } - } - - return when (partiqlType) { - PartiQLValueType.ANY -> throw UnsupportedOperationException("PartiQLValue ANY not implemented") - PartiQLValueType.NULL -> { - checkType(ExprValueType.NULL) - nullValue() - } - PartiQLValueType.MISSING -> { - checkType(ExprValueType.MISSING) - missingValue() - } - PartiQLValueType.BOOL -> when (exprValue.type) { - ExprValueType.NULL -> boolValue(null) - ExprValueType.BOOL -> boolValue(exprValue.booleanValue()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.BOOL, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.INT8 -> when (exprValue.type) { - ExprValueType.NULL -> int8Value(null) - ExprValueType.INT -> int8Value(exprValue.numberValue().toByte()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.INT8, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.INT16 -> when (exprValue.type) { - ExprValueType.NULL -> int16Value(null) - ExprValueType.INT -> int16Value(exprValue.numberValue().toShort()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.INT16, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.INT32 -> when (exprValue.type) { - ExprValueType.NULL -> int32Value(null) - ExprValueType.INT -> int32Value(exprValue.numberValue().toInt()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.INT32, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.INT64 -> when (exprValue.type) { - ExprValueType.NULL -> int64Value(null) - ExprValueType.INT -> int64Value(exprValue.numberValue().toLong()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.INT64, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.INT -> when (exprValue.type) { - ExprValueType.NULL -> intValue(null) - ExprValueType.INT -> intValue(exprValue.numberValue() as BigInteger) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.INT, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.DECIMAL_ARBITRARY -> when (exprValue.type) { - ExprValueType.NULL -> decimalValue(null) - ExprValueType.DECIMAL -> decimalValue(exprValue.numberValue() as BigDecimal) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.DECIMAL_ARBITRARY, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.FLOAT32 -> when (exprValue.type) { - ExprValueType.NULL -> float32Value(null) - ExprValueType.FLOAT -> float32Value(exprValue.numberValue().toFloat()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.FLOAT32, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.FLOAT64 -> when (exprValue.type) { - ExprValueType.NULL -> float64Value(null) - ExprValueType.FLOAT -> float64Value(exprValue.numberValue().toDouble()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.FLOAT64, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.CHAR -> when (exprValue.type) { - ExprValueType.NULL -> charValue(null) - ExprValueType.STRING -> charValue(exprValue.stringValue().first()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.CHAR, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.STRING -> when (exprValue.type) { - ExprValueType.NULL -> stringValue(null) - ExprValueType.STRING -> stringValue(exprValue.stringValue()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.STRING, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.SYMBOL -> when (exprValue.type) { - ExprValueType.NULL -> symbolValue(null) - ExprValueType.SYMBOL -> symbolValue(exprValue.stringValue()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.SYMBOL, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.BINARY -> TODO() - PartiQLValueType.BYTE -> TODO() - PartiQLValueType.BLOB -> when (exprValue.type) { - ExprValueType.NULL -> blobValue(null) - ExprValueType.BLOB -> blobValue(exprValue.bytesValue()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.BLOB, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.CLOB -> when (exprValue.type) { - ExprValueType.NULL -> clobValue(null) - ExprValueType.CLOB -> clobValue(exprValue.bytesValue()) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.CLOB, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.DATE -> when (exprValue.type) { - ExprValueType.NULL -> dateValue(null) - ExprValueType.DATE -> dateValue( - date( - exprValue.dateValue().year, - exprValue.dateValue().monthValue, - exprValue.dateValue().dayOfMonth - ) - ) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.DATE, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.TIME -> when (exprValue.type) { - ExprValueType.NULL -> timeValue(null) - ExprValueType.TIME -> timeValue( - time( - exprValue.timeValue().localTime.hour, - exprValue.timeValue().localTime.minute, - exprValue.timeValue().localTime.second, - exprValue.timeValue().localTime.nano, - exprValue.timeValue().timezoneMinute?.let { TimeZone.UtcOffset.of(it) } ?: null - ) - ) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.TIME, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.TIMESTAMP -> TODO() - PartiQLValueType.INTERVAL -> TODO() - PartiQLValueType.BAG -> when (exprValue.type) { - ExprValueType.NULL -> bagValue(null) - ExprValueType.BAG -> bagValue(exprValue.map { ExprToPartiQLValue(it, ExprToPartiQLValueType(it)) }) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.BAG, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.LIST -> when (exprValue.type) { - ExprValueType.NULL -> listValue(null) - ExprValueType.LIST -> listValue( - exprValue.map { - ExprToPartiQLValue( - it, ExprToPartiQLValueType(it) - ) - } - ) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.LIST, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.SEXP -> when (exprValue.type) { - ExprValueType.NULL -> sexpValue(null) - ExprValueType.SEXP -> sexpValue( - exprValue.map { - ExprToPartiQLValue( - it, ExprToPartiQLValueType(it) - ) - } - ) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.SEXP, ExprToPartiQLValueType(exprValue) - ) - } - PartiQLValueType.STRUCT -> when (exprValue.type) { - ExprValueType.NULL -> structValue(null) - ExprValueType.STRUCT -> structValue( - exprValue.map { - Pair( - it.name?.stringValue() ?: "", ExprToPartiQLValue(it, ExprToPartiQLValueType(it)) - ) - } - ) - else -> throw ExprToPartiQLValueTypeMismatchException( - PartiQLValueType.STRUCT, ExprToPartiQLValueType(exprValue) - ) - } - - PartiQLValueType.DECIMAL -> TODO() - } - } - - fun ExprToPartiQLValueType(exprValue: ExprValue): PartiQLValueType { - return when (exprValue.type) { - ExprValueType.MISSING -> PartiQLValueType.MISSING - ExprValueType.NULL -> PartiQLValueType.NULL - ExprValueType.BOOL -> PartiQLValueType.BOOL - ExprValueType.INT -> PartiQLValueType.INT - ExprValueType.FLOAT -> PartiQLValueType.FLOAT32 - ExprValueType.DECIMAL -> PartiQLValueType.DECIMAL_ARBITRARY - ExprValueType.DATE -> PartiQLValueType.DATE - ExprValueType.TIMESTAMP -> PartiQLValueType.TIMESTAMP - ExprValueType.TIME -> PartiQLValueType.TIME - ExprValueType.SYMBOL -> PartiQLValueType.SYMBOL - ExprValueType.STRING -> PartiQLValueType.STRING - ExprValueType.CLOB -> PartiQLValueType.CLOB - ExprValueType.BLOB -> PartiQLValueType.BLOB - ExprValueType.LIST -> PartiQLValueType.LIST - ExprValueType.SEXP -> PartiQLValueType.SEXP - ExprValueType.STRUCT -> PartiQLValueType.STRUCT - ExprValueType.BAG -> PartiQLValueType.BAG - ExprValueType.GRAPH -> TODO() - } - } - } -} diff --git a/partiql-plan/src/main/resources/partiql_plan.ion b/partiql-plan/src/main/resources/partiql_plan.ion index 1d863dd2d6..0fa3526c04 100644 --- a/partiql-plan/src/main/resources/partiql_plan.ion +++ b/partiql-plan/src/main/resources/partiql_plan.ion @@ -1,9 +1,8 @@ imports::{ kotlin: [ partiql_value::'org.partiql.value.PartiQLValue', + partiql_value_type::'org.partiql.value.PartiQLValueType', static_type::'org.partiql.types.StaticType', - scalar_signature::'org.partiql.types.function.FunctionSignature$Scalar', - aggregation_signature::'org.partiql.types.function.FunctionSignature$Aggregation', ], } @@ -33,7 +32,13 @@ catalog::{ ref::{ catalog: int, - symbol: int + symbol: int, + _: [ + cast::{ + input: partiql_value_type, + target: partiql_value_type, + } + ] } // Statements @@ -91,10 +96,15 @@ rex::{ symbol::{ root: rex, key: string }, ], + cast::{ + cast: '.ref.cast', + arg: rex, + }, + call::[ static::{ - fn: ref, - args: list::[rex] + fn: ref, + args: list::[rex], }, // Represents a dynamic function call. If all candidates are exhausted, dynamic calls will return MISSING. @@ -108,10 +118,10 @@ rex::{ _: [ candidate::{ fn: ref, - coercions: list::[optional::ref] + coercions: list::[optional::'.ref.cast'], } ] - } + }, ], case::{ @@ -270,7 +280,7 @@ rel::{ groups: list::[rex], _: [ call::{ - agg: ref, + agg: string, args: list::[rex], }, ], diff --git a/partiql-planner/build.gradle.kts b/partiql-planner/build.gradle.kts index f43b9a660f..31d63dd442 100644 --- a/partiql-planner/build.gradle.kts +++ b/partiql-planner/build.gradle.kts @@ -94,6 +94,7 @@ tasks.register("codegen") { "--poems", "builder", "--poems", "util", "--opt-in", "org.partiql.value.PartiQLValueExperimental", + "--opt-in", "org.partiql.spi.fn.FnExperimental", "./src/main/resources/partiql_plan_internal.ion" ) } diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/Errors.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/Errors.kt index 4866c350a5..8d388a17b7 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/Errors.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/Errors.kt @@ -2,6 +2,9 @@ package org.partiql.planner import org.partiql.errors.ProblemDetails import org.partiql.errors.ProblemSeverity +import org.partiql.plan.Identifier +import org.partiql.spi.BindingCase +import org.partiql.spi.BindingPath import org.partiql.types.StaticType /** @@ -24,11 +27,12 @@ public sealed class PlanningProblemDetails( public data class CompileError(val errorMessage: String) : PlanningProblemDetails(ProblemSeverity.ERROR, { errorMessage }) - public data class UndefinedVariable(val variableName: String, val caseSensitive: Boolean) : + public data class UndefinedVariable(val id: BindingPath) : PlanningProblemDetails( ProblemSeverity.ERROR, { - "Undefined variable '$variableName'." + + val caseSensitive = id.steps.any { it.case == BindingCase.SENSITIVE } + "Undefined variable '${id.key}'." + quotationHint(caseSensitive) } ) @@ -134,3 +138,15 @@ private fun quotationHint(caseSensitive: Boolean) = } else { "" } + +private fun Identifier.sql(): String = when (this) { + is Identifier.Qualified -> this.sql() + is Identifier.Symbol -> this.sql() +} + +private fun Identifier.Qualified.sql(): String = root.sql() + "." + steps.joinToString(".") { it.sql() } + +private fun Identifier.Symbol.sql(): String = when (caseSensitivity) { + Identifier.CaseSensitivity.SENSITIVE -> "\"$symbol\"" + Identifier.CaseSensitivity.INSENSITIVE -> symbol +} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlanner.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlanner.kt index 7a0f09ec5a..14ecc0eb4f 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlanner.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlanner.kt @@ -39,12 +39,13 @@ public interface PartiQLPlanner { * @property userId * @property currentCatalog * @property currentDirectory + * @property catalogs * @property instant */ public class Session( public val queryId: String, public val userId: String, - public val currentCatalog: String? = null, + public val currentCatalog: String, public val currentDirectory: List = emptyList(), public val catalogs: Map = emptyMap(), public val instant: Instant = Instant.now(), 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 3b8314e7f8..e9d8f777c6 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlannerDefault.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlannerDefault.kt @@ -32,13 +32,11 @@ internal class PartiQLPlannerDefault( // 3. Resolve variables val typer = PlanTyper(env, onProblem) - val internal = org.partiql.planner.internal.ir.PartiQLPlan( - catalogs = env.catalogs, - statement = typer.resolve(root), - ) + val typed = typer.resolve(root) + val internal = org.partiql.planner.internal.ir.PartiQLPlan(typed) // 4. Assert plan has been resolved — translating to public API - var plan = PlanTransform.visitPartiQLPlan(internal, onProblem) + var plan = PlanTransform.transform(internal, onProblem) // 5. Apply all passes for (pass in passes) { 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 5f22fd3f6f..86b734d370 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 @@ -1,267 +1,161 @@ package org.partiql.planner.internal 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.casts.CastTable +import org.partiql.planner.internal.ir.Rel import org.partiql.planner.internal.ir.Rex -import org.partiql.planner.internal.ir.catalogSymbolRef +import org.partiql.planner.internal.ir.refAgg +import org.partiql.planner.internal.ir.refFn +import org.partiql.planner.internal.ir.refObj +import org.partiql.planner.internal.ir.relOpAggregateCallResolved import org.partiql.planner.internal.ir.rex +import org.partiql.planner.internal.ir.rexOpCallDynamic +import org.partiql.planner.internal.ir.rexOpCallDynamicCandidate +import org.partiql.planner.internal.ir.rexOpCallStatic +import org.partiql.planner.internal.ir.rexOpCastResolved 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.planner.internal.typer.TypeEnv.Companion.toPath +import org.partiql.planner.internal.typer.toRuntimeType +import org.partiql.planner.internal.typer.toStaticType import org.partiql.spi.BindingPath import org.partiql.spi.connector.ConnectorMetadata -import org.partiql.spi.connector.ConnectorObjectHandle -import org.partiql.spi.connector.ConnectorObjectPath -import org.partiql.spi.connector.ConnectorSession +import org.partiql.spi.fn.FnExperimental import org.partiql.types.StaticType -import org.partiql.types.function.FunctionSignature import org.partiql.value.PartiQLValueExperimental -import org.partiql.value.stringValue +import org.partiql.value.PartiQLValueType /** - * Handle for associating a catalog name with catalog related metadata objects. - */ -internal typealias Handle = Pair - -/** - * Metadata for a resolved global variable + * [Env] is similar to the database type environment from the PartiQL Specification. This includes resolution of + * database binding values and scoped functions. * - * @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 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 + * See TypeEnv for the variables type environment. * - * | Value | Strategy | Scoping Rules | - * |------------+-----------------------+---------------| - * | LOCAL | local-first lookup | Rules 1, 2 | - * | GLOBAL | global-first lookup | Rule 3 | + * @property session */ -internal enum class ResolutionStrategy { - LOCAL, - GLOBAL, -} - -/** - * PartiQL Planner Global Environment of Catalogs backed by given plugins. - * - * @property session Session details - */ -internal class Env( - private val session: PartiQLPlanner.Session, -) { +internal class Env(private val session: PartiQLPlanner.Session) { /** - * Collect the list of all referenced globals during planning. + * Cast table used for coercion and explicit cast resolution. */ - public val catalogs = mutableListOf() + private val casts = CastTable.partiql /** - * Catalog Metadata for this query session. - */ - private val connectors = session.catalogs - - /** - * Encapsulate all function resolving logic within [FnResolver]. - * - * TODO we should be using a search_path for resolving functions. This is not possible at the moment, so we flatten - * all builtin functions to live at the top-level. At the moment, we could technically use this to have - * single-level `catalog`.`function`() syntax but that is out-of-scope for this commit. + * Current catalog [ConnectorMetadata]. Error if missing from the session. */ - public val fnResolver = FnResolver(object : Header() { - - override val namespace: String = "builtins" - - override val functions: List = - PartiQLHeader.functions + connectors.values.flatMap { it.functions } - - override val operators: List = - PartiQLHeader.operators + connectors.values.flatMap { it.operators } - - override val aggregations: List = - PartiQLHeader.aggregations + connectors.values.flatMap { it.aggregations } - }) - - private val connectorSession = object : ConnectorSession { - override fun getQueryId(): String = session.queryId - override fun getUserId(): String = session.userId - } + private val catalog: ConnectorMetadata = session.catalogs[session.currentCatalog] + ?: error("Session is missing ConnectorMetadata for current catalog ${session.currentCatalog}") /** - * Leverages a [FnResolver] to find a matching function defined in the [Header] scalar function catalog. + * A [PathResolver] for looking up objects given both unqualified and qualified names. */ - internal fun resolveFn(fn: Fn.Unresolved, args: List) = fnResolver.resolveFn(fn, args) + private val objects: PathResolverObj = PathResolverObj(catalog, session) /** - * Leverages a [FnResolver] to find a matching function defined in the [Header] aggregation function catalog. + * A [PathResolver] for looking up functions given both unqualified and qualified names. */ - internal fun resolveAgg(agg: Agg.Unresolved, args: List) = fnResolver.resolveAgg(agg, args) + private val fns: PathResolverFn = PathResolverFn(catalog, session) /** - * Fetch global object metadata from the given [BindingPath]. - * - * @param catalog Current catalog - * @param path Global identifier path - * @return + * A [PathResolver] for aggregation function lookup. */ - internal fun getObjectHandle(catalog: BindingName, path: BindingPath): Handle? { - val metadata = getMetadata(catalog) ?: return null - return metadata.second.getObjectHandle(connectorSession, path)?.let { - metadata.first to it - } - } + private val aggs: PathResolverAgg = PathResolverAgg /** - * Fetch a global variable's StaticType given its handle. + * This function looks up a global [BindingPath], returning a global reference expression. * - * @param handle - * @return - */ - internal fun getObjectDescriptor(handle: Handle): StaticType { - val metadata = getMetadata(BindingName(handle.first, BindingCase.SENSITIVE))?.second - ?: error("Unable to fetch connector metadata based on handle $handle") - return metadata.getObjectType(connectorSession, handle.second) ?: error("Unable to produce Static Type") - } - - /** - * Fetch [ConnectorMetadata] given a catalog name. + * Convert any remaining binding names (tail) to a path expression. * - * @param catalogName + * @param path * @return */ - private fun getMetadata(catalogName: BindingName): Handle? { - val catalogKey = connectors.keys.firstOrNull { catalogName.isEquivalentTo(it) } ?: return null - val metadata = connectors[catalogKey] ?: return null - return catalogKey to metadata + fun resolveObj(path: BindingPath): Rex? { + val item = objects.lookup(path) ?: return null + // Create an internal typed reference + val ref = refObj( + catalog = item.catalog, + path = item.handle.path, + type = item.handle.entity.getType(), + ) + // Rewrite as a path expression. + val root = rex(ref.type, rexOpGlobal(ref)) + val depth = calculateMatched(path, item.input, ref.path) + val tail = path.steps.drop(depth) + return if (tail.isEmpty()) root else root.toPath(tail) } - /** - * TODO optimization, check known globals before calling out to connector again - * - * @param catalog - * @param originalPath - * @param catalogPath - * @return - */ - private fun getGlobalType( - catalog: BindingName?, - originalPath: BindingPath, - catalogPath: BindingPath, - ): ResolvedVar? { - return catalog?.let { cat -> - getObjectHandle(cat, catalogPath)?.let { handle -> - getObjectDescriptor(handle).let { type -> - val depth = calculateMatched(originalPath, catalogPath, handle.second.absolutePath) - val (catalogIndex, valueIndex) = getOrAddCatalogValue( - handle.first, - handle.second.absolutePath.steps, - type - ) - // Return resolution metadata - ResolvedVar(type, catalogIndex, depth, valueIndex) - } - } + @OptIn(FnExperimental::class, PartiQLValueExperimental::class) + fun resolveFn(path: BindingPath, args: List): Rex? { + val item = fns.lookup(path) ?: return null + // Invoke FnResolver to determine if we made a match + val variants = item.handle.entity.getVariants() + val match = FnResolver.resolve(variants, args.map { it.type }) + if (match == null) { + // unable to make a match, consider returning helpful error messages given the item.variants. + return null } - } - - /** - * @return a [Pair] where [Pair.first] is the catalog index and [Pair.second] is the value index within that catalog - */ - private fun getOrAddCatalogValue( - catalogName: String, - valuePath: List, - valueType: StaticType, - ): Pair { - val catalogIndex = getOrAddCatalog(catalogName) - val symbols = catalogs[catalogIndex].symbols - return symbols.indexOfFirst { value -> - value.path == valuePath - }.let { index -> - when (index) { - -1 -> { - catalogs[catalogIndex] = catalogs[catalogIndex].copy( - symbols = symbols + listOf(Catalog.Symbol(valuePath, valueType)) + return when (match) { + is FnMatch.Dynamic -> { + val candidates = match.candidates.map { + // Create an internal typed reference for every candidate + rexOpCallDynamicCandidate( + fn = refFn( + catalog = item.catalog, + path = item.handle.path, + signature = it.signature, + ), + coercions = it.mapping.toList(), ) - catalogIndex to catalogs[catalogIndex].symbols.lastIndex } - else -> { - catalogIndex to index + // Rewrite as a dynamic call to be typed by PlanTyper + rex(StaticType.ANY, rexOpCallDynamic(args, candidates, match.exhaustive)) + } + is FnMatch.Static -> { + // Create an internal typed reference + val ref = refFn( + catalog = item.catalog, + path = item.handle.path, + signature = match.signature, + ) + // Apply the coercions as explicit casts + val coercions: List = args.mapIndexed { i, arg -> + when (val cast = match.mapping[i]) { + null -> arg + else -> rex(StaticType.ANY, rexOpCastResolved(cast, arg)) + } } + // Rewrite as a static call to be typed by PlanTyper + rex(StaticType.ANY, rexOpCallStatic(ref, coercions)) } } } - private fun getOrAddCatalog(catalogName: String): Int { - return catalogs.indexOfFirst { catalog -> - catalog.name == catalogName - }.let { - when (it) { - -1 -> { - catalogs.add(Catalog(catalogName, emptyList())) - catalogs.lastIndex - } - else -> it + @OptIn(FnExperimental::class, PartiQLValueExperimental::class) + fun resolveAgg(name: String, args: List): Rel.Op.Aggregate.Call.Resolved? { + val match = aggs.resolve(name, args) ?: return null + val agg = match.first + val mapping = match.second + // Create an internal typed reference + val ref = refAgg(name, agg) + // Apply the coercions as explicit casts + val coercions: List = args.mapIndexed { i, arg -> + when (val cast = mapping[i]) { + null -> arg + else -> rex(cast.target.toStaticType(), rexOpCastResolved(cast, arg)) } } + return relOpAggregateCallResolved(ref, coercions) } - /** - * Attempt to resolve a [BindingPath] in the global + local type environments. - */ - fun resolve(path: BindingPath, locals: TypeEnv, strategy: ResolutionStrategy): Rex? { - return when (strategy) { - ResolutionStrategy.LOCAL -> locals.resolve(path) ?: resolveGlobalBind(path) - ResolutionStrategy.GLOBAL -> resolveGlobalBind(path) ?: locals.resolve(path) - } + @OptIn(PartiQLValueExperimental::class) + fun resolveCast(input: Rex, target: PartiQLValueType): Rex.Op.Cast.Resolved? { + val operand = input.type.toRuntimeType() + val cast = casts.get(operand, target) ?: return null + return rexOpCastResolved(cast, input) } - /** - * Logic is as follows: - * 1. If Current Catalog and Schema are set, create a Path to the object and attempt to grab handle and schema. - * a. If not found, just try to find the object in the catalog. - * 2. If Current Catalog is not set: - * a. Loop through all catalogs and try to find the object. - * - * TODO: Add global bindings - * TODO: Replace paths with global variable references if found - */ - 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) - val resolvedVar = when (path.steps.size) { - 0 -> null - 1 -> getGlobalType(currentCatalog, path, absoluteCatalogPath) - 2 -> getGlobalType(currentCatalog, path, path) ?: getGlobalType(currentCatalog, path, absoluteCatalogPath) - else -> { - val inferredCatalog = path.steps[0] - val newPath = BindingPath(path.steps.subList(1, path.steps.size)) - getGlobalType(inferredCatalog, path, newPath) - ?: getGlobalType(currentCatalog, path, path) - ?: getGlobalType(currentCatalog, path, absoluteCatalogPath) - } - } ?: 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) - } + // ----------------------- + // Helpers + // ----------------------- /** * Logic for determining how many BindingNames were “matched” by the ConnectorMetadata @@ -273,17 +167,8 @@ internal class Env( private fun calculateMatched( originalPath: BindingPath, inputCatalogPath: BindingPath, - outputCatalogPath: ConnectorObjectPath, + outputCatalogPath: List, ): Int { - return originalPath.steps.size + outputCatalogPath.steps.size - inputCatalogPath.steps.size - } - - @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) + return originalPath.steps.size + outputCatalogPath.size - inputCatalogPath.steps.size } } diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/FnComparator.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/FnComparator.kt new file mode 100644 index 0000000000..4ad673b473 --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/FnComparator.kt @@ -0,0 +1,105 @@ +package org.partiql.planner.internal + +import org.partiql.spi.fn.FnExperimental +import org.partiql.spi.fn.FnParameter +import org.partiql.spi.fn.FnSignature +import org.partiql.value.PartiQLValueExperimental +import org.partiql.value.PartiQLValueType +import org.partiql.value.PartiQLValueType.ANY +import org.partiql.value.PartiQLValueType.BAG +import org.partiql.value.PartiQLValueType.BINARY +import org.partiql.value.PartiQLValueType.BLOB +import org.partiql.value.PartiQLValueType.BOOL +import org.partiql.value.PartiQLValueType.BYTE +import org.partiql.value.PartiQLValueType.CHAR +import org.partiql.value.PartiQLValueType.CLOB +import org.partiql.value.PartiQLValueType.DATE +import org.partiql.value.PartiQLValueType.DECIMAL +import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY +import org.partiql.value.PartiQLValueType.FLOAT32 +import org.partiql.value.PartiQLValueType.FLOAT64 +import org.partiql.value.PartiQLValueType.INT +import org.partiql.value.PartiQLValueType.INT16 +import org.partiql.value.PartiQLValueType.INT32 +import org.partiql.value.PartiQLValueType.INT64 +import org.partiql.value.PartiQLValueType.INT8 +import org.partiql.value.PartiQLValueType.INTERVAL +import org.partiql.value.PartiQLValueType.LIST +import org.partiql.value.PartiQLValueType.MISSING +import org.partiql.value.PartiQLValueType.NULL +import org.partiql.value.PartiQLValueType.SEXP +import org.partiql.value.PartiQLValueType.STRING +import org.partiql.value.PartiQLValueType.STRUCT +import org.partiql.value.PartiQLValueType.SYMBOL +import org.partiql.value.PartiQLValueType.TIME +import org.partiql.value.PartiQLValueType.TIMESTAMP + +/** + * Function precedence comparator; this is not formally specified. + * + * 1. Fewest args first + * 2. Parameters are compared left-to-right + */ +@OptIn(PartiQLValueExperimental::class, FnExperimental::class) +internal object FnComparator : Comparator { + + override fun compare(fn1: FnSignature, fn2: FnSignature): Int { + // Compare number of arguments + if (fn1.parameters.size != fn2.parameters.size) { + return fn1.parameters.size - fn2.parameters.size + } + // Compare operand type precedence + for (i in fn1.parameters.indices) { + val p1 = fn1.parameters[i] + val p2 = fn2.parameters[i] + val comparison = p1.compareTo(p2) + if (comparison != 0) return comparison + } + // unreachable? + return 0 + } + + private fun FnParameter.compareTo(other: FnParameter): Int = + comparePrecedence(this.type, other.type) + + private fun comparePrecedence(t1: PartiQLValueType, t2: PartiQLValueType): Int { + if (t1 == t2) return 0 + val p1 = precedence[t1]!! + val p2 = precedence[t2]!! + return p1 - p2 + } + + // This simply describes some precedence for ordering functions. + // This is not explicitly defined in the PartiQL Specification!! + // This does not imply the ability to CAST; this defines function resolution behavior. + private val precedence: Map = listOf( + NULL, + MISSING, + BOOL, + INT8, + INT16, + INT32, + INT64, + INT, + DECIMAL, + FLOAT32, + FLOAT64, + DECIMAL_ARBITRARY, // Arbitrary precision decimal has a higher precedence than FLOAT + CHAR, + STRING, + CLOB, + SYMBOL, + BINARY, + BYTE, + BLOB, + DATE, + TIME, + TIMESTAMP, + INTERVAL, + LIST, + SEXP, + BAG, + STRUCT, + ANY, + ).mapIndexed { precedence, type -> type to precedence }.toMap() +} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/FnMatch.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/FnMatch.kt new file mode 100644 index 0000000000..cd497a7604 --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/FnMatch.kt @@ -0,0 +1,47 @@ +package org.partiql.planner.internal + +import org.partiql.planner.internal.ir.Ref +import org.partiql.spi.fn.FnExperimental +import org.partiql.spi.fn.FnSignature + +/** + * Result of matching an unresolved function. + */ +@OptIn(FnExperimental::class) +internal sealed class FnMatch { + + /** + * Successful match of a static function call. + * + * @property signature + * @property mapping + */ + class Static( + val signature: FnSignature, + val mapping: Array, + ) : FnMatch() { + + /** + * The number of exact matches. Useful when ranking function matches. + */ + val exact: Int = mapping.count { it != null } + + override fun equals(other: Any?): Boolean { + if (other !is Static) return false + return signature.equals(other.signature) + } + + override fun hashCode(): Int = signature.hashCode() + } + + /** + * This represents dynamic dispatch. + * + * @property candidates Ordered list of potentially applicable functions to dispatch dynamically. + * @property exhaustive True if all argument permutations (branches) are matched. + */ + data class Dynamic( + val candidates: List, + val exhaustive: Boolean, + ) : FnMatch() +} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/FnResolver.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/FnResolver.kt new file mode 100644 index 0000000000..edbd8dcb85 --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/FnResolver.kt @@ -0,0 +1,172 @@ +package org.partiql.planner.internal + +import org.partiql.planner.internal.casts.CastTable +import org.partiql.planner.internal.ir.Ref +import org.partiql.planner.internal.typer.toRuntimeTypeOrNull +import org.partiql.spi.fn.FnExperimental +import org.partiql.spi.fn.FnSignature +import org.partiql.types.StaticType +import org.partiql.value.PartiQLValueExperimental +import org.partiql.value.PartiQLValueType +import org.partiql.value.PartiQLValueType.ANY +import org.partiql.value.PartiQLValueType.NULL + +/** + * + * Resolution of static calls. + * + * 1. Sort all functions by resolution precedence. + * 2. Check for a function accepting exactly the input argument types. If one exists, use it. + * 3. Look for the best match + * a. Discard candidates whose arguments do not match or cannot be coerced. + * b. Check all candidates and keep those with the most exact matches. + * + * Resolution of dynamic calls. + * + * + * Reference https://www.postgresql.org/docs/current/typeconv-func.html + */ +@OptIn(FnExperimental::class, PartiQLValueExperimental::class) +internal object FnResolver { + + @JvmStatic + private val casts = CastTable.partiql + + /** + * Resolution of either a static or dynamic function. + * + * @param variants + * @param args + * @return + */ + fun resolve(variants: List, args: List): FnMatch? { + + val candidates = variants + .filter { it.parameters.size == args.size } + .sortedWith(FnComparator) + .ifEmpty { return null } + + val argPermutations = buildArgumentPermutations(args).mapNotNull { argList -> + argList.map { arg -> + // Skip over if we cannot convert type to runtime type. + arg.toRuntimeTypeOrNull() ?: return@mapNotNull null + } + } + + // Match candidates on all argument permutations + var exhaustive = true + val matches = argPermutations.mapNotNull { + val m = match(candidates, it) + if (m == null) { + // we had a branch whose arguments did not match a static call + exhaustive = false + } + m + } + + // Remove duplicates while maintaining order (precedence). + val orderedUniqueFunctions = matches.toSet().toList() + val n = orderedUniqueFunctions.size + + // Static call iff only one match for every branch + return when { + n == 0 -> null + n == 1 && exhaustive -> orderedUniqueFunctions.first() + else -> FnMatch.Dynamic(orderedUniqueFunctions, exhaustive) + } + } + + /** + * Resolution of a static function. + * + * @param candidates + * @param args + * @return + */ + private fun match(candidates: List, args: List): FnMatch.Static? { + // 1. Check for an exact match + for (candidate in candidates) { + if (candidate.matches(args)) { + return FnMatch.Static(candidate, arrayOfNulls(args.size)) + } + } + // 2. Look for best match (for now, first match). + for (candidate in candidates) { + val m = candidate.match(args) + if (m != null) { + return m + } + // if (match != null && m.exact < match.exact) { + // // already had a better match. + // continue + // } + // match = m + } + // 3. No match, return null + return null + } + + /** + * Check if this function accepts the exact input argument types. Assume same arity. + */ + private fun FnSignature.matches(args: List): Boolean { + for (i in args.indices) { + val a = args[i] + val p = parameters[i] + if (a != p.type) return false + } + return true + } + + /** + * Attempt to match arguments to the parameters; return the implicit casts if necessary. + * + * @param args + * @return + */ + private fun FnSignature.match(args: List): FnMatch.Static? { + val mapping = arrayOfNulls(args.size) + for (i in args.indices) { + val arg = args[i] + val p = parameters[i] + when { + // 1. Exact match + arg == p.type -> continue + // 2. Match ANY, no coercion needed + p.type == ANY -> continue + // 3. Match NULL argument + arg == NULL -> continue + // 4. Check for a coercion + else -> when (val coercion = casts.lookupCoercion(arg, p.type)) { + null -> return null // short-circuit + else -> mapping[i] = coercion + } + } + } + return FnMatch.Static(this, mapping) + } + + private fun buildArgumentPermutations(args: List): List> { + val flattenedArgs = args.map { it.flatten().allTypes } + return buildArgumentPermutations(flattenedArgs, accumulator = emptyList()) + } + + private fun buildArgumentPermutations( + args: List>, + accumulator: List, + ): List> { + if (args.isEmpty()) { + return listOf(accumulator) + } + val first = args.first() + val rest = when (args.size) { + 1 -> emptyList() + else -> args.subList(1, args.size) + } + return buildList { + first.forEach { argSubType -> + addAll(buildArgumentPermutations(rest, accumulator + listOf(argSubType))) + } + } + } +} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Header.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Header.kt deleted file mode 100644 index cfec05de70..0000000000 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/Header.kt +++ /dev/null @@ -1,80 +0,0 @@ -package org.partiql.planner.internal - -import org.partiql.planner.internal.typer.TypeLattice -import org.partiql.types.function.FunctionParameter -import org.partiql.types.function.FunctionSignature -import org.partiql.value.PartiQLValueExperimental -import org.partiql.value.PartiQLValueType - -/** - * A (temporary) place for function definitions; there are whispers of loading this as information_schema. - */ -@OptIn(PartiQLValueExperimental::class) -internal abstract class Header { - - /** - * Definition namespace e.g. partiql, spark, redshift, ... - */ - abstract val namespace: String - - /** - * Scalar function signatures available via call syntax. - */ - open val functions: List = emptyList() - - /** - * Hidden scalar function signatures available via operator or special form syntax. - */ - open val operators: List = emptyList() - - /** - * Aggregation function signatures. - */ - open val aggregations: List = emptyList() - - /** - * Type relationships; this is primarily a helper for defining operators. - */ - internal val types: TypeLattice = TypeLattice.partiql() - - /** - * Dump the Header as SQL commands - * - * For functions, output CREATE FUNCTION statements. - */ - override fun toString(): String = buildString { - (functions + operators + aggregations).groupBy { it.name }.forEach { - appendLine("-- [${it.key}] ---------") - appendLine() - it.value.forEach { fn -> appendLine(fn) } - appendLine() - } - } - - // ==================================== - // HELPERS - // ==================================== - - companion object { - - @JvmStatic - internal fun unary(name: String, returns: PartiQLValueType, value: PartiQLValueType) = - FunctionSignature.Scalar( - name = name, - returns = returns, - parameters = listOf(FunctionParameter("value", value)), - isNullable = false, - isNullCall = true - ) - - @JvmStatic - internal fun binary(name: String, returns: PartiQLValueType, lhs: PartiQLValueType, rhs: PartiQLValueType) = - FunctionSignature.Scalar( - name = name, - returns = returns, - parameters = listOf(FunctionParameter("lhs", lhs), FunctionParameter("rhs", rhs)), - isNullable = false, - isNullCall = true - ) - } -} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathItem.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathItem.kt new file mode 100644 index 0000000000..0a05038f9b --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathItem.kt @@ -0,0 +1,18 @@ +package org.partiql.planner.internal + +import org.partiql.spi.BindingPath +import org.partiql.spi.connector.ConnectorHandle + +/** + * A simple catalog to metadata pair. + * + * @param T + * @property catalog The resolved entity's catalog name. + * @property input The input binding path that resulted in this item match. + * @property handle The resolved entity's catalog path and type information. + */ +internal data class PathItem( + @JvmField val catalog: String, + @JvmField val input: BindingPath, + @JvmField val handle: ConnectorHandle, +) diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolver.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolver.kt new file mode 100644 index 0000000000..bb89e28c60 --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolver.kt @@ -0,0 +1,118 @@ +package org.partiql.planner.internal + +import org.partiql.planner.PartiQLPlanner +import org.partiql.spi.BindingCase +import org.partiql.spi.BindingName +import org.partiql.spi.BindingPath +import org.partiql.spi.connector.ConnectorHandle +import org.partiql.spi.connector.ConnectorMetadata + +/** + * This is the base behavior for name resolution. + * + * Let N be the number of steps in a given path. + * + * 1. If N = 1 + * (a) Lookup at .. (relative in catalog) + * 2. If N = 2 + * (a) Lookup at .. (relative in catalog) + * (b) Lookup at . (absolute in catalog) + * 3. If N > 2 + * (a) Lookup at .. (relative in catalog) + * (b) Lookup at . (absolute in catalog) + * (c) Lookup as an absolute where the first step is the catalog. (absolute in system) + * + * @param T + * @property catalog + * @property session + */ +internal abstract class PathResolver( + private val catalog: ConnectorMetadata, + private val session: PartiQLPlanner.Session, +) { + + /** + * The session's current directory represented as [BindingName] steps. + */ + open val schema = session.currentDirectory.map { it.toBindingName() } + + /** + * A [PathResolver] should override this one method for which [ConnectorMetadata] API to call. + * + * @param metadata ConnectorMetadata to resolve this catalog entity in. + * @param path The catalog absolute path. + * @return + */ + abstract fun get(metadata: ConnectorMetadata, path: BindingPath): ConnectorHandle? + + /** + * Lookup a `path` following the scoping rules in the class javadoc. + * + * Returns a pair of the + * + * @param path This represents the exact path + * @return + */ + internal fun lookup(path: BindingPath): PathItem? { + val n = path.steps.size + val m = schema.size + return if (m > 0) { + val absPath = BindingPath(schema + path.steps) + when (n) { + 0 -> return null + 1 -> return get(absPath) + 2 -> return get(absPath) ?: get(path) + else -> return get(absPath) ?: get(path) ?: search(path) + } + } else { + // no need to prepend path as it's empty + when (n) { + 0 -> null + 1 -> get(path) + 2 -> get(path) + else -> get(path) ?: search(path) + } + } + } + + /** + * This gets the path in the current catalog. + * + * @param path Catalog absolute path. + * @return + */ + private fun get(path: BindingPath): PathItem? { + val handle = get(catalog, path) ?: return null + return PathItem(session.currentCatalog, path, handle) + } + + /** + * This searches with a system absolute path, using the session to lookup catalogs. + * + * @param path System absolute path. + */ + private fun search(path: BindingPath): PathItem? { + var match: Map.Entry? = null + val first: BindingName = path.steps.first() + for (catalog in session.catalogs) { + if (first.matches(catalog.key)) { + if (match != null) { + // TODO root was already matched, emit ambiguous error + return null + } + match = catalog + } + } + if (match == null) { + return null + } + // Lookup in the unambiguously matched catalog, calculating the depth matched. + val absPath = BindingPath(path.steps.drop(1)) + val catalog = match.key + val metadata = match.value + val handle = get(metadata, absPath) ?: return null + return PathItem(catalog, absPath, handle) + } + + private fun String.toBindingName() = BindingName(this, BindingCase.SENSITIVE) +} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolverAgg.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolverAgg.kt new file mode 100644 index 0000000000..4a711306ae --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolverAgg.kt @@ -0,0 +1,183 @@ +package org.partiql.planner.internal + +import org.partiql.planner.internal.casts.CastTable +import org.partiql.planner.internal.ir.Ref +import org.partiql.planner.internal.ir.Rex +import org.partiql.planner.internal.typer.toRuntimeType +import org.partiql.spi.connector.sql.builtins.Agg_ANY__BOOL__BOOL +import org.partiql.spi.connector.sql.builtins.Agg_AVG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY +import org.partiql.spi.connector.sql.builtins.Agg_AVG__FLOAT32__FLOAT32 +import org.partiql.spi.connector.sql.builtins.Agg_AVG__FLOAT64__FLOAT64 +import org.partiql.spi.connector.sql.builtins.Agg_AVG__INT16__INT16 +import org.partiql.spi.connector.sql.builtins.Agg_AVG__INT32__INT32 +import org.partiql.spi.connector.sql.builtins.Agg_AVG__INT64__INT64 +import org.partiql.spi.connector.sql.builtins.Agg_AVG__INT8__INT8 +import org.partiql.spi.connector.sql.builtins.Agg_AVG__INT__INT +import org.partiql.spi.connector.sql.builtins.Agg_COUNT_STAR____INT32 +import org.partiql.spi.connector.sql.builtins.Agg_COUNT__ANY__INT32 +import org.partiql.spi.connector.sql.builtins.Agg_EVERY__BOOL__BOOL +import org.partiql.spi.connector.sql.builtins.Agg_MAX__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY +import org.partiql.spi.connector.sql.builtins.Agg_MAX__FLOAT32__FLOAT32 +import org.partiql.spi.connector.sql.builtins.Agg_MAX__FLOAT64__FLOAT64 +import org.partiql.spi.connector.sql.builtins.Agg_MAX__INT16__INT16 +import org.partiql.spi.connector.sql.builtins.Agg_MAX__INT32__INT32 +import org.partiql.spi.connector.sql.builtins.Agg_MAX__INT64__INT64 +import org.partiql.spi.connector.sql.builtins.Agg_MAX__INT8__INT8 +import org.partiql.spi.connector.sql.builtins.Agg_MAX__INT__INT +import org.partiql.spi.connector.sql.builtins.Agg_MIN__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY +import org.partiql.spi.connector.sql.builtins.Agg_MIN__FLOAT32__FLOAT32 +import org.partiql.spi.connector.sql.builtins.Agg_MIN__FLOAT64__FLOAT64 +import org.partiql.spi.connector.sql.builtins.Agg_MIN__INT16__INT16 +import org.partiql.spi.connector.sql.builtins.Agg_MIN__INT32__INT32 +import org.partiql.spi.connector.sql.builtins.Agg_MIN__INT64__INT64 +import org.partiql.spi.connector.sql.builtins.Agg_MIN__INT8__INT8 +import org.partiql.spi.connector.sql.builtins.Agg_MIN__INT__INT +import org.partiql.spi.connector.sql.builtins.Agg_SOME__BOOL__BOOL +import org.partiql.spi.connector.sql.builtins.Agg_SUM__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY +import org.partiql.spi.connector.sql.builtins.Agg_SUM__FLOAT32__FLOAT32 +import org.partiql.spi.connector.sql.builtins.Agg_SUM__FLOAT64__FLOAT64 +import org.partiql.spi.connector.sql.builtins.Agg_SUM__INT16__INT16 +import org.partiql.spi.connector.sql.builtins.Agg_SUM__INT32__INT32 +import org.partiql.spi.connector.sql.builtins.Agg_SUM__INT64__INT64 +import org.partiql.spi.connector.sql.builtins.Agg_SUM__INT8__INT8 +import org.partiql.spi.connector.sql.builtins.Agg_SUM__INT__INT +import org.partiql.spi.fn.AggSignature +import org.partiql.spi.fn.FnExperimental +import org.partiql.value.PartiQLValueExperimental +import org.partiql.value.PartiQLValueType +import org.partiql.value.PartiQLValueType.ANY +import org.partiql.value.PartiQLValueType.NULL + +/** + * Today, all aggregations are hard-coded into the grammar. We cannot implement user-defined aggregations until + * the grammar and AST are updated appropriately. We should not have an aggregation node in the AST, just a call node. + * During planning, we would then check if a call is an aggregation and translate the AST to the appropriate algebra. + * + * PartiQL.g4 + * + * aggregate + * : func=COUNT PAREN_LEFT ASTERISK PAREN_RIGHT + * | func=(COUNT|MAX|MIN|SUM|AVG|EVERY|ANY|SOME) PAREN_LEFT setQuantifierStrategy? expr PAREN_RIGHT + * ; + * + */ +@OptIn(FnExperimental::class, PartiQLValueExperimental::class) +internal object PathResolverAgg { + + @JvmStatic + private val casts = CastTable.partiql + + private val map = listOf( + Agg_ANY__BOOL__BOOL, + Agg_AVG__INT8__INT8, + Agg_AVG__INT16__INT16, + Agg_AVG__INT32__INT32, + Agg_AVG__INT64__INT64, + Agg_AVG__INT__INT, + Agg_AVG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, + Agg_AVG__FLOAT32__FLOAT32, + Agg_AVG__FLOAT64__FLOAT64, + Agg_COUNT__ANY__INT32, + Agg_COUNT_STAR____INT32, + Agg_EVERY__BOOL__BOOL, + Agg_MAX__INT8__INT8, + Agg_MAX__INT16__INT16, + Agg_MAX__INT32__INT32, + Agg_MAX__INT64__INT64, + Agg_MAX__INT__INT, + Agg_MAX__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, + Agg_MAX__FLOAT32__FLOAT32, + Agg_MAX__FLOAT64__FLOAT64, + Agg_MIN__INT8__INT8, + Agg_MIN__INT16__INT16, + Agg_MIN__INT32__INT32, + Agg_MIN__INT64__INT64, + Agg_MIN__INT__INT, + Agg_MIN__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, + Agg_MIN__FLOAT32__FLOAT32, + Agg_MIN__FLOAT64__FLOAT64, + Agg_SOME__BOOL__BOOL, + Agg_SUM__INT8__INT8, + Agg_SUM__INT16__INT16, + Agg_SUM__INT32__INT32, + Agg_SUM__INT64__INT64, + Agg_SUM__INT__INT, + Agg_SUM__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, + Agg_SUM__FLOAT32__FLOAT32, + Agg_SUM__FLOAT64__FLOAT64, + ).map { it.signature }.groupBy { it.name } + + fun resolve(name: String, args: List): Pair>? { + val candidates = map[name] ?: return null + var hadMissingArg = false + val parameters = args.mapIndexed { i, arg -> + if (!hadMissingArg && arg.type.isMissable()) { + hadMissingArg = true + } + arg.type.toRuntimeType() + } + return match(candidates, parameters) + } + + private fun match(candidates: List, args: List): Pair>? { + // 1. Check for an exact match + for (candidate in candidates) { + if (candidate.matches(args)) { + return candidate to arrayOfNulls(args.size) + } + } + // 2. Look for best match. + var match: Pair>? = null + for (candidate in candidates) { + val m = candidate.match(args) ?: continue + // TODO AggMatch comparison + // if (match != null && m.exact < match.exact) { + // // already had a better match. + // continue + // } + match = m + } + // 3. Return best match or null + return match + } + + /** + * Check if this function accepts the exact input argument types. Assume same arity. + */ + private fun AggSignature.matches(args: List): Boolean { + for (i in args.indices) { + val a = args[i] + val p = parameters[i] + if (a != p.type) return false + } + return true + } + + /** + * Attempt to match arguments to the parameters; return the implicit casts if necessary. + * + * @param args + * @return + */ + private fun AggSignature.match(args: List): Pair>? { + val mapping = arrayOfNulls(args.size) + for (i in args.indices) { + val arg = args[i] + val p = parameters[i] + when { + // 1. Exact match + arg == p.type -> continue + // 2. Match ANY, no coercion needed + p.type == ANY -> continue + // 3. Match NULL argument + arg == NULL -> continue + // 4. Check for a coercion + else -> when (val coercion = casts.lookupCoercion(arg, p.type)) { + null -> return null // short-circuit + else -> mapping[i] = coercion + } + } + } + return this to mapping + } +} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolverFn.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolverFn.kt new file mode 100644 index 0000000000..b87ec60928 --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolverFn.kt @@ -0,0 +1,30 @@ +package org.partiql.planner.internal + +import org.partiql.planner.PartiQLPlanner +import org.partiql.spi.BindingName +import org.partiql.spi.BindingPath +import org.partiql.spi.connector.ConnectorFn +import org.partiql.spi.connector.ConnectorHandle +import org.partiql.spi.connector.ConnectorMetadata +import org.partiql.spi.fn.FnExperimental + +/** + * PathResolver which calls out to get matching function names. + + * + * @param catalog + * @param session + */ +@OptIn(FnExperimental::class) +internal class PathResolverFn( + catalog: ConnectorMetadata, + session: PartiQLPlanner.Session, +) : PathResolver(catalog, session) { + + /** + * Default INFORMATION_SCHEMA.ROUTINES. Keep empty for now for top-level lookup. + */ + override val schema: List = emptyList() + + override fun get(metadata: ConnectorMetadata, path: BindingPath): ConnectorHandle.Fn? = metadata.getFunction(path) +} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolverObj.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolverObj.kt new file mode 100644 index 0000000000..f976c10720 --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/PathResolverObj.kt @@ -0,0 +1,21 @@ +package org.partiql.planner.internal + +import org.partiql.planner.PartiQLPlanner +import org.partiql.spi.BindingPath +import org.partiql.spi.connector.ConnectorHandle +import org.partiql.spi.connector.ConnectorMetadata +import org.partiql.spi.connector.ConnectorObject + +/** + * PathResolver implementation which calls out to get database objects. + * + * @param catalog + * @param session + */ +internal class PathResolverObj( + catalog: ConnectorMetadata, + session: PartiQLPlanner.Session, +) : PathResolver(catalog, session) { + + override fun get(metadata: ConnectorMetadata, path: BindingPath): ConnectorHandle.Obj? = metadata.getObject(path) +} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/casts/CastTable.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/casts/CastTable.kt new file mode 100644 index 0000000000..533bb21f18 --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/casts/CastTable.kt @@ -0,0 +1,324 @@ +package org.partiql.planner.internal.casts + +import org.partiql.planner.internal.ir.Ref.Cast +import org.partiql.planner.internal.ir.refCast +import org.partiql.value.PartiQLValueExperimental +import org.partiql.value.PartiQLValueType +import org.partiql.value.PartiQLValueType.ANY +import org.partiql.value.PartiQLValueType.BAG +import org.partiql.value.PartiQLValueType.BINARY +import org.partiql.value.PartiQLValueType.BLOB +import org.partiql.value.PartiQLValueType.BOOL +import org.partiql.value.PartiQLValueType.BYTE +import org.partiql.value.PartiQLValueType.CHAR +import org.partiql.value.PartiQLValueType.CLOB +import org.partiql.value.PartiQLValueType.DATE +import org.partiql.value.PartiQLValueType.DECIMAL +import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY +import org.partiql.value.PartiQLValueType.FLOAT32 +import org.partiql.value.PartiQLValueType.FLOAT64 +import org.partiql.value.PartiQLValueType.INT +import org.partiql.value.PartiQLValueType.INT16 +import org.partiql.value.PartiQLValueType.INT32 +import org.partiql.value.PartiQLValueType.INT64 +import org.partiql.value.PartiQLValueType.INT8 +import org.partiql.value.PartiQLValueType.INTERVAL +import org.partiql.value.PartiQLValueType.LIST +import org.partiql.value.PartiQLValueType.MISSING +import org.partiql.value.PartiQLValueType.NULL +import org.partiql.value.PartiQLValueType.SEXP +import org.partiql.value.PartiQLValueType.STRING +import org.partiql.value.PartiQLValueType.STRUCT +import org.partiql.value.PartiQLValueType.SYMBOL +import org.partiql.value.PartiQLValueType.TIME +import org.partiql.value.PartiQLValueType.TIMESTAMP + +/** + * A place to model type relationships (for now this is to answer CAST inquiries). + * + * @property types + * @property graph Going with a matrix here (using enum ordinals) as it's simple and avoids walking. + */ +@OptIn(PartiQLValueExperimental::class) +internal class CastTable private constructor( + private val types: Array, + private val graph: Array>, +) { + + private fun relationships(): Sequence = sequence { + for (t1 in types) { + for (t2 in types) { + val r = graph[t1][t2] + if (r != null) { + yield(r) + } + } + } + } + + fun get(operand: PartiQLValueType, target: PartiQLValueType): Cast? { + val i = operand.ordinal + val j = target.ordinal + return graph[i][j] + } + + /** + * Returns the CAST function if exists, else null. + */ + fun lookupCoercion(operand: PartiQLValueType, target: PartiQLValueType): Cast? { + val i = operand.ordinal + val j = target.ordinal + val cast = graph[i][j] ?: return null + return if (cast.safety == Cast.Safety.COERCION) cast else null + } + + private operator fun Array.get(t: PartiQLValueType): T = get(t.ordinal) + + companion object { + + private val N = PartiQLValueType.values().size + + private operator fun Array.set(t: PartiQLValueType, value: T): Unit = this.set(t.ordinal, value) + + private fun PartiQLValueType.relationships(block: RelationshipBuilder.() -> Unit): Array { + return with(RelationshipBuilder(this)) { + block() + build() + } + } + + /** + * Build the PartiQL type lattice. + * + * TODO this is incomplete. + */ + @JvmStatic + val partiql: CastTable = run { + val types = PartiQLValueType.values() + val graph = arrayOfNulls>(N) + for (type in types) { + // initialize all with empty relationships + graph[type] = arrayOfNulls(N) + } + graph[ANY] = ANY.relationships { + coercion(ANY) + } + graph[NULL] = NULL.relationships { + coercion(NULL) + } + graph[MISSING] = MISSING.relationships { + coercion(MISSING) + } + graph[BOOL] = BOOL.relationships { + coercion(BOOL) + explicit(INT8) + explicit(INT16) + explicit(INT32) + explicit(INT64) + explicit(INT) + explicit(DECIMAL) + explicit(DECIMAL_ARBITRARY) + explicit(FLOAT32) + explicit(FLOAT64) + explicit(CHAR) + explicit(STRING) + explicit(SYMBOL) + } + graph[INT8] = INT8.relationships { + explicit(BOOL) + coercion(INT8) + coercion(INT16) + coercion(INT32) + coercion(INT64) + coercion(INT) + explicit(DECIMAL) + coercion(DECIMAL_ARBITRARY) + coercion(FLOAT32) + coercion(FLOAT64) + explicit(STRING) + explicit(SYMBOL) + } + graph[INT16] = INT16.relationships { + explicit(BOOL) + unsafe(INT8) + coercion(INT16) + coercion(INT32) + coercion(INT64) + coercion(INT) + explicit(DECIMAL) + coercion(DECIMAL_ARBITRARY) + coercion(FLOAT32) + coercion(FLOAT64) + explicit(STRING) + explicit(SYMBOL) + } + graph[INT32] = INT32.relationships { + explicit(BOOL) + unsafe(INT8) + unsafe(INT16) + coercion(INT32) + coercion(INT64) + coercion(INT) + explicit(DECIMAL) + coercion(DECIMAL_ARBITRARY) + coercion(FLOAT32) + coercion(FLOAT64) + explicit(STRING) + explicit(SYMBOL) + } + graph[INT64] = INT64.relationships { + explicit(BOOL) + unsafe(INT8) + unsafe(INT16) + unsafe(INT32) + coercion(INT64) + coercion(INT) + explicit(DECIMAL) + coercion(DECIMAL_ARBITRARY) + coercion(FLOAT32) + coercion(FLOAT64) + explicit(STRING) + explicit(SYMBOL) + } + graph[INT] = INT.relationships { + explicit(BOOL) + unsafe(INT8) + unsafe(INT16) + unsafe(INT32) + unsafe(INT64) + coercion(INT) + explicit(DECIMAL) + coercion(DECIMAL_ARBITRARY) + coercion(FLOAT32) + coercion(FLOAT64) + explicit(STRING) + explicit(SYMBOL) + } + graph[DECIMAL] = DECIMAL.relationships { + explicit(BOOL) + unsafe(INT8) + unsafe(INT16) + unsafe(INT32) + unsafe(INT64) + unsafe(INT) + coercion(DECIMAL) + coercion(DECIMAL_ARBITRARY) + explicit(FLOAT32) + explicit(FLOAT64) + explicit(STRING) + explicit(SYMBOL) + } + graph[DECIMAL_ARBITRARY] = DECIMAL_ARBITRARY.relationships { + explicit(BOOL) + unsafe(INT8) + unsafe(INT16) + unsafe(INT32) + unsafe(INT64) + unsafe(INT) + coercion(DECIMAL) + coercion(DECIMAL_ARBITRARY) + explicit(FLOAT32) + explicit(FLOAT64) + explicit(STRING) + explicit(SYMBOL) + } + graph[FLOAT32] = FLOAT32.relationships { + explicit(BOOL) + unsafe(INT8) + unsafe(INT16) + unsafe(INT32) + unsafe(INT64) + unsafe(INT) + unsafe(DECIMAL) + coercion(DECIMAL_ARBITRARY) + coercion(FLOAT32) + coercion(FLOAT64) + explicit(STRING) + explicit(SYMBOL) + } + graph[FLOAT64] = FLOAT64.relationships { + explicit(BOOL) + unsafe(INT8) + unsafe(INT16) + unsafe(INT32) + unsafe(INT64) + unsafe(INT) + unsafe(DECIMAL) + coercion(DECIMAL_ARBITRARY) + unsafe(FLOAT32) + coercion(FLOAT64) + explicit(STRING) + explicit(SYMBOL) + } + graph[CHAR] = CHAR.relationships { + explicit(BOOL) + coercion(CHAR) + coercion(STRING) + coercion(SYMBOL) + } + graph[STRING] = STRING.relationships { + explicit(BOOL) + unsafe(INT8) + unsafe(INT16) + unsafe(INT32) + unsafe(INT64) + unsafe(INT) + coercion(STRING) + explicit(SYMBOL) + coercion(CLOB) + } + graph[SYMBOL] = SYMBOL.relationships { + explicit(BOOL) + coercion(STRING) + coercion(SYMBOL) + coercion(CLOB) + } + graph[CLOB] = CLOB.relationships { + coercion(CLOB) + } + graph[BINARY] = arrayOfNulls(N) + graph[BYTE] = arrayOfNulls(N) + graph[BLOB] = arrayOfNulls(N) + graph[DATE] = arrayOfNulls(N) + graph[TIME] = arrayOfNulls(N) + graph[TIMESTAMP] = arrayOfNulls(N) + graph[INTERVAL] = arrayOfNulls(N) + graph[BAG] = BAG.relationships { + coercion(BAG) + } + graph[LIST] = LIST.relationships { + coercion(BAG) + coercion(SEXP) + coercion(LIST) + } + graph[SEXP] = SEXP.relationships { + coercion(BAG) + coercion(SEXP) + coercion(LIST) + } + graph[STRUCT] = STRUCT.relationships { + coercion(STRUCT) + } + CastTable(types, graph.requireNoNulls()) + } + } + + private class RelationshipBuilder(val operand: PartiQLValueType) { + + private val relationships = arrayOfNulls(N) + + fun build() = relationships + + fun coercion(target: PartiQLValueType) { + relationships[target] = refCast(operand, target, Cast.Safety.COERCION) + } + + fun explicit(target: PartiQLValueType) { + relationships[target] = refCast(operand, target, Cast.Safety.EXPLICIT) + } + + fun unsafe(target: PartiQLValueType) { + relationships[target] = refCast(operand, target, Cast.Safety.UNSAFE) + } + } +} 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 d41cef4c3d..bef4fd3c33 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,20 +1,22 @@ -@file:OptIn(PartiQLValueExperimental::class) +@file:OptIn( + PartiQLValueExperimental::class, + FnExperimental::class, +) package org.partiql.planner.`internal`.ir -import org.partiql.planner.internal.ir.builder.CatalogBuilder -import org.partiql.planner.internal.ir.builder.CatalogItemFnBuilder -import org.partiql.planner.internal.ir.builder.CatalogItemValueBuilder -import org.partiql.planner.internal.ir.builder.FnResolvedBuilder -import org.partiql.planner.internal.ir.builder.FnUnresolvedBuilder import org.partiql.planner.internal.ir.builder.IdentifierQualifiedBuilder import org.partiql.planner.internal.ir.builder.IdentifierSymbolBuilder import org.partiql.planner.internal.ir.builder.PartiQlPlanBuilder -import org.partiql.planner.internal.ir.builder.RefBuilder +import org.partiql.planner.internal.ir.builder.RefAggBuilder +import org.partiql.planner.internal.ir.builder.RefCastBuilder +import org.partiql.planner.internal.ir.builder.RefFnBuilder +import org.partiql.planner.internal.ir.builder.RefObjBuilder import org.partiql.planner.internal.ir.builder.RelBindingBuilder import org.partiql.planner.internal.ir.builder.RelBuilder import org.partiql.planner.internal.ir.builder.RelOpAggregateBuilder -import org.partiql.planner.internal.ir.builder.RelOpAggregateCallBuilder +import org.partiql.planner.internal.ir.builder.RelOpAggregateCallResolvedBuilder +import org.partiql.planner.internal.ir.builder.RelOpAggregateCallUnresolvedBuilder import org.partiql.planner.internal.ir.builder.RelOpDistinctBuilder import org.partiql.planner.internal.ir.builder.RelOpErrBuilder import org.partiql.planner.internal.ir.builder.RelOpExceptBuilder @@ -41,8 +43,11 @@ import org.partiql.planner.internal.ir.builder.RexBuilder import org.partiql.planner.internal.ir.builder.RexOpCallDynamicBuilder import org.partiql.planner.internal.ir.builder.RexOpCallDynamicCandidateBuilder import org.partiql.planner.internal.ir.builder.RexOpCallStaticBuilder +import org.partiql.planner.internal.ir.builder.RexOpCallUnresolvedBuilder import org.partiql.planner.internal.ir.builder.RexOpCaseBranchBuilder import org.partiql.planner.internal.ir.builder.RexOpCaseBuilder +import org.partiql.planner.internal.ir.builder.RexOpCastResolvedBuilder +import org.partiql.planner.internal.ir.builder.RexOpCastUnresolvedBuilder import org.partiql.planner.internal.ir.builder.RexOpCollectionBuilder import org.partiql.planner.internal.ir.builder.RexOpErrBuilder import org.partiql.planner.internal.ir.builder.RexOpGlobalBuilder @@ -60,9 +65,13 @@ import org.partiql.planner.internal.ir.builder.RexOpVarResolvedBuilder import org.partiql.planner.internal.ir.builder.RexOpVarUnresolvedBuilder import org.partiql.planner.internal.ir.builder.StatementQueryBuilder import org.partiql.planner.internal.ir.visitor.PlanVisitor +import org.partiql.spi.fn.AggSignature +import org.partiql.spi.fn.FnExperimental +import org.partiql.spi.fn.FnSignature import org.partiql.types.StaticType import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental +import org.partiql.value.PartiQLValueType import kotlin.random.Random internal abstract class PlanNode { @@ -75,17 +84,15 @@ internal abstract class PlanNode { } internal data class PartiQLPlan( - @JvmField internal val catalogs: List, @JvmField internal val statement: Statement, ) : PlanNode() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() - kids.addAll(catalogs) kids.add(statement) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitPartiQLPlan(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitPartiQLPlan(this, ctx) internal companion object { @JvmStatic @@ -93,131 +100,92 @@ internal data class PartiQLPlan( } } -internal data class Catalog( - @JvmField internal val name: String, - @JvmField internal val items: List, -) : PlanNode() { - override val children: List by lazy { - val kids = mutableListOf() - kids.addAll(items) - kids.filterNotNull() +internal sealed class Ref : PlanNode() { + public override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + is Obj -> visitor.visitRefObj(this, ctx) + is Fn -> visitor.visitRefFn(this, ctx) } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitCatalog(this, ctx) - - internal sealed class Item : PlanNode() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { - is Value -> visitor.visitCatalogItemValue(this, ctx) - is Fn -> visitor.visitCatalogItemFn(this, ctx) - } - - internal data class Value( - @JvmField internal val path: List, - @JvmField internal val type: StaticType, - ) : Item() { - override val children: List = emptyList() + internal data class Obj( + @JvmField internal val catalog: String, + @JvmField internal val path: List, + @JvmField internal val type: StaticType, + ) : Ref() { + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitCatalogItemValue(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRefObj(this, ctx) - internal companion object { - @JvmStatic - internal fun builder(): CatalogItemValueBuilder = CatalogItemValueBuilder() - } + internal companion object { + @JvmStatic + internal fun builder(): RefObjBuilder = RefObjBuilder() } + } - internal data class Fn( - @JvmField internal val path: List, - @JvmField internal val specific: String, - ) : Item() { - override val children: List = emptyList() + internal data class Fn( + @JvmField internal val catalog: String, + @JvmField internal val path: List, + @JvmField internal val signature: FnSignature, + ) : Ref() { + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitCatalogItemFn(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRefFn(this, ctx) - internal companion object { - @JvmStatic - internal fun builder(): CatalogItemFnBuilder = CatalogItemFnBuilder() - } + internal companion object { + @JvmStatic + internal fun builder(): RefFnBuilder = RefFnBuilder() } } - internal companion object { - @JvmStatic - internal fun builder(): CatalogBuilder = CatalogBuilder() - } -} - -internal data class Ref( - @JvmField internal val catalog: Int, - @JvmField internal val symbol: Int, -) : PlanNode() { - override val children: List = emptyList() - - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRef( - this, ctx - ) - - internal companion object { - @JvmStatic - internal fun builder(): RefBuilder = RefBuilder() - } -} + internal data class Cast( + @JvmField internal val input: PartiQLValueType, + @JvmField internal val target: PartiQLValueType, + @JvmField internal val safety: Safety, + ) : PlanNode() { + public override val children: List = emptyList() -internal sealed class Fn : PlanNode() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { - is Resolved -> visitor.visitFnResolved(this, ctx) - is Unresolved -> visitor.visitFnUnresolved(this, ctx) - } + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRefCast(this, ctx) - internal data class Resolved( - @JvmField internal val ref: Ref, - ) : Fn() { - override val children: List by lazy { - val kids = mutableListOf() - kids.add(ref) - kids.filterNotNull() + internal enum class Safety { + COERCION, EXPLICIT, UNSAFE, } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitFnResolved(this, ctx) - internal companion object { @JvmStatic - internal fun builder(): FnResolvedBuilder = FnResolvedBuilder() + internal fun builder(): RefCastBuilder = RefCastBuilder() } } - internal data class Unresolved( - @JvmField internal val identifier: Identifier, - ) : Fn() { - override val children: List by lazy { - val kids = mutableListOf() - kids.add(identifier) - kids.filterNotNull() - } + internal data class Agg( + @JvmField internal val name: String, + @JvmField internal val signature: AggSignature, + ) : PlanNode() { + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitFnUnresolved(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRefAgg(this, ctx) internal companion object { @JvmStatic - internal fun builder(): FnUnresolvedBuilder = FnUnresolvedBuilder() + internal fun builder(): RefAggBuilder = RefAggBuilder() } } } internal sealed class Statement : PlanNode() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + public 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, ) : Statement() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitStatementQuery(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitStatementQuery(this, ctx) internal companion object { @JvmStatic @@ -227,7 +195,7 @@ internal sealed class Statement : PlanNode() { } internal sealed class Identifier : PlanNode() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + public override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Symbol -> visitor.visitIdentifierSymbol(this, ctx) is Qualified -> visitor.visitIdentifierQualified(this, ctx) } @@ -240,9 +208,10 @@ internal sealed class Identifier : PlanNode() { @JvmField internal val symbol: String, @JvmField internal val caseSensitivity: CaseSensitivity, ) : Identifier() { - override val children: List = emptyList() + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitIdentifierSymbol(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitIdentifierSymbol(this, ctx) internal companion object { @JvmStatic @@ -254,14 +223,15 @@ internal sealed class Identifier : PlanNode() { @JvmField internal val root: Symbol, @JvmField internal val steps: List, ) : Identifier() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.addAll(steps) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitIdentifierQualified(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitIdentifierQualified(this, ctx) internal companion object { @JvmStatic @@ -274,22 +244,23 @@ internal data class Rex( @JvmField internal val type: StaticType, @JvmField internal val op: Op, ) : PlanNode() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(op) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRex( + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRex( this, ctx ) internal sealed class Op : PlanNode() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + public 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) is Path -> visitor.visitRexOpPath(this, ctx) + is Cast -> visitor.visitRexOpCast(this, ctx) is Call -> visitor.visitRexOpCall(this, ctx) is Case -> visitor.visitRexOpCase(this, ctx) is Collection -> visitor.visitRexOpCollection(this, ctx) @@ -304,9 +275,9 @@ internal data class Rex( internal data class Lit( @JvmField internal val `value`: PartiQLValue, ) : Op() { - override val children: List = emptyList() + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpLit(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpLit(this, ctx) internal companion object { @JvmStatic @@ -315,7 +286,7 @@ internal data class Rex( } internal sealed class Var : Op() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + public override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { is Resolved -> visitor.visitRexOpVarResolved(this, ctx) is Unresolved -> visitor.visitRexOpVarUnresolved(this, ctx) } @@ -327,9 +298,9 @@ internal data class Rex( internal data class Resolved( @JvmField internal val ref: Int, ) : Var() { - override val children: List = emptyList() + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpVarResolved(this, ctx) internal companion object { @@ -342,13 +313,13 @@ internal data class Rex( @JvmField internal val identifier: Identifier, @JvmField internal val scope: Scope, ) : Var() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(identifier) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpVarUnresolved(this, ctx) internal companion object { @@ -359,15 +330,16 @@ internal data class Rex( } internal data class Global( - @JvmField internal val ref: Ref, + @JvmField internal val ref: Ref.Obj, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(ref) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpGlobal(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRexOpGlobal(this, ctx) internal companion object { @JvmStatic @@ -376,7 +348,7 @@ internal data class Rex( } internal sealed class Path : Op() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + public 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) @@ -386,14 +358,14 @@ internal data class Rex( @JvmField internal val root: Rex, @JvmField internal val key: Rex, ) : Path() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.add(key) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpPathIndex(this, ctx) internal companion object { @@ -406,14 +378,15 @@ internal data class Rex( @JvmField internal val root: Rex, @JvmField internal val key: Rex, ) : Path() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.add(key) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpPathKey(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRexOpPathKey(this, ctx) internal companion object { @JvmStatic @@ -425,13 +398,13 @@ internal data class Rex( @JvmField internal val root: Rex, @JvmField internal val key: String, ) : Path() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpPathSymbol(this, ctx) internal companion object { @@ -441,24 +414,91 @@ internal data class Rex( } } + internal sealed class Cast : Op() { + public override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + is Unresolved -> visitor.visitRexOpCastUnresolved(this, ctx) + is Resolved -> visitor.visitRexOpCastResolved(this, ctx) + } + + internal data class Unresolved( + @JvmField internal val target: PartiQLValueType, + @JvmField internal val arg: Rex, + ) : Cast() { + public override val children: List by lazy { + val kids = mutableListOf() + kids.add(arg) + kids.filterNotNull() + } + + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRexOpCastUnresolved(this, ctx) + + internal companion object { + @JvmStatic + internal fun builder(): RexOpCastUnresolvedBuilder = RexOpCastUnresolvedBuilder() + } + } + + internal data class Resolved( + @JvmField internal val cast: Ref.Cast, + @JvmField internal val arg: Rex, + ) : Cast() { + public override val children: List by lazy { + val kids = mutableListOf() + kids.add(cast) + kids.add(arg) + kids.filterNotNull() + } + + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRexOpCastResolved(this, ctx) + + internal companion object { + @JvmStatic + internal fun builder(): RexOpCastResolvedBuilder = RexOpCastResolvedBuilder() + } + } + } + internal sealed class Call : Op() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + public override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + is Unresolved -> visitor.visitRexOpCallUnresolved(this, ctx) is Static -> visitor.visitRexOpCallStatic(this, ctx) is Dynamic -> visitor.visitRexOpCallDynamic(this, ctx) } + internal data class Unresolved( + @JvmField internal val identifier: Identifier, + @JvmField internal val args: List, + ) : Call() { + public override val children: List by lazy { + val kids = mutableListOf() + kids.add(identifier) + kids.addAll(args) + kids.filterNotNull() + } + + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRexOpCallUnresolved(this, ctx) + + internal companion object { + @JvmStatic + internal fun builder(): RexOpCallUnresolvedBuilder = RexOpCallUnresolvedBuilder() + } + } + internal data class Static( - @JvmField internal val fn: Fn, + @JvmField internal val fn: Ref.Fn, @JvmField internal val args: List, ) : Call() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(fn) kids.addAll(args) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCallStatic(this, ctx) internal companion object { @@ -470,29 +510,30 @@ internal data class Rex( internal data class Dynamic( @JvmField internal val args: List, @JvmField internal val candidates: List, + @JvmField internal val exhaustive: Boolean, ) : Call() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.addAll(args) kids.addAll(candidates) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCallDynamic(this, ctx) internal data class Candidate( - @JvmField internal val fn: Fn, - @JvmField internal val coercions: List, + @JvmField internal val fn: Ref.Fn, + @JvmField internal val coercions: List, ) : PlanNode() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(fn) kids.addAll(coercions) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCallDynamicCandidate(this, ctx) internal companion object { @@ -512,27 +553,27 @@ internal data class Rex( @JvmField internal val branches: List, @JvmField internal val default: Rex, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.addAll(branches) kids.add(default) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCase(this, ctx) + public 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, ) : PlanNode() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(condition) kids.add(rex) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCaseBranch(this, ctx) internal companion object { @@ -550,13 +591,14 @@ internal data class Rex( internal data class Collection( @JvmField internal val values: List, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.addAll(values) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpCollection(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRexOpCollection(this, ctx) internal companion object { @JvmStatic @@ -567,26 +609,27 @@ internal data class Rex( internal data class Struct( @JvmField internal val fields: List, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.addAll(fields) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpStruct(this, ctx) + public 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, ) : PlanNode() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(k) kids.add(v) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpStructField(this, ctx) internal companion object { @@ -606,7 +649,7 @@ internal data class Rex( @JvmField internal val `value`: Rex, @JvmField internal val rel: Rel, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(key) kids.add(value) @@ -614,7 +657,8 @@ internal data class Rex( kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpPivot(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRexOpPivot(this, ctx) internal companion object { @JvmStatic @@ -626,13 +670,14 @@ internal data class Rex( @JvmField internal val select: Select, @JvmField internal val coercion: Coercion, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(select) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpSubquery(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRexOpSubquery(this, ctx) internal enum class Coercion { SCALAR, ROW, @@ -648,14 +693,15 @@ internal data class Rex( @JvmField internal val `constructor`: Rex, @JvmField internal val rel: Rel, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(constructor) kids.add(rel) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpSelect(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRexOpSelect(this, ctx) internal companion object { @JvmStatic @@ -666,13 +712,14 @@ internal data class Rex( internal data class TupleUnion( @JvmField internal val args: List, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.addAll(args) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpTupleUnion(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRexOpTupleUnion(this, ctx) internal companion object { @JvmStatic @@ -683,9 +730,9 @@ internal data class Rex( internal data class Err( @JvmField internal val message: String, ) : Op() { - override val children: List = emptyList() + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpErr(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRexOpErr(this, ctx) internal companion object { @JvmStatic @@ -704,14 +751,14 @@ internal data class Rel( @JvmField internal val type: Type, @JvmField internal val op: Op, ) : PlanNode() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(type) kids.add(op) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRel( + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRel( this, ctx ) @@ -723,13 +770,13 @@ internal data class Rel( @JvmField internal val schema: List, @JvmField internal val props: Set, ) : PlanNode() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.addAll(schema) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelType(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelType(this, ctx) internal companion object { @JvmStatic @@ -738,7 +785,7 @@ internal data class Rel( } internal sealed class Op : PlanNode() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + public 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) @@ -760,13 +807,13 @@ internal data class Rel( internal data class Scan( @JvmField internal val rex: Rex, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(rex) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpScan(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpScan(this, ctx) internal companion object { @JvmStatic @@ -777,13 +824,14 @@ internal data class Rel( internal data class ScanIndexed( @JvmField internal val rex: Rex, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(rex) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpScanIndexed(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpScanIndexed(this, ctx) internal companion object { @JvmStatic @@ -794,13 +842,14 @@ internal data class Rel( internal data class Unpivot( @JvmField internal val rex: Rex, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(rex) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpUnpivot(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpUnpivot(this, ctx) internal companion object { @JvmStatic @@ -811,13 +860,14 @@ internal data class Rel( internal data class Distinct( @JvmField internal val input: Rel, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpDistinct(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpDistinct(this, ctx) internal companion object { @JvmStatic @@ -829,14 +879,15 @@ internal data class Rel( @JvmField internal val input: Rel, @JvmField internal val predicate: Rex, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.add(predicate) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpFilter(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpFilter(this, ctx) internal companion object { @JvmStatic @@ -848,14 +899,14 @@ internal data class Rel( @JvmField internal val input: Rel, @JvmField internal val specs: List, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.addAll(specs) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpSort(this, ctx) + public 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, @@ -865,13 +916,13 @@ internal data class Rel( @JvmField internal val rex: Rex, @JvmField internal val order: Order, ) : PlanNode() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(rex) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpSortSpec(this, ctx) internal companion object { @@ -890,14 +941,15 @@ internal data class Rel( @JvmField internal val lhs: Rel, @JvmField internal val rhs: Rel, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(lhs) kids.add(rhs) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpUnion(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpUnion(this, ctx) internal companion object { @JvmStatic @@ -909,14 +961,15 @@ internal data class Rel( @JvmField internal val lhs: Rel, @JvmField internal val rhs: Rel, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(lhs) kids.add(rhs) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpIntersect(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpIntersect(this, ctx) internal companion object { @JvmStatic @@ -928,14 +981,15 @@ internal data class Rel( @JvmField internal val lhs: Rel, @JvmField internal val rhs: Rel, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(lhs) kids.add(rhs) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcept(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpExcept(this, ctx) internal companion object { @JvmStatic @@ -947,14 +1001,15 @@ internal data class Rel( @JvmField internal val input: Rel, @JvmField internal val limit: Rex, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.add(limit) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpLimit(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpLimit(this, ctx) internal companion object { @JvmStatic @@ -966,14 +1021,15 @@ internal data class Rel( @JvmField internal val input: Rel, @JvmField internal val offset: Rex, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.add(offset) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpOffset(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpOffset(this, ctx) internal companion object { @JvmStatic @@ -985,14 +1041,15 @@ internal data class Rel( @JvmField internal val input: Rel, @JvmField internal val projections: List, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.addAll(projections) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpProject(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpProject(this, ctx) internal companion object { @JvmStatic @@ -1006,7 +1063,7 @@ internal data class Rel( @JvmField internal val rex: Rex, @JvmField internal val type: Type, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(lhs) kids.add(rhs) @@ -1014,7 +1071,7 @@ internal data class Rel( kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpJoin(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpJoin(this, ctx) internal enum class Type { INNER, LEFT, RIGHT, FULL, @@ -1032,7 +1089,7 @@ internal data class Rel( @JvmField internal val calls: List, @JvmField internal val groups: List, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.addAll(calls) @@ -1040,29 +1097,57 @@ internal data class Rel( kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpAggregate(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpAggregate(this, ctx) internal enum class Strategy { FULL, PARTIAL, } - internal data class Call( - @JvmField internal val agg: Fn, - @JvmField internal val args: List, - ) : PlanNode() { - override val children: List by lazy { - val kids = mutableListOf() - kids.add(agg) - kids.addAll(args) - kids.filterNotNull() + internal sealed class Call : PlanNode() { + public override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + is Unresolved -> visitor.visitRelOpAggregateCallUnresolved(this, ctx) + is Resolved -> visitor.visitRelOpAggregateCallResolved(this, ctx) } - override fun accept(visitor: PlanVisitor, ctx: C): R = - visitor.visitRelOpAggregateCall(this, ctx) + internal data class Unresolved( + @JvmField internal val name: String, + @JvmField internal val args: List, + ) : Call() { + public override val children: List by lazy { + val kids = mutableListOf() + kids.addAll(args) + kids.filterNotNull() + } - internal companion object { - @JvmStatic - internal fun builder(): RelOpAggregateCallBuilder = RelOpAggregateCallBuilder() + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpAggregateCallUnresolved(this, ctx) + + internal companion object { + @JvmStatic + internal fun builder(): RelOpAggregateCallUnresolvedBuilder = + RelOpAggregateCallUnresolvedBuilder() + } + } + + internal data class Resolved( + @JvmField internal val agg: Ref.Agg, + @JvmField internal val args: List, + ) : Call() { + public override val children: List by lazy { + val kids = mutableListOf() + kids.add(agg) + kids.addAll(args) + kids.filterNotNull() + } + + public override fun accept(visitor: PlanVisitor, ctx: C): R = + visitor.visitRelOpAggregateCallResolved(this, ctx) + + internal companion object { + @JvmStatic + internal fun builder(): RelOpAggregateCallResolvedBuilder = RelOpAggregateCallResolvedBuilder() + } } } @@ -1076,27 +1161,28 @@ internal data class Rel( @JvmField internal val input: Rel, @JvmField internal val items: List, ) : Op() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(input) kids.addAll(items) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExclude(this, ctx) + public 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, ) : PlanNode() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(root) kids.addAll(steps) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcludeItem(this, ctx) internal companion object { @@ -1106,7 +1192,7 @@ internal data class Rel( } internal sealed class Step : PlanNode() { - override fun accept(visitor: PlanVisitor, ctx: C): R = when (this) { + public 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) @@ -1116,13 +1202,13 @@ internal data class Rel( internal data class StructField( @JvmField internal val symbol: Identifier.Symbol, ) : Step() { - override val children: List by lazy { + public override val children: List by lazy { val kids = mutableListOf() kids.add(symbol) kids.filterNotNull() } - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcludeStepStructField(this, ctx) internal companion object { @@ -1135,9 +1221,9 @@ internal data class Rel( internal data class CollIndex( @JvmField internal val index: Int, ) : Step() { - override val children: List = emptyList() + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcludeStepCollIndex(this, ctx) internal companion object { @@ -1149,9 +1235,9 @@ internal data class Rel( internal data class StructWildcard( @JvmField internal val ` `: Char = ' ', ) : Step() { - override val children: List = emptyList() + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcludeStepStructWildcard(this, ctx) internal companion object { @@ -1164,9 +1250,9 @@ internal data class Rel( internal data class CollWildcard( @JvmField internal val ` `: Char = ' ', ) : Step() { - override val children: List = emptyList() + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpExcludeStepCollWildcard(this, ctx) internal companion object { @@ -1186,9 +1272,9 @@ internal data class Rel( internal data class Err( @JvmField internal val message: String, ) : Op() { - override val children: List = emptyList() + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpErr(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelOpErr(this, ctx) internal companion object { @JvmStatic @@ -1201,9 +1287,9 @@ internal data class Rel( @JvmField internal val name: String, @JvmField internal val type: StaticType, ) : PlanNode() { - override val children: List = emptyList() + public override val children: List = emptyList() - override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelBinding(this, ctx) + public override fun accept(visitor: PlanVisitor, ctx: C): R = visitor.visitRelBinding(this, ctx) internal companion object { @JvmStatic diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/PlanTransform.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/PlanTransform.kt index 89741aadb2..df17f8ddd7 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/PlanTransform.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/PlanTransform.kt @@ -3,11 +3,10 @@ package org.partiql.planner.internal.transforms import org.partiql.errors.ProblemCallback import org.partiql.plan.PlanNode import org.partiql.plan.partiQLPlan -import org.partiql.planner.internal.ir.Agg -import org.partiql.planner.internal.ir.Catalog -import org.partiql.planner.internal.ir.Fn +import org.partiql.plan.rexOpCast import org.partiql.planner.internal.ir.Identifier import org.partiql.planner.internal.ir.PartiQLPlan +import org.partiql.planner.internal.ir.Ref import org.partiql.planner.internal.ir.Rel import org.partiql.planner.internal.ir.Rex import org.partiql.planner.internal.ir.Statement @@ -22,58 +21,66 @@ import org.partiql.value.PartiQLValueExperimental * * Ideally this class becomes very small as the internal IR will be a thin wrapper over the public API. */ -internal object PlanTransform : PlanBaseVisitor() { - - override fun defaultReturn(node: org.partiql.planner.internal.ir.PlanNode, ctx: ProblemCallback): PlanNode { - error("Not implemented") - } - - override fun visitPartiQLPlan(node: PartiQLPlan, ctx: ProblemCallback): org.partiql.plan.PartiQLPlan { - val catalogs = node.catalogs.map { visitCatalog(it, ctx) } - val statement = visitStatement(node.statement, ctx) - return partiQLPlan(catalogs, statement) - } - - override fun visitCatalog(node: Catalog, ctx: ProblemCallback): org.partiql.plan.Catalog { - val symbols = node.symbols.map { visitCatalogSymbol(it, ctx) } - return org.partiql.plan.Catalog(node.name, symbols) - } - - override fun visitCatalogSymbol(node: Catalog.Symbol, ctx: ProblemCallback): org.partiql.plan.Catalog.Symbol { - return org.partiql.plan.Catalog.Symbol(node.path, node.type) +internal object PlanTransform { + + fun transform(node: PartiQLPlan, onProblem: ProblemCallback): org.partiql.plan.PartiQLPlan { + val symbols = Symbols.empty() + val visitor = Visitor(symbols, onProblem) + val statement = visitor.visitStatement(node.statement, Unit) + return partiQLPlan( + catalogs = symbols.build(), + statement = statement, + ) } - override fun visitCatalogSymbolRef(node: Catalog.Symbol.Ref, ctx: ProblemCallback): org.partiql.plan.Catalog.Symbol.Ref { - return org.partiql.plan.Catalog.Symbol.Ref(node.catalog, node.symbol) - } + private class Visitor( + private val symbols: Symbols, + private val onProblem: ProblemCallback, + ) : PlanBaseVisitor() { + + /** + * Vi + * + * @param node + * @param ctx + * @return + */ + override fun visitPartiQLPlan(node: PartiQLPlan, ctx: Unit): org.partiql.plan.PartiQLPlan { + val statement = visitStatement(node.statement, ctx) + return partiQLPlan(emptyList(), statement) + } - override fun visitFnResolved(node: Fn.Resolved, ctx: ProblemCallback) = org.partiql.plan.fn(node.signature) + override fun defaultReturn(node: org.partiql.planner.internal.ir.PlanNode, ctx: Unit): PlanNode { + error("Not implemented") + } - override fun visitFnUnresolved(node: Fn.Unresolved, ctx: ProblemCallback): org.partiql.plan.Rex.Op { - error("Unresolved function ${node.identifier}") - } + override fun visitRef(node: Ref, ctx: Unit) = super.visitRef(node, ctx) as org.partiql.plan.Ref - override fun visitAgg(node: Agg, ctx: ProblemCallback) = super.visitAgg(node, ctx) as org.partiql.plan.Agg + /** + * Insert into symbol table, returning the public reference. + */ + override fun visitRefObj(node: Ref.Obj, ctx: Unit) = symbols.insert(node) - override fun visitAggResolved(node: Agg.Resolved, ctx: ProblemCallback) = org.partiql.plan.Agg(node.signature) + /** + * Insert into symbol table, returning the public reference. + */ + override fun visitRefFn(node: Ref.Fn, ctx: Unit) = symbols.insert(node) - override fun visitAggUnresolved(node: Agg.Unresolved, ctx: ProblemCallback): org.partiql.plan.Rex.Op { - error("Unresolved aggregation ${node.identifier}") - } + @OptIn(PartiQLValueExperimental::class) + override fun visitRefCast(node: Ref.Cast, ctx: Unit) = org.partiql.plan.refCast(node.input, node.target) - override fun visitStatement(node: Statement, ctx: ProblemCallback) = - super.visitStatement(node, ctx) as org.partiql.plan.Statement + override fun visitStatement(node: Statement, ctx: Unit) = + super.visitStatement(node, ctx) as org.partiql.plan.Statement - override fun visitStatementQuery(node: Statement.Query, ctx: ProblemCallback): org.partiql.plan.Statement.Query { - val root = visitRex(node.root, ctx) - return org.partiql.plan.Statement.Query(root) - } + override fun visitStatementQuery(node: Statement.Query, ctx: Unit): org.partiql.plan.Statement.Query { + val root = visitRex(node.root, ctx) + return org.partiql.plan.Statement.Query(root) + } - override fun visitIdentifier(node: Identifier, ctx: ProblemCallback) = - super.visitIdentifier(node, ctx) as org.partiql.plan.Identifier + override fun visitIdentifier(node: Identifier, ctx: Unit) = + super.visitIdentifier(node, ctx) as org.partiql.plan.Identifier - override fun visitIdentifierSymbol(node: Identifier.Symbol, ctx: ProblemCallback) = - org.partiql.plan.Identifier.Symbol( + override fun visitIdentifierSymbol(node: Identifier.Symbol, ctx: Unit) = org.partiql.plan.Identifier.Symbol( symbol = node.symbol, caseSensitivity = when (node.caseSensitivity) { Identifier.CaseSensitivity.SENSITIVE -> org.partiql.plan.Identifier.CaseSensitivity.SENSITIVE @@ -81,306 +88,314 @@ internal object PlanTransform : PlanBaseVisitor() { } ) - override fun visitIdentifierQualified(node: Identifier.Qualified, ctx: ProblemCallback) = - org.partiql.plan.Identifier.Qualified( - root = visitIdentifierSymbol(node.root, ctx), - steps = node.steps.map { visitIdentifierSymbol(it, ctx) } - ) + override fun visitIdentifierQualified(node: Identifier.Qualified, ctx: Unit) = + org.partiql.plan.Identifier.Qualified( + root = visitIdentifierSymbol(node.root, ctx), + steps = node.steps.map { visitIdentifierSymbol(it, ctx) } + ) - // EXPRESSIONS + // EXPRESSIONS - override fun visitRex(node: Rex, ctx: ProblemCallback): org.partiql.plan.Rex { - val type = node.type - val op = visitRexOp(node.op, ctx) - return org.partiql.plan.Rex(type, op) - } + override fun visitRex(node: Rex, ctx: Unit): org.partiql.plan.Rex { + val type = node.type + val op = visitRexOp(node.op, ctx) + return org.partiql.plan.Rex(type, op) + } - override fun visitRexOp(node: Rex.Op, ctx: ProblemCallback) = super.visitRexOp(node, ctx) as org.partiql.plan.Rex.Op + override fun visitRexOp(node: Rex.Op, ctx: Unit) = super.visitRexOp(node, ctx) as org.partiql.plan.Rex.Op - @OptIn(PartiQLValueExperimental::class) - override fun visitRexOpLit(node: Rex.Op.Lit, ctx: ProblemCallback) = org.partiql.plan.rexOpLit(node.value) + @OptIn(PartiQLValueExperimental::class) + override fun visitRexOpLit(node: Rex.Op.Lit, ctx: Unit) = org.partiql.plan.rexOpLit(node.value) - override fun visitRexOpVar(node: Rex.Op.Var, ctx: ProblemCallback) = - super.visitRexOpVar(node, ctx) as org.partiql.plan.Rex.Op + override fun visitRexOpVar(node: Rex.Op.Var, ctx: Unit) = + super.visitRexOpVar(node, ctx) as org.partiql.plan.Rex.Op - override fun visitRexOpVarResolved(node: Rex.Op.Var.Resolved, ctx: ProblemCallback) = - org.partiql.plan.Rex.Op.Var(node.ref) + override fun visitRexOpVarResolved(node: Rex.Op.Var.Resolved, ctx: Unit) = org.partiql.plan.Rex.Op.Var(node.ref) - override fun visitRexOpVarUnresolved(node: Rex.Op.Var.Unresolved, ctx: ProblemCallback) = - org.partiql.plan.Rex.Op.Err("Unresolved variable $node") + override fun visitRexOpVarUnresolved(node: Rex.Op.Var.Unresolved, ctx: Unit) = + org.partiql.plan.Rex.Op.Err("Unresolved variable $node") - override fun visitRexOpGlobal(node: Rex.Op.Global, ctx: ProblemCallback) = org.partiql.plan.Rex.Op.Global( - ref = visitCatalogSymbolRef(node.ref, ctx) - ) + override fun visitRexOpGlobal(node: Rex.Op.Global, ctx: Unit) = org.partiql.plan.Rex.Op.Global( + ref = visitRef(node.ref, ctx) + ) - override fun visitRexOpPathIndex(node: Rex.Op.Path.Index, ctx: ProblemCallback): PlanNode { - val root = visitRex(node.root, ctx) - val key = visitRex(node.key, ctx) - return org.partiql.plan.Rex.Op.Path.Index(root, key) - } + override fun visitRexOpPathIndex(node: Rex.Op.Path.Index, ctx: Unit): PlanNode { + val root = visitRex(node.root, ctx) + val key = visitRex(node.key, ctx) + return org.partiql.plan.Rex.Op.Path.Index(root, key) + } - override fun visitRexOpPathKey(node: Rex.Op.Path.Key, ctx: ProblemCallback): PlanNode { - val root = visitRex(node.root, ctx) - val key = visitRex(node.key, ctx) - return org.partiql.plan.Rex.Op.Path.Key(root, key) - } + override fun visitRexOpPathKey(node: Rex.Op.Path.Key, ctx: Unit): PlanNode { + val root = visitRex(node.root, ctx) + val key = visitRex(node.key, ctx) + return org.partiql.plan.Rex.Op.Path.Key(root, key) + } - override fun visitRexOpPathSymbol(node: Rex.Op.Path.Symbol, ctx: ProblemCallback): PlanNode { - val root = visitRex(node.root, ctx) - return org.partiql.plan.Rex.Op.Path.Symbol(root, node.key) - } + override fun visitRexOpPathSymbol(node: Rex.Op.Path.Symbol, ctx: Unit): PlanNode { + val root = visitRex(node.root, ctx) + return org.partiql.plan.Rex.Op.Path.Symbol(root, node.key) + } - override fun visitRexOpCall(node: Rex.Op.Call, ctx: ProblemCallback) = - super.visitRexOpCall(node, ctx) as org.partiql.plan.Rex.Op + override fun visitRexOpCall(node: Rex.Op.Call, ctx: Unit) = + super.visitRexOpCall(node, ctx) as org.partiql.plan.Rex.Op - override fun visitRexOpCallStatic(node: Rex.Op.Call.Static, ctx: ProblemCallback): org.partiql.plan.Rex.Op { - val fn = visitFn(node.fn, ctx) - val args = node.args.map { visitRex(it, ctx) } - return when (fn) { - is org.partiql.plan.Fn -> { - org.partiql.plan.Rex.Op.Call.Static(fn, args) - } - is org.partiql.plan.Rex.Op -> { - // had error - fn - } - else -> { - error("Expected Fn or Err, found $fn") - } + override fun visitRexOpPath(node: Rex.Op.Path, ctx: Unit) = + super.visitRexOpPath(node, ctx) as org.partiql.plan.Rex.Op.Path + + override fun visitRexOpCast(node: Rex.Op.Cast, ctx: Unit) = + super.visitRexOpCast(node, ctx) as org.partiql.plan.Rex.Op.Cast + + override fun visitRexOpCastUnresolved(node: Rex.Op.Cast.Unresolved, ctx: Unit): PlanNode { + error("Unresolved cast $node") } - } - override fun visitRexOpCallDynamic(node: Rex.Op.Call.Dynamic, ctx: ProblemCallback): PlanNode { - val candidates = node.candidates.map { - val c = visitRexOpCallDynamicCandidate(it, ctx) - if (c is org.partiql.plan.Rex.Op.Err) return c - c as org.partiql.plan.Rex.Op.Call.Dynamic.Candidate + override fun visitRexOpCastResolved(node: Rex.Op.Cast.Resolved, ctx: Unit): PlanNode { + val cast = visitRefCast(node.cast, ctx) + val arg = visitRex(node.arg, ctx) + return rexOpCast(cast, arg) + } + + override fun visitRexOpCallUnresolved(node: Rex.Op.Call.Unresolved, ctx: Unit): PlanNode { + error("Unresolved function ${node.identifier}") } - return org.partiql.plan.Rex.Op.Call.Dynamic( - candidates = candidates, - args = node.args.map { visitRex(it, ctx) } - ) - } - override fun visitRexOpCallDynamicCandidate(node: Rex.Op.Call.Dynamic.Candidate, ctx: ProblemCallback): PlanNode { - val fn = visitFn(node.fn, ctx) - if (fn is org.partiql.plan.Rex.Op.Err) return fn - fn as org.partiql.plan.Fn - val coercions = node.coercions.map { - it?.let { - val c = visitFn(it, ctx) + override fun visitRexOpCallStatic(node: Rex.Op.Call.Static, ctx: Unit): org.partiql.plan.Rex.Op { + val fn = visitRef(node.fn, ctx) + val args = node.args.map { visitRex(it, ctx) } + return org.partiql.plan.rexOpCallStatic(fn, args) + } + + override fun visitRexOpCallDynamic(node: Rex.Op.Call.Dynamic, ctx: Unit): PlanNode { + val candidates = node.candidates.map { + val c = visitRexOpCallDynamicCandidate(it, ctx) if (c is org.partiql.plan.Rex.Op.Err) return c - c as org.partiql.plan.Fn + c as org.partiql.plan.Rex.Op.Call.Dynamic.Candidate } + return org.partiql.plan.Rex.Op.Call.Dynamic( + candidates = candidates, + args = node.args.map { visitRex(it, ctx) } + ) } - return org.partiql.plan.Rex.Op.Call.Dynamic.Candidate(fn, coercions) - } - override fun visitRexOpCase(node: Rex.Op.Case, ctx: ProblemCallback) = org.partiql.plan.Rex.Op.Case( - branches = node.branches.map { visitRexOpCaseBranch(it, ctx) }, default = visitRex(node.default, ctx) - ) + override fun visitRexOpCallDynamicCandidate(node: Rex.Op.Call.Dynamic.Candidate, ctx: Unit): PlanNode { + val fn = visitRef(node.fn, ctx) + val coercions = node.coercions.map { it?.let { visitRefCast(it, ctx) } } + return org.partiql.plan.Rex.Op.Call.Dynamic.Candidate(fn, coercions) + } - override fun visitRexOpCaseBranch(node: Rex.Op.Case.Branch, ctx: ProblemCallback) = - org.partiql.plan.Rex.Op.Case.Branch( + override fun visitRexOpCase(node: Rex.Op.Case, ctx: Unit) = org.partiql.plan.Rex.Op.Case( + branches = node.branches.map { visitRexOpCaseBranch(it, ctx) }, default = visitRex(node.default, ctx) + ) + + override fun visitRexOpCaseBranch(node: Rex.Op.Case.Branch, ctx: Unit) = org.partiql.plan.Rex.Op.Case.Branch( condition = visitRex(node.condition, ctx), rex = visitRex(node.rex, ctx) ) - override fun visitRexOpCollection(node: Rex.Op.Collection, ctx: ProblemCallback) = - org.partiql.plan.Rex.Op.Collection(values = node.values.map { visitRex(it, ctx) }) + override fun visitRexOpCollection(node: Rex.Op.Collection, ctx: Unit) = + org.partiql.plan.Rex.Op.Collection(values = node.values.map { visitRex(it, ctx) }) - override fun visitRexOpStruct(node: Rex.Op.Struct, ctx: ProblemCallback) = - org.partiql.plan.Rex.Op.Struct(fields = node.fields.map { visitRexOpStructField(it, ctx) }) + override fun visitRexOpStruct(node: Rex.Op.Struct, ctx: Unit) = + org.partiql.plan.Rex.Op.Struct(fields = node.fields.map { visitRexOpStructField(it, ctx) }) - override fun visitRexOpStructField(node: Rex.Op.Struct.Field, ctx: ProblemCallback) = - org.partiql.plan.Rex.Op.Struct.Field( + override fun visitRexOpStructField(node: Rex.Op.Struct.Field, ctx: Unit) = org.partiql.plan.Rex.Op.Struct.Field( k = visitRex(node.k, ctx), v = visitRex(node.v, ctx), ) - override fun visitRexOpPivot(node: Rex.Op.Pivot, ctx: ProblemCallback) = org.partiql.plan.Rex.Op.Pivot( - key = visitRex(node.key, ctx), - value = visitRex(node.value, ctx), - rel = visitRel(node.rel, ctx), - ) - - override fun visitRexOpSubquery(node: Rex.Op.Subquery, ctx: ProblemCallback) = org.partiql.plan.Rex.Op.Subquery( - select = visitRexOpSelect(node.select, ctx), - coercion = when (node.coercion) { - Rex.Op.Subquery.Coercion.SCALAR -> org.partiql.plan.Rex.Op.Subquery.Coercion.SCALAR - Rex.Op.Subquery.Coercion.ROW -> org.partiql.plan.Rex.Op.Subquery.Coercion.ROW - } - ) - - override fun visitRexOpSelect(node: Rex.Op.Select, ctx: ProblemCallback) = org.partiql.plan.Rex.Op.Select( - constructor = visitRex(node.constructor, ctx), - rel = visitRel(node.rel, ctx), - ) + override fun visitRexOpPivot(node: Rex.Op.Pivot, ctx: Unit) = org.partiql.plan.Rex.Op.Pivot( + key = visitRex(node.key, ctx), + value = visitRex(node.value, ctx), + rel = visitRel(node.rel, ctx), + ) - override fun visitRexOpTupleUnion(node: Rex.Op.TupleUnion, ctx: ProblemCallback) = - org.partiql.plan.Rex.Op.TupleUnion(args = node.args.map { visitRex(it, ctx) }) + override fun visitRexOpSubquery(node: Rex.Op.Subquery, ctx: Unit) = org.partiql.plan.Rex.Op.Subquery( + select = visitRexOpSelect(node.select, ctx), + coercion = when (node.coercion) { + Rex.Op.Subquery.Coercion.SCALAR -> org.partiql.plan.Rex.Op.Subquery.Coercion.SCALAR + Rex.Op.Subquery.Coercion.ROW -> org.partiql.plan.Rex.Op.Subquery.Coercion.ROW + } + ) - override fun visitRexOpErr(node: Rex.Op.Err, ctx: ProblemCallback) = org.partiql.plan.Rex.Op.Err(node.message) + override fun visitRexOpSelect(node: Rex.Op.Select, ctx: Unit) = org.partiql.plan.Rex.Op.Select( + constructor = visitRex(node.constructor, ctx), + rel = visitRel(node.rel, ctx), + ) - // RELATION OPERATORS + override fun visitRexOpTupleUnion(node: Rex.Op.TupleUnion, ctx: Unit) = + org.partiql.plan.Rex.Op.TupleUnion(args = node.args.map { visitRex(it, ctx) }) - override fun visitRel(node: Rel, ctx: ProblemCallback) = org.partiql.plan.Rel( - type = visitRelType(node.type, ctx), - op = visitRelOp(node.op, ctx), - ) + override fun visitRexOpErr(node: Rex.Op.Err, ctx: Unit) = org.partiql.plan.Rex.Op.Err(node.message) - override fun visitRelType(node: Rel.Type, ctx: ProblemCallback) = - org.partiql.plan.Rel.Type( - schema = node.schema.map { visitRelBinding(it, ctx) }, - props = node.props.map { - when (it) { - Rel.Prop.ORDERED -> org.partiql.plan.Rel.Prop.ORDERED - } - }.toSet() + // RELATION OPERATORS + override fun visitRel(node: Rel, ctx: Unit) = org.partiql.plan.Rel( + type = visitRelType(node.type, ctx), + op = visitRelOp(node.op, ctx), ) - override fun visitRelOp(node: Rel.Op, ctx: ProblemCallback) = super.visitRelOp(node, ctx) as org.partiql.plan.Rel.Op + override fun visitRelType(node: Rel.Type, ctx: Unit) = + org.partiql.plan.Rel.Type( + schema = node.schema.map { visitRelBinding(it, ctx) }, + props = node.props.map { + when (it) { + Rel.Prop.ORDERED -> org.partiql.plan.Rel.Prop.ORDERED + } + }.toSet() - override fun visitRelOpScan(node: Rel.Op.Scan, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Scan( - rex = visitRex(node.rex, ctx), - ) + ) + + override fun visitRelOp(node: Rel.Op, ctx: Unit) = super.visitRelOp(node, ctx) as org.partiql.plan.Rel.Op - override fun visitRelOpScanIndexed(node: Rel.Op.ScanIndexed, ctx: ProblemCallback) = - org.partiql.plan.Rel.Op.ScanIndexed( + override fun visitRelOpScan(node: Rel.Op.Scan, ctx: Unit) = org.partiql.plan.Rel.Op.Scan( rex = visitRex(node.rex, ctx), ) - override fun visitRelOpUnpivot(node: Rel.Op.Unpivot, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Unpivot( - rex = visitRex(node.rex, ctx), - ) + override fun visitRelOpScanIndexed(node: Rel.Op.ScanIndexed, ctx: Unit) = org.partiql.plan.Rel.Op.ScanIndexed( + rex = visitRex(node.rex, ctx), + ) - override fun visitRelOpDistinct(node: Rel.Op.Distinct, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Distinct( - input = visitRel(node.input, ctx), - ) + override fun visitRelOpUnpivot(node: Rel.Op.Unpivot, ctx: Unit) = org.partiql.plan.Rel.Op.Unpivot( + rex = visitRex(node.rex, ctx), + ) - override fun visitRelOpFilter(node: Rel.Op.Filter, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Filter( - input = visitRel(node.input, ctx), - predicate = visitRex(node.predicate, ctx), - ) + override fun visitRelOpDistinct(node: Rel.Op.Distinct, ctx: Unit) = org.partiql.plan.Rel.Op.Distinct( + input = visitRel(node.input, ctx), + ) - override fun visitRelOpSort(node: Rel.Op.Sort, ctx: ProblemCallback) = - org.partiql.plan.Rel.Op.Sort( + override fun visitRelOpFilter(node: Rel.Op.Filter, ctx: Unit) = org.partiql.plan.Rel.Op.Filter( input = visitRel(node.input, ctx), - specs = node.specs.map { visitRelOpSortSpec(it, ctx) } + predicate = visitRex(node.predicate, ctx), ) - override fun visitRelOpSortSpec(node: Rel.Op.Sort.Spec, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Sort.Spec( - rex = visitRex(node.rex, ctx), - order = when (node.order) { - Rel.Op.Sort.Order.ASC_NULLS_LAST -> org.partiql.plan.Rel.Op.Sort.Order.ASC_NULLS_LAST - Rel.Op.Sort.Order.ASC_NULLS_FIRST -> org.partiql.plan.Rel.Op.Sort.Order.ASC_NULLS_FIRST - Rel.Op.Sort.Order.DESC_NULLS_LAST -> org.partiql.plan.Rel.Op.Sort.Order.DESC_NULLS_LAST - Rel.Op.Sort.Order.DESC_NULLS_FIRST -> org.partiql.plan.Rel.Op.Sort.Order.DESC_NULLS_FIRST - } - ) + override fun visitRelOpSort(node: Rel.Op.Sort, ctx: Unit) = + org.partiql.plan.Rel.Op.Sort( + input = visitRel(node.input, ctx), + specs = node.specs.map { visitRelOpSortSpec(it, ctx) } + ) - override fun visitRelOpUnion(node: Rel.Op.Union, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Union( - lhs = visitRel(node.lhs, ctx), - rhs = visitRel(node.rhs, ctx), - ) + override fun visitRelOpSortSpec(node: Rel.Op.Sort.Spec, ctx: Unit) = org.partiql.plan.Rel.Op.Sort.Spec( + rex = visitRex(node.rex, ctx), + order = when (node.order) { + Rel.Op.Sort.Order.ASC_NULLS_LAST -> org.partiql.plan.Rel.Op.Sort.Order.ASC_NULLS_LAST + Rel.Op.Sort.Order.ASC_NULLS_FIRST -> org.partiql.plan.Rel.Op.Sort.Order.ASC_NULLS_FIRST + Rel.Op.Sort.Order.DESC_NULLS_LAST -> org.partiql.plan.Rel.Op.Sort.Order.DESC_NULLS_LAST + Rel.Op.Sort.Order.DESC_NULLS_FIRST -> org.partiql.plan.Rel.Op.Sort.Order.DESC_NULLS_FIRST + } + ) - override fun visitRelOpIntersect(node: Rel.Op.Intersect, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Intersect( - lhs = visitRel(node.lhs, ctx), - rhs = visitRel(node.rhs, ctx), - ) + override fun visitRelOpUnion(node: Rel.Op.Union, ctx: Unit) = org.partiql.plan.Rel.Op.Union( + lhs = visitRel(node.lhs, ctx), + rhs = visitRel(node.rhs, ctx), + ) - override fun visitRelOpExcept(node: Rel.Op.Except, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Except( - lhs = visitRel(node.lhs, ctx), - rhs = visitRel(node.rhs, ctx), - ) + override fun visitRelOpIntersect(node: Rel.Op.Intersect, ctx: Unit) = org.partiql.plan.Rel.Op.Intersect( + lhs = visitRel(node.lhs, ctx), + rhs = visitRel(node.rhs, ctx), + ) - override fun visitRelOpLimit(node: Rel.Op.Limit, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Limit( - input = visitRel(node.input, ctx), - limit = visitRex(node.limit, ctx), - ) + override fun visitRelOpExcept(node: Rel.Op.Except, ctx: Unit) = org.partiql.plan.Rel.Op.Except( + lhs = visitRel(node.lhs, ctx), + rhs = visitRel(node.rhs, ctx), + ) - override fun visitRelOpOffset(node: Rel.Op.Offset, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Offset( - input = visitRel(node.input, ctx), - offset = visitRex(node.offset, ctx), - ) + override fun visitRelOpLimit(node: Rel.Op.Limit, ctx: Unit) = org.partiql.plan.Rel.Op.Limit( + input = visitRel(node.input, ctx), + limit = visitRex(node.limit, ctx), + ) - override fun visitRelOpProject(node: Rel.Op.Project, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Project( - input = visitRel(node.input, ctx), - projections = node.projections.map { visitRex(it, ctx) }, - ) + override fun visitRelOpOffset(node: Rel.Op.Offset, ctx: Unit) = org.partiql.plan.Rel.Op.Offset( + input = visitRel(node.input, ctx), + offset = visitRex(node.offset, ctx), + ) - override fun visitRelOpJoin(node: Rel.Op.Join, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Join( - lhs = visitRel(node.lhs, ctx), - rhs = visitRel(node.rhs, ctx), - rex = visitRex(node.rex, ctx), - type = when (node.type) { - Rel.Op.Join.Type.INNER -> org.partiql.plan.Rel.Op.Join.Type.INNER - Rel.Op.Join.Type.LEFT -> org.partiql.plan.Rel.Op.Join.Type.LEFT - Rel.Op.Join.Type.RIGHT -> org.partiql.plan.Rel.Op.Join.Type.RIGHT - Rel.Op.Join.Type.FULL -> org.partiql.plan.Rel.Op.Join.Type.FULL - } - ) + override fun visitRelOpProject(node: Rel.Op.Project, ctx: Unit) = org.partiql.plan.Rel.Op.Project( + input = visitRel(node.input, ctx), + projections = node.projections.map { visitRex(it, ctx) }, + ) - override fun visitRelOpAggregate(node: Rel.Op.Aggregate, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Aggregate( - input = visitRel(node.input, ctx), - strategy = when (node.strategy) { - Rel.Op.Aggregate.Strategy.FULL -> org.partiql.plan.Rel.Op.Aggregate.Strategy.FULL - Rel.Op.Aggregate.Strategy.PARTIAL -> org.partiql.plan.Rel.Op.Aggregate.Strategy.PARTIAL - }, - calls = node.calls.map { visitRelOpAggregateCall(it, ctx) }, - groups = node.groups.map { visitRex(it, ctx) }, - ) + override fun visitRelOpJoin(node: Rel.Op.Join, ctx: Unit) = org.partiql.plan.Rel.Op.Join( + lhs = visitRel(node.lhs, ctx), + rhs = visitRel(node.rhs, ctx), + rex = visitRex(node.rex, ctx), + type = when (node.type) { + Rel.Op.Join.Type.INNER -> org.partiql.plan.Rel.Op.Join.Type.INNER + Rel.Op.Join.Type.LEFT -> org.partiql.plan.Rel.Op.Join.Type.LEFT + Rel.Op.Join.Type.RIGHT -> org.partiql.plan.Rel.Op.Join.Type.RIGHT + Rel.Op.Join.Type.FULL -> org.partiql.plan.Rel.Op.Join.Type.FULL + } + ) - override fun visitRelOpAggregateCall(node: Rel.Op.Aggregate.Call, ctx: ProblemCallback) = - org.partiql.plan.Rel.Op.Aggregate.Call( - agg = visitAgg(node.agg, ctx), - args = node.args.map { visitRex(it, ctx) }, + override fun visitRelOpAggregate(node: Rel.Op.Aggregate, ctx: Unit) = org.partiql.plan.Rel.Op.Aggregate( + input = visitRel(node.input, ctx), + strategy = when (node.strategy) { + Rel.Op.Aggregate.Strategy.FULL -> org.partiql.plan.Rel.Op.Aggregate.Strategy.FULL + Rel.Op.Aggregate.Strategy.PARTIAL -> org.partiql.plan.Rel.Op.Aggregate.Strategy.PARTIAL + }, + calls = node.calls.map { visitRelOpAggregateCall(it, ctx) }, + groups = node.groups.map { visitRex(it, ctx) }, ) - override fun visitRelOpExclude(node: Rel.Op.Exclude, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Exclude( - input = visitRel(node.input, ctx), - items = node.items.map { visitRelOpExcludeItem(it, ctx) }, - ) + override fun visitRelOpAggregateCall(node: Rel.Op.Aggregate.Call, ctx: Unit) = + super.visitRelOpAggregateCall(node, ctx) as org.partiql.plan.Rel.Op.Aggregate.Call - override fun visitRelOpExcludeItem(node: Rel.Op.Exclude.Item, ctx: ProblemCallback): org.partiql.plan.Rel.Op.Exclude.Item { - val root = when (node.root) { - is Rex.Op.Var.Resolved -> visitRexOpVar(node.root, ctx) as org.partiql.plan.Rex.Op.Var - is Rex.Op.Var.Unresolved -> org.partiql.plan.Rex.Op.Var(-1) // unresolved in `PlanTyper` results in error + override fun visitRelOpAggregateCallUnresolved(node: Rel.Op.Aggregate.Call.Unresolved, ctx: Unit): PlanNode { + error("Unresolved aggregate call $node") } - return org.partiql.plan.Rel.Op.Exclude.Item( - root = root, - steps = node.steps.map { visitRelOpExcludeStep(it, ctx) }, - ) - } - override fun visitRelOpExcludeStep(node: Rel.Op.Exclude.Step, ctx: ProblemCallback) = - super.visit(node, ctx) as org.partiql.plan.Rel.Op.Exclude.Step + override fun visitRelOpAggregateCallResolved(node: Rel.Op.Aggregate.Call.Resolved, ctx: Unit): PlanNode { + val agg = node.agg.name + val args = node.args.map { visitRex(it, ctx) } + return org.partiql.plan.relOpAggregateCall(node.agg.name, args) + } - override fun visitRelOpExcludeStepStructField(node: Rel.Op.Exclude.Step.StructField, ctx: ProblemCallback) = - org.partiql.plan.Rel.Op.Exclude.Step.StructField( - symbol = visitIdentifierSymbol(node.symbol, ctx), + override fun visitRelOpExclude(node: Rel.Op.Exclude, ctx: Unit) = org.partiql.plan.Rel.Op.Exclude( + input = visitRel(node.input, ctx), + items = node.items.map { visitRelOpExcludeItem(it, ctx) }, ) - override fun visitRelOpExcludeStepCollIndex(node: Rel.Op.Exclude.Step.CollIndex, ctx: ProblemCallback) = - org.partiql.plan.Rel.Op.Exclude.Step.CollIndex( - index = node.index, - ) + override fun visitRelOpExcludeItem( + node: Rel.Op.Exclude.Item, + ctx: Unit, + ): org.partiql.plan.Rel.Op.Exclude.Item { + val root = when (node.root) { + is Rex.Op.Var.Resolved -> visitRexOpVar(node.root, ctx) as org.partiql.plan.Rex.Op.Var + is Rex.Op.Var.Unresolved -> org.partiql.plan.Rex.Op.Var(-1) // unresolved in `PlanTyper` results in error + } + return org.partiql.plan.Rel.Op.Exclude.Item( + root = root, + steps = node.steps.map { visitRelOpExcludeStep(it, ctx) }, + ) + } - override fun visitRelOpExcludeStepStructWildcard( - node: Rel.Op.Exclude.Step.StructWildcard, - ctx: ProblemCallback, - ) = org.partiql.plan.Rel.Op.Exclude.Step.StructWildcard() + override fun visitRelOpExcludeStep(node: Rel.Op.Exclude.Step, ctx: Unit) = + super.visit(node, ctx) as org.partiql.plan.Rel.Op.Exclude.Step - override fun visitRelOpExcludeStepCollWildcard( - node: Rel.Op.Exclude.Step.CollWildcard, - ctx: ProblemCallback, - ) = org.partiql.plan.Rel.Op.Exclude.Step.CollWildcard() + override fun visitRelOpExcludeStepStructField(node: Rel.Op.Exclude.Step.StructField, ctx: Unit) = + org.partiql.plan.Rel.Op.Exclude.Step.StructField( + symbol = visitIdentifierSymbol(node.symbol, ctx), + ) - override fun visitRelOpErr(node: Rel.Op.Err, ctx: ProblemCallback) = org.partiql.plan.Rel.Op.Err(node.message) + override fun visitRelOpExcludeStepCollIndex(node: Rel.Op.Exclude.Step.CollIndex, ctx: Unit) = + org.partiql.plan.Rel.Op.Exclude.Step.CollIndex( + index = node.index, + ) - override fun visitRelBinding(node: Rel.Binding, ctx: ProblemCallback) = org.partiql.plan.Rel.Binding( - name = node.name, - type = node.type, - ) + override fun visitRelOpExcludeStepStructWildcard( + node: Rel.Op.Exclude.Step.StructWildcard, + ctx: Unit, + ) = org.partiql.plan.Rel.Op.Exclude.Step.StructWildcard() + + override fun visitRelOpExcludeStepCollWildcard( + node: Rel.Op.Exclude.Step.CollWildcard, + ctx: Unit, + ) = org.partiql.plan.Rel.Op.Exclude.Step.CollWildcard() + + override fun visitRelOpErr(node: Rel.Op.Err, ctx: Unit) = org.partiql.plan.Rel.Op.Err(node.message) + + override fun visitRelBinding(node: Rel.Binding, ctx: Unit) = org.partiql.plan.Rel.Binding( + name = node.name, + type = node.type, + ) + } } \ No newline at end of file diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt index 73cba006fc..bb25e4427d 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt @@ -31,13 +31,13 @@ import org.partiql.ast.helpers.toBinder import org.partiql.ast.util.AstRewriter import org.partiql.ast.visitor.AstBaseVisitor import org.partiql.planner.internal.Env +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.aggUnresolved import org.partiql.planner.internal.ir.rel import org.partiql.planner.internal.ir.relBinding import org.partiql.planner.internal.ir.relOpAggregate -import org.partiql.planner.internal.ir.relOpAggregateCall +import org.partiql.planner.internal.ir.relOpAggregateCallUnresolved import org.partiql.planner.internal.ir.relOpDistinct import org.partiql.planner.internal.ir.relOpErr import org.partiql.planner.internal.ir.relOpExcept @@ -362,8 +362,11 @@ internal object RelConverter { schema.add(binding) val args = expr.args.map { arg -> arg.toRex(env) } val id = AstToPlan.convert(expr.function) - val fn = aggUnresolved(id) - relOpAggregateCall(fn, args) + val name = when (id) { + is Identifier.Qualified -> error("Qualified aggregation calls are not supported.") + is Identifier.Symbol -> id.symbol.lowercase() + } + relOpAggregateCallUnresolved(name, args) } var groups = emptyList() if (groupBy != null) { diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt index 498dea8a2c..94e60d37ae 100644 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RexConverter.kt @@ -25,11 +25,11 @@ import org.partiql.planner.internal.Env import org.partiql.planner.internal.ir.Identifier import org.partiql.planner.internal.ir.Rex import org.partiql.planner.internal.ir.builder.plan -import org.partiql.planner.internal.ir.fnUnresolved import org.partiql.planner.internal.ir.identifierQualified import org.partiql.planner.internal.ir.identifierSymbol import org.partiql.planner.internal.ir.rex -import org.partiql.planner.internal.ir.rexOpCallStatic +import org.partiql.planner.internal.ir.rexOpCallUnresolved +import org.partiql.planner.internal.ir.rexOpCastUnresolved import org.partiql.planner.internal.ir.rexOpCollection import org.partiql.planner.internal.ir.rexOpLit import org.partiql.planner.internal.ir.rexOpPathIndex @@ -43,10 +43,9 @@ import org.partiql.planner.internal.ir.rexOpVarUnresolved import org.partiql.planner.internal.typer.toNonNullStaticType import org.partiql.planner.internal.typer.toStaticType import org.partiql.types.StaticType -import org.partiql.types.TimeType import org.partiql.value.PartiQLValueExperimental +import org.partiql.value.PartiQLValueType import org.partiql.value.StringValue -import org.partiql.value.boolValue import org.partiql.value.int32Value import org.partiql.value.int64Value import org.partiql.value.io.PartiQLValueIonReaderBuilder @@ -104,10 +103,14 @@ internal object RexConverter { * @param ctx * @return */ - private fun visitExprCoerce(node: Expr, ctx: Env, coercion: Rex.Op.Subquery.Coercion = Rex.Op.Subquery.Coercion.SCALAR): Rex { + private fun visitExprCoerce( + node: Expr, + ctx: Env, + coercion: Rex.Op.Subquery.Coercion = Rex.Op.Subquery.Coercion.SCALAR, + ): Rex { val rex = super.visitExpr(node, ctx) return when (rex.op is Rex.Op.Select) { - true -> rex(StaticType.ANY, rexOpSubquery(rex.op as Rex.Op.Select, coercion)) + true -> rex(StaticType.ANY, rexOpSubquery(rex.op, coercion)) else -> rex } } @@ -129,9 +132,8 @@ internal object RexConverter { val arg = visitExprCoerce(node.expr, context) val args = listOf(arg) // Fn - val id = identifierSymbol(node.op.name.lowercase(), Identifier.CaseSensitivity.SENSITIVE) - val fn = fnUnresolved(id, true) - val op = rexOpCallStatic(fn, args) + val id = identifierSymbol(node.op.name.lowercase(), Identifier.CaseSensitivity.INSENSITIVE) + val op = rexOpCallUnresolved(id, args) return rex(type, op) } @@ -147,11 +149,8 @@ internal object RexConverter { rex(type, op) } else -> { - // Fn - val id = identifierSymbol(node.op.name.lowercase(), Identifier.CaseSensitivity.SENSITIVE) - val fn = fnUnresolved(id, true) - // Rex - val op = rexOpCallStatic(fn, args) + val id = identifierSymbol(node.op.name.lowercase(), Identifier.CaseSensitivity.INSENSITIVE) + val op = rexOpCallUnresolved(id, args) rex(type, op) } } @@ -193,7 +192,10 @@ internal object RexConverter { when (identifierSteps.size) { 0 -> root to node.steps else -> { - val newRoot = rex(StaticType.ANY, rexOpVarUnresolved(mergeIdentifiers(op.identifier, identifierSteps), op.scope)) + val newRoot = rex( + StaticType.ANY, + rexOpVarUnresolved(mergeIdentifiers(op.identifier, identifierSteps), op.scope) + ) val newSteps = node.steps.subList(identifierSteps.size, node.steps.size) newRoot to newSteps } @@ -224,7 +226,10 @@ internal object RexConverter { is Expr.Path.Step.Symbol -> { val identifier = AstToPlan.convert(step.symbol) when (identifier.caseSensitivity) { - Identifier.CaseSensitivity.SENSITIVE -> rexOpPathKey(current, rexString(identifier.symbol)) + Identifier.CaseSensitivity.SENSITIVE -> rexOpPathKey( + current, + rexString(identifier.symbol) + ) Identifier.CaseSensitivity.INSENSITIVE -> rexOpPathSymbol(current, identifier.symbol) } } @@ -245,11 +250,10 @@ internal object RexConverter { if (id is Identifier.Symbol && id.symbol.equals("TUPLEUNION", ignoreCase = true)) { return visitExprCallTupleUnion(node, context) } - val fn = fnUnresolved(id, false) // Args val args = node.args.map { visitExprCoerce(it, context) } // Rex - val op = rexOpCallStatic(fn, args) + val op = rexOpCallUnresolved(id, args) return rex(type, op) } @@ -269,11 +273,10 @@ internal object RexConverter { // Converts AST CASE (x) WHEN y THEN z --> Plan CASE WHEN x = y THEN z val id = identifierSymbol(Expr.Binary.Op.EQ.name.lowercase(), Identifier.CaseSensitivity.SENSITIVE) - val fn = fnUnresolved(id, true) val createBranch: (Rex, Rex) -> Rex.Op.Case.Branch = { condition: Rex, result: Rex -> val updatedCondition = when (rex) { null -> condition - else -> rex(type, rexOpCallStatic(fn.copy(), listOf(rex, condition))) + else -> rex(type, rexOpCallUnresolved(id, listOf(rex, condition))) } rexOpCaseBranch(updatedCondition, result) } @@ -470,8 +473,7 @@ internal object RexConverter { val expr1 = visitExpr(node.value, ctx) val expr2 = visitExpr(node.nullifier, ctx) val id = identifierSymbol(Expr.Binary.Op.EQ.name.lowercase(), Identifier.CaseSensitivity.SENSITIVE) - val fn = fnUnresolved(id, true) - val call = rexOpCallStatic(fn, listOf(expr1, expr2)) + val call = rexOpCallUnresolved(id, listOf(expr1, expr2)) val branches = listOf( rexOpCaseBranch(rex(type, call), rex(type = StaticType.NULL, op = rexOpLit(value = nullValue()))), ) @@ -529,7 +531,7 @@ internal object RexConverter { } // TODO: We may want to add a trim_both for trim(BOTH FROM arg) else -> when (arg1) { - null -> callNonHidden("trim", arg0) + null -> call("trim", arg0) else -> call("trim_chars", arg0, arg1) } } @@ -547,44 +549,45 @@ internal object RexConverter { // TODO: Ignoring type parameter now override fun visitExprCast(node: Expr.Cast, ctx: Env): Rex { val type = node.asType - val arg0 = visitExprCoerce(node.value, ctx) - return when (type) { - is Type.NullType -> rex(StaticType.NULL, call("cast_null", arg0)) - is Type.Missing -> rex(StaticType.MISSING, call("cast_missing", arg0)) - is Type.Bool -> rex(StaticType.BOOL, call("cast_bool", arg0)) - is Type.Tinyint -> TODO("Static Type does not have TINYINT type") - is Type.Smallint, is Type.Int2 -> rex(StaticType.INT2, call("cast_int16", arg0)) - is Type.Int4 -> rex(StaticType.INT4, call("cast_int32", arg0)) - is Type.Bigint, is Type.Int8 -> rex(StaticType.INT8, call("cast_int64", arg0)) - is Type.Int -> rex(StaticType.INT, call("cast_int", arg0)) - is Type.Real -> TODO("Static Type does not have REAL type") - is Type.Float32 -> TODO("Static Type does not have FLOAT32 type") - is Type.Float64 -> rex(StaticType.FLOAT, call("cast_float64", arg0)) - is Type.Decimal -> rex(StaticType.DECIMAL, call("cast_decimal", arg0)) - is Type.Numeric -> rex(StaticType.DECIMAL, call("cast_numeric", arg0)) - is Type.Char -> rex(StaticType.CHAR, call("cast_char", arg0)) - is Type.Varchar -> rex(StaticType.STRING, call("cast_varchar", arg0)) - is Type.String -> rex(StaticType.STRING, call("cast_string", arg0)) - is Type.Symbol -> rex(StaticType.SYMBOL, call("cast_symbol", arg0)) - is Type.Bit -> TODO("Static Type does not have Bit type") - is Type.BitVarying -> TODO("Static Type does not have BitVarying type") - is Type.ByteString -> TODO("Static Type does not have ByteString type") - is Type.Blob -> rex(StaticType.BLOB, call("cast_blob", arg0)) - is Type.Clob -> rex(StaticType.CLOB, call("cast_clob", arg0)) - is Type.Date -> rex(StaticType.DATE, call("cast_date", arg0)) - is Type.Time -> rex(StaticType.TIME, call("cast_time", arg0)) - is Type.TimeWithTz -> rex(TimeType(null, true), call("cast_timeWithTz", arg0)) - is Type.Timestamp -> TODO("Need to rebase main") - is Type.TimestampWithTz -> rex(StaticType.TIMESTAMP, call("cast_timeWithTz", arg0)) - is Type.Interval -> TODO("Static Type does not have Interval type") - is Type.Bag -> rex(StaticType.BAG, call("cast_bag", arg0)) - is Type.List -> rex(StaticType.LIST, call("cast_list", arg0)) - is Type.Sexp -> rex(StaticType.SEXP, call("cast_sexp", arg0)) - is Type.Tuple -> rex(StaticType.STRUCT, call("cast_tuple", arg0)) - is Type.Struct -> rex(StaticType.STRUCT, call("cast_struct", arg0)) - is Type.Any -> rex(StaticType.ANY, call("cast_any", arg0)) + val arg = visitExprCoerce(node.value, ctx) + val target = when (type) { + is Type.NullType -> PartiQLValueType.NULL + is Type.Missing -> PartiQLValueType.MISSING + is Type.Bool -> PartiQLValueType.BOOL + is Type.Tinyint -> PartiQLValueType.INT8 + is Type.Smallint, is Type.Int2 -> PartiQLValueType.INT16 + is Type.Int4 -> PartiQLValueType.INT32 + is Type.Bigint, is Type.Int8 -> PartiQLValueType.INT64 + is Type.Int -> PartiQLValueType.INT + is Type.Real -> PartiQLValueType.FLOAT64 + is Type.Float32 -> PartiQLValueType.FLOAT32 + is Type.Float64 -> PartiQLValueType.FLOAT64 + is Type.Decimal -> if (type.scale != null) PartiQLValueType.DECIMAL else PartiQLValueType.DECIMAL_ARBITRARY + is Type.Numeric -> if (type.scale != null) PartiQLValueType.DECIMAL else PartiQLValueType.DECIMAL_ARBITRARY + is Type.Char -> PartiQLValueType.CHAR + is Type.Varchar -> PartiQLValueType.STRING + is Type.String -> PartiQLValueType.STRING + is Type.Symbol -> PartiQLValueType.SYMBOL + is Type.Bit -> PartiQLValueType.BINARY + is Type.BitVarying -> PartiQLValueType.BINARY + is Type.ByteString -> PartiQLValueType.BINARY + is Type.Blob -> PartiQLValueType.BLOB + is Type.Clob -> PartiQLValueType.CLOB + is Type.Date -> PartiQLValueType.DATE + is Type.Time -> PartiQLValueType.TIME + is Type.TimeWithTz -> PartiQLValueType.TIME + is Type.Timestamp -> PartiQLValueType.TIMESTAMP + is Type.TimestampWithTz -> PartiQLValueType.TIMESTAMP + is Type.Interval -> PartiQLValueType.INTERVAL + is Type.Bag -> PartiQLValueType.BAG + is Type.List -> PartiQLValueType.LIST + is Type.Sexp -> PartiQLValueType.SEXP + is Type.Tuple -> PartiQLValueType.STRUCT + is Type.Struct -> PartiQLValueType.STRUCT + is Type.Any -> PartiQLValueType.ANY is Type.Custom -> TODO("Custom type not supported ") } + return rex(StaticType.ANY, rexOpCastUnresolved(target, arg)) } override fun visitExprCanCast(node: Expr.CanCast, ctx: Env): Rex { @@ -634,39 +637,22 @@ internal object RexConverter { // Helpers - private fun bool(v: Boolean): Rex { - val type = StaticType.BOOL - val op = rexOpLit(boolValue(v)) - return rex(type, op) - } - - private fun negate(call: Rex.Op.Call): Rex.Op.Call.Static { + private fun negate(call: Rex.Op.Call): Rex.Op.Call { val name = Expr.Unary.Op.NOT.name val id = identifierSymbol(name.lowercase(), Identifier.CaseSensitivity.SENSITIVE) - val fn = fnUnresolved(id, true) // wrap val arg = rex(StaticType.BOOL, call) // rewrite call - return rexOpCallStatic(fn, listOf(arg)) + return rexOpCallUnresolved(id, listOf(arg)) } /** * Create a [Rex.Op.Call.Static] node which has a hidden unresolved Function. * The purpose of having such hidden function is to prevent usage of generated function name in query text. */ - private fun call(name: String, vararg args: Rex): Rex.Op.Call.Static { - val id = identifierSymbol(name, Identifier.CaseSensitivity.SENSITIVE) - val fn = fnUnresolved(id, true) - return rexOpCallStatic(fn, args.toList()) - } - - /** - * Create a [Rex.Op.Call.Static] node which has a non-hidden unresolved Function. - */ - private fun callNonHidden(name: String, vararg args: Rex): Rex.Op.Call.Static { - val id = identifierSymbol(name, Identifier.CaseSensitivity.SENSITIVE) - val fn = fnUnresolved(id, false) - return rexOpCallStatic(fn, args.toList()) + private fun call(name: String, vararg args: Rex): Rex.Op.Call { + val id = identifierSymbol(name, Identifier.CaseSensitivity.INSENSITIVE) + return rexOpCallUnresolved(id, args.toList()) } private fun Int?.toRex() = rex(StaticType.INT4, rexOpLit(int32Value(this))) diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/Symbols.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/Symbols.kt new file mode 100644 index 0000000000..349cdf2949 --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/Symbols.kt @@ -0,0 +1,60 @@ +package org.partiql.planner.internal.transforms + +import org.partiql.plan.Catalog +import org.partiql.plan.builder.CatalogBuilder +import org.partiql.plan.catalogItemFn +import org.partiql.plan.catalogItemValue +import org.partiql.planner.internal.ir.Ref +import org.partiql.spi.fn.FnExperimental +import org.partiql.plan.Ref as CatalogRef + +/** + * Symbols is a helper class for maintaining resolved catalog symbols during planning. + */ +internal class Symbols private constructor() { + + private val catalogs: MutableList = mutableListOf() + + companion object { + + @JvmStatic + fun empty() = Symbols() + } + + fun build(): List { + return catalogs.map { it.build() } + } + + fun insert(ref: Ref.Obj): CatalogRef = insert( + catalog = ref.catalog, + item = catalogItemValue(ref.path, ref.type), + ) + + @OptIn(FnExperimental::class) + fun insert(ref: Ref.Fn): CatalogRef = insert( + catalog = ref.catalog, + item = catalogItemFn(ref.path, ref.signature.specific), + ) + + private fun insert(catalog: String, item: Catalog.Item): CatalogRef { + val i = upsert(catalog) + val c = catalogs[i] + var j = 0 + while (j < c.items.size) { + if (c.items[j] == item) { + break + } + j++ + } + c.items.add(item) + return CatalogRef(i, j) + } + + private fun upsert(catalog: String): Int { + catalogs.forEachIndexed { i, c -> + if (c.name == catalog) return i + } + catalogs.add(CatalogBuilder(name = catalog)) + return catalogs.size - 1 + } +} diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/FnResolver.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/FnResolver.kt deleted file mode 100644 index ab5a88add8..0000000000 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/FnResolver.kt +++ /dev/null @@ -1,458 +0,0 @@ -package org.partiql.planner.internal.typer - -import org.partiql.planner.internal.Header -import org.partiql.planner.internal.ir.Agg -import org.partiql.planner.internal.ir.Fn -import org.partiql.planner.internal.ir.Identifier -import org.partiql.planner.internal.ir.Rex -import org.partiql.types.StaticType -import org.partiql.types.function.FunctionParameter -import org.partiql.types.function.FunctionSignature -import org.partiql.value.PartiQLValueExperimental -import org.partiql.value.PartiQLValueType -import org.partiql.value.PartiQLValueType.ANY -import org.partiql.value.PartiQLValueType.BAG -import org.partiql.value.PartiQLValueType.BINARY -import org.partiql.value.PartiQLValueType.BLOB -import org.partiql.value.PartiQLValueType.BOOL -import org.partiql.value.PartiQLValueType.BYTE -import org.partiql.value.PartiQLValueType.CHAR -import org.partiql.value.PartiQLValueType.CLOB -import org.partiql.value.PartiQLValueType.DATE -import org.partiql.value.PartiQLValueType.DECIMAL -import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY -import org.partiql.value.PartiQLValueType.FLOAT32 -import org.partiql.value.PartiQLValueType.FLOAT64 -import org.partiql.value.PartiQLValueType.INT -import org.partiql.value.PartiQLValueType.INT16 -import org.partiql.value.PartiQLValueType.INT32 -import org.partiql.value.PartiQLValueType.INT64 -import org.partiql.value.PartiQLValueType.INT8 -import org.partiql.value.PartiQLValueType.INTERVAL -import org.partiql.value.PartiQLValueType.LIST -import org.partiql.value.PartiQLValueType.MISSING -import org.partiql.value.PartiQLValueType.NULL -import org.partiql.value.PartiQLValueType.SEXP -import org.partiql.value.PartiQLValueType.STRING -import org.partiql.value.PartiQLValueType.STRUCT -import org.partiql.value.PartiQLValueType.SYMBOL -import org.partiql.value.PartiQLValueType.TIME -import org.partiql.value.PartiQLValueType.TIMESTAMP - -/** - * Function signature lookup by name. - */ -internal typealias FnMap = Map> - -/** - * Function arguments list. The planner is responsible for mapping arguments to parameters. - */ -internal typealias Args = List - -/** - * Parameter mapping list tells the planner where to insert implicit casts. Null is the identity. - */ -internal typealias Mapping = List - -/** - * Tells us which function matched, and how the arguments are mapped. - */ -internal class Match( - public val signature: T, - public val mapping: Mapping, -) - -/** - * Result of attempting to match an unresolved function. - */ -internal sealed class FnMatch { - - /** - * 7.1 Inputs with wrong types - * It follows that all functions return MISSING when one of their inputs is MISSING - * - * @property signature - * @property mapping - * @property isMissable TRUE when anyone of the arguments _could_ be MISSING. We *always* propagate MISSING. - */ - public data class Ok( - public val signature: T, - public val mapping: Mapping, - public val isMissable: Boolean, - ) : FnMatch() - - /** - * This represents dynamic dispatch. - * - * @property candidates an ordered list of potentially applicable functions to dispatch dynamically. - * @property isMissable TRUE when the argument permutations may not definitively invoke one of the candidates. You - * can think of [isMissable] as being the same as "not exhaustive". For example, if we have ABS(INT | STRING), then - * this function call [isMissable] because there isn't an `ABS(STRING)` function signature AKA we haven't exhausted - * all the arguments. On the other hand, take an "exhaustive" scenario: ABS(INT | DEC). In this case, [isMissable] - * is false because we have functions for each potential argument AKA we have exhausted the arguments. - */ - public data class Dynamic( - public val candidates: List>, - public val isMissable: Boolean - ) : FnMatch() - - public data class Error( - public val identifier: Identifier, - public val args: List, - public val candidates: List, - ) : FnMatch() -} - -/** - * Logic for matching signatures to arguments — this class contains all cast/coercion logic. In my opinion, casts - * and coercions should come along with the type lattice. Considering we don't really have this, it is simple enough - * at the moment to keep that information (derived from the current TypeLattice) with the [FnResolver]. - */ -@OptIn(PartiQLValueExperimental::class) -internal class FnResolver(private val header: Header) { - - /** - * All headers use the same type lattice (we don't have a design for plugging type systems at the moment). - */ - private val types = TypeLattice.partiql() - - /** - * Calculate a queryable map of scalar function signatures. - */ - private val functions: FnMap - - /** - * Calculate a queryable map of scalar function signatures from special forms. - */ - private val operators: FnMap - - /** - * Calculate a queryable map of aggregation function signatures - */ - private val aggregations: FnMap - - /** - * A place to quickly lookup a cast can return missing; lookup by "SPECIFIC" - */ - private val unsafeCastSet: Set - - init { - val (casts, unsafeCasts) = casts() - unsafeCastSet = unsafeCasts - // combine all header definitions - val fns = header.functions - functions = fns.toFnMap() - operators = (header.operators + casts).toFnMap() - aggregations = header.aggregations.toFnMap() - } - - /** - * Group list of [FunctionSignature] by name. - */ - private fun List.toFnMap(): FnMap = this - .distinctBy { it.specific } - .sortedWith(fnPrecedence) - .groupBy { it.name } - - /** - * Leverages a [FnResolver] to find a matching function defined in the [Header] scalar function catalog. - */ - public fun resolveFn(fn: Fn.Unresolved, args: List): FnMatch { - val candidates = lookup(fn) - var canReturnMissing = false - val parameterPermutations = buildArgumentPermutations(args.map { it.type }).mapNotNull { argList -> - argList.mapIndexed { i, arg -> - if (arg.isMissable()) { - canReturnMissing = true - } - // Skip over if we cannot convert type to runtime type. - val argType = arg.toRuntimeTypeOrNull() ?: return@mapNotNull null - FunctionParameter("arg-$i", argType) - } - } - val potentialFunctions = parameterPermutations.mapNotNull { parameters -> - when (val match = match(candidates, parameters)) { - null -> { - canReturnMissing = true - null - } - else -> { - val isMissable = canReturnMissing || isUnsafeCast(match.signature.specific) - FnMatch.Ok(match.signature, match.mapping, isMissable) - } - } - } - // Remove duplicates while maintaining order (precedence). - val orderedUniqueFunctions = potentialFunctions.toSet().toList() - return when (orderedUniqueFunctions.size) { - 0 -> FnMatch.Error(fn.identifier, args, candidates) - 1 -> orderedUniqueFunctions.first() - else -> FnMatch.Dynamic(orderedUniqueFunctions, canReturnMissing) - } - } - - private fun buildArgumentPermutations(args: List): List> { - val flattenedArgs = args.map { it.flatten().allTypes } - return buildArgumentPermutations(flattenedArgs, accumulator = emptyList()) - } - - private fun buildArgumentPermutations( - args: List>, - accumulator: List, - ): List> { - if (args.isEmpty()) { - return listOf(accumulator) - } - val first = args.first() - val rest = when (args.size) { - 1 -> emptyList() - else -> args.subList(1, args.size) - } - return buildList { - first.forEach { argSubType -> - addAll(buildArgumentPermutations(rest, accumulator + listOf(argSubType))) - } - } - } - - /** - * Leverages a [FnResolver] to find a matching function defined in the [Header] aggregation function catalog. - */ - public fun resolveAgg(agg: Agg.Unresolved, args: List): FnMatch { - val candidates = lookup(agg) - var hadMissingArg = false - val parameters = args.mapIndexed { i, arg -> - if (!hadMissingArg && arg.type.isMissable()) { - hadMissingArg = true - } - FunctionParameter("arg-$i", arg.type.toRuntimeType()) - } - val match = match(candidates, parameters) - return when (match) { - null -> FnMatch.Error(agg.identifier, args, candidates) - else -> { - val isMissable = hadMissingArg || isUnsafeCast(match.signature.specific) - FnMatch.Ok(match.signature, match.mapping, isMissable) - } - } - } - - /** - * Functions are sorted by precedence (which is not rigorously defined/specified at the moment). - */ - private fun match(signatures: List, args: Args): Match? { - for (signature in signatures) { - val mapping = match(signature, args) - if (mapping != null) { - return Match(signature, mapping) - } - } - return null - } - - /** - * Attempt to match arguments to the parameters; return the implicit casts if necessary. - * - * TODO we need to constrain the allowable runtime types for an ANY typed parameter. - */ - fun match(signature: FunctionSignature, args: Args): Mapping? { - if (signature.parameters.size != args.size) { - return null - } - val mapping = ArrayList(args.size) - for (i in args.indices) { - val a = args[i] - val p = signature.parameters[i] - when { - // 1. Exact match - a.type == p.type -> mapping.add(null) - // 2. Match ANY, no coercion needed - p.type == ANY -> mapping.add(null) - // 3. Match NULL argument - a.type == NULL -> mapping.add(null) - // 4. Check for a coercion - else -> { - val coercion = lookupCoercion(a.type, p.type) - when (coercion) { - null -> return null // short-circuit - else -> mapping.add(coercion) - } - } - } - } - // if all elements requires casting, then no match - // because there must be another function definition that requires no casting - return if (mapping.isEmpty() || mapping.contains(null)) { - // we made a match - mapping - } else { - null - } - } - - /** - * Return a list of all scalar function signatures matching the given identifier. - */ - private fun lookup(ref: Fn.Unresolved): List { - val name = getFnName(ref.identifier) - return when (ref.isHidden) { - true -> operators.getOrDefault(name, emptyList()) - else -> functions.getOrDefault(name, emptyList()) - } - } - - /** - * Return a list of all aggregation function signatures matching the given identifier. - */ - private fun lookup(ref: Agg.Unresolved): List { - val name = getFnName(ref.identifier) - return aggregations.getOrDefault(name, emptyList()) - } - - /** - * Return a normalized function identifier for lookup in our list of function definitions. - */ - private fun getFnName(identifier: Identifier): String = when (identifier) { - is Identifier.Qualified -> throw IllegalArgumentException("Qualified function identifiers not supported") - is Identifier.Symbol -> identifier.symbol.lowercase() - } - - // ==================================== - // CASTS and COERCIONS - // ==================================== - - /** - * Returns the CAST function if exists, else null. - */ - private fun lookupCoercion(valueType: PartiQLValueType, targetType: PartiQLValueType): FunctionSignature.Scalar? { - if (!types.canCoerce(valueType, targetType)) { - return null - } - val name = castName(targetType) - val casts = operators.getOrDefault(name, emptyList()) - for (cast in casts) { - if (cast.parameters.isEmpty()) { - break // should be unreachable - } - if (valueType == cast.parameters[0].type) return cast - } - return null - } - - /** - * Easy lookup of whether this CAST can return MISSING. - */ - private fun isUnsafeCast(specific: String): Boolean = unsafeCastSet.contains(specific) - - /** - * Generate all CAST functions from the given lattice. - * - * @return Pair(0) is the function list, Pair(1) represents the unsafe cast specifics - */ - private fun casts(): Pair, Set> { - val casts = mutableListOf() - val unsafeCastSet = mutableSetOf() - for (t1 in types.types) { - for (t2 in types.types) { - val r = types.graph[t1.ordinal][t2.ordinal] - if (r != null) { - val fn = cast(t1, t2) - casts.add(fn) - if (r.cast == CastType.UNSAFE) unsafeCastSet.add(fn.specific) - } - } - } - return casts to unsafeCastSet - } - - /** - * Define CASTS with some mangled name; CAST(x AS T) -> cast_t(x) - * - * CAST(x AS INT8) -> cast_int64(x) - * - * But what about parameterized types? Are the parameters dropped in casts, or do parameters become arguments? - */ - private fun castName(type: PartiQLValueType) = "cast_${type.name.lowercase()}" - - internal fun cast(operand: PartiQLValueType, target: PartiQLValueType) = - FunctionSignature.Scalar( - name = castName(target), - returns = target, - parameters = listOf( - FunctionParameter("value", operand), - ), - isNullable = false, - isNullCall = true - ) - - companion object { - - // ==================================== - // SORTING - // ==================================== - - // Function precedence comparator - // 1. Fewest args first - // 2. Parameters are compared left-to-right - @JvmStatic - private val fnPrecedence = Comparator { fn1, fn2 -> - // Compare number of arguments - if (fn1.parameters.size != fn2.parameters.size) { - return@Comparator fn1.parameters.size - fn2.parameters.size - } - // Compare operand type precedence - for (i in fn1.parameters.indices) { - val p1 = fn1.parameters[i] - val p2 = fn2.parameters[i] - val comparison = p1.compareTo(p2) - if (comparison != 0) return@Comparator comparison - } - // unreachable? - 0 - } - - private fun FunctionParameter.compareTo(other: FunctionParameter): Int = - comparePrecedence(this.type, other.type) - - private fun comparePrecedence(t1: PartiQLValueType, t2: PartiQLValueType): Int { - if (t1 == t2) return 0 - val p1 = precedence[t1]!! - val p2 = precedence[t2]!! - return p1 - p2 - } - - // This simply describes some precedence for ordering functions. - // This is not explicitly defined in the PartiQL Specification!! - // This does not imply the ability to CAST; this defines function resolution behavior. - private val precedence: Map = listOf( - NULL, - MISSING, - BOOL, - INT8, - INT16, - INT32, - INT64, - INT, - DECIMAL, - FLOAT32, - FLOAT64, - DECIMAL_ARBITRARY, // Arbitrary precision decimal has a higher precedence than FLOAT - CHAR, - STRING, - CLOB, - SYMBOL, - BINARY, - BYTE, - BLOB, - DATE, - TIME, - TIMESTAMP, - INTERVAL, - LIST, - SEXP, - BAG, - STRUCT, - ANY, - ).mapIndexed { precedence, type -> type to precedence }.toMap() - } -} 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 1c15078553..07ec207cd6 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 @@ -21,21 +21,17 @@ import org.partiql.errors.ProblemCallback 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.ir.Agg -import org.partiql.planner.internal.ir.Fn import org.partiql.planner.internal.ir.Identifier import org.partiql.planner.internal.ir.PlanNode +import org.partiql.planner.internal.ir.Ref.Cast.Safety.UNSAFE 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.fnResolved import org.partiql.planner.internal.ir.identifierSymbol import org.partiql.planner.internal.ir.rel import org.partiql.planner.internal.ir.relBinding import org.partiql.planner.internal.ir.relOpAggregate -import org.partiql.planner.internal.ir.relOpAggregateCall +import org.partiql.planner.internal.ir.relOpAggregateCallUnresolved import org.partiql.planner.internal.ir.relOpDistinct import org.partiql.planner.internal.ir.relOpErr import org.partiql.planner.internal.ir.relOpExclude @@ -51,9 +47,6 @@ import org.partiql.planner.internal.ir.relOpSort import org.partiql.planner.internal.ir.relOpUnpivot import org.partiql.planner.internal.ir.relType import org.partiql.planner.internal.ir.rex -import org.partiql.planner.internal.ir.rexOpCallDynamic -import org.partiql.planner.internal.ir.rexOpCallDynamicCandidate -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 @@ -71,6 +64,8 @@ import org.partiql.planner.internal.ir.util.PlanRewriter import org.partiql.spi.BindingCase import org.partiql.spi.BindingName import org.partiql.spi.BindingPath +import org.partiql.spi.fn.FnExperimental +import org.partiql.spi.fn.FnSignature import org.partiql.types.AnyOfType import org.partiql.types.AnyType import org.partiql.types.BagType @@ -91,7 +86,6 @@ import org.partiql.types.StaticType.Companion.unionOf import org.partiql.types.StringType import org.partiql.types.StructType import org.partiql.types.TupleConstraint -import org.partiql.types.function.FunctionSignature import org.partiql.value.BoolValue import org.partiql.value.PartiQLValueExperimental import org.partiql.value.TextValue @@ -120,7 +114,7 @@ internal class PlanTyper( } // root TypeEnv has no bindings val typeEnv = TypeEnv(schema = emptyList()) - val root = statement.root.type(typeEnv) + val root = statement.root.type(typeEnv, Scope.GLOBAL) return statementQuery(root) } @@ -132,7 +126,7 @@ internal class PlanTyper( */ private inner class RelTyper( private val outer: TypeEnv, - private val strategy: ResolutionStrategy, + private val strategy: Scope, ) : PlanRewriter() { override fun visitRel(node: Rel, ctx: Rel.Type?) = visitRelOp(node.op, node.type) as Rel @@ -142,7 +136,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, ResolutionStrategy.GLOBAL) + val rex = node.rex.type(outer, Scope.GLOBAL) // compute rel type val valueT = getElementTypeForFromSource(rex.type) val type = ctx!!.copyWithSchema(listOf(valueT)) @@ -161,7 +155,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, ResolutionStrategy.GLOBAL) + val rex = node.rex.type(outer, Scope.GLOBAL) // compute rel type val valueT = getElementTypeForFromSource(rex.type) val indexT = StaticType.INT8 @@ -176,7 +170,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, ResolutionStrategy.GLOBAL) + val rex = node.rex.type(outer, Scope.GLOBAL) // only UNPIVOT a struct if (rex.type !is StructType) { @@ -187,7 +181,7 @@ internal class PlanTyper( // compute element type val t = rex.type val e = if (t.contentClosed) { - StaticType.unionOf(t.fields.map { it.value }.toSet()).flatten() + unionOf(t.fields.map { it.value }.toSet()).flatten() } else { ANY } @@ -252,7 +246,7 @@ internal class PlanTyper( // compute input schema val input = visitRel(node.input, ctx) // type limit expression using outer scope with global resolution - val limit = node.limit.type(outer, ResolutionStrategy.GLOBAL) + val limit = node.limit.type(outer, Scope.GLOBAL) // check types assertAsInt(limit.type) // compute output schema @@ -266,7 +260,7 @@ internal class PlanTyper( // compute input schema val input = visitRel(node.input, ctx) // type offset expression using outer scope with global resolution - val offset = node.offset.type(outer, ResolutionStrategy.GLOBAL) + val offset = node.offset.type(outer, Scope.GLOBAL) // check types assertAsInt(offset.type) // compute output schema @@ -280,9 +274,9 @@ internal class PlanTyper( // compute input schema val input = visitRel(node.input, ctx) // type sub-nodes - val typeEnv = TypeEnv(input.type.schema) + val locals = TypeEnv(input.type.schema) val projections = node.projections.map { - it.type(typeEnv) + it.type(locals) } // compute output schema val schema = projections.map { it.type } @@ -307,6 +301,7 @@ internal class PlanTyper( Rel.Op.Join.Type.FULL -> l.pad() + r.pad() } val type = relType(schema, ctx!!.props) + val locals = type.schema // Type the condition on the output schema val condition = node.rex.type(TypeEnv(type.schema)) @@ -386,13 +381,13 @@ internal class PlanTyper( val input = visitRel(node.input, ctx) // type the calls and groups - val typer = RexTyper(TypeEnv(input.type.schema), ResolutionStrategy.LOCAL) + val typer = RexTyper(TypeEnv(input.type.schema), Scope.LOCAL) // typing of aggregate calls is slightly more complicated because they are not expressions. val calls = node.calls.mapIndexed { i, call -> - when (val agg = call.agg) { - is Agg.Resolved -> call to ctx!!.schema[i].type - is Agg.Unresolved -> typer.resolveAgg(agg, call.args) + when (val agg = call) { + is Rel.Op.Aggregate.Call.Resolved -> call to ctx!!.schema[i].type + is Rel.Op.Aggregate.Call.Unresolved -> typer.resolveAgg(agg) } } val groups = node.groups.map { typer.visitRex(it, null) } @@ -425,7 +420,7 @@ internal class PlanTyper( @OptIn(PartiQLValueExperimental::class) private inner class RexTyper( private val locals: TypeEnv, - private val strategy: ResolutionStrategy, + private val strategy: Scope, ) : PlanRewriter() { override fun visitRex(node: Rex, ctx: StaticType?): Rex = visitRexOp(node.op, node.type) as Rex @@ -443,23 +438,22 @@ internal class PlanTyper( override fun visitRexOpVarUnresolved(node: Rex.Op.Var.Unresolved, ctx: StaticType?): Rex { val path = node.identifier.toBindingPath() - val strategy = when (node.scope) { + val scope = when (node.scope) { Rex.Op.Var.Scope.DEFAULT -> strategy - Rex.Op.Var.Scope.LOCAL -> ResolutionStrategy.LOCAL + Rex.Op.Var.Scope.LOCAL -> Scope.LOCAL + } + val resolvedVar = when (scope) { + Scope.LOCAL -> locals.resolve(path) ?: env.resolveObj(path) + Scope.GLOBAL -> env.resolveObj(path) ?: locals.resolve(path) } - val resolvedVar = env.resolve(path, locals, strategy) if (resolvedVar == null) { - handleUndefinedVariable(path.steps.last()) - return rex(ANY, rexOpErr("Undefined variable ${node.identifier}")) + handleUndefinedVariable(node.identifier) + return rexErr("Undefined variable `${node.identifier.debug()}`") } return visitRex(resolvedVar, null) } - override fun visitRexOpGlobal(node: Rex.Op.Global, ctx: StaticType?): Rex { - val catalog = env.catalogs[node.ref.catalog] - val type = catalog.symbols[node.ref.symbol].type - return rex(type, node) - } + override fun visitRexOpGlobal(node: Rex.Op.Global, ctx: StaticType?): Rex = rex(node.ref.type, node) override fun visitRexOpPathIndex(node: Rex.Op.Path.Index, ctx: StaticType?): Rex { val root = visitRex(node.root, node.root.type) @@ -523,14 +517,12 @@ 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) + 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)) + pathType, rexOpPathKey(root, rexString(replacementId.symbol)) ) } } @@ -563,11 +555,53 @@ internal class PlanTyper( val path = super.visitRexOpPath(node, ctx) as Rex if (path.type == MISSING) { handleAlwaysMissing() - return rexErr("Path always returns missing $node") + return rexErr("Path always returns missing: ${node.debug()}") } return path } + override fun visitRexOpCastUnresolved(node: Rex.Op.Cast.Unresolved, ctx: StaticType?): Rex { + val arg = visitRex(node.arg, null) + val cast = env.resolveCast(arg, node.target) + if (cast == null) { + handleUnknownCast(node) + return rexErr("Invalid CAST operator") + } + return visitRexOpCastResolved(cast, null) + } + + override fun visitRexOpCastResolved(node: Rex.Op.Cast.Resolved, ctx: StaticType?): Rex { + val missable = node.arg.type.isMissable() || node.cast.safety == UNSAFE + var type = node.cast.target.toNonNullStaticType() + if (missable) { + type = unionOf(type, MISSING) + } + return rex(type, node) + } + + override fun visitRexOpCallUnresolved(node: Rex.Op.Call.Unresolved, ctx: StaticType?): Rex { + // Type the arguments + val args = node.args.map { + val arg = visitRex(it, null) + if (arg.op is Rex.Op.Err) { + // don't attempt to resolve a function which has erroneous arguments. + return arg + } + arg + } + // Attempt to resolve in the environment + val path = node.identifier.toBindingPath() + val rex = env.resolveFn(path, args) + if (rex == null) { + handleUnknownFunction(node, args) + val name = node.identifier.debug() + val types = args.joinToString { "<${it.type}>" } + return rexErr("Unable to resolve function $name($types)") + } + // Pass off to Rex.Op.Call.Static or Rex.Op.Call.Dynamic for typing. + return visitRex(rex, null) + } + /** * Resolve and type scalar function calls. * @@ -575,109 +609,54 @@ internal class PlanTyper( * @param ctx * @return */ + @OptIn(FnExperimental::class) override fun visitRexOpCallStatic(node: Rex.Op.Call.Static, ctx: StaticType?): Rex { - // Already resolved; unreachable but handle gracefully. - if (node.fn is Fn.Resolved) return rex(ctx!!, node) - - // Type the arguments - val fn = node.fn as Fn.Unresolved - val isNotMissable = fn.isNotMissable() - val args = node.args.map { visitRex(it, null) } - - // Try to match the arguments to functions defined in the catalog - return when (val match = env.resolveFn(fn, args)) { - is FnMatch.Ok -> toRexCall(match, args, isNotMissable) - is FnMatch.Dynamic -> { - val types = mutableSetOf() - if (match.isMissable && !isNotMissable) { - types.add(MISSING) - } - val candidates = match.candidates.map { candidate -> - val rex = toRexCall(candidate, args, isNotMissable) - val staticCall = rex.op as? Rex.Op.Call.Static ?: error("ToRexCall should always return a static call.") - val resolvedFn = staticCall.fn as? Fn.Resolved ?: error("This should have been resolved") - types.add(rex.type) - val coercions = candidate.mapping.map { it?.let { fnResolved(it) } } - rexOpCallDynamicCandidate(fn = resolvedFn, coercions = coercions) - } - val op = rexOpCallDynamic(args = args, candidates = candidates) - rex(type = StaticType.unionOf(types).flatten(), op = op) + // Apply the coercions as explicit casts + val args: List = node.args.map { + // Propagate MISSING argument. + if (it.type == MissingType && node.fn.signature.isMissingCall) { + handleAlwaysMissing() + return rex(MISSING, node) } - is FnMatch.Error -> { - handleUnknownFunction(match) - rexErr("Unknown scalar function $fn") + // Type the coercions + when (val op = it.op) { + is Rex.Op.Cast.Resolved -> visitRexOpCastResolved(op, null) + else -> it } } + // Infer fn return type + val type = inferFnType(node.fn.signature, args) + return rex(type, node) } + /** + * Typing of a dynamic function call. + * + * isMissable TRUE when the argument permutations may not definitively invoke one of the candidates. + * You can think of [isMissable] as being the same as "not exhaustive". For example, if we have ABS(INT | STRING), then + * this function call [isMissable] because there isn't an `ABS(STRING)` function signature AKA we haven't exhausted + * all the arguments. On the other hand, take an "exhaustive" scenario: ABS(INT | DEC). In this case, [isMissable] + * is false because we have functions for each potential argument AKA we have exhausted the arguments. + * + * + * @param node + * @param ctx + * @return + */ + @OptIn(FnExperimental::class) override fun visitRexOpCallDynamic(node: Rex.Op.Call.Dynamic, ctx: StaticType?): Rex { - return rex(ANY, rexOpErr("Direct dynamic calls are not supported. This should have been a static call.")) - } - - private fun toRexCall(match: FnMatch.Ok, args: List, isNotMissable: Boolean): Rex { - // Found a match! - val newFn = fnResolved(match.signature) - val newArgs = rewriteFnArgs(match.mapping, args) - val returns = newFn.signature.returns - - // 7.1 All functions return MISSING when one of their inputs is MISSING (except `=`) - newArgs.forEach { - if (it.type == MissingType && !isNotMissable) { - handleAlwaysMissing() - return rex(MISSING, rexOpCallStatic(newFn, newArgs)) - } - } - - // If a function is NOT Missable (i.e., does not propagate MISSING) - // then treat MISSING as null. - var isMissing = false - var isMissable = false - if (isNotMissable) { - if (newArgs.any { it.type is MissingType }) { - isMissing = true - } else if (newArgs.any { it.type.isMissable() }) { - isMissable = true - } - } - - // Determine the nullability of the return type - var isNull = false // True iff NULL CALL and has a NULL arg - var isNullable = false // True iff NULL CALL and has a NULLABLE arg; or is a NULLABLE operator - if (newFn.signature.isNullCall) { - if (isMissing) { - isNull = true - } else if (isMissable) { - isNullable = true - } else { - for (arg in newArgs) { - if (arg.type is NullType) { - isNull = true - break - } - if (arg.type.isNullable()) { - isNullable = true - break - } - } - } - } - isNullable = isNullable || newFn.signature.isNullable - - // Return type with calculated nullability - var type = when { - isNull -> NULL - isNullable -> returns.toStaticType() - else -> returns.toNonNullStaticType() - } - - // Some operators can return MISSING during runtime - if (match.isMissable && !isNotMissable) { - type = StaticType.unionOf(type, MISSING) + var isMissingCall = false + val types = node.candidates.map { candidate -> + isMissingCall = isMissingCall || candidate.fn.signature.isMissingCall + inferFnType(candidate.fn.signature, node.args) + }.toMutableSet() + + // We had a branch (arg type permutation) without a candidate. + if (!node.exhaustive) { + types.add(MISSING) } - // Finally, rewrite this node - val op = rexOpCallStatic(newFn, newArgs) - return rex(type.flatten(), op) + return rex(type = unionOf(types).flatten(), op = node) } override fun visitRexOpCase(node: Rex.Op.Case, ctx: StaticType?): Rex { @@ -704,7 +683,7 @@ internal class PlanTyper( else -> when (isLiteralBool(newBranches[0].condition, true)) { true -> newBranches[0].rex false -> rex( - type = StaticType.unionOf(resultTypes.toSet()).flatten(), + type = unionOf(resultTypes.toSet()).flatten(), node.copy(branches = newBranches, default = default) ) } @@ -749,11 +728,10 @@ internal class PlanTyper( } /** - * This takes in a [Rex.Op.Case.Branch.condition] and [Rex.Op.Case.Branch.rex]. If the [condition] is a type check, - * AKA ` IS STRUCT`, then this function will return a new [Rex.Op.Case.Branch] whose [Rex.Op.Case.Branch.rex] - * assumes that the type will always be a struct. The [Rex.Op.Case.Branch.condition] will be replaced by a - * boolean literal if it is KNOWN whether a branch will always/never execute. This can be used to prune the - * branch in subsequent passes. + * This takes in a branch condition and its result expression. + * + * 1. If the condition is a type check T (ie ` IS T`), then this function will be typed as T. + * 2. If a branch condition is known to be false, it will be removed. * * TODO: Currently, this only folds type checking for STRUCTs. We need to add support for all other types. * @@ -761,12 +739,12 @@ internal class PlanTyper( * `WHEN { 'a': { 'b': 1} }.a IS STRUCT THEN { 'a': { 'b': 1} }.a.b`. We can discuss this later, but I'm * currently limiting the scope of this intentionally. */ + @OptIn(FnExperimental::class) private fun foldCaseBranch(condition: Rex, result: Rex): Rex.Op.Case.Branch { - val call = condition.op as? Rex.Op.Call ?: return rexOpCaseBranch(condition, result) - when (call) { + return when (val call = condition.op) { is Rex.Op.Call.Dynamic -> { val rex = call.candidates.map { candidate -> - val fn = candidate.fn as? Fn.Resolved ?: return rexOpCaseBranch(condition, result) + val fn = candidate.fn if (fn.signature.name.equals("is_struct", ignoreCase = true).not()) { return rexOpCaseBranch(condition, result) } @@ -780,11 +758,10 @@ internal class PlanTyper( } } val type = rex.toUnionType().flatten() - return rexOpCaseBranch(condition, result.copy(type)) } is Rex.Op.Call.Static -> { - val fn = call.fn as? Fn.Resolved ?: return rexOpCaseBranch(condition, result) + val fn = call.fn if (fn.signature.name.equals("is_struct", ignoreCase = true).not()) { return rexOpCaseBranch(condition, result) } @@ -804,6 +781,7 @@ internal class PlanTyper( } return rexOpCaseBranch(simplifiedCondition, rex) } + else -> rexOpCaseBranch(condition, result) } } @@ -827,10 +805,14 @@ internal class PlanTyper( @OptIn(PartiQLValueExperimental::class) override fun visitRexOpStruct(node: Rex.Op.Struct, ctx: StaticType?): Rex { - val fields = node.fields.map { + val fields = node.fields.mapNotNull { val k = visitRex(it.k, it.k.type) val v = visitRex(it.v, it.v.type) - rexOpStructField(k, v) + if (v.type is MissingType) { + null + } else { + rexOpStructField(k, v) + } } var structIsClosed = true val structTypeFields = mutableListOf() @@ -871,11 +853,11 @@ 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) - val key = node.key.type(typeEnv) - val value = node.value.type(typeEnv) + val typer = RexTyper(typeEnv, Scope.LOCAL) + val key = typer.visitRex(node.key, null) + val value = typer.visitRex(node.value, null) val type = StructType( - contentClosed = false, - constraints = setOf(TupleConstraint.Open(true)) + contentClosed = false, constraints = setOf(TupleConstraint.Open(true)) ) val op = rexOpPivot(key, value, rel) return rex(type, op) @@ -961,7 +943,7 @@ internal class PlanTyper( val potentialTypes = buildArgumentPermutations(argTypes).map { argumentList -> calculateTupleUnionOutputType(argumentList) } - StaticType.unionOf(potentialTypes.toSet()).flatten() + unionOf(potentialTypes.toSet()).flatten() } } val op = rexOpTupleUnion(args) @@ -1122,13 +1104,13 @@ internal class PlanTyper( val (name, type) = when { // 1. Struct is closed and ordered isClosed && isOrdered -> { - struct.fields.firstOrNull { entry -> binding.isEquivalentTo(entry.key) }?.let { + struct.fields.firstOrNull { entry -> binding.matches(entry.key) }?.let { (sensitive(it.key) to it.value) } ?: (key to MISSING) } // 2. Struct is closed isClosed -> { - val matches = struct.fields.filter { entry -> binding.isEquivalentTo(entry.key) } + val matches = struct.fields.filter { entry -> binding.matches(entry.key) } when (matches.size) { 0 -> (key to MISSING) 1 -> matches.first().let { (sensitive(it.key) to it.value) } @@ -1138,7 +1120,7 @@ internal class PlanTyper( true -> sensitive(firstKey) false -> key } - sharedKey to StaticType.unionOf(matches.map { it.value }.toSet()).flatten() + sharedKey to unionOf(matches.map { it.value }.toSet()).flatten() } } } @@ -1151,6 +1133,51 @@ internal class PlanTyper( private fun sensitive(str: String): Identifier.Symbol = identifierSymbol(str, Identifier.CaseSensitivity.SENSITIVE) + @OptIn(FnExperimental::class) + private fun inferFnType(fn: FnSignature, args: List): StaticType { + + // Determine role of NULL and MISSING in the return type + var hadNull = false + var hadNullable = false + var hadMissing = false + var hadMissable = false + for (arg in args) { + val t = arg.type + when { + t is MissingType -> hadMissing = true + t is NullType -> hadNull = true + t.isMissable() -> hadMissable = true + t.isNullable() -> hadNullable = true + } + } + + // True iff NULL CALL and had a NULL arg; or NOT missable and had MISSING argument + val isNull = (fn.isNullCall && hadNull) || (!fn.isMissable && hadMissing) + + // True iff NULL CALL and had a NULLABLE arg; or is a NULLABLE operator + val isNullable = (fn.isNullCall && hadNullable) || fn.isNullable || (!fn.isMissable && hadMissable) + + // True iff MISSING CALL and had a MISSING arg. + val isMissing = fn.isMissingCall && hadMissing + + // True iff MISSING CALL and had a MISSABLE arg + val isMissable = (fn.isMissingCall && hadMissable) && fn.isMissable + + // Return type with calculated nullability + var type: StaticType = when { + isNull -> NULL + isNullable -> fn.returns.toStaticType() + else -> fn.returns.toNonNullStaticType() + } + + // Propagate MISSING unless this operator explicitly doesn't return missing (fn.isMissable = false). + if (isMissable) { + type = unionOf(type, MISSING) + } + + return type.flatten() + } + /** * Resolution and typing of aggregation function calls. * @@ -1165,57 +1192,51 @@ internal class PlanTyper( * Let TX be the single-column table that is the result of applying the * to each row of T and eliminating null values <--- all NULL values are eliminated as inputs */ - fun resolveAgg(agg: Agg.Unresolved, arguments: List): Pair { - var missingArg = false - val args = arguments.map { + @OptIn(FnExperimental::class) + fun resolveAgg(node: Rel.Op.Aggregate.Call.Unresolved): Pair { + + // Type the arguments + var isMissable = false + val args = node.args.map { val arg = visitRex(it, null) - if (arg.type.isMissable()) missingArg = true + if (arg.op is Rex.Op.Err) { + // don't attempt to resolve an aggregation with erroneous arguments. + handleUnknownAggregation(node) + return node to ANY + } else if (arg.type is MissingType) { + handleAlwaysMissing() + return relOpAggregateCallUnresolved(node.name, listOf(rexErr("MISSING"))) to MissingType + } else if (arg.type.isMissable()) { + isMissable = true + } arg } - // - if (missingArg) { - handleAlwaysMissing() - return relOpAggregateCall(agg, listOf(rexErr("MISSING"))) to MissingType + // Resolve the function + val call = env.resolveAgg(node.name, args) + if (call == null) { + handleUnknownAggregation(node) + return node to ANY } - // Try to match the arguments to functions defined in the catalog - return when (val match = env.resolveAgg(agg, args)) { - is FnMatch.Ok -> { - // Found a match! - val newAgg = aggResolved(match.signature) - val newArgs = rewriteFnArgs(match.mapping, args) - val returns = newAgg.signature.returns - - // Return type with calculated nullability - var type = when { - newAgg.signature.isNullable -> returns.toStaticType() - else -> returns.toNonNullStaticType() - } - - // Some operators can return MISSING during runtime - if (match.isMissable) { - type = StaticType.unionOf(type, MISSING).flatten() - } - - // Finally, rewrite this node - relOpAggregateCall(newAgg, newArgs) to type - } - is FnMatch.Dynamic -> TODO("Dynamic aggregates not yet supported.") - is FnMatch.Error -> { - handleUnknownFunction(match) - return relOpAggregateCall(agg, listOf(rexErr("MISSING"))) to MissingType - } + // Treat MISSING as NULL in aggregations. + val isNullable = call.agg.signature.isNullable || isMissable + val returns = call.agg.signature.returns + val type: StaticType = when { + isNullable -> returns.toStaticType() + else -> returns.toNonNullStaticType() } + // + return call to type } } // HELPERS - private fun Rel.type(locals: TypeEnv, strategy: ResolutionStrategy = ResolutionStrategy.LOCAL): Rel = + private fun Rel.type(locals: TypeEnv, strategy: Scope = Scope.LOCAL): Rel = RelTyper(locals, strategy).visitRel(this, null) - private fun Rex.type(locals: TypeEnv, strategy: ResolutionStrategy = ResolutionStrategy.LOCAL) = + private fun Rex.type(locals: TypeEnv, strategy: Scope = Scope.LOCAL) = RexTyper(locals, strategy).visitRex(this, this.type) private fun rexErr(message: String) = rex(MISSING, rexOpErr(message)) @@ -1242,11 +1263,12 @@ internal class PlanTyper( is Identifier.Symbol -> BindingPath(listOf(this.toBindingName())) } - private fun Identifier.Qualified.toBindingPath() = BindingPath(steps = listOf(this.root.toBindingName()) + steps.map { it.toBindingName() }) + private fun Identifier.Qualified.toBindingPath() = + BindingPath(steps = listOf(this.root.toBindingName()) + steps.map { it.toBindingName() }) private fun Identifier.Symbol.toBindingName() = BindingName( name = symbol, - bindingCase = when (caseSensitivity) { + case = when (caseSensitivity) { Identifier.CaseSensitivity.SENSITIVE -> BindingCase.SENSITIVE Identifier.CaseSensitivity.INSENSITIVE -> BindingCase.INSENSITIVE } @@ -1268,28 +1290,6 @@ internal class PlanTyper( else -> fromSourceType } - /** - * Rewrites function arguments, wrapping in the given function if exists. - */ - private fun rewriteFnArgs(mapping: List, args: List): List { - if (mapping.size != args.size) { - error("Fatal, malformed function mapping") // should be unreachable given how a mapping is generated. - } - val newArgs = mutableListOf() - for (i in mapping.indices) { - var a = args[i] - val m = mapping[i] - if (m != null) { - // rewrite - val type = m.returns.toNonNullStaticType() - val cast = rexOpCallStatic(fnResolved(m), listOf(a)) - a = rex(type, cast) - } - newArgs.add(a) - } - return newArgs - } - private fun assertAsInt(type: StaticType) { if (type.flatten().allTypes.any { variant -> variant is IntType }.not()) { handleUnexpectedType(type, setOf(StaticType.INT)) @@ -1298,11 +1298,11 @@ internal class PlanTyper( // ERRORS - private fun handleUndefinedVariable(name: BindingName) { + private fun handleUndefinedVariable(id: Identifier) { + val publicId = id.toBindingPath() onProblem( Problem( - sourceLocation = UNKNOWN_PROBLEM_LOCATION, - details = PlanningProblemDetails.UndefinedVariable(name.name, name.bindingCase == BindingCase.SENSITIVE) + sourceLocation = UNKNOWN_PROBLEM_LOCATION, details = PlanningProblemDetails.UndefinedVariable(publicId) ) ) } @@ -1316,13 +1316,36 @@ internal class PlanTyper( ) } - private fun handleUnknownFunction(match: FnMatch.Error<*>) { + private fun handleUnknownCast(node: Rex.Op.Cast.Unresolved) { + onProblem( + Problem( + sourceLocation = UNKNOWN_PROBLEM_LOCATION, + details = PlanningProblemDetails.UnknownFunction( + identifier = "CAST( AS ${node.target})", args = listOf(node.arg.type) + ) + ) + ) + } + + private fun handleUnknownAggregation(node: Rel.Op.Aggregate.Call.Unresolved) { + onProblem( + Problem( + sourceLocation = UNKNOWN_PROBLEM_LOCATION, + details = PlanningProblemDetails.UnknownFunction( + identifier = node.name, + args = node.args.map { it.type } + ) + ) + ) + } + + private fun handleUnknownFunction(node: Rex.Op.Call.Unresolved, args: List) { onProblem( Problem( sourceLocation = UNKNOWN_PROBLEM_LOCATION, details = PlanningProblemDetails.UnknownFunction( - match.identifier.normalize(), - match.args.map { a -> a.type }, + identifier = node.identifier.debug(), + args = args.map { it.type } ) ) ) @@ -1341,51 +1364,21 @@ internal class PlanTyper( onProblem( Problem( sourceLocation = UNKNOWN_PROBLEM_LOCATION, - details = PlanningProblemDetails.UnresolvedExcludeExprRoot( - when (root) { - is Identifier.Symbol -> root.symbol - is Identifier.Qualified -> root.toString() - } - ) + details = PlanningProblemDetails.UnresolvedExcludeExprRoot(root.debug()) ) ) } // HELPERS - private fun Identifier.normalize(): String = when (this) { - is Identifier.Qualified -> (listOf(root.normalize()) + steps.map { it.normalize() }).joinToString(".") + private fun Identifier.debug(): String = when (this) { + is Identifier.Qualified -> (listOf(root.debug()) + steps.map { it.debug() }).joinToString(".") is Identifier.Symbol -> when (caseSensitivity) { - Identifier.CaseSensitivity.SENSITIVE -> symbol - Identifier.CaseSensitivity.INSENSITIVE -> symbol.lowercase() - } - } - - /** - * Indicates whether the given functions propagate Missing. - * - * Currently, Logical Functions : AND, OR, NOT, IS NULL, IS MISSING - * the equal function, function do not propagate Missing. - */ - private fun Fn.Unresolved.isNotMissable(): Boolean { - return when (identifier) { - is Identifier.Qualified -> false - is Identifier.Symbol -> when (identifier.symbol) { - "and" -> true - "or" -> true - "not" -> true - "eq" -> true - "is_null" -> true - "is_missing" -> true - else -> false - } + Identifier.CaseSensitivity.SENSITIVE -> "\"$symbol\"" + Identifier.CaseSensitivity.INSENSITIVE -> symbol } } - private fun Fn.Unresolved.isTypeAssertion(): Boolean { - return (identifier is Identifier.Symbol && identifier.symbol.startsWith("is")) - } - /** * This will make all binding values nullables. If the value is a struct, each field will be nullable. * @@ -1433,4 +1426,38 @@ internal class PlanTyper( Identifier.CaseSensitivity.SENSITIVE -> symbol.equals(other) Identifier.CaseSensitivity.INSENSITIVE -> symbol.equals(other, ignoreCase = true) } + + /** + * Pretty-print a path and its root type. + * + * @return + */ + private fun Rex.Op.Path.debug(): String { + val steps = mutableListOf() + var curr: Rex = rex(ANY, this) + while (true) { + curr = when (val op = curr.op) { + is Rex.Op.Path.Index -> { + steps.add("${op.key}") + op.root + } + is Rex.Op.Path.Key -> { + val k = op.key.op + if (k is Rex.Op.Lit && k.value is TextValue<*>) { + steps.add("${k.value.string}") + } else { + steps.add("${op.key}") + } + op.root + } + is Rex.Op.Path.Symbol -> { + steps.add(op.key) + op.root + } + else -> break + } + } + // curr is root + return "`${steps.joinToString(".")}` on root $curr" + } } diff --git a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/Scope.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/Scope.kt new file mode 100644 index 0000000000..42eda6d22d --- /dev/null +++ b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/Scope.kt @@ -0,0 +1,14 @@ +package org.partiql.planner.internal.typer + +/** + * Variable resolution strategies — https://partiql.org/assets/PartiQL-Specification.pdf#page=35 + * + * | Value | Strategy | Scoping Rules | + * |------------+-----------------------+---------------| + * | LOCAL | local-first lookup | Rules 1, 2 | + * | GLOBAL | global-first lookup | Rule 3 | + */ +internal enum class Scope { + LOCAL, + GLOBAL, +} 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 index d413abde04..f028d09fda 100644 --- 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 @@ -62,7 +62,7 @@ internal class TypeEnv(public val schema: List) { for (i in schema.indices) { val local = schema[i] val type = local.type - if (name.isEquivalentTo(local.name)) { + if (name.matches(local.name)) { if (r != null) { // TODO root was already matched, emit ambiguous error. return null @@ -114,24 +114,6 @@ internal class TypeEnv(public val schema: List) { 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]. * @@ -145,11 +127,33 @@ internal class TypeEnv(public val schema: List) { */ private fun StructType.containsKey(name: BindingName): Boolean? { for (f in fields) { - if (name.isEquivalentTo(f.key)) { + if (name.matches(f.key)) { return true } } val closed = constraints.contains(TupleConstraint.Open(false)) return if (closed) false else null } + + companion object { + + /** + * 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 + */ + @JvmStatic + @OptIn(PartiQLValueExperimental::class) + internal fun Rex.toPath(steps: List): Rex = steps.fold(this) { curr, step -> + val op = when (step.case) { + 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/TypeLattice.kt b/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeLattice.kt deleted file mode 100644 index 767dd91922..0000000000 --- a/partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/TypeLattice.kt +++ /dev/null @@ -1,375 +0,0 @@ -package org.partiql.planner.internal.typer - -import org.partiql.value.PartiQLValueExperimental -import org.partiql.value.PartiQLValueType -import org.partiql.value.PartiQLValueType.ANY -import org.partiql.value.PartiQLValueType.BAG -import org.partiql.value.PartiQLValueType.BINARY -import org.partiql.value.PartiQLValueType.BLOB -import org.partiql.value.PartiQLValueType.BOOL -import org.partiql.value.PartiQLValueType.BYTE -import org.partiql.value.PartiQLValueType.CHAR -import org.partiql.value.PartiQLValueType.CLOB -import org.partiql.value.PartiQLValueType.DATE -import org.partiql.value.PartiQLValueType.DECIMAL -import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY -import org.partiql.value.PartiQLValueType.FLOAT32 -import org.partiql.value.PartiQLValueType.FLOAT64 -import org.partiql.value.PartiQLValueType.INT -import org.partiql.value.PartiQLValueType.INT16 -import org.partiql.value.PartiQLValueType.INT32 -import org.partiql.value.PartiQLValueType.INT64 -import org.partiql.value.PartiQLValueType.INT8 -import org.partiql.value.PartiQLValueType.INTERVAL -import org.partiql.value.PartiQLValueType.LIST -import org.partiql.value.PartiQLValueType.MISSING -import org.partiql.value.PartiQLValueType.NULL -import org.partiql.value.PartiQLValueType.SEXP -import org.partiql.value.PartiQLValueType.STRING -import org.partiql.value.PartiQLValueType.STRUCT -import org.partiql.value.PartiQLValueType.SYMBOL -import org.partiql.value.PartiQLValueType.TIME -import org.partiql.value.PartiQLValueType.TIMESTAMP - -/** - * Going with a matrix here (using enum ordinals) as it's simple and avoids walking. - */ -internal typealias TypeGraph = Array> - -/** - * Each edge represents a type relationship - */ -internal data class TypeRelationship(val cast: CastType) - -/** - * An COERCION will be inserted by the compiler during function resolution, an EXPLICIT CAST will never be inserted. - * - * COERCION: Lossless CAST(V AS T) -> T - * EXPLICIT: Lossy CAST(V AS T) -> T - * UNSAFE: CAST(V AS T) -> T|MISSING - */ -internal enum class CastType { COERCION, EXPLICIT, UNSAFE } - -/** - * A place to model type relationships (for now this is to answer CAST inquiries). - * - * Is this indeed a lattice? It's a rather smart sounding word. - */ -@OptIn(PartiQLValueExperimental::class) -internal class TypeLattice private constructor( - public val types: Array, - public val graph: TypeGraph, -) { - - public fun canCoerce(operand: PartiQLValueType, target: PartiQLValueType): Boolean { - return graph[operand][target]?.cast == CastType.COERCION - } - - internal val all = PartiQLValueType.values() - - internal val nullable = listOf( - NULL, // null.null - MISSING, // missing - ) - - internal val integer = listOf( - INT8, - INT16, - INT32, - INT64, - INT, - ) - - internal val numeric = listOf( - INT8, - INT16, - INT32, - INT64, - INT, - DECIMAL_ARBITRARY, - FLOAT32, - FLOAT64, - ) - - internal val text = listOf( - STRING, - SYMBOL, - CLOB, - ) - - internal val collections = listOf( - BAG, - LIST, - SEXP, - ) - - internal val datetime = listOf( - DATE, - TIME, - TIMESTAMP, - ) - - /** - * Dump the graph as an Asciidoc table. - */ - override fun toString(): String = buildString { - appendLine("|===") - appendLine() - // Header - append("| | ").appendLine(types.joinToString("| ")) - // Body - for (t1 in types) { - append("| $t1 ") - for (t2 in types) { - val symbol = when (val r = graph[t1][t2]) { - null -> "X" - else -> when (r.cast) { - CastType.COERCION -> "⬤" - CastType.EXPLICIT -> "◯" - CastType.UNSAFE -> "△" - } - } - append("| $symbol ") - } - appendLine() - } - appendLine() - appendLine("|===") - } - - private operator fun Array.get(t: PartiQLValueType): T = get(t.ordinal) - - companion object { - - private val N = PartiQLValueType.values().size - - private fun relationships(vararg relationships: Pair): Array { - val arr = arrayOfNulls(N) - for (type in relationships) { - arr[type.first] = type.second - } - return arr - } - - private fun coercion(): TypeRelationship = TypeRelationship(CastType.COERCION) - - private fun explicit(): TypeRelationship = TypeRelationship(CastType.EXPLICIT) - - private fun unsafe(): TypeRelationship = TypeRelationship(CastType.UNSAFE) - - private operator fun Array.set(t: PartiQLValueType, value: T): Unit = this.set(t.ordinal, value) - - /** - * Build the PartiQL type lattice. - * - * TODO this is incomplete. - */ - public fun partiql(): TypeLattice { - val types = PartiQLValueType.values() - val graph = arrayOfNulls>(N) - for (type in types) { - // initialize all with empty relationships - graph[type] = arrayOfNulls(N) - } - graph[ANY] = relationships( - ANY to coercion() - ) - graph[NULL] = relationships( - NULL to coercion() - ) - graph[MISSING] = relationships( - MISSING to coercion() - ) - graph[BOOL] = relationships( - BOOL to coercion(), - INT8 to explicit(), - INT16 to explicit(), - INT32 to explicit(), - INT64 to explicit(), - INT to explicit(), - DECIMAL to explicit(), - DECIMAL_ARBITRARY to explicit(), - FLOAT32 to explicit(), - FLOAT64 to explicit(), - CHAR to explicit(), - STRING to explicit(), - SYMBOL to explicit(), - ) - graph[INT8] = relationships( - BOOL to explicit(), - INT8 to coercion(), - INT16 to coercion(), - INT32 to coercion(), - INT64 to coercion(), - INT to coercion(), - DECIMAL to explicit(), - DECIMAL_ARBITRARY to coercion(), - FLOAT32 to coercion(), - FLOAT64 to coercion(), - STRING to explicit(), - SYMBOL to explicit(), - ) - graph[INT16] = relationships( - BOOL to explicit(), - INT8 to unsafe(), - INT16 to coercion(), - INT32 to coercion(), - INT64 to coercion(), - INT to coercion(), - DECIMAL to explicit(), - DECIMAL_ARBITRARY to coercion(), - FLOAT32 to coercion(), - FLOAT64 to coercion(), - STRING to explicit(), - SYMBOL to explicit(), - ) - graph[INT32] = relationships( - BOOL to explicit(), - INT8 to unsafe(), - INT16 to unsafe(), - INT32 to coercion(), - INT64 to coercion(), - INT to coercion(), - DECIMAL to explicit(), - DECIMAL_ARBITRARY to coercion(), - FLOAT32 to coercion(), - FLOAT64 to coercion(), - STRING to explicit(), - SYMBOL to explicit(), - ) - graph[INT64] = relationships( - BOOL to explicit(), - INT8 to unsafe(), - INT16 to unsafe(), - INT32 to unsafe(), - INT64 to coercion(), - INT to coercion(), - DECIMAL to explicit(), - DECIMAL_ARBITRARY to coercion(), - FLOAT32 to coercion(), - FLOAT64 to coercion(), - STRING to explicit(), - SYMBOL to explicit(), - ) - graph[INT] = relationships( - BOOL to explicit(), - INT8 to unsafe(), - INT16 to unsafe(), - INT32 to unsafe(), - INT64 to unsafe(), - INT to coercion(), - DECIMAL to explicit(), - DECIMAL_ARBITRARY to coercion(), - FLOAT32 to coercion(), - FLOAT64 to coercion(), - STRING to explicit(), - SYMBOL to explicit(), - ) - graph[DECIMAL] = relationships( - BOOL 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 explicit(), - FLOAT64 to explicit(), - STRING to explicit(), - SYMBOL to explicit(), - ) - graph[DECIMAL_ARBITRARY] = relationships( - BOOL 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 explicit(), - FLOAT64 to explicit(), - STRING to explicit(), - SYMBOL to explicit(), - ) - graph[FLOAT32] = relationships( - BOOL 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[FLOAT64] = relationships( - BOOL to explicit(), - INT8 to unsafe(), - INT16 to unsafe(), - INT32 to unsafe(), - INT64 to unsafe(), - INT to unsafe(), - DECIMAL to unsafe(), - DECIMAL_ARBITRARY to coercion(), - FLOAT64 to coercion(), - STRING to explicit(), - SYMBOL to explicit(), - ) - graph[CHAR] = relationships( - BOOL to explicit(), - CHAR to coercion(), - STRING to coercion(), - SYMBOL to coercion(), - ) - graph[STRING] = relationships( - BOOL to explicit(), - INT8 to unsafe(), - INT16 to unsafe(), - INT32 to unsafe(), - INT64 to unsafe(), - INT to unsafe(), - STRING to coercion(), - SYMBOL to explicit(), - CLOB to coercion(), - ) - graph[SYMBOL] = relationships( - BOOL to explicit(), - STRING to coercion(), - SYMBOL to coercion(), - CLOB to coercion(), - ) - graph[CLOB] = relationships( - CLOB to coercion(), - ) - graph[BINARY] = arrayOfNulls(N) - graph[BYTE] = arrayOfNulls(N) - graph[BLOB] = arrayOfNulls(N) - graph[DATE] = arrayOfNulls(N) - graph[TIME] = arrayOfNulls(N) - graph[TIMESTAMP] = arrayOfNulls(N) - graph[INTERVAL] = arrayOfNulls(N) - graph[BAG] = relationships( - BAG to coercion(), - ) - graph[LIST] = relationships( - BAG to coercion(), - SEXP to coercion(), - LIST to coercion(), - ) - graph[SEXP] = relationships( - BAG to coercion(), - SEXP to coercion(), - LIST to coercion(), - ) - graph[STRUCT] = relationships( - STRUCT to coercion(), - ) - return TypeLattice(types, graph.requireNoNulls()) - } - } -} diff --git a/partiql-planner/src/main/resources/partiql_plan_internal.ion b/partiql-planner/src/main/resources/partiql_plan_internal.ion index 2e8aa6e3d0..cd122717b7 100644 --- a/partiql-planner/src/main/resources/partiql_plan_internal.ion +++ b/partiql-planner/src/main/resources/partiql_plan_internal.ion @@ -1,48 +1,48 @@ imports::{ kotlin: [ partiql_value::'org.partiql.value.PartiQLValue', + partiql_value_type::'org.partiql.value.PartiQLValueType', static_type::'org.partiql.types.StaticType', + fn_signature::'org.partiql.spi.fn.FnSignature', + agg_signature::'org.partiql.spi.fn.AggSignature', ], } parti_q_l_plan::{ - catalogs: list::[catalog], // (catalogs ...) statement: statement, // (statement ...) } -catalog::{ - name: string, - items: list::[item], - _: [ - item::[ - value::{ - path: list::[string], - type: static_type, - }, - fn::{ - path: list::[string], - specific: string, - }, - ] - ] -} - // Reference to some item in a catalog. - -ref::{ - catalog: int, - symbol: int -} - -// Functions - -fn::[ - resolved::{ - ref: ref, +// In the internal plan, we inline additional typing information. +// When transforming to the public plan we produce a symbol table, +// replacing each internal ref with a pointer ref to the public plan's catalog list. + +ref::[ + obj::{ + catalog: string, + path: list::[string], + type: static_type, }, - unresolved::{ - identifier: identifier, + fn::{ + catalog: string, + path: list::[string], + signature: fn_signature, }, + _::[ + cast::{ + input: partiql_value_type, + target: partiql_value_type, + safety: [ + COERCION, // Lossless CAST(V AS T) -> T + EXPLICIT, // Lossy CAST(V AS T) -> T + UNSAFE, // CAST(V AS T) -> T|MISSING + ] + }, + agg::{ + name: string, + signature: agg_signature, + }, + ] ] // Statements @@ -98,7 +98,7 @@ rex::{ ], global::{ - ref: ref, + ref: '.ref.obj', }, path::[ @@ -112,10 +112,27 @@ rex::{ symbol::{ root: rex, key: string }, ], + cast::[ + unresolved::{ + target: partiql_value_type, + arg: rex, + }, + resolved::{ + cast: '.ref.cast', + arg: rex, + } + ], + call::[ + + unresolved::{ + identifier: identifier, + args: list::[rex], + }, + static::{ - fn: fn, - args: list::[rex] + fn: '.ref.fn', + args: list::[rex], }, // Represents a dynamic function call. If all candidates are exhausted, dynamic calls will return MISSING. @@ -126,13 +143,14 @@ rex::{ dynamic::{ args: list::[rex], candidates: list::[candidate], + exhaustive: bool, _: [ candidate::{ - fn: fn, - coercions: list::[optional::fn] + fn: '.ref.fn', + coercions: list::[optional::'.ref.cast'], } ] - } + }, ], case::{ @@ -290,10 +308,16 @@ rel::{ calls: list::[call], groups: list::[rex], _: [ - call::{ - agg: fn, - args: list::[rex], - }, + call::[ + unresolved::{ + name: string, + args: list::[rex], + }, + resolved::{ + agg: '.ref.agg', + args: list::[rex], + }, + ] ], }, diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/HeaderTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/HeaderTest.kt deleted file mode 100644 index 47b98ca0f3..0000000000 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/HeaderTest.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.partiql.planner - -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.partiql.planner.internal.PartiQLHeader - -class HeaderTest { - - @Test - @Disabled - fun print() { - println(PartiQLHeader) - } -} diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/PlanTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/PlanTest.kt index 4bbae73928..2731bd9627 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/PlanTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/PlanTest.kt @@ -12,7 +12,14 @@ import org.partiql.planner.test.PartiQLTest import org.partiql.planner.test.PartiQLTestProvider import org.partiql.planner.util.PlanNodeEquivalentVisitor import org.partiql.planner.util.ProblemCollector +import org.partiql.plugins.memory.MemoryCatalog import org.partiql.plugins.memory.MemoryConnector +import org.partiql.plugins.memory.MemoryObject +import org.partiql.spi.BindingCase +import org.partiql.spi.BindingName +import org.partiql.spi.BindingPath +import org.partiql.spi.connector.ConnectorMetadata +import org.partiql.spi.connector.ConnectorSession import org.partiql.types.BagType import org.partiql.types.StaticType import org.partiql.types.StructType @@ -36,42 +43,45 @@ class PlanTest { val input = PartiQLTestProvider().apply { load() } - val metadata = MemoryConnector.Metadata.of( - "default.t" to BagType( - StructType( - listOf( - StructType.Field("a", StaticType.BOOL), - StructType.Field("b", StaticType.INT4), - StructType.Field("c", StaticType.STRING), - StructType.Field( - "d", - StructType( - listOf(StructType.Field("e", StaticType.STRING)), - contentClosed = true, - emptyList(), - setOf(TupleConstraint.Open(false)), - emptyMap() - ) - ), - StructType.Field("x", StaticType.ANY), - StructType.Field("z", StaticType.STRING), - StructType.Field("v", StaticType.STRING), + val type = BagType( + StructType( + listOf( + StructType.Field("a", StaticType.BOOL), + StructType.Field("b", StaticType.INT4), + StructType.Field("c", StaticType.STRING), + StructType.Field( + "d", + StructType( + listOf(StructType.Field("e", StaticType.STRING)), + contentClosed = true, + emptyList(), + setOf(TupleConstraint.Open(false)), + emptyMap() + ) ), - contentClosed = true, - emptyList(), - setOf(TupleConstraint.Open(false)), - emptyMap() - ) + StructType.Field("x", StaticType.ANY), + StructType.Field("z", StaticType.STRING), + StructType.Field("v", StaticType.STRING), + ), + contentClosed = true, + emptyList(), + setOf(TupleConstraint.Open(false)), + emptyMap() ) ) + val connectorSession = object : ConnectorSession { + override fun getQueryId(): String = "query-id" + override fun getUserId(): String = "user-id" + } + val session: (PartiQLTest.Key) -> PartiQLPlanner.Session = { key -> PartiQLPlanner.Session( queryId = key.toString(), userId = "user_id", currentCatalog = "default", currentDirectory = listOf(), - catalogs = mapOf("default" to metadata), + catalogs = mapOf("default" to buildMetadata("default")), instant = Instant.now(), ) } @@ -84,6 +94,20 @@ class PlanTest { planner.plan(ast, session(test.key), problemCollector) } + fun buildMetadata(catalogName: String): ConnectorMetadata { + val catalog = MemoryCatalog(catalogName) + // Insert binding + val name = BindingPath( + listOf( + BindingName("default", BindingCase.INSENSITIVE), + BindingName("a", BindingCase.INSENSITIVE), + ) + ) + val obj = MemoryObject(type) + catalog.insert(name, obj) + return MemoryConnector(catalog).getMetadata(connectorSession) + } + @TestFactory fun factory(): Stream { val r = root.toFile() 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 3f83b5b309..ad4c3ff29b 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 @@ -1,81 +1,65 @@ package org.partiql.planner.internal -import org.junit.jupiter.api.Assertions.assertNull -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.typer.TypeEnv -import org.partiql.plugins.local.LocalConnector -import org.partiql.spi.BindingCase -import org.partiql.spi.BindingName -import org.partiql.spi.BindingPath -import org.partiql.types.StaticType -import java.util.Random -import kotlin.io.path.toPath -import kotlin.test.assertEquals -import kotlin.test.assertNotNull - class EnvTest { - companion object { - - private val root = this::class.java.getResource("/catalogs/default/pql")!!.toURI().toPath() - - private val EMPTY_TYPE_ENV = TypeEnv(schema = emptyList()) - - private val GLOBAL_OS = Catalog( - name = "pql", - symbols = listOf( - Catalog.Symbol(path = listOf("main", "os"), type = StaticType.STRING) - ) - ) - } - - private lateinit var env: Env - - @BeforeEach - fun init() { - env = Env( - PartiQLPlanner.Session( - queryId = Random().nextInt().toString(), - userId = "test-user", - currentCatalog = "pql", - currentDirectory = listOf("main"), - catalogs = mapOf( - "pql" to LocalConnector.Metadata(root) - ), - ) - ) - } - - @Test - fun testGlobalMatchingSensitiveName() { - val path = BindingPath(listOf(BindingName("os", BindingCase.SENSITIVE))) - assertNotNull(env.resolve(path, EMPTY_TYPE_ENV, ResolutionStrategy.GLOBAL)) - assertEquals(1, env.catalogs.size) - assert(env.catalogs.contains(GLOBAL_OS)) - } - - @Test - fun testGlobalMatchingInsensitiveName() { - val path = BindingPath(listOf(BindingName("oS", BindingCase.INSENSITIVE))) - assertNotNull(env.resolve(path, EMPTY_TYPE_ENV, ResolutionStrategy.GLOBAL)) - assertEquals(1, env.catalogs.size) - assert(env.catalogs.contains(GLOBAL_OS)) - } - - @Test - fun testGlobalNotMatchingSensitiveName() { - val path = BindingPath(listOf(BindingName("oS", BindingCase.SENSITIVE))) - 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, ResolutionStrategy.GLOBAL)) - assert(env.catalogs.isEmpty()) - } + // companion object { + // + // private val root = this::class.java.getResource("/catalogs/default/pql")!!.toURI().toPath() + // + // private val EMPTY_TYPE_ENV = TypeEnv(schema = emptyList()) + // + // private val GLOBAL_OS = Catalog( + // name = "pql", + // symbols = listOf( + // Catalog.Symbol(path = listOf("main", "os"), type = StaticType.STRING) + // ) + // ) + // } + // + // private lateinit var env: Env + // + // @BeforeEach + // fun init() { + // env = Env( + // PartiQLPlanner.Session( + // queryId = Random().nextInt().toString(), + // userId = "test-user", + // currentCatalog = "pql", + // currentDirectory = listOf("main"), + // catalogs = mapOf( + // "pql" to LocalConnector.Metadata(root) + // ), + // ) + // ) + // } + // + // @Test + // fun testGlobalMatchingSensitiveName() { + // val path = BindingPath(listOf(BindingName("os", BindingCase.SENSITIVE))) + // assertNotNull(env.resolve(path, EMPTY_TYPE_ENV, Scope.GLOBAL)) + // assertEquals(1, env.catalogs.size) + // assert(env.catalogs.contains(GLOBAL_OS)) + // } + // + // @Test + // fun testGlobalMatchingInsensitiveName() { + // val path = BindingPath(listOf(BindingName("oS", BindingCase.INSENSITIVE))) + // assertNotNull(env.resolve(path, EMPTY_TYPE_ENV, Scope.GLOBAL)) + // assertEquals(1, env.catalogs.size) + // assert(env.catalogs.contains(GLOBAL_OS)) + // } + // + // @Test + // fun testGlobalNotMatchingSensitiveName() { + // val path = BindingPath(listOf(BindingName("oS", BindingCase.SENSITIVE))) + // assertNull(env.resolve(path, EMPTY_TYPE_ENV, Scope.GLOBAL)) + // assert(env.catalogs.isEmpty()) + // } + // + // @Test + // fun testGlobalNotMatchingInsensitiveName() { + // val path = BindingPath(listOf(BindingName("nonexistent", BindingCase.INSENSITIVE))) + // assertNull(env.resolve(path, EMPTY_TYPE_ENV, Scope.GLOBAL)) + // assert(env.catalogs.isEmpty()) + // } } diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/FunctionResolverTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/FnResolverTest.kt similarity index 52% rename from partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/FunctionResolverTest.kt rename to partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/FnResolverTest.kt index feda1cb2aa..763033fabf 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/FunctionResolverTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/FnResolverTest.kt @@ -2,9 +2,12 @@ package org.partiql.planner.internal.typer import org.junit.jupiter.api.Test import org.junit.jupiter.api.fail -import org.partiql.planner.internal.Header -import org.partiql.types.function.FunctionParameter -import org.partiql.types.function.FunctionSignature +import org.partiql.planner.internal.FnMatch +import org.partiql.planner.internal.FnResolver +import org.partiql.spi.fn.FnExperimental +import org.partiql.spi.fn.FnParameter +import org.partiql.spi.fn.FnSignature +import org.partiql.types.StaticType import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType @@ -13,69 +16,54 @@ import org.partiql.value.PartiQLValueType * We may be able to pretty-print with string equals to also simplify things. * Only the "types" of expressions matter, we ignore the underlying ops. */ -@OptIn(PartiQLValueExperimental::class) -class FunctionResolverTest { +@OptIn(PartiQLValueExperimental::class, FnExperimental::class) +class FnResolverTest { @Test fun sanity() { // 1 + 1.0 -> 2.0 - val fn = Header.binary( - name = "plus", - returns = PartiQLValueType.FLOAT64, - lhs = PartiQLValueType.FLOAT64, - rhs = PartiQLValueType.FLOAT64, - ) - val args = listOf( - FunctionParameter("arg-0", PartiQLValueType.INT32), - FunctionParameter("arg-1", PartiQLValueType.FLOAT64), + val variants = listOf( + FnSignature( + name = "plus", + returns = PartiQLValueType.FLOAT64, + parameters = listOf( + FnParameter("arg-0", PartiQLValueType.FLOAT64), + FnParameter("arg-1", PartiQLValueType.FLOAT64), + ), + ) ) + val args = listOf(StaticType.INT4, StaticType.FLOAT) val expectedImplicitCasts = listOf(true, false) - val case = Case.Success(fn, args, expectedImplicitCasts) + val case = Case.Success(variants, args, expectedImplicitCasts) case.assert() } @Test fun split() { - val args = listOf( - FunctionParameter("arg-0", PartiQLValueType.STRING), - FunctionParameter("arg-1", PartiQLValueType.STRING), + val variants = listOf( + FnSignature( + name = "split", + returns = PartiQLValueType.LIST, + parameters = listOf( + FnParameter("value", PartiQLValueType.STRING), + FnParameter("delimiter", PartiQLValueType.STRING), + ), + isNullable = false, + ) ) + val args = listOf(StaticType.STRING, StaticType.STRING) val expectedImplicitCasts = listOf(false, false) - val case = Case.Success(split, args, expectedImplicitCasts) + val case = Case.Success(variants, args, expectedImplicitCasts) case.assert() } - companion object { - - val split = FunctionSignature.Scalar( - name = "split", - returns = PartiQLValueType.LIST, - parameters = listOf( - FunctionParameter("value", PartiQLValueType.STRING), - FunctionParameter("delimiter", PartiQLValueType.STRING), - ), - isNullable = false, - ) - - private val myHeader = object : Header() { - - override val namespace: String = "my_header" - - override val functions: List = listOf( - split - ) - } - - private val resolver = FnResolver(myHeader) - } - private sealed class Case { abstract fun assert() class Success( - private val signature: FunctionSignature, - private val inputs: List, + private val variants: List, + private val inputs: List, private val expectedImplicitCast: List, ) : Case() { @@ -85,19 +73,26 @@ class FunctionResolverTest { * TODO actually look into what the CAST functions are. */ override fun assert() { - val mapping = resolver.match(signature, inputs) + val match = FnResolver.resolve(variants, inputs) val diffs = mutableListOf() val message = buildString { - appendLine("Given arguments did not match function signature") - appendLine(signature) + appendLine("Given arguments did not match any function signature") appendLine("Input: (${inputs.joinToString()}})") } - if (mapping == null || mapping.size != expectedImplicitCast.size) { + if (match == null) { fail { message } } + if (match !is FnMatch.Static) { + fail { "Dynamic match, expected static match: $message" } + } + + if (match.mapping.size != expectedImplicitCast.size) { + fail { "Mapping size does not match expected mapping size: $message" } + } + // compare args - for (i in mapping.indices) { - val m = mapping[i] + for (i in match.mapping.indices) { + val m = match.mapping[i] val shouldCast = expectedImplicitCast[i] val diff: String? = when { m == null && shouldCast -> "Arg[$i] is missing an implicit CAST" diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PartiQLTyperTestBase.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PartiQLTyperTestBase.kt index 7ad14eb2e7..132bf2b8a2 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PartiQLTyperTestBase.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PartiQLTyperTestBase.kt @@ -10,8 +10,14 @@ import org.partiql.planner.PartiQLPlanner import org.partiql.planner.test.PartiQLTest import org.partiql.planner.test.PartiQLTestProvider import org.partiql.planner.util.ProblemCollector +import org.partiql.plugins.memory.MemoryCatalog import org.partiql.plugins.memory.MemoryConnector +import org.partiql.plugins.memory.MemoryObject +import org.partiql.spi.BindingCase +import org.partiql.spi.BindingName +import org.partiql.spi.BindingPath import org.partiql.spi.connector.ConnectorMetadata +import org.partiql.spi.connector.ConnectorSession import org.partiql.types.StaticType import java.util.Random import java.util.stream.Stream @@ -42,6 +48,11 @@ abstract class PartiQLTyperTestBase { ) ) } + + internal val connectorSession = object : ConnectorSession { + override fun getQueryId(): String = "test" + override fun getUserId(): String = "test" + } } val inputs = PartiQLTestProvider().apply { load() } @@ -51,6 +62,22 @@ abstract class PartiQLTyperTestBase { planner.plan(ast, session(catalog, metadata), collector) } + /** + * Build a ConnectorMetadata instance from the list of types. + */ + private fun buildMetadata(catalog: String, types: List): ConnectorMetadata { + val cat = MemoryCatalog(catalog) + val connector = MemoryConnector(cat) + + // define all bindings + types.forEachIndexed { i, t -> + val binding = BindingPath(listOf(BindingName("t${i + 1}", BindingCase.SENSITIVE))) + val obj = MemoryObject(t) + cat.insert(binding, obj) + } + return connector.getMetadata(connectorSession) + } + fun testGen( testCategory: String, tests: List, @@ -62,13 +89,7 @@ abstract class PartiQLTyperTestBase { val children = argsMap.flatMap { (key, value) -> value.mapIndexed { index: Int, types: List -> val testName = "${testCategory}_${key}_$index" - val metadata = MemoryConnector.Metadata.of( - *( - types.mapIndexed { i, t -> - "t${i + 1}" to t - }.toTypedArray() - ) - ) + val metadata = buildMetadata(testName, types) val displayName = "$group | $testName | $types" val statement = test.statement // Assert diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTest.kt index 3645e13fa3..aff6a1e87f 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTest.kt @@ -5,8 +5,8 @@ import org.partiql.planner.PartiQLPlanner import org.partiql.planner.internal.Env import org.partiql.planner.internal.ir.Identifier import org.partiql.planner.internal.ir.Rex -import org.partiql.planner.internal.ir.catalogSymbolRef import org.partiql.planner.internal.ir.identifierSymbol +import org.partiql.planner.internal.ir.refObj import org.partiql.planner.internal.ir.rex import org.partiql.planner.internal.ir.rexOpGlobal import org.partiql.planner.internal.ir.rexOpLit @@ -189,7 +189,7 @@ class PlanTyperTest { private class PlanTyperWrapper( internal val typer: PlanTyper, - internal val collector: ProblemCollector + internal val collector: ProblemCollector, ) /** @@ -209,7 +209,9 @@ class PlanTyperTest { val wrapper = getTyper() val typer = wrapper.typer val input = statementQuery(LITERAL_STRUCT_1.pathSymbol("first_key").pathKey("sEcoNd_KEY")) - val expected = statementQuery(LITERAL_STRUCT_1_TYPED.pathKey("FiRsT_KeY", LITERAL_STRUCT_1_FIRST_KEY_TYPE).pathKey("sEcoNd_KEY", INT4)) + val expected = statementQuery( + LITERAL_STRUCT_1_TYPED.pathKey("FiRsT_KeY", LITERAL_STRUCT_1_FIRST_KEY_TYPE).pathKey("sEcoNd_KEY", INT4) + ) val actual = typer.resolve(input) assertEquals(expected, actual) @@ -222,7 +224,12 @@ class PlanTyperTest { val input = statementQuery( unresolvedSensitiveVar("closed_ordered_duplicates_struct").pathSymbol("DEFINITION") ) - val expected = statementQuery(global(ORDERED_DUPLICATES_STRUCT).pathKey("definition", STRING)) + val expected = statementQuery( + global( + type = ORDERED_DUPLICATES_STRUCT, + path = listOf("main", "closed_ordered_duplicates_struct"), + ).pathKey("definition", STRING) + ) val actual = typer.resolve(input) assertEquals(expected, actual) @@ -233,7 +240,12 @@ class PlanTyperTest { val wrapper = getTyper() val typer = wrapper.typer val input = statementQuery(unresolvedSensitiveVar("closed_ordered_duplicates_struct").pathKey("DEFINITION")) - val expected = statementQuery(global(ORDERED_DUPLICATES_STRUCT).pathKey("DEFINITION", DECIMAL)) + val expected = statementQuery( + global( + type = ORDERED_DUPLICATES_STRUCT, + path = listOf("main", "closed_ordered_duplicates_struct"), + ).pathKey("DEFINITION", DECIMAL) + ) val actual = typer.resolve(input) assertEquals(expected, actual) @@ -244,7 +256,15 @@ class PlanTyperTest { val wrapper = getTyper() val typer = wrapper.typer val input = statementQuery(unresolvedSensitiveVar("closed_duplicates_struct").pathSymbol("DEFINITION")) - val expected = statementQuery(global(DUPLICATES_STRUCT).pathSymbol("DEFINITION", StaticType.unionOf(STRING, FLOAT, DECIMAL))) + val expected = statementQuery( + global( + type = DUPLICATES_STRUCT, + path = listOf("main", "closed_duplicates_struct"), + ).pathSymbol( + "DEFINITION", + StaticType.unionOf(STRING, FLOAT, DECIMAL) + ) + ) val actual = typer.resolve(input) assertEquals(expected, actual) @@ -255,7 +275,12 @@ class PlanTyperTest { val wrapper = getTyper() val typer = wrapper.typer val input = statementQuery(unresolvedSensitiveVar("closed_duplicates_struct").pathKey("DEFINITION")) - val expected = statementQuery(global(DUPLICATES_STRUCT).pathKey("DEFINITION", DECIMAL)) + val expected = statementQuery( + global( + type = DUPLICATES_STRUCT, + path = listOf("main", "closed_duplicates_struct"), + ).pathKey("DEFINITION", DECIMAL) + ) val actual = typer.resolve(input) assertEquals(expected, actual) @@ -266,7 +291,15 @@ class PlanTyperTest { val wrapper = getTyper() val typer = wrapper.typer val input = statementQuery(unresolvedSensitiveVar("closed_duplicates_struct").pathKey("definition")) - val expected = statementQuery(global(DUPLICATES_STRUCT).pathKey("definition", StaticType.unionOf(StaticType.STRING, StaticType.FLOAT))) + val expected = statementQuery( + global( + type = DUPLICATES_STRUCT, + path = listOf("main", "closed_duplicates_struct"), + ).pathKey( + "definition", + StaticType.unionOf(StaticType.STRING, StaticType.FLOAT) + ) + ) val actual = typer.resolve(input) assertEquals(expected, actual) @@ -277,7 +310,12 @@ class PlanTyperTest { val wrapper = getTyper() val typer = wrapper.typer val input = statementQuery(unresolvedSensitiveVar("open_duplicates_struct").pathKey("definition")) - val expected = statementQuery(global(OPEN_DUPLICATES_STRUCT).pathKey("definition")) + val expected = statementQuery( + global( + type = OPEN_DUPLICATES_STRUCT, + path = listOf("main", "open_duplicates_struct"), + ).pathKey("definition") + ) val actual = typer.resolve(input) assertEquals(expected, actual) @@ -288,7 +326,15 @@ class PlanTyperTest { val wrapper = getTyper() val typer = wrapper.typer val input = statementQuery(unresolvedSensitiveVar("closed_union_duplicates_struct").pathSymbol("definition")) - val expected = statementQuery(global(CLOSED_UNION_DUPLICATES_STRUCT).pathSymbol("definition", StaticType.unionOf(STRING, FLOAT, DECIMAL, INT2))) + val expected = statementQuery( + global( + type = CLOSED_UNION_DUPLICATES_STRUCT, + path = listOf("main", "closed_union_duplicates_struct"), + ).pathSymbol( + "definition", + StaticType.unionOf(STRING, FLOAT, DECIMAL, INT2) + ) + ) val actual = typer.resolve(input) assertEquals(expected, actual) @@ -299,7 +345,15 @@ class PlanTyperTest { val wrapper = getTyper() val typer = wrapper.typer val input = statementQuery(unresolvedSensitiveVar("closed_union_duplicates_struct").pathKey("definition")) - val expected = statementQuery(global(CLOSED_UNION_DUPLICATES_STRUCT).pathKey("definition", StaticType.unionOf(STRING, FLOAT, INT2))) + val expected = statementQuery( + global( + type = CLOSED_UNION_DUPLICATES_STRUCT, + path = listOf("main", "closed_union_duplicates_struct"), + ).pathKey( + "definition", + StaticType.unionOf(STRING, FLOAT, INT2) + ) + ) val actual = typer.resolve(input) assertEquals(expected, actual) @@ -322,10 +376,10 @@ class PlanTyperTest { ) } - private fun global(type: StaticType, catalogIndex: Int = 0, symbolIndex: Int = 0): Rex { + private fun global(type: StaticType, path: List): Rex { return rex( type, - rexOpGlobal(catalogSymbolRef(catalogIndex, symbolIndex)) + rexOpGlobal(refObj(catalog = "pql", path = path, type)) ) } } 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 ad8114067c..93490e9460 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 @@ -25,15 +25,19 @@ import org.partiql.planner.test.PartiQLTest import org.partiql.planner.test.PartiQLTestProvider import org.partiql.planner.util.ProblemCollector import org.partiql.plugins.local.toStaticType +import org.partiql.plugins.memory.MemoryCatalog import org.partiql.plugins.memory.MemoryConnector +import org.partiql.plugins.memory.MemoryObject +import org.partiql.spi.BindingCase +import org.partiql.spi.BindingName +import org.partiql.spi.BindingPath import org.partiql.spi.connector.ConnectorMetadata +import org.partiql.spi.connector.ConnectorSession import org.partiql.types.AnyOfType -import org.partiql.types.AnyType 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 @@ -49,31 +53,32 @@ class PlanTyperTestsPorted { val name: String, val key: PartiQLTest.Key? = null, val query: String? = null, - val catalog: String? = null, + val catalog: String = "pql", val catalogPath: List = emptyList(), val expected: StaticType, val warnings: ProblemHandler? = null, ) : TestCase() { - override fun toString(): String = "$name : $query" + override fun toString(): String = "$name : ${query ?: key}" } class ErrorTestCase( val name: String, val key: PartiQLTest.Key? = null, val query: String? = null, - val catalog: String? = null, + val catalog: String = "pql", val catalogPath: List = emptyList(), val note: String? = null, val expected: StaticType? = null, val problemHandler: ProblemHandler? = null, ) : TestCase() { - override fun toString(): String = "$name : $query" + + override fun toString(): String = "$name : ${query ?: key}" } class ThrowingExceptionTestCase( val name: String, val query: String, - val catalog: String? = null, + val catalog: String = "pql", val catalogPath: List = emptyList(), val note: String? = null, val expectedThrowable: KClass, @@ -96,34 +101,44 @@ class PlanTyperTestsPorted { } } + val session = object : ConnectorSession { + override fun getQueryId(): String = "query-id" + override fun getUserId(): String = "user-id" + } + /** * MemoryConnector.Factory from reading the resources in /resource_path.txt for Github CI/CD. */ val catalogs: List> by lazy { val inputStream = this::class.java.getResourceAsStream("/resource_path.txt")!! - val map = mutableMapOf>>() + val map = mutableMapOf>>() inputStream.reader().readLines().forEach { path -> if (path.startsWith("catalogs/default")) { val schema = this::class.java.getResourceAsStream("/$path")!! val ion = loadSingleElement(schema.reader().readText()) val staticType = ion.toStaticType() - val steps = path.split('/').drop(2) // drop the catalogs/default + val steps = path.substring(0, path.length - 4).split('/').drop(2) // drop the catalogs/default val catalogName = steps.first() - val subPath = steps + val bindingSteps = steps .drop(1) - .joinToString(".") { it.lowercase() } - .let { - it.substring(0, it.length - 4) - } + .map { BindingName(it, BindingCase.INSENSITIVE) } + val bindingPath = BindingPath(bindingSteps) if (map.containsKey(catalogName)) { - map[catalogName]!!.add(subPath to staticType) + map[catalogName]!!.add(bindingPath to staticType) } else { - map[catalogName] = mutableListOf(subPath to staticType) + map[catalogName] = mutableListOf(bindingPath to staticType) } } } - map.entries.map { - it.key to MemoryConnector.Metadata.of(*it.value.toTypedArray()) + map.entries.map { (catalogName, bindings) -> + val catalog = MemoryCatalog(catalogName) + val connector = MemoryConnector(catalog) + for (binding in bindings) { + val path = binding.first + val obj = MemoryObject(binding.second) + catalog.insert(path, obj) + } + catalogName to connector.getMetadata(session) } } @@ -214,6 +229,8 @@ class PlanTyperTestsPorted { ) ) + private fun name(symbol: String) = BindingPath(listOf(BindingName(symbol, BindingCase.INSENSITIVE))) + // // Parameterized Test Source // @@ -455,31 +472,31 @@ class PlanTyperTestsPorted { name = "DECIMAL AS INT2", key = key("cast-00"), catalog = "pql", - expected = StaticType.INT2, + expected = StaticType.unionOf(StaticType.INT2, StaticType.MISSING), ), SuccessTestCase( name = "DECIMAL AS INT4", key = key("cast-01"), catalog = "pql", - expected = StaticType.INT4, + expected = StaticType.unionOf(StaticType.INT4, StaticType.MISSING), ), SuccessTestCase( name = "DECIMAL AS INT8", key = key("cast-02"), catalog = "pql", - expected = StaticType.INT8, + expected = StaticType.unionOf(StaticType.INT8, StaticType.MISSING), ), SuccessTestCase( name = "DECIMAL AS INT", key = key("cast-03"), catalog = "pql", - expected = StaticType.INT, + expected = StaticType.unionOf(StaticType.INT, StaticType.MISSING), ), SuccessTestCase( name = "DECIMAL AS BIGINT", key = key("cast-04"), catalog = "pql", - expected = StaticType.INT8, + expected = StaticType.unionOf(StaticType.INT8, StaticType.MISSING), ), SuccessTestCase( name = "DECIMAL_ARBITRARY AS DECIMAL", @@ -796,7 +813,7 @@ class PlanTyperTestsPorted { problemHandler = assertProblemExists { Problem( UNKNOWN_PROBLEM_LOCATION, - PlanningProblemDetails.UndefinedVariable("a", false) + PlanningProblemDetails.UndefinedVariable(name("a")) ) } ), @@ -2013,7 +2030,7 @@ class PlanTyperTestsPorted { problemHandler = assertProblemExists { Problem( UNKNOWN_PROBLEM_LOCATION, - PlanningProblemDetails.UndefinedVariable("unknown_col", false) + PlanningProblemDetails.UndefinedVariable(name("unknown_col")) ) } ), @@ -2533,7 +2550,7 @@ class PlanTyperTestsPorted { problemHandler = assertProblemExists { Problem( UNKNOWN_PROBLEM_LOCATION, - PlanningProblemDetails.UndefinedVariable("main", true) + PlanningProblemDetails.UndefinedVariable(name("main")) ) } ), @@ -2546,7 +2563,7 @@ class PlanTyperTestsPorted { problemHandler = assertProblemExists { Problem( UNKNOWN_PROBLEM_LOCATION, - PlanningProblemDetails.UndefinedVariable("pql", true) + PlanningProblemDetails.UndefinedVariable(name("pql")) ) } ), @@ -3130,7 +3147,7 @@ class PlanTyperTestsPorted { buildString { appendLine(collector.problems.toString()) appendLine() - PlanPrinter.append(this, statement) + PlanPrinter.append(this, plan) } } val actual = statement.root.type @@ -3140,7 +3157,7 @@ class PlanTyperTestsPorted { appendLine("Expect: ${tc.expected}") appendLine("Actual: $actual") appendLine() - PlanPrinter.append(this, statement) + PlanPrinter.append(this, plan) } } } @@ -3224,31 +3241,20 @@ class PlanTyperTestsPorted { name = "Pets should not be accessible #1", query = "SELECT * FROM pets", expected = BagType( - StaticType.unionOf( - StructType( - fields = emptyMap(), - contentClosed = false, - constraints = setOf( - TupleConstraint.Open(true), - TupleConstraint.UniqueAttrs(false), - ) - ), - StructType( - fields = mapOf( - "_1" to StaticType.ANY - ), - contentClosed = true, - constraints = setOf( - TupleConstraint.Open(false), - TupleConstraint.UniqueAttrs(true), - ) - ), - ) + StructType( + fields = emptyMap(), + contentClosed = true, + constraints = setOf( + TupleConstraint.Open(false), + TupleConstraint.UniqueAttrs(true), + TupleConstraint.Ordered, + ) + ), ), problemHandler = assertProblemExists { Problem( UNKNOWN_PROBLEM_LOCATION, - PlanningProblemDetails.UndefinedVariable("pets", false) + PlanningProblemDetails.UndefinedVariable(name("pets")) ) } ), @@ -3257,31 +3263,20 @@ class PlanTyperTestsPorted { catalog = CATALOG_AWS, query = "SELECT * FROM pets", expected = BagType( - StaticType.unionOf( - StructType( - fields = emptyMap(), - contentClosed = false, - constraints = setOf( - TupleConstraint.Open(true), - TupleConstraint.UniqueAttrs(false), - ) - ), - StructType( - fields = mapOf( - "_1" to StaticType.ANY - ), - contentClosed = true, - constraints = setOf( - TupleConstraint.Open(false), - TupleConstraint.UniqueAttrs(true), - ) - ), - ) + StructType( + fields = emptyMap(), + contentClosed = true, + constraints = setOf( + TupleConstraint.Open(false), + TupleConstraint.UniqueAttrs(true), + TupleConstraint.Ordered, + ) + ), ), problemHandler = assertProblemExists { Problem( UNKNOWN_PROBLEM_LOCATION, - PlanningProblemDetails.UndefinedVariable("pets", false) + PlanningProblemDetails.UndefinedVariable(name("pets")) ) } ), @@ -3324,31 +3319,27 @@ class PlanTyperTestsPorted { name = "Test #7", query = "SELECT * FROM ddb.pets", expected = BagType( - StaticType.unionOf( - StructType( - fields = emptyMap(), - contentClosed = false, - constraints = setOf( - TupleConstraint.Open(true), - TupleConstraint.UniqueAttrs(false), - ) - ), - StructType( - fields = mapOf( - "_1" to StaticType.ANY - ), - contentClosed = true, - constraints = setOf( - TupleConstraint.Open(false), - TupleConstraint.UniqueAttrs(true), - ) - ), - ) + StructType( + fields = emptyList(), + contentClosed = true, + constraints = setOf( + TupleConstraint.Open(false), + TupleConstraint.UniqueAttrs(true), + TupleConstraint.Ordered, + ) + ), ), problemHandler = assertProblemExists { Problem( UNKNOWN_PROBLEM_LOCATION, - PlanningProblemDetails.UndefinedVariable("pets", false) + PlanningProblemDetails.UndefinedVariable( + BindingPath( + steps = listOf( + BindingName("ddb", BindingCase.INSENSITIVE), + BindingName("pets", BindingCase.INSENSITIVE), + ) + ) + ) ) } ), @@ -3363,14 +3354,14 @@ class PlanTyperTestsPorted { catalog = CATALOG_B, catalogPath = listOf("b"), query = "b.b", - expected = TYPE_B_B_B + expected = TYPE_B_B_B_B ), TestCase.SuccessTestCase( name = "Test #12", catalog = CATALOG_AWS, catalogPath = listOf("ddb"), - query = "SELECT * FROM b.b", - expected = TABLE_AWS_B_B + query = "SELECT * FROM b", + expected = TABLE_AWS_DDB_B ), TestCase.SuccessTestCase( name = "Test #13", @@ -3394,7 +3385,7 @@ class PlanTyperTestsPorted { name = "Test #16", catalog = CATALOG_B, query = "b.b.b", - expected = TYPE_B_B_B + expected = TYPE_B_B_B_B ), TestCase.SuccessTestCase( name = "Test #17", @@ -3407,7 +3398,7 @@ class PlanTyperTestsPorted { catalog = CATALOG_B, catalogPath = listOf("b"), query = "b.b.b", - expected = TYPE_B_B_B + expected = TYPE_B_B_B_B_B ), TestCase.SuccessTestCase( name = "Test #19", @@ -3423,20 +3414,20 @@ class PlanTyperTestsPorted { name = "Test #21", catalog = CATALOG_B, query = "b.b.b.b", - expected = TYPE_B_B_B_B + expected = TYPE_B_B_B_B_B ), SuccessTestCase( name = "Test #22", catalog = CATALOG_B, - query = "b.b.b.c", - expected = TYPE_B_B_C + query = "b.b.c", + expected = TYPE_B_B_B_C ), SuccessTestCase( name = "Test #23", catalog = CATALOG_B, catalogPath = listOf("b"), - query = "b.b.b.b", - expected = TYPE_B_B_B_B + query = "b.b.b", + expected = TYPE_B_B_B_B_B ), SuccessTestCase( name = "Test #24", @@ -3444,9 +3435,9 @@ class PlanTyperTestsPorted { expected = TYPE_B_B_B_B_B ), SuccessTestCase( - name = "Test #24", + name = "Test #25", catalog = CATALOG_B, - query = "b.b.b.b.b", + query = "b.b.b.b", expected = TYPE_B_B_B_B_B ), SuccessTestCase( @@ -3577,7 +3568,7 @@ class PlanTyperTestsPorted { catalog = CATALOG_DB, catalogPath = DB_SCHEMA_MARKETS, query = "order_info.\"CUSTOMER_ID\" = 1", - expected = StaticType.NULL + expected = StaticType.MISSING ), SuccessTestCase( name = "Case Sensitive success", @@ -3614,11 +3605,11 @@ class PlanTyperTestsPorted { query = "non_existing_column = 1", // Function resolves to EQ__ANY_ANY__BOOL // Which can return BOOL Or NULL - expected = StaticType.unionOf(StaticType.BOOL, StaticType.NULL), + expected = StaticType.MISSING, problemHandler = assertProblemExists { Problem( UNKNOWN_PROBLEM_LOCATION, - PlanningProblemDetails.UndefinedVariable("non_existing_column", false) + PlanningProblemDetails.UndefinedVariable(name("non_existing_column")) ) } ), @@ -3661,7 +3652,7 @@ class PlanTyperTestsPorted { query = "SELECT unknown_col FROM orders WHERE customer_id = 1", expected = BagType( StructType( - fields = mapOf("unknown_col" to AnyType()), + fields = emptyList(), contentClosed = true, constraints = setOf( TupleConstraint.Open(false), @@ -3673,7 +3664,7 @@ class PlanTyperTestsPorted { problemHandler = assertProblemExists { Problem( UNKNOWN_PROBLEM_LOCATION, - PlanningProblemDetails.UndefinedVariable("unknown_col", false) + PlanningProblemDetails.UndefinedVariable(name("unknown_col")) ) } ), diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/TypeLatticeTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/TypeLatticeTest.kt deleted file mode 100644 index 9d02aaa66a..0000000000 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/TypeLatticeTest.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.partiql.planner.internal.typer - -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -class TypeLatticeTest { - - @Test - @Disabled - fun latticeAsciidocDump() { - // this test only exists for dumping the type lattice as Asciidoc - println(TypeLattice.partiql()) - } -} diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/util/PlanNodeEquivalentVisitor.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/util/PlanNodeEquivalentVisitor.kt index 04179370b6..31ae7d401d 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/util/PlanNodeEquivalentVisitor.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/util/PlanNodeEquivalentVisitor.kt @@ -1,8 +1,5 @@ package org.partiql.planner.util -import org.partiql.plan.Agg -import org.partiql.plan.Catalog -import org.partiql.plan.Fn import org.partiql.plan.Identifier import org.partiql.plan.PlanNode import org.partiql.plan.Rel @@ -16,42 +13,42 @@ import org.partiql.value.PartiQLValueExperimental class PlanNodeEquivalentVisitor : PlanBaseVisitor() { override fun visit(node: PlanNode, ctx: PlanNode): Boolean = node.accept(this, ctx) - override fun visitCatalog(node: Catalog, ctx: PlanNode): Boolean { - if (!super.visitCatalog(node, ctx)) return false - ctx as Catalog - if (node.name != ctx.name) return false - return true - } - - override fun visitCatalogSymbol(node: Catalog.Symbol, ctx: PlanNode): Boolean { - if (!super.visitCatalogSymbol(node, ctx)) return false - ctx as Catalog.Symbol - if (node.path != ctx.path) return false - if (node.type != ctx.type) return false - return true - } - - override fun visitCatalogSymbolRef(node: Catalog.Symbol.Ref, ctx: PlanNode): Boolean { - if (!super.visitCatalogSymbolRef(node, ctx)) return false - ctx as Catalog.Symbol.Ref - if (node.catalog != ctx.catalog) return false - if (node.symbol != ctx.symbol) return false - return true - } - - override fun visitFn(node: Fn, ctx: PlanNode): Boolean { - if (!super.visitFn(node, ctx)) return false - ctx as Fn - if (node.signature != ctx.signature) return false - return true - } - - override fun visitAgg(node: Agg, ctx: PlanNode): Boolean { - if (!super.visitAgg(node, ctx)) return false - ctx as Agg - if (node.signature != ctx.signature) return false - return true - } + // override fun visitCatalog(node: Catalog, ctx: PlanNode): Boolean { + // if (!super.visitCatalog(node, ctx)) return false + // ctx as Catalog + // if (node.name != ctx.name) return false + // return true + // } + // + // override fun visitCatalogSymbol(node: Catalog.Symbol, ctx: PlanNode): Boolean { + // if (!super.visitCatalogSymbol(node, ctx)) return false + // ctx as Catalog.Symbol + // if (node.path != ctx.path) return false + // if (node.type != ctx.type) return false + // return true + // } + // + // override fun visitCatalogSymbolRef(node: Catalog.Symbol.Ref, ctx: PlanNode): Boolean { + // if (!super.visitCatalogSymbolRef(node, ctx)) return false + // ctx as Catalog.Symbol.Ref + // if (node.catalog != ctx.catalog) return false + // if (node.symbol != ctx.symbol) return false + // return true + // } + // + // override fun visitFn(node: Fn, ctx: PlanNode): Boolean { + // if (!super.visitFn(node, ctx)) return false + // ctx as Fn + // if (node.signature != ctx.signature) return false + // return true + // } + // + // override fun visitAgg(node: Agg, ctx: PlanNode): Boolean { + // if (!super.visitAgg(node, ctx)) return false + // ctx as Agg + // if (node.signature != ctx.signature) return false + // return true + // } override fun visitIdentifierSymbol(node: Identifier.Symbol, ctx: PlanNode): Boolean { if (!super.visitIdentifierSymbol(node, ctx)) return false diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorFn.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorFn.kt index 67b99ea03e..acb8c81094 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorFn.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorFn.kt @@ -21,9 +21,9 @@ import org.partiql.spi.fn.FnSignature public interface ConnectorFn { /** - * Returns a function's type. + * Returns a function's variants. * * @return */ - public fun getType(): FnSignature + public fun getVariants(): List } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorFnProvider.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorFnProvider.kt index 708221623e..68dcf08b60 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorFnProvider.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorFnProvider.kt @@ -14,9 +14,8 @@ package org.partiql.spi.connector -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental -import org.partiql.spi.fn.FnScalar /** * A [ConnectorFnProvider] implementation is responsible for providing a function implementation given a handle. @@ -24,7 +23,5 @@ import org.partiql.spi.fn.FnScalar @FnExperimental public interface ConnectorFnProvider { - public fun getFnScalar(handle: ConnectorHandle.Fn): FnScalar? - - public fun getFnAggregation(handle: ConnectorHandle.Fn): FnAggregation? + public fun getFn(handle: ConnectorHandle.Fn, specific: String): Fn? } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorMetadata.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorMetadata.kt index ccc35d2cb7..77dea443c9 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorMetadata.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorMetadata.kt @@ -45,5 +45,5 @@ public interface ConnectorMetadata { * @return */ @FnExperimental - public fun getFunctions(path: BindingPath): List + public fun getFunction(path: BindingPath): ConnectorHandle.Fn? } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorObject.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorObject.kt index 4e4f1cae44..c2eb134594 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorObject.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/ConnectorObject.kt @@ -30,5 +30,5 @@ public interface ConnectorObject { * * @return */ - public fun getType(): StaticType? + public fun getType(): StaticType } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlBuiltins.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlBuiltins.kt index 5ddba714fa..f54adafc61 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlBuiltins.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlBuiltins.kt @@ -1,465 +1,18 @@ package org.partiql.spi.connector.sql -// I could not find a good way to disable the wildcard restriction under ktlint 0.42.1 -// on their doc, it seems like we can suppress the wildcard import from 0.47.0 onward -// but upgrade ktlint will change a large number of files ... -// leaving those as is for now -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_ANY__BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_AVG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_AVG__FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_AVG__FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_AVG__INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_AVG__INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_AVG__INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_AVG__INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_AVG__INT__INT -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_COUNT_STAR____INT32 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_COUNT__ANY__INT32 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_EVERY__BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MAX__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MAX__FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MAX__FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MAX__INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MAX__INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MAX__INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MAX__INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MAX__INT__INT -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MIN__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MIN__FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MIN__FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MIN__INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MIN__INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MIN__INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MIN__INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_MIN__INT__INT -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_SOME__BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_SUM__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_SUM__FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_SUM__FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_SUM__INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_SUM__INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_SUM__INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_SUM__INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.agg.Agg_SUM__INT__INT -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_AND__BOOL_BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_AND__BOOL_MISSING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_AND__MISSING_BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_AND__MISSING_MISSING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__CLOB_CLOB_CLOB__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__DATE_DATE_DATE__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__FLOAT32_FLOAT32_FLOAT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__FLOAT64_FLOAT64_FLOAT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__INT16_INT16_INT16__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__INT32_INT32_INT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__INT64_INT64_INT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__INT8_INT8_INT8__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__INT_INT_INT__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__STRING_STRING_STRING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__SYMBOL_SYMBOL_SYMBOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__TIMESTAMP_TIMESTAMP_TIMESTAMP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BETWEEN__TIME_TIME_TIME__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BITWISE_AND__INT16_INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BITWISE_AND__INT32_INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BITWISE_AND__INT64_INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BITWISE_AND__INT8_INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_BITWISE_AND__INT_INT__INT -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_CONCAT__CLOB_CLOB__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_CONCAT__STRING_STRING__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_CONCAT__SYMBOL_SYMBOL__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_CURRENT_DATE____DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_CURRENT_USER____STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_DAY__INT32_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_DAY__INT32_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_DAY__INT32_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_DAY__INT64_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_DAY__INT64_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_DAY__INT64_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_DAY__INT_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_DAY__INT_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_DAY__INT_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_HOUR__INT32_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_HOUR__INT32_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_HOUR__INT32_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_HOUR__INT64_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_HOUR__INT64_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_HOUR__INT64_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_HOUR__INT_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_HOUR__INT_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_HOUR__INT_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MINUTE__INT32_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MINUTE__INT32_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MINUTE__INT32_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MINUTE__INT64_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MINUTE__INT64_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MINUTE__INT64_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MINUTE__INT_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MINUTE__INT_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MINUTE__INT_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MONTH__INT32_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MONTH__INT32_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MONTH__INT32_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MONTH__INT64_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MONTH__INT64_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MONTH__INT64_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MONTH__INT_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MONTH__INT_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_MONTH__INT_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_SECOND__INT32_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_SECOND__INT32_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_SECOND__INT32_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_SECOND__INT64_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_SECOND__INT64_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_SECOND__INT64_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_SECOND__INT_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_SECOND__INT_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_SECOND__INT_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_YEAR__INT32_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_YEAR__INT32_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_YEAR__INT32_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_YEAR__INT64_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_YEAR__INT64_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_YEAR__INT64_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_YEAR__INT_DATE__DATE -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_YEAR__INT_TIMESTAMP__TIMESTAMP -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_ADD_YEAR__INT_TIME__TIME -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_DAY__DATE_DATE__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_DAY__TIMESTAMP_TIMESTAMP__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_DAY__TIME_TIME__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_HOUR__DATE_DATE__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_HOUR__TIMESTAMP_TIMESTAMP__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_HOUR__TIME_TIME__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_MINUTE__DATE_DATE__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_MINUTE__TIMESTAMP_TIMESTAMP__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_MINUTE__TIME_TIME__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_MONTH__DATE_DATE__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_MONTH__TIMESTAMP_TIMESTAMP__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_MONTH__TIME_TIME__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_SECOND__DATE_DATE__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_SECOND__TIMESTAMP_TIMESTAMP__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_SECOND__TIME_TIME__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_YEAR__DATE_DATE__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_YEAR__TIMESTAMP_TIMESTAMP__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DATE_DIFF_YEAR__TIME_TIME__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DIVIDE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DIVIDE__FLOAT32_FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DIVIDE__FLOAT64_FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DIVIDE__INT16_INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DIVIDE__INT32_INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DIVIDE__INT64_INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DIVIDE__INT8_INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_DIVIDE__INT_INT__INT -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__ANY_ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__BAG_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__BINARY_BINARY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__BLOB_BLOB__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__BOOL_BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__BYTE_BYTE__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__CHAR_CHAR__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__CLOB_CLOB__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__DATE_DATE__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__DECIMAL_DECIMAL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__FLOAT32_FLOAT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__FLOAT64_FLOAT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__INT16_INT16__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__INT32_INT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__INT64_INT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__INT8_INT8__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__INTERVAL_INTERVAL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__INT_INT__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__LIST_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__MISSING_MISSING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__NULL_NULL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__SEXP_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__STRING_STRING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__STRUCT_STRUCT__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__SYMBOL_SYMBOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__TIMESTAMP_TIMESTAMP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_EQ__TIME_TIME__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__BOOL_BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__CLOB_CLOB__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__DATE_DATE__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__FLOAT32_FLOAT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__FLOAT64_FLOAT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__INT16_INT16__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__INT32_INT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__INT64_INT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__INT8_INT8__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__INT_INT__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__STRING_STRING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__SYMBOL_SYMBOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__TIMESTAMP_TIMESTAMP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GTE__TIME_TIME__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__BOOL_BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__CLOB_CLOB__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__DATE_DATE__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__FLOAT32_FLOAT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__FLOAT64_FLOAT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__INT16_INT16__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__INT32_INT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__INT64_INT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__INT8_INT8__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__INT_INT__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__STRING_STRING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__SYMBOL_SYMBOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__TIMESTAMP_TIMESTAMP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_GT__TIME_TIME__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__ANY_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__ANY_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__ANY_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BAG_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BAG_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BAG_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BINARY_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BINARY_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BINARY_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BLOB_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BLOB_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BLOB_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BOOL_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BOOL_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BOOL_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BYTE_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BYTE_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__BYTE_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__CHAR_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__CHAR_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__CHAR_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__CLOB_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__CLOB_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__CLOB_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__DATE_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__DATE_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__DATE_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__DECIMAL_ARBITRARY_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__DECIMAL_ARBITRARY_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__DECIMAL_ARBITRARY_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__DECIMAL_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__DECIMAL_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__DECIMAL_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__FLOAT32_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__FLOAT32_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__FLOAT32_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__FLOAT64_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__FLOAT64_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__FLOAT64_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT16_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT16_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT16_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT32_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT32_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT32_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT64_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT64_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT64_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT8_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT8_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT8_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INTERVAL_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INTERVAL_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INTERVAL_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__INT_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__LIST_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__LIST_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__LIST_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__MISSING_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__MISSING_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__MISSING_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__NULL_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__NULL_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__NULL_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__SEXP_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__SEXP_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__SEXP_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__STRING_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__STRING_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__STRING_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__STRUCT_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__STRUCT_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__STRUCT_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__SYMBOL_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__SYMBOL_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__SYMBOL_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__TIMESTAMP_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__TIMESTAMP_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__TIMESTAMP_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__TIME_BAG__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__TIME_LIST__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IN_COLLECTION__TIME_SEXP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_ANY__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_BAG__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_BINARY__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_BLOB__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_BOOL__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_BYTE__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_CHAR__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_CHAR__INT32_ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_CLOB__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_DATE__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_DECIMAL_ARBITRARY__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_DECIMAL__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_DECIMAL__INT32_INT32_ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_FLOAT32__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_FLOAT64__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_INT16__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_INT32__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_INT64__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_INT8__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_INTERVAL__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_INT__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_LIST__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_MISSING__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_NULL__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_SEXP__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_STRING__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_STRING__INT32_ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_STRUCT__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_SYMBOL__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_TIMESTAMP__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_TIMESTAMP__BOOL_INT32_ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_TIME__ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_IS_TIME__BOOL_INT32_ANY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LIKE_ESCAPE__CLOB_CLOB_CLOB__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LIKE_ESCAPE__STRING_STRING_STRING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LIKE_ESCAPE__SYMBOL_SYMBOL_SYMBOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LIKE__CLOB_CLOB__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LIKE__STRING_STRING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LIKE__SYMBOL_SYMBOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LOWER__CLOB__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LOWER__STRING__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LOWER__SYMBOL__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__BOOL_BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__CLOB_CLOB__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__DATE_DATE__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__FLOAT32_FLOAT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__FLOAT64_FLOAT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__INT16_INT16__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__INT32_INT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__INT64_INT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__INT8_INT8__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__INT_INT__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__STRING_STRING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__SYMBOL_SYMBOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__TIMESTAMP_TIMESTAMP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LTE__TIME_TIME__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__BOOL_BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__CLOB_CLOB__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__DATE_DATE__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__FLOAT32_FLOAT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__FLOAT64_FLOAT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__INT16_INT16__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__INT32_INT32__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__INT64_INT64__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__INT8_INT8__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__INT_INT__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__STRING_STRING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__SYMBOL_SYMBOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__TIMESTAMP_TIMESTAMP__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_LT__TIME_TIME__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MINUS__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MINUS__FLOAT32_FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MINUS__FLOAT64_FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MINUS__INT16_INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MINUS__INT32_INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MINUS__INT64_INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MINUS__INT8_INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MINUS__INT_INT__INT -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MODULO__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MODULO__FLOAT32_FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MODULO__FLOAT64_FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MODULO__INT16_INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MODULO__INT32_INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MODULO__INT64_INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MODULO__INT8_INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_MODULO__INT_INT__INT -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_NEG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_NEG__FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_NEG__FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_NEG__INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_NEG__INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_NEG__INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_NEG__INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_NEG__INT__INT -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_NOT__BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_NOT__MISSING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_OR__BOOL_BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_OR__BOOL_MISSING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_OR__MISSING_BOOL__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_OR__MISSING_MISSING__BOOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_PLUS__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_PLUS__FLOAT32_FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_PLUS__FLOAT64_FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_PLUS__INT16_INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_PLUS__INT32_INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_PLUS__INT64_INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_PLUS__INT8_INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_PLUS__INT_INT__INT -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POSITION__CLOB_CLOB__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POSITION__STRING_STRING__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POSITION__SYMBOL_SYMBOL__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POS__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POS__FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POS__FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POS__INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POS__INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POS__INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POS__INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_POS__INT__INT -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_SUBSTRING__CLOB_INT64_INT64__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_SUBSTRING__CLOB_INT64__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_SUBSTRING__STRING_INT64_INT64__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_SUBSTRING__STRING_INT64__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_SUBSTRING__SYMBOL_INT64_INT64__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_SUBSTRING__SYMBOL_INT64__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TIMES__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TIMES__FLOAT32_FLOAT32__FLOAT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TIMES__FLOAT64_FLOAT64__FLOAT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TIMES__INT16_INT16__INT16 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TIMES__INT32_INT32__INT32 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TIMES__INT64_INT64__INT64 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TIMES__INT8_INT8__INT8 -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TIMES__INT_INT__INT -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_CHARS__CLOB_CLOB__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_CHARS__STRING_STRING__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_CHARS__SYMBOL_SYMBOL__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_LEADING_CHARS__CLOB_CLOB__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_LEADING_CHARS__STRING_STRING__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_LEADING_CHARS__SYMBOL_SYMBOL__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_LEADING__CLOB__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_LEADING__STRING__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_LEADING__SYMBOL__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_TRAILING_CHARS__CLOB_CLOB__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_TRAILING_CHARS__STRING_STRING__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_TRAILING_CHARS__SYMBOL_SYMBOL__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_TRAILING__CLOB__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_TRAILING__STRING__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM_TRAILING__SYMBOL__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM__CLOB__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM__STRING__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_TRIM__SYMBOL__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_UPPER__CLOB__CLOB -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_UPPER__STRING__STRING -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_UPPER__SYMBOL__SYMBOL -import org.partiql.spi.connector.sql.internal.builtins.scalar.Fn_UTCNOW____TIMESTAMP +/* ktlint-disable no-wildcard-imports */ +import org.partiql.spi.connector.sql.builtins.* import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental -import org.partiql.value.PartiQLValueExperimental /** * This is where we will register all SQL builtins. For now, we wrap the generated header to keep the diff small. */ -@OptIn(PartiQLValueExperimental::class, FnExperimental::class) +@OptIn(FnExperimental::class) internal object SqlBuiltins { @JvmStatic - private val scalars: List = listOf( + val builtins: List = listOf( Fn_POS__INT8__INT8, Fn_POS__INT16__INT16, Fn_POS__INT32__INT32, @@ -942,10 +495,4 @@ internal object SqlBuiltins { Fn_CURRENT_USER____STRING, Fn_CURRENT_DATE____DATE ) - - @JvmStatic - private val aggregations: List = listOf(Agg_EVERY__BOOL__BOOL, Agg_ANY__BOOL__BOOL, Agg_SOME__BOOL__BOOL, Agg_COUNT__ANY__INT32, Agg_COUNT_STAR____INT32, Agg_MIN__INT8__INT8, Agg_MIN__INT16__INT16, Agg_MIN__INT32__INT32, Agg_MIN__INT64__INT64, Agg_MIN__INT__INT, Agg_MIN__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, Agg_MIN__FLOAT32__FLOAT32, Agg_MIN__FLOAT64__FLOAT64, Agg_MAX__INT8__INT8, Agg_MAX__INT16__INT16, Agg_MAX__INT32__INT32, Agg_MAX__INT64__INT64, Agg_MAX__INT__INT, Agg_MAX__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, Agg_MAX__FLOAT32__FLOAT32, Agg_MAX__FLOAT64__FLOAT64, Agg_SUM__INT8__INT8, Agg_SUM__INT16__INT16, Agg_SUM__INT32__INT32, Agg_SUM__INT64__INT64, Agg_SUM__INT__INT, Agg_SUM__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, Agg_SUM__FLOAT32__FLOAT32, Agg_SUM__FLOAT64__FLOAT64, Agg_AVG__INT8__INT8, Agg_AVG__INT16__INT16, Agg_AVG__INT32__INT32, Agg_AVG__INT64__INT64, Agg_AVG__INT__INT, Agg_AVG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY, Agg_AVG__FLOAT32__FLOAT32, Agg_AVG__FLOAT64__FLOAT64) - - @JvmStatic - val builtins: List = scalars + aggregations } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlConnector.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlConnector.kt index 0285078ec5..15e2f3c032 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlConnector.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlConnector.kt @@ -39,15 +39,10 @@ public abstract class SqlConnector : Connector { * @param session * @return */ - override fun getMetadata(session: ConnectorSession): ConnectorMetadata { - val delegate = getSqlMetadata(session) - return SqlMetadata(session, info, delegate) - } + abstract override fun getMetadata(session: ConnectorSession): SqlMetadata override fun getBindings(): ConnectorBindings = SqlBindings(info) @FnExperimental override fun getFunctions(): ConnectorFnProvider = SqlFnProvider(info.functions) - - public abstract fun getSqlMetadata(session: ConnectorSession): ConnectorMetadata } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlFn.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlFn.kt index 2c10529711..11a90e42cc 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlFn.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlFn.kt @@ -21,12 +21,14 @@ import org.partiql.spi.fn.FnSignature /** * Simple [ConnectorFn] implementation wrapping a signature. * - * @property signature + * @property name + * @property variants */ @OptIn(FnExperimental::class) public class SqlFn( - private val signature: FnSignature, + private val name: String, + private val variants: List, ) : ConnectorFn { - override fun getType(): FnSignature = signature + override fun getVariants(): List = variants } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlFnProvider.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlFnProvider.kt index 29397d258c..2fb35e89be 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlFnProvider.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlFnProvider.kt @@ -16,10 +16,9 @@ package org.partiql.spi.connector.sql import org.partiql.spi.connector.ConnectorFnProvider import org.partiql.spi.connector.ConnectorHandle -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnIndex -import org.partiql.spi.fn.FnScalar /** * A basic [ConnectorFnProvider] over an [FnIndex]. @@ -27,17 +26,9 @@ import org.partiql.spi.fn.FnScalar @OptIn(FnExperimental::class) public class SqlFnProvider(private val index: FnIndex) : ConnectorFnProvider { - override fun getFnScalar(handle: ConnectorHandle.Fn): FnScalar? { + override fun getFn(handle: ConnectorHandle.Fn, specific: String): Fn? { val path = handle.path - val type = handle.entity.getType() - val fn = index.get(path, type.specific) - return if (fn is FnScalar) fn else null - } - - override fun getFnAggregation(handle: ConnectorHandle.Fn): FnAggregation? { - val path = handle.path - val type = handle.entity.getType() - val fn = index.get(path, type.specific) - return if (fn is FnAggregation) fn else null + val fn = index.get(path, specific) + return if (fn is Fn) fn else null } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlMetadata.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlMetadata.kt index 9179d210ee..3bcdd9214e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlMetadata.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/SqlMetadata.kt @@ -26,12 +26,10 @@ import org.partiql.spi.fn.FnExperimental * * @property session * @property info - * @property delegate */ -public class SqlMetadata( +public open class SqlMetadata( private val session: ConnectorSession, private val info: InfoSchema, - private val delegate: ConnectorMetadata, ) : ConnectorMetadata { /** @@ -40,13 +38,16 @@ public class SqlMetadata( * @param path * @return */ - override fun getObject(path: BindingPath): ConnectorHandle.Obj? = delegate.getObject(path) + override fun getObject(path: BindingPath): ConnectorHandle.Obj? = null @FnExperimental - override fun getFunctions(path: BindingPath): List { - val cnf = path.normalized - return info.functions.list(cnf).map { - ConnectorHandle.Fn(cnf, SqlFn(it.signature)) + override fun getFunction(path: BindingPath): ConnectorHandle.Fn? { + val cnf = path.steps.map { it.name.uppercase() } + val name = cnf.last() + val variants = info.functions.get(cnf).map { it.signature } + if (variants.isEmpty()) { + return null } + return ConnectorHandle.Fn(cnf, SqlFn(name, variants)) } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggAny.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAny.kt similarity index 64% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggAny.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAny.kt index c3c5a39d49..0023d64d1a 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggAny.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAny.kt @@ -1,19 +1,19 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.agg +package org.partiql.spi.connector.sql.builtins -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Agg +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_ANY__BOOL__BOOL : FnAggregation { +public object Agg_ANY__BOOL__BOOL : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "any", returns = BOOL, parameters = listOf( @@ -23,7 +23,7 @@ internal object Agg_ANY__BOOL__BOOL : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation any not implemented") } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggAvg.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAvg.kt similarity index 67% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggAvg.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAvg.kt index 252dec5d99..5a7f2e0fff 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggAvg.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggAvg.kt @@ -1,12 +1,12 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.agg +package org.partiql.spi.connector.sql.builtins -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Agg +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY import org.partiql.value.PartiQLValueType.FLOAT32 @@ -18,9 +18,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_AVG__INT8__INT8 : FnAggregation { +public object Agg_AVG__INT8__INT8 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "avg", returns = INT8, parameters = listOf( @@ -30,15 +30,15 @@ internal object Agg_AVG__INT8__INT8 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation avg not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_AVG__INT16__INT16 : FnAggregation { +public object Agg_AVG__INT16__INT16 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "avg", returns = INT16, parameters = listOf( @@ -48,15 +48,15 @@ internal object Agg_AVG__INT16__INT16 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation avg not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_AVG__INT32__INT32 : FnAggregation { +public object Agg_AVG__INT32__INT32 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "avg", returns = INT32, parameters = listOf( @@ -66,15 +66,15 @@ internal object Agg_AVG__INT32__INT32 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation avg not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_AVG__INT64__INT64 : FnAggregation { +public object Agg_AVG__INT64__INT64 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "avg", returns = INT64, parameters = listOf( @@ -84,15 +84,15 @@ internal object Agg_AVG__INT64__INT64 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation avg not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_AVG__INT__INT : FnAggregation { +public object Agg_AVG__INT__INT : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "avg", returns = INT, parameters = listOf( @@ -102,15 +102,15 @@ internal object Agg_AVG__INT__INT : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation avg not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_AVG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnAggregation { +public object Agg_AVG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "avg", returns = DECIMAL_ARBITRARY, parameters = listOf( @@ -120,15 +120,15 @@ internal object Agg_AVG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation avg not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_AVG__FLOAT32__FLOAT32 : FnAggregation { +public object Agg_AVG__FLOAT32__FLOAT32 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "avg", returns = FLOAT32, parameters = listOf( @@ -138,15 +138,15 @@ internal object Agg_AVG__FLOAT32__FLOAT32 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation avg not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_AVG__FLOAT64__FLOAT64 : FnAggregation { +public object Agg_AVG__FLOAT64__FLOAT64 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "avg", returns = FLOAT64, parameters = listOf( @@ -156,7 +156,7 @@ internal object Agg_AVG__FLOAT64__FLOAT64 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation avg not implemented") } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggCount.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggCount.kt similarity index 65% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggCount.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggCount.kt index 3aced66e3d..8cc44e1c5e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggCount.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggCount.kt @@ -1,20 +1,20 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.agg +package org.partiql.spi.connector.sql.builtins -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Agg +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.INT32 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_COUNT__ANY__INT32 : FnAggregation { +public object Agg_COUNT__ANY__INT32 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "count", returns = INT32, parameters = listOf( @@ -24,7 +24,7 @@ internal object Agg_COUNT__ANY__INT32 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation count not implemented") } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggCountStar.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggCountStar.kt similarity index 60% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggCountStar.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggCountStar.kt index e70acb597f..b1ad728ccb 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggCountStar.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggCountStar.kt @@ -1,18 +1,18 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.agg +package org.partiql.spi.connector.sql.builtins -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Agg +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental -import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.INT32 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_COUNT_STAR____INT32 : FnAggregation { +public object Agg_COUNT_STAR____INT32 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "count_star", returns = INT32, parameters = listOf(), @@ -20,7 +20,7 @@ internal object Agg_COUNT_STAR____INT32 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation count_star not implemented") } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggEvery.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggEvery.kt similarity index 64% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggEvery.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggEvery.kt index a0d9da97b1..c5a2014d04 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggEvery.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggEvery.kt @@ -1,19 +1,19 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.agg +package org.partiql.spi.connector.sql.builtins -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Agg +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_EVERY__BOOL__BOOL : FnAggregation { +public object Agg_EVERY__BOOL__BOOL : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "every", returns = BOOL, parameters = listOf( @@ -23,7 +23,7 @@ internal object Agg_EVERY__BOOL__BOOL : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation every not implemented") } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggMax.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggMax.kt similarity index 67% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggMax.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggMax.kt index 1906dfffec..f17fed0f7c 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggMax.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggMax.kt @@ -1,12 +1,12 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.agg +package org.partiql.spi.connector.sql.builtins -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Agg +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY import org.partiql.value.PartiQLValueType.FLOAT32 @@ -18,9 +18,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MAX__INT8__INT8 : FnAggregation { +public object Agg_MAX__INT8__INT8 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "max", returns = INT8, parameters = listOf( @@ -30,15 +30,15 @@ internal object Agg_MAX__INT8__INT8 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation max not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MAX__INT16__INT16 : FnAggregation { +public object Agg_MAX__INT16__INT16 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "max", returns = INT16, parameters = listOf( @@ -48,15 +48,15 @@ internal object Agg_MAX__INT16__INT16 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation max not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MAX__INT32__INT32 : FnAggregation { +public object Agg_MAX__INT32__INT32 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "max", returns = INT32, parameters = listOf( @@ -66,15 +66,15 @@ internal object Agg_MAX__INT32__INT32 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation max not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MAX__INT64__INT64 : FnAggregation { +public object Agg_MAX__INT64__INT64 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "max", returns = INT64, parameters = listOf( @@ -84,15 +84,15 @@ internal object Agg_MAX__INT64__INT64 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation max not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MAX__INT__INT : FnAggregation { +public object Agg_MAX__INT__INT : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "max", returns = INT, parameters = listOf( @@ -102,15 +102,15 @@ internal object Agg_MAX__INT__INT : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation max not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MAX__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnAggregation { +public object Agg_MAX__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "max", returns = DECIMAL_ARBITRARY, parameters = listOf( @@ -120,15 +120,15 @@ internal object Agg_MAX__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation max not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MAX__FLOAT32__FLOAT32 : FnAggregation { +public object Agg_MAX__FLOAT32__FLOAT32 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "max", returns = FLOAT32, parameters = listOf( @@ -138,15 +138,15 @@ internal object Agg_MAX__FLOAT32__FLOAT32 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation max not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MAX__FLOAT64__FLOAT64 : FnAggregation { +public object Agg_MAX__FLOAT64__FLOAT64 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "max", returns = FLOAT64, parameters = listOf( @@ -156,7 +156,7 @@ internal object Agg_MAX__FLOAT64__FLOAT64 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation max not implemented") } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggMin.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggMin.kt similarity index 67% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggMin.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggMin.kt index 77ff846962..10047d6864 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggMin.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggMin.kt @@ -1,12 +1,12 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.agg +package org.partiql.spi.connector.sql.builtins -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Agg +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY import org.partiql.value.PartiQLValueType.FLOAT32 @@ -18,9 +18,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MIN__INT8__INT8 : FnAggregation { +public object Agg_MIN__INT8__INT8 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "min", returns = INT8, parameters = listOf( @@ -30,15 +30,15 @@ internal object Agg_MIN__INT8__INT8 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation min not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MIN__INT16__INT16 : FnAggregation { +public object Agg_MIN__INT16__INT16 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "min", returns = INT16, parameters = listOf( @@ -48,15 +48,15 @@ internal object Agg_MIN__INT16__INT16 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation min not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MIN__INT32__INT32 : FnAggregation { +public object Agg_MIN__INT32__INT32 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "min", returns = INT32, parameters = listOf( @@ -66,15 +66,15 @@ internal object Agg_MIN__INT32__INT32 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation min not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MIN__INT64__INT64 : FnAggregation { +public object Agg_MIN__INT64__INT64 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "min", returns = INT64, parameters = listOf( @@ -84,15 +84,15 @@ internal object Agg_MIN__INT64__INT64 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation min not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MIN__INT__INT : FnAggregation { +public object Agg_MIN__INT__INT : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "min", returns = INT, parameters = listOf( @@ -102,15 +102,15 @@ internal object Agg_MIN__INT__INT : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation min not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MIN__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnAggregation { +public object Agg_MIN__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "min", returns = DECIMAL_ARBITRARY, parameters = listOf( @@ -120,15 +120,15 @@ internal object Agg_MIN__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation min not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MIN__FLOAT32__FLOAT32 : FnAggregation { +public object Agg_MIN__FLOAT32__FLOAT32 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "min", returns = FLOAT32, parameters = listOf( @@ -138,15 +138,15 @@ internal object Agg_MIN__FLOAT32__FLOAT32 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation min not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_MIN__FLOAT64__FLOAT64 : FnAggregation { +public object Agg_MIN__FLOAT64__FLOAT64 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "min", returns = FLOAT64, parameters = listOf( @@ -156,7 +156,7 @@ internal object Agg_MIN__FLOAT64__FLOAT64 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation min not implemented") } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggSome.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggSome.kt similarity index 64% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggSome.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggSome.kt index 8322e2c3d5..1a1b279252 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggSome.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggSome.kt @@ -1,19 +1,19 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.agg +package org.partiql.spi.connector.sql.builtins -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Agg +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_SOME__BOOL__BOOL : FnAggregation { +public object Agg_SOME__BOOL__BOOL : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "some", returns = BOOL, parameters = listOf( @@ -23,7 +23,7 @@ internal object Agg_SOME__BOOL__BOOL : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation some not implemented") } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggSum.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggSum.kt similarity index 67% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggSum.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggSum.kt index eb0af6572a..b0f73000b6 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg/AggSum.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggSum.kt @@ -1,12 +1,12 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.agg +package org.partiql.spi.connector.sql.builtins -import org.partiql.spi.fn.FnAggregation +import org.partiql.spi.fn.Agg +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.DECIMAL_ARBITRARY import org.partiql.value.PartiQLValueType.FLOAT32 @@ -18,9 +18,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_SUM__INT8__INT8 : FnAggregation { +public object Agg_SUM__INT8__INT8 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "sum", returns = INT8, parameters = listOf( @@ -30,15 +30,15 @@ internal object Agg_SUM__INT8__INT8 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation sum not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_SUM__INT16__INT16 : FnAggregation { +public object Agg_SUM__INT16__INT16 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "sum", returns = INT16, parameters = listOf( @@ -48,15 +48,15 @@ internal object Agg_SUM__INT16__INT16 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation sum not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_SUM__INT32__INT32 : FnAggregation { +public object Agg_SUM__INT32__INT32 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "sum", returns = INT32, parameters = listOf( @@ -66,15 +66,15 @@ internal object Agg_SUM__INT32__INT32 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation sum not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_SUM__INT64__INT64 : FnAggregation { +public object Agg_SUM__INT64__INT64 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "sum", returns = INT64, parameters = listOf( @@ -84,15 +84,15 @@ internal object Agg_SUM__INT64__INT64 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation sum not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_SUM__INT__INT : FnAggregation { +public object Agg_SUM__INT__INT : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "sum", returns = INT, parameters = listOf( @@ -102,15 +102,15 @@ internal object Agg_SUM__INT__INT : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation sum not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_SUM__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnAggregation { +public object Agg_SUM__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "sum", returns = DECIMAL_ARBITRARY, parameters = listOf( @@ -120,15 +120,15 @@ internal object Agg_SUM__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation sum not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_SUM__FLOAT32__FLOAT32 : FnAggregation { +public object Agg_SUM__FLOAT32__FLOAT32 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "sum", returns = FLOAT32, parameters = listOf( @@ -138,15 +138,15 @@ internal object Agg_SUM__FLOAT32__FLOAT32 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation sum not implemented") } } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Agg_SUM__FLOAT64__FLOAT64 : FnAggregation { +public object Agg_SUM__FLOAT64__FLOAT64 : Agg { - override val signature = FnSignature.Aggregation( + override val signature: AggSignature = AggSignature( name = "sum", returns = FLOAT64, parameters = listOf( @@ -156,7 +156,7 @@ internal object Agg_SUM__FLOAT64__FLOAT64 : FnAggregation { isDecomposable = true ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation sum not implemented") } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnAnd.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnAnd.kt similarity index 77% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnAnd.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnAnd.kt index 77bf9dccf5..30a864a856 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnAnd.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnAnd.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.BOOL import org.partiql.value.PartiQLValueType.MISSING @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_AND__BOOL_BOOL__BOOL : FnScalar { +internal object Fn_AND__BOOL_BOOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "and", returns = BOOL, parameters = listOf( @@ -24,6 +24,7 @@ internal object Fn_AND__BOOL_BOOL__BOOL : FnScalar { ), isNullCall = false, isNullable = true, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -32,9 +33,9 @@ internal object Fn_AND__BOOL_BOOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_AND__MISSING_BOOL__BOOL : FnScalar { +internal object Fn_AND__MISSING_BOOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "and", returns = BOOL, parameters = listOf( @@ -43,6 +44,7 @@ internal object Fn_AND__MISSING_BOOL__BOOL : FnScalar { ), isNullCall = false, isNullable = true, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -51,9 +53,9 @@ internal object Fn_AND__MISSING_BOOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_AND__BOOL_MISSING__BOOL : FnScalar { +internal object Fn_AND__BOOL_MISSING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "and", returns = BOOL, parameters = listOf( @@ -62,6 +64,7 @@ internal object Fn_AND__BOOL_MISSING__BOOL : FnScalar { ), isNullCall = false, isNullable = true, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -70,9 +73,9 @@ internal object Fn_AND__BOOL_MISSING__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_AND__MISSING_MISSING__BOOL : FnScalar { +internal object Fn_AND__MISSING_MISSING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "and", returns = BOOL, parameters = listOf( @@ -81,6 +84,7 @@ internal object Fn_AND__MISSING_MISSING__BOOL : FnScalar { ), isNullCall = false, isNullable = true, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnBetween.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnBetween.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnBetween.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnBetween.kt index 8e93d8da87..f0c0778fd3 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnBetween.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnBetween.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -26,9 +26,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__INT8_INT8_INT8__BOOL : FnScalar { +internal object Fn_BETWEEN__INT8_INT8_INT8__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -46,9 +46,9 @@ internal object Fn_BETWEEN__INT8_INT8_INT8__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__INT16_INT16_INT16__BOOL : FnScalar { +internal object Fn_BETWEEN__INT16_INT16_INT16__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -66,9 +66,9 @@ internal object Fn_BETWEEN__INT16_INT16_INT16__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__INT32_INT32_INT32__BOOL : FnScalar { +internal object Fn_BETWEEN__INT32_INT32_INT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -86,9 +86,9 @@ internal object Fn_BETWEEN__INT32_INT32_INT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__INT64_INT64_INT64__BOOL : FnScalar { +internal object Fn_BETWEEN__INT64_INT64_INT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -106,9 +106,9 @@ internal object Fn_BETWEEN__INT64_INT64_INT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__INT_INT_INT__BOOL : FnScalar { +internal object Fn_BETWEEN__INT_INT_INT__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -126,9 +126,9 @@ internal object Fn_BETWEEN__INT_INT_INT__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { +internal object Fn_BETWEEN__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -146,9 +146,9 @@ internal object Fn_BETWEEN__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY_DECIMAL_ARBITRAR } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__FLOAT32_FLOAT32_FLOAT32__BOOL : FnScalar { +internal object Fn_BETWEEN__FLOAT32_FLOAT32_FLOAT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -166,9 +166,9 @@ internal object Fn_BETWEEN__FLOAT32_FLOAT32_FLOAT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__FLOAT64_FLOAT64_FLOAT64__BOOL : FnScalar { +internal object Fn_BETWEEN__FLOAT64_FLOAT64_FLOAT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -186,9 +186,9 @@ internal object Fn_BETWEEN__FLOAT64_FLOAT64_FLOAT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__STRING_STRING_STRING__BOOL : FnScalar { +internal object Fn_BETWEEN__STRING_STRING_STRING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -206,9 +206,9 @@ internal object Fn_BETWEEN__STRING_STRING_STRING__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__SYMBOL_SYMBOL_SYMBOL__BOOL : FnScalar { +internal object Fn_BETWEEN__SYMBOL_SYMBOL_SYMBOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -226,9 +226,9 @@ internal object Fn_BETWEEN__SYMBOL_SYMBOL_SYMBOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__CLOB_CLOB_CLOB__BOOL : FnScalar { +internal object Fn_BETWEEN__CLOB_CLOB_CLOB__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -246,9 +246,9 @@ internal object Fn_BETWEEN__CLOB_CLOB_CLOB__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__DATE_DATE_DATE__BOOL : FnScalar { +internal object Fn_BETWEEN__DATE_DATE_DATE__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -266,9 +266,9 @@ internal object Fn_BETWEEN__DATE_DATE_DATE__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__TIME_TIME_TIME__BOOL : FnScalar { +internal object Fn_BETWEEN__TIME_TIME_TIME__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -286,9 +286,9 @@ internal object Fn_BETWEEN__TIME_TIME_TIME__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BETWEEN__TIMESTAMP_TIMESTAMP_TIMESTAMP__BOOL : FnScalar { +internal object Fn_BETWEEN__TIMESTAMP_TIMESTAMP_TIMESTAMP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "between", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnBitwiseAnd.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnBitwiseAnd.kt similarity index 80% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnBitwiseAnd.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnBitwiseAnd.kt index 43d0a56d8e..1b5c554a5b 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnBitwiseAnd.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnBitwiseAnd.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -16,9 +16,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BITWISE_AND__INT8_INT8__INT8 : FnScalar { +internal object Fn_BITWISE_AND__INT8_INT8__INT8 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "bitwise_and", returns = INT8, parameters = listOf( @@ -35,9 +35,9 @@ internal object Fn_BITWISE_AND__INT8_INT8__INT8 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BITWISE_AND__INT16_INT16__INT16 : FnScalar { +internal object Fn_BITWISE_AND__INT16_INT16__INT16 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "bitwise_and", returns = INT16, parameters = listOf( @@ -54,9 +54,9 @@ internal object Fn_BITWISE_AND__INT16_INT16__INT16 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BITWISE_AND__INT32_INT32__INT32 : FnScalar { +internal object Fn_BITWISE_AND__INT32_INT32__INT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "bitwise_and", returns = INT32, parameters = listOf( @@ -73,9 +73,9 @@ internal object Fn_BITWISE_AND__INT32_INT32__INT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BITWISE_AND__INT64_INT64__INT64 : FnScalar { +internal object Fn_BITWISE_AND__INT64_INT64__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "bitwise_and", returns = INT64, parameters = listOf( @@ -92,9 +92,9 @@ internal object Fn_BITWISE_AND__INT64_INT64__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_BITWISE_AND__INT_INT__INT : FnScalar { +internal object Fn_BITWISE_AND__INT_INT__INT : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "bitwise_and", returns = INT, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnConcat.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnConcat.kt similarity index 79% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnConcat.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnConcat.kt index ff7578c66d..383405683a 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnConcat.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnConcat.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_CONCAT__STRING_STRING__STRING : FnScalar { +internal object Fn_CONCAT__STRING_STRING__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "concat", returns = STRING, parameters = listOf( @@ -33,9 +33,9 @@ internal object Fn_CONCAT__STRING_STRING__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_CONCAT__SYMBOL_SYMBOL__SYMBOL : FnScalar { +internal object Fn_CONCAT__SYMBOL_SYMBOL__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "concat", returns = SYMBOL, parameters = listOf( @@ -52,9 +52,9 @@ internal object Fn_CONCAT__SYMBOL_SYMBOL__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_CONCAT__CLOB_CLOB__CLOB : FnScalar { +internal object Fn_CONCAT__CLOB_CLOB__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "concat", returns = CLOB, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnCurrentDate.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnCurrentDate.kt similarity index 75% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnCurrentDate.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnCurrentDate.kt index debd201a1c..b802665068 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnCurrentDate.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnCurrentDate.kt @@ -1,19 +1,19 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.DATE @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_CURRENT_DATE____DATE : FnScalar { +internal object Fn_CURRENT_DATE____DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "current_date", returns = DATE, parameters = listOf(), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnCurrentUser.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnCurrentUser.kt similarity index 75% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnCurrentUser.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnCurrentUser.kt index 6935cfea1e..94f427dbde 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnCurrentUser.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnCurrentUser.kt @@ -1,19 +1,19 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.STRING @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_CURRENT_USER____STRING : FnScalar { +internal object Fn_CURRENT_USER____STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "current_user", returns = STRING, parameters = listOf(), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddDay.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddDay.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddDay.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddDay.kt index 2ad56684f0..b3e5809c21 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddDay.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddDay.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -17,9 +17,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_DAY__INT32_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_DAY__INT32_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_day", returns = DATE, parameters = listOf( @@ -36,9 +36,9 @@ internal object Fn_DATE_ADD_DAY__INT32_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_DAY__INT64_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_DAY__INT64_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_day", returns = DATE, parameters = listOf( @@ -55,9 +55,9 @@ internal object Fn_DATE_ADD_DAY__INT64_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_DAY__INT_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_DAY__INT_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_day", returns = DATE, parameters = listOf( @@ -74,9 +74,9 @@ internal object Fn_DATE_ADD_DAY__INT_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_DAY__INT32_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_DAY__INT32_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_day", returns = TIME, parameters = listOf( @@ -93,9 +93,9 @@ internal object Fn_DATE_ADD_DAY__INT32_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_DAY__INT64_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_DAY__INT64_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_day", returns = TIME, parameters = listOf( @@ -112,9 +112,9 @@ internal object Fn_DATE_ADD_DAY__INT64_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_DAY__INT_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_DAY__INT_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_day", returns = TIME, parameters = listOf( @@ -131,9 +131,9 @@ internal object Fn_DATE_ADD_DAY__INT_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_DAY__INT32_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_DAY__INT32_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_day", returns = TIMESTAMP, parameters = listOf( @@ -150,9 +150,9 @@ internal object Fn_DATE_ADD_DAY__INT32_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_DAY__INT64_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_DAY__INT64_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_day", returns = TIMESTAMP, parameters = listOf( @@ -169,9 +169,9 @@ internal object Fn_DATE_ADD_DAY__INT64_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_DAY__INT_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_DAY__INT_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_day", returns = TIMESTAMP, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddHour.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddHour.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddHour.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddHour.kt index 01f58de5b6..13bb6962c0 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddHour.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddHour.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -17,9 +17,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_HOUR__INT32_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_HOUR__INT32_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_hour", returns = DATE, parameters = listOf( @@ -36,9 +36,9 @@ internal object Fn_DATE_ADD_HOUR__INT32_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_HOUR__INT64_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_HOUR__INT64_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_hour", returns = DATE, parameters = listOf( @@ -55,9 +55,9 @@ internal object Fn_DATE_ADD_HOUR__INT64_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_HOUR__INT_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_HOUR__INT_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_hour", returns = DATE, parameters = listOf( @@ -74,9 +74,9 @@ internal object Fn_DATE_ADD_HOUR__INT_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_HOUR__INT32_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_HOUR__INT32_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_hour", returns = TIME, parameters = listOf( @@ -93,9 +93,9 @@ internal object Fn_DATE_ADD_HOUR__INT32_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_HOUR__INT64_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_HOUR__INT64_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_hour", returns = TIME, parameters = listOf( @@ -112,9 +112,9 @@ internal object Fn_DATE_ADD_HOUR__INT64_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_HOUR__INT_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_HOUR__INT_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_hour", returns = TIME, parameters = listOf( @@ -131,9 +131,9 @@ internal object Fn_DATE_ADD_HOUR__INT_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_HOUR__INT32_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_HOUR__INT32_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_hour", returns = TIMESTAMP, parameters = listOf( @@ -150,9 +150,9 @@ internal object Fn_DATE_ADD_HOUR__INT32_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_HOUR__INT64_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_HOUR__INT64_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_hour", returns = TIMESTAMP, parameters = listOf( @@ -169,9 +169,9 @@ internal object Fn_DATE_ADD_HOUR__INT64_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_HOUR__INT_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_HOUR__INT_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_hour", returns = TIMESTAMP, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddMinute.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddMinute.kt similarity index 83% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddMinute.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddMinute.kt index 88e4b665b3..71442341ad 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddMinute.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddMinute.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -17,9 +17,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MINUTE__INT32_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_MINUTE__INT32_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_minute", returns = DATE, parameters = listOf( @@ -36,9 +36,9 @@ internal object Fn_DATE_ADD_MINUTE__INT32_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MINUTE__INT64_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_MINUTE__INT64_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_minute", returns = DATE, parameters = listOf( @@ -55,9 +55,9 @@ internal object Fn_DATE_ADD_MINUTE__INT64_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MINUTE__INT_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_MINUTE__INT_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_minute", returns = DATE, parameters = listOf( @@ -74,9 +74,9 @@ internal object Fn_DATE_ADD_MINUTE__INT_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MINUTE__INT32_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_MINUTE__INT32_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_minute", returns = TIME, parameters = listOf( @@ -93,9 +93,9 @@ internal object Fn_DATE_ADD_MINUTE__INT32_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MINUTE__INT64_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_MINUTE__INT64_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_minute", returns = TIME, parameters = listOf( @@ -112,9 +112,9 @@ internal object Fn_DATE_ADD_MINUTE__INT64_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MINUTE__INT_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_MINUTE__INT_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_minute", returns = TIME, parameters = listOf( @@ -131,9 +131,9 @@ internal object Fn_DATE_ADD_MINUTE__INT_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MINUTE__INT32_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_MINUTE__INT32_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_minute", returns = TIMESTAMP, parameters = listOf( @@ -150,9 +150,9 @@ internal object Fn_DATE_ADD_MINUTE__INT32_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MINUTE__INT64_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_MINUTE__INT64_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_minute", returns = TIMESTAMP, parameters = listOf( @@ -169,9 +169,9 @@ internal object Fn_DATE_ADD_MINUTE__INT64_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MINUTE__INT_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_MINUTE__INT_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_minute", returns = TIMESTAMP, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddMonth.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddMonth.kt similarity index 83% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddMonth.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddMonth.kt index 4e4a5cef56..53dd303c57 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddMonth.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddMonth.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -17,9 +17,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MONTH__INT32_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_MONTH__INT32_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_month", returns = DATE, parameters = listOf( @@ -36,9 +36,9 @@ internal object Fn_DATE_ADD_MONTH__INT32_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MONTH__INT64_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_MONTH__INT64_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_month", returns = DATE, parameters = listOf( @@ -55,9 +55,9 @@ internal object Fn_DATE_ADD_MONTH__INT64_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MONTH__INT_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_MONTH__INT_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_month", returns = DATE, parameters = listOf( @@ -74,9 +74,9 @@ internal object Fn_DATE_ADD_MONTH__INT_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MONTH__INT32_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_MONTH__INT32_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_month", returns = TIME, parameters = listOf( @@ -93,9 +93,9 @@ internal object Fn_DATE_ADD_MONTH__INT32_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MONTH__INT64_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_MONTH__INT64_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_month", returns = TIME, parameters = listOf( @@ -112,9 +112,9 @@ internal object Fn_DATE_ADD_MONTH__INT64_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MONTH__INT_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_MONTH__INT_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_month", returns = TIME, parameters = listOf( @@ -131,9 +131,9 @@ internal object Fn_DATE_ADD_MONTH__INT_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MONTH__INT32_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_MONTH__INT32_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_month", returns = TIMESTAMP, parameters = listOf( @@ -150,9 +150,9 @@ internal object Fn_DATE_ADD_MONTH__INT32_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MONTH__INT64_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_MONTH__INT64_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_month", returns = TIMESTAMP, parameters = listOf( @@ -169,9 +169,9 @@ internal object Fn_DATE_ADD_MONTH__INT64_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_MONTH__INT_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_MONTH__INT_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_month", returns = TIMESTAMP, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddSecond.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddSecond.kt similarity index 83% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddSecond.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddSecond.kt index 794631c0f0..46284819ce 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddSecond.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddSecond.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -17,9 +17,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_SECOND__INT32_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_SECOND__INT32_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_second", returns = DATE, parameters = listOf( @@ -36,9 +36,9 @@ internal object Fn_DATE_ADD_SECOND__INT32_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_SECOND__INT64_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_SECOND__INT64_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_second", returns = DATE, parameters = listOf( @@ -55,9 +55,9 @@ internal object Fn_DATE_ADD_SECOND__INT64_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_SECOND__INT_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_SECOND__INT_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_second", returns = DATE, parameters = listOf( @@ -74,9 +74,9 @@ internal object Fn_DATE_ADD_SECOND__INT_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_SECOND__INT32_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_SECOND__INT32_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_second", returns = TIME, parameters = listOf( @@ -93,9 +93,9 @@ internal object Fn_DATE_ADD_SECOND__INT32_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_SECOND__INT64_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_SECOND__INT64_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_second", returns = TIME, parameters = listOf( @@ -112,9 +112,9 @@ internal object Fn_DATE_ADD_SECOND__INT64_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_SECOND__INT_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_SECOND__INT_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_second", returns = TIME, parameters = listOf( @@ -131,9 +131,9 @@ internal object Fn_DATE_ADD_SECOND__INT_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_SECOND__INT32_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_SECOND__INT32_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_second", returns = TIMESTAMP, parameters = listOf( @@ -150,9 +150,9 @@ internal object Fn_DATE_ADD_SECOND__INT32_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_SECOND__INT64_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_SECOND__INT64_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_second", returns = TIMESTAMP, parameters = listOf( @@ -169,9 +169,9 @@ internal object Fn_DATE_ADD_SECOND__INT64_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_SECOND__INT_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_SECOND__INT_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_second", returns = TIMESTAMP, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddYear.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddYear.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddYear.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddYear.kt index 7a4ff8bcee..4dc4ab42c7 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateAddYear.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateAddYear.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -17,9 +17,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_YEAR__INT32_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_YEAR__INT32_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_year", returns = DATE, parameters = listOf( @@ -36,9 +36,9 @@ internal object Fn_DATE_ADD_YEAR__INT32_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_YEAR__INT64_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_YEAR__INT64_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_year", returns = DATE, parameters = listOf( @@ -55,9 +55,9 @@ internal object Fn_DATE_ADD_YEAR__INT64_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_YEAR__INT_DATE__DATE : FnScalar { +internal object Fn_DATE_ADD_YEAR__INT_DATE__DATE : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_year", returns = DATE, parameters = listOf( @@ -74,9 +74,9 @@ internal object Fn_DATE_ADD_YEAR__INT_DATE__DATE : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_YEAR__INT32_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_YEAR__INT32_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_year", returns = TIME, parameters = listOf( @@ -93,9 +93,9 @@ internal object Fn_DATE_ADD_YEAR__INT32_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_YEAR__INT64_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_YEAR__INT64_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_year", returns = TIME, parameters = listOf( @@ -112,9 +112,9 @@ internal object Fn_DATE_ADD_YEAR__INT64_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_YEAR__INT_TIME__TIME : FnScalar { +internal object Fn_DATE_ADD_YEAR__INT_TIME__TIME : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_year", returns = TIME, parameters = listOf( @@ -131,9 +131,9 @@ internal object Fn_DATE_ADD_YEAR__INT_TIME__TIME : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_YEAR__INT32_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_YEAR__INT32_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_year", returns = TIMESTAMP, parameters = listOf( @@ -150,9 +150,9 @@ internal object Fn_DATE_ADD_YEAR__INT32_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_YEAR__INT64_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_YEAR__INT64_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_year", returns = TIMESTAMP, parameters = listOf( @@ -169,9 +169,9 @@ internal object Fn_DATE_ADD_YEAR__INT64_TIMESTAMP__TIMESTAMP : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_ADD_YEAR__INT_TIMESTAMP__TIMESTAMP : FnScalar { +internal object Fn_DATE_ADD_YEAR__INT_TIMESTAMP__TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_add_year", returns = TIMESTAMP, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffDay.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffDay.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffDay.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffDay.kt index 1051186cac..186b17f58b 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffDay.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffDay.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -15,9 +15,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_DAY__DATE_DATE__INT64 : FnScalar { +internal object Fn_DATE_DIFF_DAY__DATE_DATE__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_day", returns = INT64, parameters = listOf( @@ -34,9 +34,9 @@ internal object Fn_DATE_DIFF_DAY__DATE_DATE__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_DAY__TIME_TIME__INT64 : FnScalar { +internal object Fn_DATE_DIFF_DAY__TIME_TIME__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_day", returns = INT64, parameters = listOf( @@ -53,9 +53,9 @@ internal object Fn_DATE_DIFF_DAY__TIME_TIME__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_DAY__TIMESTAMP_TIMESTAMP__INT64 : FnScalar { +internal object Fn_DATE_DIFF_DAY__TIMESTAMP_TIMESTAMP__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_day", returns = INT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffHour.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffHour.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffHour.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffHour.kt index e058d3bdaf..7f4426e745 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffHour.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffHour.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -15,9 +15,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_HOUR__DATE_DATE__INT64 : FnScalar { +internal object Fn_DATE_DIFF_HOUR__DATE_DATE__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_hour", returns = INT64, parameters = listOf( @@ -34,9 +34,9 @@ internal object Fn_DATE_DIFF_HOUR__DATE_DATE__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_HOUR__TIME_TIME__INT64 : FnScalar { +internal object Fn_DATE_DIFF_HOUR__TIME_TIME__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_hour", returns = INT64, parameters = listOf( @@ -53,9 +53,9 @@ internal object Fn_DATE_DIFF_HOUR__TIME_TIME__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_HOUR__TIMESTAMP_TIMESTAMP__INT64 : FnScalar { +internal object Fn_DATE_DIFF_HOUR__TIMESTAMP_TIMESTAMP__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_hour", returns = INT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffMinute.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffMinute.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffMinute.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffMinute.kt index f24ea8ff3c..8c0c52de88 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffMinute.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffMinute.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -15,9 +15,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_MINUTE__DATE_DATE__INT64 : FnScalar { +internal object Fn_DATE_DIFF_MINUTE__DATE_DATE__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_minute", returns = INT64, parameters = listOf( @@ -34,9 +34,9 @@ internal object Fn_DATE_DIFF_MINUTE__DATE_DATE__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_MINUTE__TIME_TIME__INT64 : FnScalar { +internal object Fn_DATE_DIFF_MINUTE__TIME_TIME__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_minute", returns = INT64, parameters = listOf( @@ -53,9 +53,9 @@ internal object Fn_DATE_DIFF_MINUTE__TIME_TIME__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_MINUTE__TIMESTAMP_TIMESTAMP__INT64 : FnScalar { +internal object Fn_DATE_DIFF_MINUTE__TIMESTAMP_TIMESTAMP__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_minute", returns = INT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffMonth.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffMonth.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffMonth.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffMonth.kt index 0041e3bacb..d45eef371f 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffMonth.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffMonth.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -15,9 +15,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_MONTH__DATE_DATE__INT64 : FnScalar { +internal object Fn_DATE_DIFF_MONTH__DATE_DATE__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_month", returns = INT64, parameters = listOf( @@ -34,9 +34,9 @@ internal object Fn_DATE_DIFF_MONTH__DATE_DATE__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_MONTH__TIME_TIME__INT64 : FnScalar { +internal object Fn_DATE_DIFF_MONTH__TIME_TIME__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_month", returns = INT64, parameters = listOf( @@ -53,9 +53,9 @@ internal object Fn_DATE_DIFF_MONTH__TIME_TIME__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_MONTH__TIMESTAMP_TIMESTAMP__INT64 : FnScalar { +internal object Fn_DATE_DIFF_MONTH__TIMESTAMP_TIMESTAMP__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_month", returns = INT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffSecond.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffSecond.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffSecond.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffSecond.kt index d7425fcac6..0e347c564e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffSecond.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffSecond.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -15,9 +15,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_SECOND__DATE_DATE__INT64 : FnScalar { +internal object Fn_DATE_DIFF_SECOND__DATE_DATE__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_second", returns = INT64, parameters = listOf( @@ -34,9 +34,9 @@ internal object Fn_DATE_DIFF_SECOND__DATE_DATE__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_SECOND__TIME_TIME__INT64 : FnScalar { +internal object Fn_DATE_DIFF_SECOND__TIME_TIME__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_second", returns = INT64, parameters = listOf( @@ -53,9 +53,9 @@ internal object Fn_DATE_DIFF_SECOND__TIME_TIME__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_SECOND__TIMESTAMP_TIMESTAMP__INT64 : FnScalar { +internal object Fn_DATE_DIFF_SECOND__TIMESTAMP_TIMESTAMP__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_second", returns = INT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffYear.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffYear.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffYear.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffYear.kt index 6a501daba2..1f124b3db8 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDateDiffYear.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDateDiffYear.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -15,9 +15,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_YEAR__DATE_DATE__INT64 : FnScalar { +internal object Fn_DATE_DIFF_YEAR__DATE_DATE__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_year", returns = INT64, parameters = listOf( @@ -34,9 +34,9 @@ internal object Fn_DATE_DIFF_YEAR__DATE_DATE__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_YEAR__TIME_TIME__INT64 : FnScalar { +internal object Fn_DATE_DIFF_YEAR__TIME_TIME__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_year", returns = INT64, parameters = listOf( @@ -53,9 +53,9 @@ internal object Fn_DATE_DIFF_YEAR__TIME_TIME__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DATE_DIFF_YEAR__TIMESTAMP_TIMESTAMP__INT64 : FnScalar { +internal object Fn_DATE_DIFF_YEAR__TIMESTAMP_TIMESTAMP__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "date_diff_year", returns = INT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDivide.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDivide.kt similarity index 81% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDivide.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDivide.kt index 4ef1140809..5183fe6415 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnDivide.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnDivide.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -19,9 +19,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DIVIDE__INT8_INT8__INT8 : FnScalar { +internal object Fn_DIVIDE__INT8_INT8__INT8 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "divide", returns = INT8, parameters = listOf( @@ -38,9 +38,9 @@ internal object Fn_DIVIDE__INT8_INT8__INT8 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DIVIDE__INT16_INT16__INT16 : FnScalar { +internal object Fn_DIVIDE__INT16_INT16__INT16 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "divide", returns = INT16, parameters = listOf( @@ -57,9 +57,9 @@ internal object Fn_DIVIDE__INT16_INT16__INT16 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DIVIDE__INT32_INT32__INT32 : FnScalar { +internal object Fn_DIVIDE__INT32_INT32__INT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "divide", returns = INT32, parameters = listOf( @@ -76,9 +76,9 @@ internal object Fn_DIVIDE__INT32_INT32__INT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DIVIDE__INT64_INT64__INT64 : FnScalar { +internal object Fn_DIVIDE__INT64_INT64__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "divide", returns = INT64, parameters = listOf( @@ -95,9 +95,9 @@ internal object Fn_DIVIDE__INT64_INT64__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DIVIDE__INT_INT__INT : FnScalar { +internal object Fn_DIVIDE__INT_INT__INT : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "divide", returns = INT, parameters = listOf( @@ -114,9 +114,9 @@ internal object Fn_DIVIDE__INT_INT__INT : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DIVIDE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnScalar { +internal object Fn_DIVIDE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "divide", returns = DECIMAL_ARBITRARY, parameters = listOf( @@ -133,9 +133,9 @@ internal object Fn_DIVIDE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRAR } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DIVIDE__FLOAT32_FLOAT32__FLOAT32 : FnScalar { +internal object Fn_DIVIDE__FLOAT32_FLOAT32__FLOAT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "divide", returns = FLOAT32, parameters = listOf( @@ -152,9 +152,9 @@ internal object Fn_DIVIDE__FLOAT32_FLOAT32__FLOAT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_DIVIDE__FLOAT64_FLOAT64__FLOAT64 : FnScalar { +internal object Fn_DIVIDE__FLOAT64_FLOAT64__FLOAT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "divide", returns = FLOAT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnEq.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnEq.kt similarity index 75% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnEq.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnEq.kt index 6041b7af14..a05b22f8e1 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnEq.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnEq.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -39,17 +39,19 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__ANY_ANY__BOOL : FnScalar { +internal object Fn_EQ__ANY_ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", ANY), FnParameter("rhs", ANY), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -58,17 +60,19 @@ internal object Fn_EQ__ANY_ANY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__BOOL_BOOL__BOOL : FnScalar { +internal object Fn_EQ__BOOL_BOOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", BOOL), FnParameter("rhs", BOOL), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -77,17 +81,19 @@ internal object Fn_EQ__BOOL_BOOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__INT8_INT8__BOOL : FnScalar { +internal object Fn_EQ__INT8_INT8__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", INT8), FnParameter("rhs", INT8), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -96,17 +102,19 @@ internal object Fn_EQ__INT8_INT8__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__INT16_INT16__BOOL : FnScalar { +internal object Fn_EQ__INT16_INT16__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", INT16), FnParameter("rhs", INT16), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -115,17 +123,19 @@ internal object Fn_EQ__INT16_INT16__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__INT32_INT32__BOOL : FnScalar { +internal object Fn_EQ__INT32_INT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", INT32), FnParameter("rhs", INT32), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -134,17 +144,19 @@ internal object Fn_EQ__INT32_INT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__INT64_INT64__BOOL : FnScalar { +internal object Fn_EQ__INT64_INT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", INT64), FnParameter("rhs", INT64), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -153,17 +165,19 @@ internal object Fn_EQ__INT64_INT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__INT_INT__BOOL : FnScalar { +internal object Fn_EQ__INT_INT__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", INT), FnParameter("rhs", INT), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -172,17 +186,19 @@ internal object Fn_EQ__INT_INT__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__DECIMAL_DECIMAL__BOOL : FnScalar { +internal object Fn_EQ__DECIMAL_DECIMAL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", DECIMAL), FnParameter("rhs", DECIMAL), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -191,17 +207,19 @@ internal object Fn_EQ__DECIMAL_DECIMAL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { +internal object Fn_EQ__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", DECIMAL_ARBITRARY), FnParameter("rhs", DECIMAL_ARBITRARY), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -210,17 +228,19 @@ internal object Fn_EQ__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__FLOAT32_FLOAT32__BOOL : FnScalar { +internal object Fn_EQ__FLOAT32_FLOAT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", FLOAT32), FnParameter("rhs", FLOAT32), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -229,17 +249,19 @@ internal object Fn_EQ__FLOAT32_FLOAT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__FLOAT64_FLOAT64__BOOL : FnScalar { +internal object Fn_EQ__FLOAT64_FLOAT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", FLOAT64), FnParameter("rhs", FLOAT64), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -248,17 +270,19 @@ internal object Fn_EQ__FLOAT64_FLOAT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__CHAR_CHAR__BOOL : FnScalar { +internal object Fn_EQ__CHAR_CHAR__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", CHAR), FnParameter("rhs", CHAR), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -267,17 +291,19 @@ internal object Fn_EQ__CHAR_CHAR__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__STRING_STRING__BOOL : FnScalar { +internal object Fn_EQ__STRING_STRING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", STRING), FnParameter("rhs", STRING), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -286,17 +312,19 @@ internal object Fn_EQ__STRING_STRING__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__SYMBOL_SYMBOL__BOOL : FnScalar { +internal object Fn_EQ__SYMBOL_SYMBOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", SYMBOL), FnParameter("rhs", SYMBOL), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -305,17 +333,19 @@ internal object Fn_EQ__SYMBOL_SYMBOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__BINARY_BINARY__BOOL : FnScalar { +internal object Fn_EQ__BINARY_BINARY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", BINARY), FnParameter("rhs", BINARY), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -324,17 +354,19 @@ internal object Fn_EQ__BINARY_BINARY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__BYTE_BYTE__BOOL : FnScalar { +internal object Fn_EQ__BYTE_BYTE__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", BYTE), FnParameter("rhs", BYTE), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -343,17 +375,19 @@ internal object Fn_EQ__BYTE_BYTE__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__BLOB_BLOB__BOOL : FnScalar { +internal object Fn_EQ__BLOB_BLOB__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", BLOB), FnParameter("rhs", BLOB), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -362,17 +396,19 @@ internal object Fn_EQ__BLOB_BLOB__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__CLOB_CLOB__BOOL : FnScalar { +internal object Fn_EQ__CLOB_CLOB__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", CLOB), FnParameter("rhs", CLOB), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -381,17 +417,19 @@ internal object Fn_EQ__CLOB_CLOB__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__DATE_DATE__BOOL : FnScalar { +internal object Fn_EQ__DATE_DATE__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", DATE), FnParameter("rhs", DATE), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -400,17 +438,19 @@ internal object Fn_EQ__DATE_DATE__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__TIME_TIME__BOOL : FnScalar { +internal object Fn_EQ__TIME_TIME__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", TIME), FnParameter("rhs", TIME), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -419,17 +459,19 @@ internal object Fn_EQ__TIME_TIME__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__TIMESTAMP_TIMESTAMP__BOOL : FnScalar { +internal object Fn_EQ__TIMESTAMP_TIMESTAMP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", TIMESTAMP), FnParameter("rhs", TIMESTAMP), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -438,17 +480,19 @@ internal object Fn_EQ__TIMESTAMP_TIMESTAMP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__INTERVAL_INTERVAL__BOOL : FnScalar { +internal object Fn_EQ__INTERVAL_INTERVAL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", INTERVAL), FnParameter("rhs", INTERVAL), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -457,17 +501,19 @@ internal object Fn_EQ__INTERVAL_INTERVAL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__BAG_BAG__BOOL : FnScalar { +internal object Fn_EQ__BAG_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", BAG), FnParameter("rhs", BAG), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -476,17 +522,19 @@ internal object Fn_EQ__BAG_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__LIST_LIST__BOOL : FnScalar { +internal object Fn_EQ__LIST_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", LIST), FnParameter("rhs", LIST), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -495,17 +543,19 @@ internal object Fn_EQ__LIST_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__SEXP_SEXP__BOOL : FnScalar { +internal object Fn_EQ__SEXP_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", SEXP), FnParameter("rhs", SEXP), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -514,17 +564,19 @@ internal object Fn_EQ__SEXP_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__STRUCT_STRUCT__BOOL : FnScalar { +internal object Fn_EQ__STRUCT_STRUCT__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", STRUCT), FnParameter("rhs", STRUCT), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -533,17 +585,19 @@ internal object Fn_EQ__STRUCT_STRUCT__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__NULL_NULL__BOOL : FnScalar { +internal object Fn_EQ__NULL_NULL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", NULL), FnParameter("rhs", NULL), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -552,17 +606,19 @@ internal object Fn_EQ__NULL_NULL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_EQ__MISSING_MISSING__BOOL : FnScalar { +internal object Fn_EQ__MISSING_MISSING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "eq", returns = BOOL, parameters = listOf( FnParameter("lhs", MISSING), FnParameter("rhs", MISSING), ), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnGt.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnGt.kt similarity index 81% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnGt.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnGt.kt index 20ed2cac5a..f8d75b1645 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnGt.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnGt.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -26,9 +26,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__INT8_INT8__BOOL : FnScalar { +internal object Fn_GT__INT8_INT8__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -45,9 +45,9 @@ internal object Fn_GT__INT8_INT8__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__INT16_INT16__BOOL : FnScalar { +internal object Fn_GT__INT16_INT16__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -64,9 +64,9 @@ internal object Fn_GT__INT16_INT16__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__INT32_INT32__BOOL : FnScalar { +internal object Fn_GT__INT32_INT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -83,9 +83,9 @@ internal object Fn_GT__INT32_INT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__INT64_INT64__BOOL : FnScalar { +internal object Fn_GT__INT64_INT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -102,9 +102,9 @@ internal object Fn_GT__INT64_INT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__INT_INT__BOOL : FnScalar { +internal object Fn_GT__INT_INT__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -121,9 +121,9 @@ internal object Fn_GT__INT_INT__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { +internal object Fn_GT__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -140,9 +140,9 @@ internal object Fn_GT__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__FLOAT32_FLOAT32__BOOL : FnScalar { +internal object Fn_GT__FLOAT32_FLOAT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -159,9 +159,9 @@ internal object Fn_GT__FLOAT32_FLOAT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__FLOAT64_FLOAT64__BOOL : FnScalar { +internal object Fn_GT__FLOAT64_FLOAT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -178,9 +178,9 @@ internal object Fn_GT__FLOAT64_FLOAT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__STRING_STRING__BOOL : FnScalar { +internal object Fn_GT__STRING_STRING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -197,9 +197,9 @@ internal object Fn_GT__STRING_STRING__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__SYMBOL_SYMBOL__BOOL : FnScalar { +internal object Fn_GT__SYMBOL_SYMBOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -216,9 +216,9 @@ internal object Fn_GT__SYMBOL_SYMBOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__CLOB_CLOB__BOOL : FnScalar { +internal object Fn_GT__CLOB_CLOB__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -235,9 +235,9 @@ internal object Fn_GT__CLOB_CLOB__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__DATE_DATE__BOOL : FnScalar { +internal object Fn_GT__DATE_DATE__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -254,9 +254,9 @@ internal object Fn_GT__DATE_DATE__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__TIME_TIME__BOOL : FnScalar { +internal object Fn_GT__TIME_TIME__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -273,9 +273,9 @@ internal object Fn_GT__TIME_TIME__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__TIMESTAMP_TIMESTAMP__BOOL : FnScalar { +internal object Fn_GT__TIMESTAMP_TIMESTAMP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( @@ -292,9 +292,9 @@ internal object Fn_GT__TIMESTAMP_TIMESTAMP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GT__BOOL_BOOL__BOOL : FnScalar { +internal object Fn_GT__BOOL_BOOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gt", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnGte.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnGte.kt similarity index 81% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnGte.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnGte.kt index 656963bdd1..8fe241cbe8 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnGte.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnGte.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -26,9 +26,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__INT8_INT8__BOOL : FnScalar { +internal object Fn_GTE__INT8_INT8__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -45,9 +45,9 @@ internal object Fn_GTE__INT8_INT8__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__INT16_INT16__BOOL : FnScalar { +internal object Fn_GTE__INT16_INT16__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -64,9 +64,9 @@ internal object Fn_GTE__INT16_INT16__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__INT32_INT32__BOOL : FnScalar { +internal object Fn_GTE__INT32_INT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -83,9 +83,9 @@ internal object Fn_GTE__INT32_INT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__INT64_INT64__BOOL : FnScalar { +internal object Fn_GTE__INT64_INT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -102,9 +102,9 @@ internal object Fn_GTE__INT64_INT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__INT_INT__BOOL : FnScalar { +internal object Fn_GTE__INT_INT__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -121,9 +121,9 @@ internal object Fn_GTE__INT_INT__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { +internal object Fn_GTE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -140,9 +140,9 @@ internal object Fn_GTE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__FLOAT32_FLOAT32__BOOL : FnScalar { +internal object Fn_GTE__FLOAT32_FLOAT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -159,9 +159,9 @@ internal object Fn_GTE__FLOAT32_FLOAT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__FLOAT64_FLOAT64__BOOL : FnScalar { +internal object Fn_GTE__FLOAT64_FLOAT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -178,9 +178,9 @@ internal object Fn_GTE__FLOAT64_FLOAT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__STRING_STRING__BOOL : FnScalar { +internal object Fn_GTE__STRING_STRING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -197,9 +197,9 @@ internal object Fn_GTE__STRING_STRING__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__SYMBOL_SYMBOL__BOOL : FnScalar { +internal object Fn_GTE__SYMBOL_SYMBOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -216,9 +216,9 @@ internal object Fn_GTE__SYMBOL_SYMBOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__CLOB_CLOB__BOOL : FnScalar { +internal object Fn_GTE__CLOB_CLOB__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -235,9 +235,9 @@ internal object Fn_GTE__CLOB_CLOB__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__DATE_DATE__BOOL : FnScalar { +internal object Fn_GTE__DATE_DATE__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -254,9 +254,9 @@ internal object Fn_GTE__DATE_DATE__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__TIME_TIME__BOOL : FnScalar { +internal object Fn_GTE__TIME_TIME__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -273,9 +273,9 @@ internal object Fn_GTE__TIME_TIME__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__TIMESTAMP_TIMESTAMP__BOOL : FnScalar { +internal object Fn_GTE__TIMESTAMP_TIMESTAMP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( @@ -292,9 +292,9 @@ internal object Fn_GTE__TIMESTAMP_TIMESTAMP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_GTE__BOOL_BOOL__BOOL : FnScalar { +internal object Fn_GTE__BOOL_BOOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "gte", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnInCollection.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnInCollection.kt similarity index 80% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnInCollection.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnInCollection.kt index 90ac6cce38..b401f665cc 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnInCollection.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnInCollection.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -39,9 +39,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__ANY_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__ANY_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -58,9 +58,9 @@ internal object Fn_IN_COLLECTION__ANY_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__ANY_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__ANY_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -77,9 +77,9 @@ internal object Fn_IN_COLLECTION__ANY_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__ANY_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__ANY_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -96,9 +96,9 @@ internal object Fn_IN_COLLECTION__ANY_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BOOL_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BOOL_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -115,9 +115,9 @@ internal object Fn_IN_COLLECTION__BOOL_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BOOL_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BOOL_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -134,9 +134,9 @@ internal object Fn_IN_COLLECTION__BOOL_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BOOL_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BOOL_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -153,9 +153,9 @@ internal object Fn_IN_COLLECTION__BOOL_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT8_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT8_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -172,9 +172,9 @@ internal object Fn_IN_COLLECTION__INT8_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT8_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT8_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -191,9 +191,9 @@ internal object Fn_IN_COLLECTION__INT8_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT8_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT8_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -210,9 +210,9 @@ internal object Fn_IN_COLLECTION__INT8_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT16_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT16_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -229,9 +229,9 @@ internal object Fn_IN_COLLECTION__INT16_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT16_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT16_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -248,9 +248,9 @@ internal object Fn_IN_COLLECTION__INT16_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT16_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT16_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -267,9 +267,9 @@ internal object Fn_IN_COLLECTION__INT16_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT32_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT32_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -286,9 +286,9 @@ internal object Fn_IN_COLLECTION__INT32_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT32_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT32_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -305,9 +305,9 @@ internal object Fn_IN_COLLECTION__INT32_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT32_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT32_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -324,9 +324,9 @@ internal object Fn_IN_COLLECTION__INT32_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT64_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT64_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -343,9 +343,9 @@ internal object Fn_IN_COLLECTION__INT64_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT64_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT64_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -362,9 +362,9 @@ internal object Fn_IN_COLLECTION__INT64_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT64_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT64_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -381,9 +381,9 @@ internal object Fn_IN_COLLECTION__INT64_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -400,9 +400,9 @@ internal object Fn_IN_COLLECTION__INT_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -419,9 +419,9 @@ internal object Fn_IN_COLLECTION__INT_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INT_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INT_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -438,9 +438,9 @@ internal object Fn_IN_COLLECTION__INT_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__DECIMAL_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__DECIMAL_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -457,9 +457,9 @@ internal object Fn_IN_COLLECTION__DECIMAL_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__DECIMAL_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__DECIMAL_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -476,9 +476,9 @@ internal object Fn_IN_COLLECTION__DECIMAL_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__DECIMAL_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__DECIMAL_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -495,9 +495,9 @@ internal object Fn_IN_COLLECTION__DECIMAL_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__DECIMAL_ARBITRARY_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__DECIMAL_ARBITRARY_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -514,9 +514,9 @@ internal object Fn_IN_COLLECTION__DECIMAL_ARBITRARY_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__DECIMAL_ARBITRARY_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__DECIMAL_ARBITRARY_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -533,9 +533,9 @@ internal object Fn_IN_COLLECTION__DECIMAL_ARBITRARY_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__DECIMAL_ARBITRARY_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__DECIMAL_ARBITRARY_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -552,9 +552,9 @@ internal object Fn_IN_COLLECTION__DECIMAL_ARBITRARY_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__FLOAT32_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__FLOAT32_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -571,9 +571,9 @@ internal object Fn_IN_COLLECTION__FLOAT32_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__FLOAT32_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__FLOAT32_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -590,9 +590,9 @@ internal object Fn_IN_COLLECTION__FLOAT32_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__FLOAT32_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__FLOAT32_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -609,9 +609,9 @@ internal object Fn_IN_COLLECTION__FLOAT32_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__FLOAT64_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__FLOAT64_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -628,9 +628,9 @@ internal object Fn_IN_COLLECTION__FLOAT64_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__FLOAT64_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__FLOAT64_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -647,9 +647,9 @@ internal object Fn_IN_COLLECTION__FLOAT64_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__FLOAT64_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__FLOAT64_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -666,9 +666,9 @@ internal object Fn_IN_COLLECTION__FLOAT64_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__CHAR_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__CHAR_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -685,9 +685,9 @@ internal object Fn_IN_COLLECTION__CHAR_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__CHAR_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__CHAR_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -704,9 +704,9 @@ internal object Fn_IN_COLLECTION__CHAR_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__CHAR_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__CHAR_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -723,9 +723,9 @@ internal object Fn_IN_COLLECTION__CHAR_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__STRING_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__STRING_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -742,9 +742,9 @@ internal object Fn_IN_COLLECTION__STRING_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__STRING_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__STRING_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -761,9 +761,9 @@ internal object Fn_IN_COLLECTION__STRING_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__STRING_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__STRING_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -780,9 +780,9 @@ internal object Fn_IN_COLLECTION__STRING_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__SYMBOL_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__SYMBOL_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -799,9 +799,9 @@ internal object Fn_IN_COLLECTION__SYMBOL_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__SYMBOL_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__SYMBOL_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -818,9 +818,9 @@ internal object Fn_IN_COLLECTION__SYMBOL_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__SYMBOL_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__SYMBOL_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -837,9 +837,9 @@ internal object Fn_IN_COLLECTION__SYMBOL_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BINARY_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BINARY_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -856,9 +856,9 @@ internal object Fn_IN_COLLECTION__BINARY_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BINARY_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BINARY_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -875,9 +875,9 @@ internal object Fn_IN_COLLECTION__BINARY_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BINARY_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BINARY_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -894,9 +894,9 @@ internal object Fn_IN_COLLECTION__BINARY_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BYTE_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BYTE_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -913,9 +913,9 @@ internal object Fn_IN_COLLECTION__BYTE_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BYTE_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BYTE_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -932,9 +932,9 @@ internal object Fn_IN_COLLECTION__BYTE_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BYTE_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BYTE_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -951,9 +951,9 @@ internal object Fn_IN_COLLECTION__BYTE_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BLOB_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BLOB_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -970,9 +970,9 @@ internal object Fn_IN_COLLECTION__BLOB_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BLOB_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BLOB_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -989,9 +989,9 @@ internal object Fn_IN_COLLECTION__BLOB_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BLOB_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BLOB_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1008,9 +1008,9 @@ internal object Fn_IN_COLLECTION__BLOB_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__CLOB_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__CLOB_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1027,9 +1027,9 @@ internal object Fn_IN_COLLECTION__CLOB_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__CLOB_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__CLOB_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1046,9 +1046,9 @@ internal object Fn_IN_COLLECTION__CLOB_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__CLOB_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__CLOB_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1065,9 +1065,9 @@ internal object Fn_IN_COLLECTION__CLOB_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__DATE_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__DATE_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1084,9 +1084,9 @@ internal object Fn_IN_COLLECTION__DATE_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__DATE_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__DATE_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1103,9 +1103,9 @@ internal object Fn_IN_COLLECTION__DATE_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__DATE_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__DATE_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1122,9 +1122,9 @@ internal object Fn_IN_COLLECTION__DATE_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__TIME_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__TIME_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1141,9 +1141,9 @@ internal object Fn_IN_COLLECTION__TIME_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__TIME_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__TIME_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1160,9 +1160,9 @@ internal object Fn_IN_COLLECTION__TIME_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__TIME_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__TIME_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1179,9 +1179,9 @@ internal object Fn_IN_COLLECTION__TIME_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__TIMESTAMP_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__TIMESTAMP_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1198,9 +1198,9 @@ internal object Fn_IN_COLLECTION__TIMESTAMP_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__TIMESTAMP_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__TIMESTAMP_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1217,9 +1217,9 @@ internal object Fn_IN_COLLECTION__TIMESTAMP_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__TIMESTAMP_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__TIMESTAMP_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1236,9 +1236,9 @@ internal object Fn_IN_COLLECTION__TIMESTAMP_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INTERVAL_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INTERVAL_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1255,9 +1255,9 @@ internal object Fn_IN_COLLECTION__INTERVAL_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INTERVAL_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INTERVAL_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1274,9 +1274,9 @@ internal object Fn_IN_COLLECTION__INTERVAL_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__INTERVAL_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__INTERVAL_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1293,9 +1293,9 @@ internal object Fn_IN_COLLECTION__INTERVAL_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BAG_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BAG_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1312,9 +1312,9 @@ internal object Fn_IN_COLLECTION__BAG_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BAG_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BAG_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1331,9 +1331,9 @@ internal object Fn_IN_COLLECTION__BAG_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__BAG_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__BAG_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1350,9 +1350,9 @@ internal object Fn_IN_COLLECTION__BAG_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__LIST_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__LIST_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1369,9 +1369,9 @@ internal object Fn_IN_COLLECTION__LIST_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__LIST_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__LIST_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1388,9 +1388,9 @@ internal object Fn_IN_COLLECTION__LIST_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__LIST_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__LIST_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1407,9 +1407,9 @@ internal object Fn_IN_COLLECTION__LIST_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__SEXP_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__SEXP_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1426,9 +1426,9 @@ internal object Fn_IN_COLLECTION__SEXP_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__SEXP_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__SEXP_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1445,9 +1445,9 @@ internal object Fn_IN_COLLECTION__SEXP_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__SEXP_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__SEXP_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1464,9 +1464,9 @@ internal object Fn_IN_COLLECTION__SEXP_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__STRUCT_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__STRUCT_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1483,9 +1483,9 @@ internal object Fn_IN_COLLECTION__STRUCT_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__STRUCT_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__STRUCT_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1502,9 +1502,9 @@ internal object Fn_IN_COLLECTION__STRUCT_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__STRUCT_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__STRUCT_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1521,9 +1521,9 @@ internal object Fn_IN_COLLECTION__STRUCT_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__NULL_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__NULL_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1540,9 +1540,9 @@ internal object Fn_IN_COLLECTION__NULL_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__NULL_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__NULL_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1559,9 +1559,9 @@ internal object Fn_IN_COLLECTION__NULL_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__NULL_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__NULL_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1578,9 +1578,9 @@ internal object Fn_IN_COLLECTION__NULL_SEXP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__MISSING_BAG__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__MISSING_BAG__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1597,9 +1597,9 @@ internal object Fn_IN_COLLECTION__MISSING_BAG__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__MISSING_LIST__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__MISSING_LIST__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -1616,9 +1616,9 @@ internal object Fn_IN_COLLECTION__MISSING_LIST__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IN_COLLECTION__MISSING_SEXP__BOOL : FnScalar { +internal object Fn_IN_COLLECTION__MISSING_SEXP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsAny.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsAny.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsAny.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsAny.kt index 443dea1ff0..0935cfa165 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsAny.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsAny.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_ANY__ANY__BOOL : FnScalar { +internal object Fn_IS_ANY__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_any", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBag.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBag.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBag.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBag.kt index 723e91fd18..d38c504c6b 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBag.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBag.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_BAG__ANY__BOOL : FnScalar { +internal object Fn_IS_BAG__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_bag", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBinary.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBinary.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBinary.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBinary.kt index 525eadf9cf..af3b082cbe 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBinary.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBinary.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_BINARY__ANY__BOOL : FnScalar { +internal object Fn_IS_BINARY__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_binary", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBlob.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBlob.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBlob.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBlob.kt index c4b9e594a7..db7c060083 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBlob.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBlob.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_BLOB__ANY__BOOL : FnScalar { +internal object Fn_IS_BLOB__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_blob", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBool.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBool.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBool.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBool.kt index d7d2131346..3b555826da 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsBool.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsBool.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_BOOL__ANY__BOOL : FnScalar { +internal object Fn_IS_BOOL__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_bool", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsByte.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsByte.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsByte.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsByte.kt index 22390822d4..95bd7f0f54 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsByte.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsByte.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_BYTE__ANY__BOOL : FnScalar { +internal object Fn_IS_BYTE__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_byte", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsChar.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsChar.kt similarity index 79% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsChar.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsChar.kt index a8353f49d4..73e1b6ac5b 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsChar.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsChar.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.BOOL import org.partiql.value.PartiQLValueType.INT32 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_CHAR__ANY__BOOL : FnScalar { +internal object Fn_IS_CHAR__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_char", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), @@ -30,9 +30,9 @@ internal object Fn_IS_CHAR__ANY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_CHAR__INT32_ANY__BOOL : FnScalar { +internal object Fn_IS_CHAR__INT32_ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_char", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsClob.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsClob.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsClob.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsClob.kt index 48b88e6439..1c63068ada 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsClob.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsClob.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_CLOB__ANY__BOOL : FnScalar { +internal object Fn_IS_CLOB__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_clob", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsDate.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsDate.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsDate.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsDate.kt index ccb206559c..053fcca21a 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsDate.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsDate.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_DATE__ANY__BOOL : FnScalar { +internal object Fn_IS_DATE__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_date", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsDecimal.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsDecimal.kt similarity index 79% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsDecimal.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsDecimal.kt index b4670ee5c7..0734666985 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsDecimal.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsDecimal.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.BOOL import org.partiql.value.PartiQLValueType.INT32 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_DECIMAL__ANY__BOOL : FnScalar { +internal object Fn_IS_DECIMAL__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_decimal", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), @@ -30,9 +30,9 @@ internal object Fn_IS_DECIMAL__ANY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_DECIMAL__INT32_INT32_ANY__BOOL : FnScalar { +internal object Fn_IS_DECIMAL__INT32_INT32_ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_decimal", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsDecimalArbitrary.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsDecimalArbitrary.kt similarity index 77% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsDecimalArbitrary.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsDecimalArbitrary.kt index 6b9611bfcb..50775e6f69 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsDecimalArbitrary.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsDecimalArbitrary.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_DECIMAL_ARBITRARY__ANY__BOOL : FnScalar { +internal object Fn_IS_DECIMAL_ARBITRARY__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_decimal_arbitrary", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsFloat32.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsFloat32.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsFloat32.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsFloat32.kt index 83ff5b720f..0404e40b95 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsFloat32.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsFloat32.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_FLOAT32__ANY__BOOL : FnScalar { +internal object Fn_IS_FLOAT32__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_float32", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsFloat64.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsFloat64.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsFloat64.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsFloat64.kt index af4028bcee..f342381891 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsFloat64.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsFloat64.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_FLOAT64__ANY__BOOL : FnScalar { +internal object Fn_IS_FLOAT64__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_float64", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt.kt index 6eed56e546..f24a02e960 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_INT__ANY__BOOL : FnScalar { +internal object Fn_IS_INT__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_int", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt16.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt16.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt16.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt16.kt index 285df72042..22f6ad3376 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt16.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt16.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_INT16__ANY__BOOL : FnScalar { +internal object Fn_IS_INT16__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_int16", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt32.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt32.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt32.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt32.kt index a7c546c487..e727919cd6 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt32.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt32.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_INT32__ANY__BOOL : FnScalar { +internal object Fn_IS_INT32__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_int32", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt64.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt64.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt64.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt64.kt index 9a01b91442..c9295241eb 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt64.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt64.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_INT64__ANY__BOOL : FnScalar { +internal object Fn_IS_INT64__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_int64", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt8.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt8.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt8.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt8.kt index 99c699b68c..43a145f7e6 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInt8.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInt8.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_INT8__ANY__BOOL : FnScalar { +internal object Fn_IS_INT8__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_int8", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInterval.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInterval.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInterval.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInterval.kt index 9b5263eb07..1dea870796 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsInterval.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsInterval.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_INTERVAL__ANY__BOOL : FnScalar { +internal object Fn_IS_INTERVAL__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_interval", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsList.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsList.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsList.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsList.kt index df8845a13e..0bfcdbc0cf 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsList.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsList.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_LIST__ANY__BOOL : FnScalar { +internal object Fn_IS_LIST__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_list", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsMissing.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsMissing.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsMissing.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsMissing.kt index 288ad17e69..6cf4c619c8 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsMissing.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsMissing.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,14 +13,15 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_MISSING__ANY__BOOL : FnScalar { +internal object Fn_IS_MISSING__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_missing", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), isNullCall = false, isNullable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsNull.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsNull.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsNull.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsNull.kt index d95c8e1987..6fddc7fbb9 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsNull.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsNull.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,14 +13,15 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_NULL__ANY__BOOL : FnScalar { +internal object Fn_IS_NULL__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_null", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), isNullCall = false, isNullable = false, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsSexp.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsSexp.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsSexp.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsSexp.kt index 2060ca859a..35adcc161a 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsSexp.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsSexp.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_SEXP__ANY__BOOL : FnScalar { +internal object Fn_IS_SEXP__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_sexp", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsString.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsString.kt similarity index 79% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsString.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsString.kt index e217a8f7c1..aaf0dea974 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsString.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsString.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.BOOL import org.partiql.value.PartiQLValueType.INT32 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_STRING__ANY__BOOL : FnScalar { +internal object Fn_IS_STRING__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_string", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), @@ -30,9 +30,9 @@ internal object Fn_IS_STRING__ANY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_STRING__INT32_ANY__BOOL : FnScalar { +internal object Fn_IS_STRING__INT32_ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_string", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsStruct.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsStruct.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsStruct.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsStruct.kt index 1881762175..d6e1185001 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsStruct.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsStruct.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_STRUCT__ANY__BOOL : FnScalar { +internal object Fn_IS_STRUCT__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_struct", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsSymbol.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsSymbol.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsSymbol.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsSymbol.kt index 650617955d..00016bd6cf 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsSymbol.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsSymbol.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.ANY import org.partiql.value.PartiQLValueType.BOOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_SYMBOL__ANY__BOOL : FnScalar { +internal object Fn_IS_SYMBOL__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_symbol", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsTime.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsTime.kt similarity index 80% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsTime.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsTime.kt index 6c90276d72..a93caed82d 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsTime.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsTime.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.BOOL import org.partiql.value.PartiQLValueType.INT32 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_TIME__ANY__BOOL : FnScalar { +internal object Fn_IS_TIME__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_time", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), @@ -30,9 +30,9 @@ internal object Fn_IS_TIME__ANY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_TIME__BOOL_INT32_ANY__BOOL : FnScalar { +internal object Fn_IS_TIME__BOOL_INT32_ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_time", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsTimestamp.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsTimestamp.kt similarity index 79% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsTimestamp.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsTimestamp.kt index 88e6f5f577..a16f79bc63 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnIsTimestamp.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnIsTimestamp.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.BOOL import org.partiql.value.PartiQLValueType.INT32 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_TIMESTAMP__ANY__BOOL : FnScalar { +internal object Fn_IS_TIMESTAMP__ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_timestamp", returns = BOOL, parameters = listOf(FnParameter("value", ANY),), @@ -30,9 +30,9 @@ internal object Fn_IS_TIMESTAMP__ANY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_IS_TIMESTAMP__BOOL_INT32_ANY__BOOL : FnScalar { +internal object Fn_IS_TIMESTAMP__BOOL_INT32_ANY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "is_timestamp", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLike.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLike.kt similarity index 80% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLike.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLike.kt index 39d2fa7c57..f2a62f9469 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLike.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLike.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -15,9 +15,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LIKE__STRING_STRING__BOOL : FnScalar { +internal object Fn_LIKE__STRING_STRING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "like", returns = BOOL, parameters = listOf( @@ -34,9 +34,9 @@ internal object Fn_LIKE__STRING_STRING__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LIKE__SYMBOL_SYMBOL__BOOL : FnScalar { +internal object Fn_LIKE__SYMBOL_SYMBOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "like", returns = BOOL, parameters = listOf( @@ -53,9 +53,9 @@ internal object Fn_LIKE__SYMBOL_SYMBOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LIKE__CLOB_CLOB__BOOL : FnScalar { +internal object Fn_LIKE__CLOB_CLOB__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "like", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLikeEscape.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLikeEscape.kt similarity index 80% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLikeEscape.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLikeEscape.kt index 529620e159..fadb6fca72 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLikeEscape.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLikeEscape.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -15,9 +15,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LIKE_ESCAPE__STRING_STRING_STRING__BOOL : FnScalar { +internal object Fn_LIKE_ESCAPE__STRING_STRING_STRING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "like_escape", returns = BOOL, parameters = listOf( @@ -35,9 +35,9 @@ internal object Fn_LIKE_ESCAPE__STRING_STRING_STRING__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LIKE_ESCAPE__SYMBOL_SYMBOL_SYMBOL__BOOL : FnScalar { +internal object Fn_LIKE_ESCAPE__SYMBOL_SYMBOL_SYMBOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "like_escape", returns = BOOL, parameters = listOf( @@ -55,9 +55,9 @@ internal object Fn_LIKE_ESCAPE__SYMBOL_SYMBOL_SYMBOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LIKE_ESCAPE__CLOB_CLOB_CLOB__BOOL : FnScalar { +internal object Fn_LIKE_ESCAPE__CLOB_CLOB_CLOB__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "like_escape", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLower.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLower.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLower.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLower.kt index 3f7159c721..c9d1d6ac1d 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLower.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLower.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LOWER__STRING__STRING : FnScalar { +internal object Fn_LOWER__STRING__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lower", returns = STRING, parameters = listOf(FnParameter("value", STRING),), @@ -30,9 +30,9 @@ internal object Fn_LOWER__STRING__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LOWER__SYMBOL__SYMBOL : FnScalar { +internal object Fn_LOWER__SYMBOL__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lower", returns = SYMBOL, parameters = listOf(FnParameter("value", SYMBOL),), @@ -46,9 +46,9 @@ internal object Fn_LOWER__SYMBOL__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LOWER__CLOB__CLOB : FnScalar { +internal object Fn_LOWER__CLOB__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lower", returns = CLOB, parameters = listOf(FnParameter("value", CLOB),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLt.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLt.kt similarity index 81% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLt.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLt.kt index 782b7dc260..6d9d2b8882 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLt.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLt.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -26,9 +26,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__INT8_INT8__BOOL : FnScalar { +internal object Fn_LT__INT8_INT8__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -45,9 +45,9 @@ internal object Fn_LT__INT8_INT8__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__INT16_INT16__BOOL : FnScalar { +internal object Fn_LT__INT16_INT16__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -64,9 +64,9 @@ internal object Fn_LT__INT16_INT16__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__INT32_INT32__BOOL : FnScalar { +internal object Fn_LT__INT32_INT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -83,9 +83,9 @@ internal object Fn_LT__INT32_INT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__INT64_INT64__BOOL : FnScalar { +internal object Fn_LT__INT64_INT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -102,9 +102,9 @@ internal object Fn_LT__INT64_INT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__INT_INT__BOOL : FnScalar { +internal object Fn_LT__INT_INT__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -121,9 +121,9 @@ internal object Fn_LT__INT_INT__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { +internal object Fn_LT__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -140,9 +140,9 @@ internal object Fn_LT__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__FLOAT32_FLOAT32__BOOL : FnScalar { +internal object Fn_LT__FLOAT32_FLOAT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -159,9 +159,9 @@ internal object Fn_LT__FLOAT32_FLOAT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__FLOAT64_FLOAT64__BOOL : FnScalar { +internal object Fn_LT__FLOAT64_FLOAT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -178,9 +178,9 @@ internal object Fn_LT__FLOAT64_FLOAT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__STRING_STRING__BOOL : FnScalar { +internal object Fn_LT__STRING_STRING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -197,9 +197,9 @@ internal object Fn_LT__STRING_STRING__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__SYMBOL_SYMBOL__BOOL : FnScalar { +internal object Fn_LT__SYMBOL_SYMBOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -216,9 +216,9 @@ internal object Fn_LT__SYMBOL_SYMBOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__CLOB_CLOB__BOOL : FnScalar { +internal object Fn_LT__CLOB_CLOB__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -235,9 +235,9 @@ internal object Fn_LT__CLOB_CLOB__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__DATE_DATE__BOOL : FnScalar { +internal object Fn_LT__DATE_DATE__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -254,9 +254,9 @@ internal object Fn_LT__DATE_DATE__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__TIME_TIME__BOOL : FnScalar { +internal object Fn_LT__TIME_TIME__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -273,9 +273,9 @@ internal object Fn_LT__TIME_TIME__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__TIMESTAMP_TIMESTAMP__BOOL : FnScalar { +internal object Fn_LT__TIMESTAMP_TIMESTAMP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( @@ -292,9 +292,9 @@ internal object Fn_LT__TIMESTAMP_TIMESTAMP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LT__BOOL_BOOL__BOOL : FnScalar { +internal object Fn_LT__BOOL_BOOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lt", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLte.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLte.kt similarity index 81% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLte.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLte.kt index 742f56be18..df71b591f6 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnLte.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnLte.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -26,9 +26,9 @@ import org.partiql.value.PartiQLValueType.TIME import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__INT8_INT8__BOOL : FnScalar { +internal object Fn_LTE__INT8_INT8__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -45,9 +45,9 @@ internal object Fn_LTE__INT8_INT8__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__INT16_INT16__BOOL : FnScalar { +internal object Fn_LTE__INT16_INT16__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -64,9 +64,9 @@ internal object Fn_LTE__INT16_INT16__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__INT32_INT32__BOOL : FnScalar { +internal object Fn_LTE__INT32_INT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -83,9 +83,9 @@ internal object Fn_LTE__INT32_INT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__INT64_INT64__BOOL : FnScalar { +internal object Fn_LTE__INT64_INT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -102,9 +102,9 @@ internal object Fn_LTE__INT64_INT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__INT_INT__BOOL : FnScalar { +internal object Fn_LTE__INT_INT__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -121,9 +121,9 @@ internal object Fn_LTE__INT_INT__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { +internal object Fn_LTE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -140,9 +140,9 @@ internal object Fn_LTE__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__FLOAT32_FLOAT32__BOOL : FnScalar { +internal object Fn_LTE__FLOAT32_FLOAT32__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -159,9 +159,9 @@ internal object Fn_LTE__FLOAT32_FLOAT32__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__FLOAT64_FLOAT64__BOOL : FnScalar { +internal object Fn_LTE__FLOAT64_FLOAT64__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -178,9 +178,9 @@ internal object Fn_LTE__FLOAT64_FLOAT64__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__STRING_STRING__BOOL : FnScalar { +internal object Fn_LTE__STRING_STRING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -197,9 +197,9 @@ internal object Fn_LTE__STRING_STRING__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__SYMBOL_SYMBOL__BOOL : FnScalar { +internal object Fn_LTE__SYMBOL_SYMBOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -216,9 +216,9 @@ internal object Fn_LTE__SYMBOL_SYMBOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__CLOB_CLOB__BOOL : FnScalar { +internal object Fn_LTE__CLOB_CLOB__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -235,9 +235,9 @@ internal object Fn_LTE__CLOB_CLOB__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__DATE_DATE__BOOL : FnScalar { +internal object Fn_LTE__DATE_DATE__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -254,9 +254,9 @@ internal object Fn_LTE__DATE_DATE__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__TIME_TIME__BOOL : FnScalar { +internal object Fn_LTE__TIME_TIME__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -273,9 +273,9 @@ internal object Fn_LTE__TIME_TIME__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__TIMESTAMP_TIMESTAMP__BOOL : FnScalar { +internal object Fn_LTE__TIMESTAMP_TIMESTAMP__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( @@ -292,9 +292,9 @@ internal object Fn_LTE__TIMESTAMP_TIMESTAMP__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_LTE__BOOL_BOOL__BOOL : FnScalar { +internal object Fn_LTE__BOOL_BOOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "lte", returns = BOOL, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnMinus.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnMinus.kt similarity index 81% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnMinus.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnMinus.kt index 527190b129..fee1180a15 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnMinus.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnMinus.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -19,9 +19,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MINUS__INT8_INT8__INT8 : FnScalar { +internal object Fn_MINUS__INT8_INT8__INT8 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "minus", returns = INT8, parameters = listOf( @@ -38,9 +38,9 @@ internal object Fn_MINUS__INT8_INT8__INT8 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MINUS__INT16_INT16__INT16 : FnScalar { +internal object Fn_MINUS__INT16_INT16__INT16 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "minus", returns = INT16, parameters = listOf( @@ -57,9 +57,9 @@ internal object Fn_MINUS__INT16_INT16__INT16 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MINUS__INT32_INT32__INT32 : FnScalar { +internal object Fn_MINUS__INT32_INT32__INT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "minus", returns = INT32, parameters = listOf( @@ -76,9 +76,9 @@ internal object Fn_MINUS__INT32_INT32__INT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MINUS__INT64_INT64__INT64 : FnScalar { +internal object Fn_MINUS__INT64_INT64__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "minus", returns = INT64, parameters = listOf( @@ -95,9 +95,9 @@ internal object Fn_MINUS__INT64_INT64__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MINUS__INT_INT__INT : FnScalar { +internal object Fn_MINUS__INT_INT__INT : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "minus", returns = INT, parameters = listOf( @@ -114,9 +114,9 @@ internal object Fn_MINUS__INT_INT__INT : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MINUS__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnScalar { +internal object Fn_MINUS__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "minus", returns = DECIMAL_ARBITRARY, parameters = listOf( @@ -133,9 +133,9 @@ internal object Fn_MINUS__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MINUS__FLOAT32_FLOAT32__FLOAT32 : FnScalar { +internal object Fn_MINUS__FLOAT32_FLOAT32__FLOAT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "minus", returns = FLOAT32, parameters = listOf( @@ -152,9 +152,9 @@ internal object Fn_MINUS__FLOAT32_FLOAT32__FLOAT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MINUS__FLOAT64_FLOAT64__FLOAT64 : FnScalar { +internal object Fn_MINUS__FLOAT64_FLOAT64__FLOAT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "minus", returns = FLOAT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnModulo.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnModulo.kt similarity index 81% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnModulo.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnModulo.kt index 38b34a0f74..93118c42a7 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnModulo.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnModulo.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -19,9 +19,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MODULO__INT8_INT8__INT8 : FnScalar { +internal object Fn_MODULO__INT8_INT8__INT8 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "modulo", returns = INT8, parameters = listOf( @@ -38,9 +38,9 @@ internal object Fn_MODULO__INT8_INT8__INT8 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MODULO__INT16_INT16__INT16 : FnScalar { +internal object Fn_MODULO__INT16_INT16__INT16 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "modulo", returns = INT16, parameters = listOf( @@ -57,9 +57,9 @@ internal object Fn_MODULO__INT16_INT16__INT16 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MODULO__INT32_INT32__INT32 : FnScalar { +internal object Fn_MODULO__INT32_INT32__INT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "modulo", returns = INT32, parameters = listOf( @@ -76,9 +76,9 @@ internal object Fn_MODULO__INT32_INT32__INT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MODULO__INT64_INT64__INT64 : FnScalar { +internal object Fn_MODULO__INT64_INT64__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "modulo", returns = INT64, parameters = listOf( @@ -95,9 +95,9 @@ internal object Fn_MODULO__INT64_INT64__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MODULO__INT_INT__INT : FnScalar { +internal object Fn_MODULO__INT_INT__INT : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "modulo", returns = INT, parameters = listOf( @@ -114,9 +114,9 @@ internal object Fn_MODULO__INT_INT__INT : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MODULO__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnScalar { +internal object Fn_MODULO__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "modulo", returns = DECIMAL_ARBITRARY, parameters = listOf( @@ -133,9 +133,9 @@ internal object Fn_MODULO__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRAR } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MODULO__FLOAT32_FLOAT32__FLOAT32 : FnScalar { +internal object Fn_MODULO__FLOAT32_FLOAT32__FLOAT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "modulo", returns = FLOAT32, parameters = listOf( @@ -152,9 +152,9 @@ internal object Fn_MODULO__FLOAT32_FLOAT32__FLOAT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_MODULO__FLOAT64_FLOAT64__FLOAT64 : FnScalar { +internal object Fn_MODULO__FLOAT64_FLOAT64__FLOAT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "modulo", returns = FLOAT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnNeg.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnNeg.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnNeg.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnNeg.kt index 4552d0ffa2..b8b297354f 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnNeg.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnNeg.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -19,14 +19,15 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_NEG__INT8__INT8 : FnScalar { +internal object Fn_NEG__INT8__INT8 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "neg", returns = INT8, parameters = listOf(FnParameter("value", INT8),), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, ) override fun invoke(args: Array): PartiQLValue { @@ -35,14 +36,15 @@ internal object Fn_NEG__INT8__INT8 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_NEG__INT16__INT16 : FnScalar { +internal object Fn_NEG__INT16__INT16 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "neg", returns = INT16, parameters = listOf(FnParameter("value", INT16),), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, ) override fun invoke(args: Array): PartiQLValue { @@ -51,14 +53,15 @@ internal object Fn_NEG__INT16__INT16 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_NEG__INT32__INT32 : FnScalar { +internal object Fn_NEG__INT32__INT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "neg", returns = INT32, parameters = listOf(FnParameter("value", INT32),), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, ) override fun invoke(args: Array): PartiQLValue { @@ -67,14 +70,15 @@ internal object Fn_NEG__INT32__INT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_NEG__INT64__INT64 : FnScalar { +internal object Fn_NEG__INT64__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "neg", returns = INT64, parameters = listOf(FnParameter("value", INT64),), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, ) override fun invoke(args: Array): PartiQLValue { @@ -83,14 +87,15 @@ internal object Fn_NEG__INT64__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_NEG__INT__INT : FnScalar { +internal object Fn_NEG__INT__INT : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "neg", returns = INT, parameters = listOf(FnParameter("value", INT),), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, ) override fun invoke(args: Array): PartiQLValue { @@ -99,14 +104,15 @@ internal object Fn_NEG__INT__INT : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_NEG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnScalar { +internal object Fn_NEG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "neg", returns = DECIMAL_ARBITRARY, parameters = listOf(FnParameter("value", DECIMAL_ARBITRARY),), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, ) override fun invoke(args: Array): PartiQLValue { @@ -115,14 +121,15 @@ internal object Fn_NEG__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_NEG__FLOAT32__FLOAT32 : FnScalar { +internal object Fn_NEG__FLOAT32__FLOAT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "neg", returns = FLOAT32, parameters = listOf(FnParameter("value", FLOAT32),), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, ) override fun invoke(args: Array): PartiQLValue { @@ -131,14 +138,15 @@ internal object Fn_NEG__FLOAT32__FLOAT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_NEG__FLOAT64__FLOAT64 : FnScalar { +internal object Fn_NEG__FLOAT64__FLOAT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "neg", returns = FLOAT64, parameters = listOf(FnParameter("value", FLOAT64),), - isNullCall = true, isNullable = false, + isNullCall = true, + isMissable = false, ) override fun invoke(args: Array): PartiQLValue { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnNot.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnNot.kt similarity index 66% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnNot.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnNot.kt index 8a10bab61f..4374d90f63 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnNot.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnNot.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,14 +13,16 @@ import org.partiql.value.PartiQLValueType.BOOL import org.partiql.value.PartiQLValueType.MISSING @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_NOT__BOOL__BOOL : FnScalar { +internal object Fn_NOT__BOOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "not", returns = BOOL, - parameters = listOf(FnParameter("value", BOOL),), + parameters = listOf(FnParameter("value", BOOL)), isNullCall = true, isNullable = false, + isMissingCall = false, + isMissable = false, ) override fun invoke(args: Array): PartiQLValue { @@ -29,14 +31,16 @@ internal object Fn_NOT__BOOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_NOT__MISSING__BOOL : FnScalar { +internal object Fn_NOT__MISSING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "not", returns = BOOL, - parameters = listOf(FnParameter("value", MISSING),), + parameters = listOf(FnParameter("value", MISSING)), isNullCall = true, isNullable = false, + isMissingCall = false, + isMissable = false, ) override fun invoke(args: Array): PartiQLValue { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnOr.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnOr.kt similarity index 77% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnOr.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnOr.kt index 0b62458c6b..68534a370f 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnOr.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnOr.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -13,9 +13,9 @@ import org.partiql.value.PartiQLValueType.BOOL import org.partiql.value.PartiQLValueType.MISSING @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_OR__BOOL_BOOL__BOOL : FnScalar { +internal object Fn_OR__BOOL_BOOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "or", returns = BOOL, parameters = listOf( @@ -24,6 +24,7 @@ internal object Fn_OR__BOOL_BOOL__BOOL : FnScalar { ), isNullCall = false, isNullable = true, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -32,9 +33,9 @@ internal object Fn_OR__BOOL_BOOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_OR__MISSING_BOOL__BOOL : FnScalar { +internal object Fn_OR__MISSING_BOOL__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "or", returns = BOOL, parameters = listOf( @@ -43,6 +44,7 @@ internal object Fn_OR__MISSING_BOOL__BOOL : FnScalar { ), isNullCall = false, isNullable = true, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -51,9 +53,9 @@ internal object Fn_OR__MISSING_BOOL__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_OR__BOOL_MISSING__BOOL : FnScalar { +internal object Fn_OR__BOOL_MISSING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "or", returns = BOOL, parameters = listOf( @@ -62,6 +64,7 @@ internal object Fn_OR__BOOL_MISSING__BOOL : FnScalar { ), isNullCall = false, isNullable = true, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { @@ -70,9 +73,9 @@ internal object Fn_OR__BOOL_MISSING__BOOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_OR__MISSING_MISSING__BOOL : FnScalar { +internal object Fn_OR__MISSING_MISSING__BOOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "or", returns = BOOL, parameters = listOf( @@ -81,6 +84,7 @@ internal object Fn_OR__MISSING_MISSING__BOOL : FnScalar { ), isNullCall = false, isNullable = true, + isMissingCall = false, ) override fun invoke(args: Array): PartiQLValue { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnPlus.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnPlus.kt similarity index 81% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnPlus.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnPlus.kt index f89fc2baf5..245229300f 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnPlus.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnPlus.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -19,9 +19,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_PLUS__INT8_INT8__INT8 : FnScalar { +internal object Fn_PLUS__INT8_INT8__INT8 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "plus", returns = INT8, parameters = listOf( @@ -38,9 +38,9 @@ internal object Fn_PLUS__INT8_INT8__INT8 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_PLUS__INT16_INT16__INT16 : FnScalar { +internal object Fn_PLUS__INT16_INT16__INT16 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "plus", returns = INT16, parameters = listOf( @@ -57,9 +57,9 @@ internal object Fn_PLUS__INT16_INT16__INT16 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_PLUS__INT32_INT32__INT32 : FnScalar { +internal object Fn_PLUS__INT32_INT32__INT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "plus", returns = INT32, parameters = listOf( @@ -76,9 +76,9 @@ internal object Fn_PLUS__INT32_INT32__INT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_PLUS__INT64_INT64__INT64 : FnScalar { +internal object Fn_PLUS__INT64_INT64__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "plus", returns = INT64, parameters = listOf( @@ -95,9 +95,9 @@ internal object Fn_PLUS__INT64_INT64__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_PLUS__INT_INT__INT : FnScalar { +internal object Fn_PLUS__INT_INT__INT : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "plus", returns = INT, parameters = listOf( @@ -114,9 +114,9 @@ internal object Fn_PLUS__INT_INT__INT : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_PLUS__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnScalar { +internal object Fn_PLUS__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "plus", returns = DECIMAL_ARBITRARY, parameters = listOf( @@ -133,9 +133,9 @@ internal object Fn_PLUS__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_PLUS__FLOAT32_FLOAT32__FLOAT32 : FnScalar { +internal object Fn_PLUS__FLOAT32_FLOAT32__FLOAT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "plus", returns = FLOAT32, parameters = listOf( @@ -152,9 +152,9 @@ internal object Fn_PLUS__FLOAT32_FLOAT32__FLOAT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_PLUS__FLOAT64_FLOAT64__FLOAT64 : FnScalar { +internal object Fn_PLUS__FLOAT64_FLOAT64__FLOAT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "plus", returns = FLOAT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnPos.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnPos.kt similarity index 80% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnPos.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnPos.kt index 7d45479d59..9d35952c99 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnPos.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnPos.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -19,9 +19,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POS__INT8__INT8 : FnScalar { +internal object Fn_POS__INT8__INT8 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "pos", returns = INT8, parameters = listOf(FnParameter("value", INT8),), @@ -35,9 +35,9 @@ internal object Fn_POS__INT8__INT8 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POS__INT16__INT16 : FnScalar { +internal object Fn_POS__INT16__INT16 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "pos", returns = INT16, parameters = listOf(FnParameter("value", INT16),), @@ -51,9 +51,9 @@ internal object Fn_POS__INT16__INT16 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POS__INT32__INT32 : FnScalar { +internal object Fn_POS__INT32__INT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "pos", returns = INT32, parameters = listOf(FnParameter("value", INT32),), @@ -67,9 +67,9 @@ internal object Fn_POS__INT32__INT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POS__INT64__INT64 : FnScalar { +internal object Fn_POS__INT64__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "pos", returns = INT64, parameters = listOf(FnParameter("value", INT64),), @@ -83,9 +83,9 @@ internal object Fn_POS__INT64__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POS__INT__INT : FnScalar { +internal object Fn_POS__INT__INT : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "pos", returns = INT, parameters = listOf(FnParameter("value", INT),), @@ -99,9 +99,9 @@ internal object Fn_POS__INT__INT : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POS__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnScalar { +internal object Fn_POS__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "pos", returns = DECIMAL_ARBITRARY, parameters = listOf(FnParameter("value", DECIMAL_ARBITRARY),), @@ -115,9 +115,9 @@ internal object Fn_POS__DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POS__FLOAT32__FLOAT32 : FnScalar { +internal object Fn_POS__FLOAT32__FLOAT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "pos", returns = FLOAT32, parameters = listOf(FnParameter("value", FLOAT32),), @@ -131,9 +131,9 @@ internal object Fn_POS__FLOAT32__FLOAT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POS__FLOAT64__FLOAT64 : FnScalar { +internal object Fn_POS__FLOAT64__FLOAT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "pos", returns = FLOAT64, parameters = listOf(FnParameter("value", FLOAT64),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnPosition.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnPosition.kt similarity index 80% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnPosition.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnPosition.kt index af863b2fa0..2decac54cc 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnPosition.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnPosition.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -15,9 +15,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POSITION__STRING_STRING__INT64 : FnScalar { +internal object Fn_POSITION__STRING_STRING__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "position", returns = INT64, parameters = listOf( @@ -34,9 +34,9 @@ internal object Fn_POSITION__STRING_STRING__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POSITION__SYMBOL_SYMBOL__INT64 : FnScalar { +internal object Fn_POSITION__SYMBOL_SYMBOL__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "position", returns = INT64, parameters = listOf( @@ -53,9 +53,9 @@ internal object Fn_POSITION__SYMBOL_SYMBOL__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_POSITION__CLOB_CLOB__INT64 : FnScalar { +internal object Fn_POSITION__CLOB_CLOB__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "position", returns = INT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnSubstring.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnSubstring.kt similarity index 80% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnSubstring.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnSubstring.kt index 49f5315ab3..73ceca97ad 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnSubstring.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnSubstring.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -15,9 +15,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_SUBSTRING__STRING_INT64__STRING : FnScalar { +internal object Fn_SUBSTRING__STRING_INT64__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "substring", returns = STRING, parameters = listOf( @@ -34,9 +34,9 @@ internal object Fn_SUBSTRING__STRING_INT64__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_SUBSTRING__STRING_INT64_INT64__STRING : FnScalar { +internal object Fn_SUBSTRING__STRING_INT64_INT64__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "substring", returns = STRING, parameters = listOf( @@ -54,9 +54,9 @@ internal object Fn_SUBSTRING__STRING_INT64_INT64__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_SUBSTRING__SYMBOL_INT64__SYMBOL : FnScalar { +internal object Fn_SUBSTRING__SYMBOL_INT64__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "substring", returns = SYMBOL, parameters = listOf( @@ -73,9 +73,9 @@ internal object Fn_SUBSTRING__SYMBOL_INT64__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_SUBSTRING__SYMBOL_INT64_INT64__SYMBOL : FnScalar { +internal object Fn_SUBSTRING__SYMBOL_INT64_INT64__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "substring", returns = SYMBOL, parameters = listOf( @@ -93,9 +93,9 @@ internal object Fn_SUBSTRING__SYMBOL_INT64_INT64__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_SUBSTRING__CLOB_INT64__CLOB : FnScalar { +internal object Fn_SUBSTRING__CLOB_INT64__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "substring", returns = CLOB, parameters = listOf( @@ -112,9 +112,9 @@ internal object Fn_SUBSTRING__CLOB_INT64__CLOB : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_SUBSTRING__CLOB_INT64_INT64__CLOB : FnScalar { +internal object Fn_SUBSTRING__CLOB_INT64_INT64__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "substring", returns = CLOB, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTimes.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTimes.kt similarity index 81% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTimes.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTimes.kt index 075f3ab20e..3089eceaee 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTimes.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTimes.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -19,9 +19,9 @@ import org.partiql.value.PartiQLValueType.INT64 import org.partiql.value.PartiQLValueType.INT8 @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TIMES__INT8_INT8__INT8 : FnScalar { +internal object Fn_TIMES__INT8_INT8__INT8 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "times", returns = INT8, parameters = listOf( @@ -38,9 +38,9 @@ internal object Fn_TIMES__INT8_INT8__INT8 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TIMES__INT16_INT16__INT16 : FnScalar { +internal object Fn_TIMES__INT16_INT16__INT16 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "times", returns = INT16, parameters = listOf( @@ -57,9 +57,9 @@ internal object Fn_TIMES__INT16_INT16__INT16 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TIMES__INT32_INT32__INT32 : FnScalar { +internal object Fn_TIMES__INT32_INT32__INT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "times", returns = INT32, parameters = listOf( @@ -76,9 +76,9 @@ internal object Fn_TIMES__INT32_INT32__INT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TIMES__INT64_INT64__INT64 : FnScalar { +internal object Fn_TIMES__INT64_INT64__INT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "times", returns = INT64, parameters = listOf( @@ -95,9 +95,9 @@ internal object Fn_TIMES__INT64_INT64__INT64 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TIMES__INT_INT__INT : FnScalar { +internal object Fn_TIMES__INT_INT__INT : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "times", returns = INT, parameters = listOf( @@ -114,9 +114,9 @@ internal object Fn_TIMES__INT_INT__INT : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TIMES__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : FnScalar { +internal object Fn_TIMES__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "times", returns = DECIMAL_ARBITRARY, parameters = listOf( @@ -133,9 +133,9 @@ internal object Fn_TIMES__DECIMAL_ARBITRARY_DECIMAL_ARBITRARY__DECIMAL_ARBITRARY } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TIMES__FLOAT32_FLOAT32__FLOAT32 : FnScalar { +internal object Fn_TIMES__FLOAT32_FLOAT32__FLOAT32 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "times", returns = FLOAT32, parameters = listOf( @@ -152,9 +152,9 @@ internal object Fn_TIMES__FLOAT32_FLOAT32__FLOAT32 : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TIMES__FLOAT64_FLOAT64__FLOAT64 : FnScalar { +internal object Fn_TIMES__FLOAT64_FLOAT64__FLOAT64 : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "times", returns = FLOAT64, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrim.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrim.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrim.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrim.kt index 07e7db602f..f1bc0bf6f9 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrim.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrim.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM__STRING__STRING : FnScalar { +internal object Fn_TRIM__STRING__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim", returns = STRING, parameters = listOf(FnParameter("value", STRING),), @@ -30,9 +30,9 @@ internal object Fn_TRIM__STRING__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM__SYMBOL__SYMBOL : FnScalar { +internal object Fn_TRIM__SYMBOL__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim", returns = SYMBOL, parameters = listOf(FnParameter("value", SYMBOL),), @@ -46,9 +46,9 @@ internal object Fn_TRIM__SYMBOL__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM__CLOB__CLOB : FnScalar { +internal object Fn_TRIM__CLOB__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim", returns = CLOB, parameters = listOf(FnParameter("value", CLOB),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimChars.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimChars.kt similarity index 79% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimChars.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimChars.kt index 58552bd99f..eba02057b3 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimChars.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimChars.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_CHARS__STRING_STRING__STRING : FnScalar { +internal object Fn_TRIM_CHARS__STRING_STRING__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_chars", returns = STRING, parameters = listOf( @@ -33,9 +33,9 @@ internal object Fn_TRIM_CHARS__STRING_STRING__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_CHARS__SYMBOL_SYMBOL__SYMBOL : FnScalar { +internal object Fn_TRIM_CHARS__SYMBOL_SYMBOL__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_chars", returns = SYMBOL, parameters = listOf( @@ -52,9 +52,9 @@ internal object Fn_TRIM_CHARS__SYMBOL_SYMBOL__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_CHARS__CLOB_CLOB__CLOB : FnScalar { +internal object Fn_TRIM_CHARS__CLOB_CLOB__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_chars", returns = CLOB, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimLeading.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimLeading.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimLeading.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimLeading.kt index 01a250d6bb..c38199ee47 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimLeading.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimLeading.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_LEADING__STRING__STRING : FnScalar { +internal object Fn_TRIM_LEADING__STRING__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_leading", returns = STRING, parameters = listOf(FnParameter("value", STRING),), @@ -30,9 +30,9 @@ internal object Fn_TRIM_LEADING__STRING__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_LEADING__SYMBOL__SYMBOL : FnScalar { +internal object Fn_TRIM_LEADING__SYMBOL__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_leading", returns = SYMBOL, parameters = listOf(FnParameter("value", SYMBOL),), @@ -46,9 +46,9 @@ internal object Fn_TRIM_LEADING__SYMBOL__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_LEADING__CLOB__CLOB : FnScalar { +internal object Fn_TRIM_LEADING__CLOB__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_leading", returns = CLOB, parameters = listOf(FnParameter("value", CLOB),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimLeadingChars.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimLeadingChars.kt similarity index 84% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimLeadingChars.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimLeadingChars.kt index 7f811ca738..9973f8c493 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimLeadingChars.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimLeadingChars.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_LEADING_CHARS__STRING_STRING__STRING : FnScalar { +internal object Fn_TRIM_LEADING_CHARS__STRING_STRING__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_leading_chars", returns = STRING, parameters = listOf( @@ -33,9 +33,9 @@ internal object Fn_TRIM_LEADING_CHARS__STRING_STRING__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_LEADING_CHARS__SYMBOL_SYMBOL__SYMBOL : FnScalar { +internal object Fn_TRIM_LEADING_CHARS__SYMBOL_SYMBOL__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_leading_chars", returns = SYMBOL, parameters = listOf( @@ -52,9 +52,9 @@ internal object Fn_TRIM_LEADING_CHARS__SYMBOL_SYMBOL__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_LEADING_CHARS__CLOB_CLOB__CLOB : FnScalar { +internal object Fn_TRIM_LEADING_CHARS__CLOB_CLOB__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_leading_chars", returns = CLOB, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimTrailing.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimTrailing.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimTrailing.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimTrailing.kt index 8502ead34a..39b81aec47 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimTrailing.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimTrailing.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_TRAILING__STRING__STRING : FnScalar { +internal object Fn_TRIM_TRAILING__STRING__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_trailing", returns = STRING, parameters = listOf(FnParameter("value", STRING),), @@ -30,9 +30,9 @@ internal object Fn_TRIM_TRAILING__STRING__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_TRAILING__SYMBOL__SYMBOL : FnScalar { +internal object Fn_TRIM_TRAILING__SYMBOL__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_trailing", returns = SYMBOL, parameters = listOf(FnParameter("value", SYMBOL),), @@ -46,9 +46,9 @@ internal object Fn_TRIM_TRAILING__SYMBOL__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_TRAILING__CLOB__CLOB : FnScalar { +internal object Fn_TRIM_TRAILING__CLOB__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_trailing", returns = CLOB, parameters = listOf(FnParameter("value", CLOB),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimTrailingChars.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimTrailingChars.kt similarity index 84% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimTrailingChars.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimTrailingChars.kt index 1aa3c32b92..48bdad6739 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnTrimTrailingChars.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnTrimTrailingChars.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_TRAILING_CHARS__STRING_STRING__STRING : FnScalar { +internal object Fn_TRIM_TRAILING_CHARS__STRING_STRING__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_trailing_chars", returns = STRING, parameters = listOf( @@ -33,9 +33,9 @@ internal object Fn_TRIM_TRAILING_CHARS__STRING_STRING__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_TRAILING_CHARS__SYMBOL_SYMBOL__SYMBOL : FnScalar { +internal object Fn_TRIM_TRAILING_CHARS__SYMBOL_SYMBOL__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_trailing_chars", returns = SYMBOL, parameters = listOf( @@ -52,9 +52,9 @@ internal object Fn_TRIM_TRAILING_CHARS__SYMBOL_SYMBOL__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_TRIM_TRAILING_CHARS__CLOB_CLOB__CLOB : FnScalar { +internal object Fn_TRIM_TRAILING_CHARS__CLOB_CLOB__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "trim_trailing_chars", returns = CLOB, parameters = listOf( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnUpper.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnUpper.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnUpper.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnUpper.kt index 48421a8be8..479da6a6ba 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnUpper.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnUpper.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -14,9 +14,9 @@ import org.partiql.value.PartiQLValueType.STRING import org.partiql.value.PartiQLValueType.SYMBOL @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_UPPER__STRING__STRING : FnScalar { +internal object Fn_UPPER__STRING__STRING : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "upper", returns = STRING, parameters = listOf(FnParameter("value", STRING),), @@ -30,9 +30,9 @@ internal object Fn_UPPER__STRING__STRING : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_UPPER__SYMBOL__SYMBOL : FnScalar { +internal object Fn_UPPER__SYMBOL__SYMBOL : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "upper", returns = SYMBOL, parameters = listOf(FnParameter("value", SYMBOL),), @@ -46,9 +46,9 @@ internal object Fn_UPPER__SYMBOL__SYMBOL : FnScalar { } @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_UPPER__CLOB__CLOB : FnScalar { +internal object Fn_UPPER__CLOB__CLOB : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "upper", returns = CLOB, parameters = listOf(FnParameter("value", CLOB),), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnUtcnow.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnUtcnow.kt similarity index 75% rename from partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnUtcnow.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnUtcnow.kt index 15d4f61904..e888e0f765 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/scalar/FnUtcnow.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/FnUtcnow.kt @@ -1,19 +1,19 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.connector.sql.internal.builtins.scalar +package org.partiql.spi.connector.sql.builtins +import org.partiql.spi.fn.Fn import org.partiql.spi.fn.FnExperimental -import org.partiql.spi.fn.FnScalar import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental import org.partiql.value.PartiQLValueType.TIMESTAMP @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object Fn_UTCNOW____TIMESTAMP : FnScalar { +internal object Fn_UTCNOW____TIMESTAMP : Fn { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "utcnow", returns = TIMESTAMP, parameters = listOf(), diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/info/InfoViewRoutines.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/info/InfoViewRoutines.kt index 46a513129e..64e0fe29fa 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/info/InfoViewRoutines.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/info/InfoViewRoutines.kt @@ -26,7 +26,7 @@ internal class InfoViewRoutines(private val index: FnIndex) : InfoView { ) ) - @PartiQLValueExperimental + @OptIn(PartiQLValueExperimental::class) override fun value(): PartiQLValue { return bagValue(listOf(nullValue())) } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnAggregation.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/Agg.kt similarity index 90% rename from partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnAggregation.kt rename to partiql-spi/src/main/kotlin/org/partiql/spi/fn/Agg.kt index 01bc3126e4..53b5b642e6 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnAggregation.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/Agg.kt @@ -7,12 +7,12 @@ import org.partiql.value.PartiQLValueExperimental * Represents an SQL table-value expression call. */ @FnExperimental -public interface FnAggregation : Fn { +public interface Agg { /** * Aggregation function signature. */ - public override val signature: FnSignature.Aggregation + public val signature: AggSignature /** * Instantiates a stateful accumulator for this aggregation function. diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/AggSignature.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/AggSignature.kt new file mode 100644 index 0000000000..26a9357396 --- /dev/null +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/AggSignature.kt @@ -0,0 +1,70 @@ +package org.partiql.spi.fn + +import org.partiql.value.PartiQLValueExperimental +import org.partiql.value.PartiQLValueType + +/** + * Represents the signature of a PartiQL aggregation function. + * + * @property isDecomposable Flag indicating this aggregation can be decomposed + * @constructor + */ +@FnExperimental +@OptIn(PartiQLValueExperimental::class) +public class AggSignature( + @JvmField public val name: String, + @JvmField public val returns: PartiQLValueType, + @JvmField public val parameters: List, + @JvmField public val description: String? = null, + @JvmField public val isNullable: Boolean = true, + @JvmField public val isDecomposable: Boolean = true, +) { + + /** + * Symbolic name of this operator of the form NAME__INPUTS__RETURNS + */ + public val specific: String = buildString { + append(name.uppercase()) + append("__") + append(parameters.joinToString("_") { it.type.name }) + append("__") + append(returns.name) + } + + /** + * Use the symbolic name for easy debugging + * + * @return + */ + override fun toString(): String = specific + + override fun equals(other: Any?): Boolean { + if (other !is AggSignature) return false + if ( + other.name != name || + other.returns != returns || + other.parameters.size != parameters.size || + other.isDecomposable != isDecomposable || + other.isNullable != isNullable + ) { + return false + } + // all other parts equal, compare parameters (ignore names) + for (i in parameters.indices) { + val p1 = parameters[i] + val p2 = other.parameters[i] + if (p1.type != p2.type) return false + } + return true + } + + override fun hashCode(): Int { + var result = name.hashCode() + result = 31 * result + returns.hashCode() + result = 31 * result + parameters.hashCode() + result = 31 * result + isDecomposable.hashCode() + result = 31 * result + isNullable.hashCode() + result = 31 * result + (description?.hashCode() ?: 0) + return result + } +} diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/Fn.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/Fn.kt index 8d60faff58..e0744ec89a 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/Fn.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/Fn.kt @@ -1,10 +1,25 @@ package org.partiql.spi.fn +import org.partiql.value.PartiQLValue +import org.partiql.value.PartiQLValueExperimental + /** - * Simple common interface shared between [FnScalar] and [FnAggregation]. + * Represents a scalar function (SQL row-value call expression). */ @FnExperimental public interface Fn { + /** + * Scalar function signature. + */ public val signature: FnSignature + + /** + * Invoke the routine with the given arguments. + * + * @param args + * @return + */ + @OptIn(PartiQLValueExperimental::class) + public fun invoke(args: Array): PartiQLValue } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnIndex.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnIndex.kt index 2705b58141..71a7964731 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnIndex.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnIndex.kt @@ -12,10 +12,10 @@ public interface FnIndex { * @param path * @return */ - public fun list(path: List): List + public fun get(path: List): List /** - * Lookup a function by its specific name. + * Lookup a function signature by its specific name. * * @param specific * @return @@ -38,12 +38,15 @@ public interface FnIndex { } /** - * TODO + * Creates a map of function name to variants; variants are keyed by their specific. * * @return */ public fun build(): FnIndex { - return FnIndexMap(emptyMap()) + val fns = builtins + .groupBy { it.signature.name.uppercase() } + .mapValues { e -> e.value.associateBy { f -> f.signature.specific } } + return FnIndexMap(fns) } } diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnIndexMap.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnIndexMap.kt index 3c657f7343..5f07cf40f8 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnIndexMap.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnIndexMap.kt @@ -8,7 +8,7 @@ package org.partiql.spi.fn @OptIn(FnExperimental::class) internal class FnIndexMap(private val map: Map>) : FnIndex { - override fun list(path: List): List { + override fun get(path: List): List { val key = path.joinToString(".") val variants = map[key] ?: emptyMap() return variants.values.toList() diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnScalar.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnScalar.kt deleted file mode 100644 index ab4d6c5c2c..0000000000 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnScalar.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.partiql.spi.fn - -import org.partiql.value.PartiQLValue -import org.partiql.value.PartiQLValueExperimental - -/** - * Represents an SQL row-value expression call. - */ -@FnExperimental -public interface FnScalar : Fn { - - /** - * Scalar function signature. - */ - public override val signature: FnSignature.Scalar - - /** - * Invoke the routine with the given arguments. - * - * @param args - * @return - */ - @OptIn(PartiQLValueExperimental::class) - public fun invoke(args: Array): PartiQLValue -} diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnSignature.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnSignature.kt index fa95f39251..822ed7f7bc 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnSignature.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/fn/FnSignature.kt @@ -13,16 +13,24 @@ import org.partiql.value.PartiQLValueType * @property returns Operator return type * @property parameters Operator parameters * @property description Optional operator description + * @property isDeterministic Flag indicating this function always produces the same output given the same input. * @property isNullable Flag indicating this function's operator may return a NULL value. + * @property isNullCall Flag indicating if any of the call arguments is NULL, then return NULL. + * @property isMissable Flag indicating this function's operator may return a MISSING value. + * @property isMissingCall Flag indicating if any of the call arguments is MISSING, the return MISSING. */ -@OptIn(PartiQLValueExperimental::class) @FnExperimental -public sealed class FnSignature( +@OptIn(PartiQLValueExperimental::class) +public class FnSignature( @JvmField public val name: String, @JvmField public val returns: PartiQLValueType, @JvmField public val parameters: List, @JvmField public val description: String? = null, + @JvmField public val isDeterministic: Boolean = true, @JvmField public val isNullable: Boolean = true, + @JvmField public val isNullCall: Boolean = false, + @JvmField public val isMissable: Boolean = true, + @JvmField public val isMissingCall: Boolean = true, ) { /** @@ -43,139 +51,75 @@ public sealed class FnSignature( */ override fun toString(): String = specific - /** - * Represents the signature of a PartiQL scalar function. - * - * @property isDeterministic Flag indicating this function always produces the same output given the same input. - * @property isNullCall Flag indicating if any of the call arguments is NULL, then return NULL. - * @constructor - */ - public class Scalar( - name: String, - returns: PartiQLValueType, - parameters: List, - description: String? = null, - isNullable: Boolean = true, - @JvmField public val isDeterministic: Boolean = true, - @JvmField public val isNullCall: Boolean = false, - ) : FnSignature(name, returns, parameters, description, isNullable) { - - override fun equals(other: Any?): Boolean { - if (other !is Scalar) return false - if ( - other.name != name || - other.returns != returns || - other.parameters.size != parameters.size || - other.isDeterministic != isDeterministic || - other.isNullCall != isNullCall || - other.isNullable != isNullable - ) { - return false - } - // all other parts equal, compare parameters (ignore names) - for (i in parameters.indices) { - val p1 = parameters[i] - val p2 = other.parameters[i] - if (p1.type != p2.type) return false - } - return true + override fun equals(other: Any?): Boolean { + if (other !is FnSignature) return false + if ( + other.name != name || + other.returns != returns || + other.parameters.size != parameters.size || + other.isDeterministic != isDeterministic || + other.isNullCall != isNullCall || + other.isNullable != isNullable + ) { + return false } - - override fun hashCode(): Int { - var result = name.hashCode() - result = 31 * result + returns.hashCode() - result = 31 * result + parameters.hashCode() - result = 31 * result + isDeterministic.hashCode() - result = 31 * result + isNullCall.hashCode() - result = 31 * result + isNullable.hashCode() - result = 31 * result + (description?.hashCode() ?: 0) - return result + // all other parts equal, compare parameters (ignore names) + for (i in parameters.indices) { + val p1 = parameters[i] + val p2 = other.parameters[i] + if (p1.type != p2.type) return false } + return true + } - // Logic for writing a [FunctionSignature] using SQL `CREATE FUNCTION` syntax. - - /** - * SQL-99 p.542 - */ - private val deterministicCharacteristic = when (isDeterministic) { - true -> "DETERMINISTIC" - else -> "NOT DETERMINISTIC" - } + override fun hashCode(): Int { + var result = name.hashCode() + result = 31 * result + returns.hashCode() + result = 31 * result + parameters.hashCode() + result = 31 * result + isDeterministic.hashCode() + result = 31 * result + isNullCall.hashCode() + result = 31 * result + isNullable.hashCode() + result = 31 * result + (description?.hashCode() ?: 0) + return result + } - /** - * SQL-99 p.543 - */ - private val nullCallClause = when (isNullCall) { - true -> "RETURNS NULL ON NULL INPUT" - else -> "CALLED ON NULL INPUT" - } + // Logic for writing a [FunctionSignature] using SQL `CREATE FUNCTION` syntax. - public fun sql(): String = buildString { - val fn = name.uppercase() - val indent = " " - append("CREATE FUNCTION \"$fn\" (") - if (parameters.isNotEmpty()) { - val extent = parameters.maxOf { it.name.length } - for (i in parameters.indices) { - val p = parameters[i] - val ws = (extent - p.name.length) + 1 - appendLine() - append(indent).append(p.name.uppercase()).append(" ".repeat(ws)).append(p.type.name) - if (i != parameters.size - 1) append(",") - } - } - appendLine(" )") - append(indent).appendLine("RETURNS $returns") - append(indent).appendLine("SPECIFIC $specific") - append(indent).appendLine(deterministicCharacteristic) - append(indent).appendLine(nullCallClause) - append(indent).appendLine("RETURN $fn ( ${parameters.joinToString { it.name.uppercase() }} ) ;") - } + /** + * SQL-99 p.542 + */ + private val deterministicCharacteristic = when (isDeterministic) { + true -> "DETERMINISTIC" + else -> "NOT DETERMINISTIC" } /** - * Represents the signature of a PartiQL aggregation function. - * - * @property isDecomposable Flag indicating this aggregation can be decomposed - * @constructor + * SQL-99 p.543 */ - public class Aggregation( - name: String, - returns: PartiQLValueType, - parameters: List, - description: String? = null, - isNullable: Boolean = true, - @JvmField public val isDecomposable: Boolean = true, - ) : FnSignature(name, returns, parameters, description, isNullable) { + private val nullCallClause = when (isNullCall) { + true -> "RETURNS NULL ON NULL INPUT" + else -> "CALLED ON NULL INPUT" + } - override fun equals(other: Any?): Boolean { - if (other !is Aggregation) return false - if ( - other.name != name || - other.returns != returns || - other.parameters.size != parameters.size || - other.isDecomposable != isDecomposable || - other.isNullable != isNullable - ) { - return false - } - // all other parts equal, compare parameters (ignore names) + public fun sql(): String = buildString { + val fn = name.uppercase() + val indent = " " + append("CREATE FUNCTION \"$fn\" (") + if (parameters.isNotEmpty()) { + val extent = parameters.maxOf { it.name.length } for (i in parameters.indices) { - val p1 = parameters[i] - val p2 = other.parameters[i] - if (p1.type != p2.type) return false + val p = parameters[i] + val ws = (extent - p.name.length) + 1 + appendLine() + append(indent).append(p.name.uppercase()).append(" ".repeat(ws)).append(p.type.name) + if (i != parameters.size - 1) append(",") } - return true - } - - override fun hashCode(): Int { - var result = name.hashCode() - result = 31 * result + returns.hashCode() - result = 31 * result + parameters.hashCode() - result = 31 * result + isDecomposable.hashCode() - result = 31 * result + isNullable.hashCode() - result = 31 * result + (description?.hashCode() ?: 0) - return result } + appendLine(" )") + append(indent).appendLine("RETURNS $returns") + append(indent).appendLine("SPECIFIC $specific") + append(indent).appendLine(deterministicCharacteristic) + append(indent).appendLine(nullCallClause) + append(indent).appendLine("RETURN $fn ( ${parameters.joinToString { it.name.uppercase() }} ) ;") } } diff --git a/partiql-spi/src/test/kotlin/org/partiql/spi/connector/sql/HeaderCodeGen.kt b/partiql-spi/src/test/kotlin/org/partiql/spi/connector/sql/HeaderCodeGen.kt index 73b0036bc5..6807bf8854 100644 --- a/partiql-spi/src/test/kotlin/org/partiql/spi/connector/sql/HeaderCodeGen.kt +++ b/partiql-spi/src/test/kotlin/org/partiql/spi/connector/sql/HeaderCodeGen.kt @@ -1,17 +1,20 @@ package org.partiql.spi.connector.sql import net.pearx.kasechange.toPascalCase +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import java.io.File const val imports = """ +import org.partiql.spi.fn.Agg +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter import org.partiql.spi.fn.FnScalar -import org.partiql.spi.fn.FnAggregation import org.partiql.spi.fn.FnSignature import org.partiql.value.PartiQLValueExperimental import org.partiql.value.* @@ -31,7 +34,7 @@ const val TEMPLATE_SCALAR = """ @OptIn(PartiQLValueExperimental::class, FnExperimental::class) internal object %s : FnScalar { - override val signature = FnSignature.Scalar( + override val signature = FnSignature( name = "%s", returns = %s, parameters = listOf(%s), @@ -56,9 +59,9 @@ internal object %s : FnScalar { */ const val TEMPLATE_AGG = """ @OptIn(PartiQLValueExperimental::class, FnExperimental::class) -internal object %s : FnAggregation { +internal object %s : Agg { - override val signature = FnSignature.Aggregation( + override val signature = AggSignature( name = "%s", returns = %s, parameters = listOf(%s), @@ -66,30 +69,30 @@ internal object %s : FnAggregation { isDecomposable = %b ) - override fun accumulator(): FnAggregation.Accumulator { + override fun accumulator(): Agg.Accumulator { TODO("Aggregation %s not implemented") } } """ +@Disabled @OptIn(PartiQLValueExperimental::class, FnExperimental::class) class HeaderCodeGen { @Test fun scalars() { - generate("package org.partiql.spi.connector.sql.internal.builtins.scalar", TEMPLATE_SCALAR, "Fn", SqlHeader.functions) - generate("package org.partiql.spi.connector.sql.internal.builtins.scalar", TEMPLATE_SCALAR, "Fn", SqlHeader.operators()) + generateFns("package org.partiql.spi.connector.sql.internal.builtins", TEMPLATE_SCALAR, "Fn", SqlHeader.fns) } @Test fun aggregations() { - generate("package org.partiql.spi.connector.sql.internal.builtins.agg", TEMPLATE_AGG, "Agg", SqlHeader.aggregations) + generateAggs("package org.partiql.spi.connector.sql.internal.builtins", TEMPLATE_AGG, "Agg", SqlHeader.aggs) } /** * Writes function implementation to file, prints list of classes */ - private fun generate( + private fun generateFns( packageName: String, template: String, prefix: String, @@ -97,7 +100,7 @@ class HeaderCodeGen { ) { val clazzes = mutableListOf() val funcs = signatures.groupBy { it.name } - val pathToDir = "./src/main/kotlin/org/partiql/spi/connector/sql/internal/builtins/agg" + val pathToDir = "./src/main/kotlin/org/partiql/spi/connector/sql/builtins" for ((name, fns) in funcs) { val pre = "${prefix}_$name".toPascalCase() val file = File("$pathToDir/$pre.kt") @@ -124,14 +127,46 @@ class HeaderCodeGen { println() } - @OptIn(FnExperimental::class) - private fun toParams(clazz: String, fn: FnSignature) = when (fn) { - is FnSignature.Aggregation -> toParams(clazz, fn) - is FnSignature.Scalar -> toParams(clazz, fn) + /** + * Writes function implementation to file, prints list of classes + */ + private fun generateAggs( + packageName: String, + template: String, + prefix: String, + signatures: List, + ) { + val clazzes = mutableListOf() + val funcs = signatures.groupBy { it.name } + val pathToDir = "./src/main/kotlin/org/partiql/spi/connector/sql/builtins" + for ((name, fns) in funcs) { + val pre = "${prefix}_$name".toPascalCase() + val file = File("$pathToDir/$pre.kt") + file.printWriter().use { + it.appendLine("// ktlint-disable filename") + it.appendLine("@file:Suppress(\"ClassName\")") + it.appendLine() + it.appendLine(packageName) + it.appendLine() + it.appendLine(imports) + it.appendLine() + fns.forEach { sig -> + val clazz = "${prefix}_${sig.specific}" + val params = toParams(clazz, sig) + val code = String.format(template, *params) + it.appendLine(code) + it.appendLine() + clazzes.add(clazz) + } + } + } + println("-- GENERATED") + println("listOf(${clazzes.joinToString()})") + println() } @OptIn(FnExperimental::class) - private fun toParams(clazz: String, fn: FnSignature.Scalar): Array { + private fun toParams(clazz: String, fn: FnSignature): Array { val snake = fn.name val returns = fn.returns.name val parameters = fn.parameters.mapIndexed { i, p -> @@ -141,13 +176,13 @@ class HeaderCodeGen { } @OptIn(FnExperimental::class) - private fun toParams(clazz: String, fn: FnSignature.Aggregation): Array { - val snake = fn.name - val returns = fn.returns.name + private fun toParams(clazz: String, agg: AggSignature): Array { + val snake = agg.name + val returns = agg.returns.name var parameters = "" - for (p in fn.parameters) { + for (p in agg.parameters) { parameters += "FnParameter(\"${p.name}\", ${p.type.name}),\n" } - return arrayOf(clazz, snake, returns, parameters, fn.isNullable, fn.isDecomposable, snake) + return arrayOf(clazz, snake, returns, parameters, agg.isNullable, agg.isDecomposable, snake) } } diff --git a/partiql-spi/src/test/kotlin/org/partiql/spi/connector/sql/SqlHeader.kt b/partiql-spi/src/test/kotlin/org/partiql/spi/connector/sql/SqlHeader.kt index af7f532825..62e467e032 100644 --- a/partiql-spi/src/test/kotlin/org/partiql/spi/connector/sql/SqlHeader.kt +++ b/partiql-spi/src/test/kotlin/org/partiql/spi/connector/sql/SqlHeader.kt @@ -1,5 +1,6 @@ package org.partiql.spi.connector.sql +import org.partiql.spi.fn.AggSignature import org.partiql.spi.fn.FnExperimental import org.partiql.spi.fn.FnParameter import org.partiql.spi.fn.FnSignature @@ -85,7 +86,7 @@ internal object SqlHeader { /** * PartiQL Scalar Functions */ - val functions: List = listOf( + val fns: List = listOf( builtins(), logical(), predicate(), @@ -97,12 +98,12 @@ internal object SqlHeader { /** * PartiQL Aggregation Functions accessible via */ - val aggregations: List = aggBuiltins() + val aggs: List = aggBuiltins() /** * Generate all unary and binary operator signatures. */ - public fun operators(): List = listOf( + private fun operators(): List = listOf( pos(), neg(), plus(), @@ -119,7 +120,7 @@ internal object SqlHeader { * * Predicate function IS NULL, IS MISSING, `=`(Equal) does not propagate `MISSING`. */ - private fun predicate(): List = listOf( + private fun predicate(): List = listOf( // SQL // 8.2 - comparison predicate lt(), @@ -163,7 +164,7 @@ internal object SqlHeader { * 1. The `MISSING` value, when convert to a truth value, becomes a `UNKNOWN`. * 2. `UNKNOWN` truth value, when converting to PartiQL Value, becomes NULL of boolean type. */ - private fun logical(): List = listOf( + private fun logical(): List = listOf( not(), and(), or(), @@ -172,7 +173,7 @@ internal object SqlHeader { /** * SQL Builtins (not special forms) */ - private fun builtins(): List = listOf( + private fun builtins(): List = listOf( upper(), lower(), trim(), @@ -182,7 +183,7 @@ internal object SqlHeader { /** * SQL and PartiQL special forms */ - private fun special(): List = listOf( + private fun special(): List = listOf( position(), substring(), trimSpecial(), @@ -197,22 +198,22 @@ internal object SqlHeader { * * @return */ - private fun system(): List = listOf( + private fun system(): List = listOf( currentUser(), currentDate(), ) // OPERATORS - private fun not(): List = listOf( - FnSignature.Scalar( + private fun not(): List = listOf( + FnSignature( name = "not", returns = BOOL, isNullCall = true, isNullable = false, parameters = listOf(FnParameter("value", BOOL)), ), - FnSignature.Scalar( + FnSignature( name = "not", returns = BOOL, isNullCall = true, @@ -221,16 +222,16 @@ internal object SqlHeader { ), ) - private fun pos(): List = numeric.map { t -> + private fun pos(): List = numeric.map { t -> unary("pos", t, t) } - private fun neg(): List = numeric.map { t -> + private fun neg(): List = numeric.map { t -> unary("neg", t, t) } - private fun eq(): List = all.map { t -> - FnSignature.Scalar( + private fun eq(): List = all.map { t -> + FnSignature( name = "eq", returns = BOOL, parameters = listOf(FnParameter("lhs", t), FnParameter("rhs", t)), @@ -239,29 +240,29 @@ internal object SqlHeader { ) } - private fun and(): List = listOf( - FnSignature.Scalar( + private fun and(): List = listOf( + FnSignature( name = "and", returns = BOOL, isNullCall = false, isNullable = true, parameters = listOf(FnParameter("lhs", BOOL), FnParameter("rhs", BOOL)), ), - FnSignature.Scalar( + FnSignature( name = "and", returns = BOOL, isNullCall = false, isNullable = true, parameters = listOf(FnParameter("lhs", MISSING), FnParameter("rhs", BOOL)), ), - FnSignature.Scalar( + FnSignature( name = "and", returns = BOOL, isNullCall = false, isNullable = true, parameters = listOf(FnParameter("lhs", BOOL), FnParameter("rhs", MISSING)), ), - FnSignature.Scalar( + FnSignature( name = "and", returns = BOOL, isNullCall = false, @@ -270,29 +271,29 @@ internal object SqlHeader { ), ) - private fun or(): List = listOf( - FnSignature.Scalar( + private fun or(): List = listOf( + FnSignature( name = "or", returns = BOOL, isNullCall = false, isNullable = true, parameters = listOf(FnParameter("lhs", BOOL), FnParameter("rhs", BOOL)), ), - FnSignature.Scalar( + FnSignature( name = "or", returns = BOOL, isNullCall = false, isNullable = true, parameters = listOf(FnParameter("lhs", MISSING), FnParameter("rhs", BOOL)), ), - FnSignature.Scalar( + FnSignature( name = "or", returns = BOOL, isNullCall = false, isNullable = true, parameters = listOf(FnParameter("lhs", BOOL), FnParameter("rhs", MISSING)), ), - FnSignature.Scalar( + FnSignature( name = "or", returns = BOOL, isNullCall = false, @@ -301,53 +302,53 @@ internal object SqlHeader { ), ) - private fun lt(): List = (numeric + text + datetime + BOOL).map { t -> + private fun lt(): List = (numeric + text + datetime + BOOL).map { t -> binary("lt", BOOL, t, t) } - private fun lte(): List = (numeric + text + datetime + BOOL).map { t -> + private fun lte(): List = (numeric + text + datetime + BOOL).map { t -> binary("lte", BOOL, t, t) } - private fun gt(): List = (numeric + text + datetime + BOOL).map { t -> + private fun gt(): List = (numeric + text + datetime + BOOL).map { t -> binary("gt", BOOL, t, t) } - private fun gte(): List = (numeric + text + datetime + BOOL).map { t -> + private fun gte(): List = (numeric + text + datetime + BOOL).map { t -> binary("gte", BOOL, t, t) } - private fun plus(): List = numeric.map { t -> + private fun plus(): List = numeric.map { t -> binary("plus", t, t, t) } - private fun minus(): List = numeric.map { t -> + private fun minus(): List = numeric.map { t -> binary("minus", t, t, t) } - private fun times(): List = numeric.map { t -> + private fun times(): List = numeric.map { t -> binary("times", t, t, t) } - private fun div(): List = numeric.map { t -> + private fun div(): List = numeric.map { t -> binary("divide", t, t, t) } - private fun mod(): List = numeric.map { t -> + private fun mod(): List = numeric.map { t -> binary("modulo", t, t, t) } - private fun concat(): List = text.map { t -> + private fun concat(): List = text.map { t -> binary("concat", t, t, t) } - private fun bitwiseAnd(): List = integer.map { t -> + private fun bitwiseAnd(): List = integer.map { t -> binary("bitwise_and", t, t, t) } // BUILT INS - private fun upper(): List = text.map { t -> - FnSignature.Scalar( + private fun upper(): List = text.map { t -> + FnSignature( name = "upper", returns = t, parameters = listOf(FnParameter("value", t)), @@ -356,8 +357,8 @@ internal object SqlHeader { ) } - private fun lower(): List = text.map { t -> - FnSignature.Scalar( + private fun lower(): List = text.map { t -> + FnSignature( name = "lower", returns = t, parameters = listOf(FnParameter("value", t)), @@ -368,9 +369,9 @@ internal object SqlHeader { // SPECIAL FORMS - private fun like(): List = text.flatMap { t -> + private fun like(): List = text.flatMap { t -> listOf( - FnSignature.Scalar( + FnSignature( name = "like", returns = BOOL, parameters = listOf( @@ -380,7 +381,7 @@ internal object SqlHeader { isNullCall = true, isNullable = false, ), - FnSignature.Scalar( + FnSignature( name = "like_escape", returns = BOOL, parameters = listOf( @@ -394,8 +395,8 @@ internal object SqlHeader { ) } - private fun between(): List = (numeric + text + datetime).map { t -> - FnSignature.Scalar( + private fun between(): List = (numeric + text + datetime).map { t -> + FnSignature( name = "between", returns = BOOL, parameters = listOf( @@ -408,9 +409,9 @@ internal object SqlHeader { ) } - private fun inCollection(): List = all.map { element -> + private fun inCollection(): List = all.map { element -> collections.map { collection -> - FnSignature.Scalar( + FnSignature( name = "in_collection", returns = BOOL, parameters = listOf( @@ -423,8 +424,8 @@ internal object SqlHeader { } }.flatten() - private fun isNull(): List = listOf( - FnSignature.Scalar( + private fun isNull(): List = listOf( + FnSignature( name = "is_null", returns = BOOL, parameters = listOf( FnParameter("value", ANY) // TODO: Decide if we need to further segment this @@ -433,8 +434,8 @@ internal object SqlHeader { ) ) - private fun isMissing(): List = listOf( - FnSignature.Scalar( + private fun isMissing(): List = listOf( + FnSignature( name = "is_missing", returns = BOOL, parameters = listOf( FnParameter("value", ANY) // TODO: Decide if we need to further segment this @@ -446,8 +447,8 @@ internal object SqlHeader { // To model type assertion, generating a list of assertion function based on the type, // and the parameter will be the value entered. // i.e., 1 is INT2 => is_int16(1) - private fun isType(): List = all.filterNot { it == NULL || it == MISSING }.map { element -> - FnSignature.Scalar( + private fun isType(): List = all.filterNot { it == NULL || it == MISSING }.map { element -> + FnSignature( name = "is_${element.name.lowercase()}", returns = BOOL, parameters = listOf( @@ -461,8 +462,8 @@ internal object SqlHeader { // In type assertion, it is possible for types to have args // i.e., 'a' is CHAR(2) // we put type parameter before value. - private fun isTypeSingleArg(): List = listOf(CHAR, STRING).map { element -> - FnSignature.Scalar( + private fun isTypeSingleArg(): List = listOf(CHAR, STRING).map { element -> + FnSignature( name = "is_${element.name.lowercase()}", returns = BOOL, parameters = listOf( FnParameter("type_parameter_1", INT32), FnParameter("value", ANY) @@ -471,8 +472,8 @@ internal object SqlHeader { ) } - private fun isTypeDoubleArgsInt(): List = listOf(DECIMAL).map { element -> - FnSignature.Scalar( + private fun isTypeDoubleArgsInt(): List = listOf(DECIMAL).map { element -> + FnSignature( name = "is_${element.name.lowercase()}", returns = BOOL, parameters = listOf( FnParameter("type_parameter_1", INT32), @@ -483,8 +484,8 @@ internal object SqlHeader { ) } - private fun isTypeTime(): List = listOf(TIME, TIMESTAMP).map { element -> - FnSignature.Scalar( + private fun isTypeTime(): List = listOf(TIME, TIMESTAMP).map { element -> + FnSignature( name = "is_${element.name.lowercase()}", returns = BOOL, parameters = listOf( FnParameter("type_parameter_1", BOOL), @@ -497,9 +498,9 @@ internal object SqlHeader { // SUBSTRING (expression, start[, length]?) // SUBSTRINGG(expression from start [FOR length]? ) - private fun substring(): List = text.map { t -> + private fun substring(): List = text.map { t -> listOf( - FnSignature.Scalar( + FnSignature( name = "substring", returns = t, parameters = listOf( @@ -509,7 +510,7 @@ internal object SqlHeader { isNullable = false, isNullCall = true, ), - FnSignature.Scalar( + FnSignature( name = "substring", returns = t, parameters = listOf( @@ -525,8 +526,8 @@ internal object SqlHeader { // position (str1, str2) // position (str1 in str2) - private fun position(): List = text.map { t -> - FnSignature.Scalar( + private fun position(): List = text.map { t -> + FnSignature( name = "position", returns = INT64, parameters = listOf( @@ -539,8 +540,8 @@ internal object SqlHeader { } // trim(str) - private fun trim(): List = text.map { t -> - FnSignature.Scalar( + private fun trim(): List = text.map { t -> + FnSignature( name = "trim", returns = t, parameters = listOf( @@ -552,11 +553,11 @@ internal object SqlHeader { } // TODO: We need to add a special form function for TRIM(BOTH FROM value) - private fun trimSpecial(): List = text.map { t -> + private fun trimSpecial(): List = text.map { t -> listOf( // TRIM(chars FROM value) // TRIM(both chars from value) - FnSignature.Scalar( + FnSignature( name = "trim_chars", returns = t, parameters = listOf( @@ -567,7 +568,7 @@ internal object SqlHeader { isNullCall = true, ), // TRIM(LEADING FROM value) - FnSignature.Scalar( + FnSignature( name = "trim_leading", returns = t, parameters = listOf( @@ -577,7 +578,7 @@ internal object SqlHeader { isNullCall = true, ), // TRIM(LEADING chars FROM value) - FnSignature.Scalar( + FnSignature( name = "trim_leading_chars", returns = t, parameters = listOf( @@ -588,7 +589,7 @@ internal object SqlHeader { isNullCall = true, ), // TRIM(TRAILING FROM value) - FnSignature.Scalar( + FnSignature( name = "trim_trailing", returns = t, parameters = listOf( @@ -598,7 +599,7 @@ internal object SqlHeader { isNullCall = true, ), // TRIM(TRAILING chars FROM value) - FnSignature.Scalar( + FnSignature( name = "trim_trailing_chars", returns = t, parameters = listOf( @@ -612,21 +613,21 @@ internal object SqlHeader { }.flatten() // TODO - private fun overlay(): List = emptyList() + private fun overlay(): List = emptyList() // TODO - private fun extract(): List = emptyList() + private fun extract(): List = emptyList() - private fun dateAdd(): List { + private fun dateAdd(): List { val intervals = listOf(INT32, INT64, INT) - val operators = mutableListOf() + val operators = mutableListOf() for (field in DatetimeField.values()) { for (type in datetime) { if (field == DatetimeField.TIMEZONE_HOUR || field == DatetimeField.TIMEZONE_MINUTE) { continue } for (interval in intervals) { - val signature = FnSignature.Scalar( + val signature = FnSignature( name = "date_add_${field.name.lowercase()}", returns = type, parameters = listOf( @@ -643,14 +644,14 @@ internal object SqlHeader { return operators } - private fun dateDiff(): List { - val operators = mutableListOf() + private fun dateDiff(): List { + val operators = mutableListOf() for (field in DatetimeField.values()) { for (type in datetime) { if (field == DatetimeField.TIMEZONE_HOUR || field == DatetimeField.TIMEZONE_MINUTE) { continue } - val signature = FnSignature.Scalar( + val signature = FnSignature( name = "date_diff_${field.name.lowercase()}", returns = INT64, parameters = listOf( @@ -666,8 +667,8 @@ internal object SqlHeader { return operators } - private fun utcNow(): List = listOf( - FnSignature.Scalar( + private fun utcNow(): List = listOf( + FnSignature( name = "utcnow", returns = TIMESTAMP, parameters = emptyList(), @@ -675,14 +676,14 @@ internal object SqlHeader { ) ) - private fun currentUser() = FnSignature.Scalar( + private fun currentUser() = FnSignature( name = "current_user", returns = STRING, parameters = emptyList(), isNullable = true, ) - private fun currentDate() = FnSignature.Scalar( + private fun currentDate() = FnSignature( name = "current_date", returns = DATE, parameters = emptyList(), @@ -696,7 +697,7 @@ internal object SqlHeader { /** * SQL and PartiQL Aggregation Builtins */ - private fun aggBuiltins(): List = listOf( + private fun aggBuiltins(): List = listOf( every(), any(), some(), @@ -708,7 +709,7 @@ internal object SqlHeader { ).flatten() private fun every() = listOf( - FnSignature.Aggregation( + AggSignature( name = "every", returns = BOOL, parameters = listOf(FnParameter("value", BOOL)), @@ -717,7 +718,7 @@ internal object SqlHeader { ) private fun any() = listOf( - FnSignature.Aggregation( + AggSignature( name = "any", returns = BOOL, parameters = listOf(FnParameter("value", BOOL)), @@ -726,7 +727,7 @@ internal object SqlHeader { ) private fun some() = listOf( - FnSignature.Aggregation( + AggSignature( name = "some", returns = BOOL, parameters = listOf(FnParameter("value", BOOL)), @@ -735,13 +736,13 @@ internal object SqlHeader { ) private fun count() = listOf( - FnSignature.Aggregation( + AggSignature( name = "count", returns = INT32, parameters = listOf(FnParameter("value", ANY)), isNullable = false, ), - FnSignature.Aggregation( + AggSignature( name = "count_star", returns = INT32, parameters = listOf(), @@ -750,7 +751,7 @@ internal object SqlHeader { ) private fun min() = numeric.map { - FnSignature.Aggregation( + AggSignature( name = "min", returns = it, parameters = listOf(FnParameter("value", it)), @@ -759,7 +760,7 @@ internal object SqlHeader { } private fun max() = numeric.map { - FnSignature.Aggregation( + AggSignature( name = "max", returns = it, parameters = listOf(FnParameter("value", it)), @@ -768,7 +769,7 @@ internal object SqlHeader { } private fun sum() = numeric.map { - FnSignature.Aggregation( + AggSignature( name = "sum", returns = it, parameters = listOf(FnParameter("value", it)), @@ -777,7 +778,7 @@ internal object SqlHeader { } private fun avg() = numeric.map { - FnSignature.Aggregation( + AggSignature( name = "avg", returns = it, parameters = listOf(FnParameter("value", it)), @@ -790,7 +791,7 @@ internal object SqlHeader { // ==================================== @JvmStatic - internal fun unary(name: String, returns: PartiQLValueType, value: PartiQLValueType) = FnSignature.Scalar( + internal fun unary(name: String, returns: PartiQLValueType, value: PartiQLValueType) = FnSignature( name = name, returns = returns, parameters = listOf(FnParameter("value", value)), @@ -800,7 +801,7 @@ internal object SqlHeader { @JvmStatic internal fun binary(name: String, returns: PartiQLValueType, lhs: PartiQLValueType, rhs: PartiQLValueType) = - FnSignature.Scalar( + FnSignature( name = name, returns = returns, parameters = listOf(FnParameter("lhs", lhs), FnParameter("rhs", rhs)), @@ -814,7 +815,13 @@ internal object SqlHeader { * For functions, output CREATE FUNCTION statements. */ override fun toString(): String = buildString { - (functions + aggregations).groupBy { it.name }.forEach { + fns.groupBy { it.name }.forEach { + appendLine("-- [${it.key}] ---------") + appendLine() + it.value.forEach { fn -> appendLine(fn) } + appendLine() + } + aggs.groupBy { it.name }.forEach { appendLine("-- [${it.key}] ---------") appendLine() it.value.forEach { fn -> appendLine(fn) } diff --git a/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalConnector.kt b/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalConnector.kt index 30743aff0d..1de387e8df 100644 --- a/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalConnector.kt +++ b/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalConnector.kt @@ -108,7 +108,7 @@ public class LocalConnector( } @FnExperimental - override fun getFunctions(path: BindingPath): List { + override fun getFunction(path: BindingPath): ConnectorHandle.Fn? { TODO("Not yet implemented") } diff --git a/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryConnector.kt b/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryConnector.kt index a96e37df7c..081d237ebf 100644 --- a/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryConnector.kt +++ b/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryConnector.kt @@ -16,31 +16,17 @@ package org.partiql.plugins.memory import com.amazon.ionelement.api.StructElement -import org.partiql.spi.BindingPath import org.partiql.spi.connector.Connector -import org.partiql.spi.connector.ConnectorHandle -import org.partiql.spi.connector.ConnectorMetadata import org.partiql.spi.connector.ConnectorSession import org.partiql.spi.connector.sql.SqlConnector import org.partiql.spi.connector.sql.SqlMetadata -import org.partiql.spi.fn.FnExperimental /** * This is a plugin used for testing and is not a versioned API per semver. */ -internal class MemoryConnector(private val catalog: MemoryCatalog) : SqlConnector() { +public class MemoryConnector(private val catalog: MemoryCatalog) : SqlConnector() { - override fun getSqlMetadata(session: ConnectorSession): ConnectorMetadata = - SqlMetadata( - session, info, - object : ConnectorMetadata { - - override fun getObject(path: BindingPath): ConnectorHandle.Obj? = catalog.find(path) - - @FnExperimental - override fun getFunctions(path: BindingPath): List = emptyList() - } - ) + override fun getMetadata(session: ConnectorSession): SqlMetadata = MemoryMetadata(catalog, session, info) internal class Factory(private val catalogs: List) : Connector.Factory { diff --git a/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryMetadata.kt b/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryMetadata.kt new file mode 100644 index 0000000000..2818d85803 --- /dev/null +++ b/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryMetadata.kt @@ -0,0 +1,24 @@ +package org.partiql.plugins.memory + +import org.partiql.spi.BindingPath +import org.partiql.spi.connector.ConnectorHandle +import org.partiql.spi.connector.ConnectorSession +import org.partiql.spi.connector.sql.SqlMetadata +import org.partiql.spi.connector.sql.info.InfoSchema +import org.partiql.spi.fn.FnExperimental + +internal class MemoryMetadata( + private val catalog: MemoryCatalog, + session: ConnectorSession, + info: InfoSchema, +) : SqlMetadata(session, info) { + + override fun getObject(path: BindingPath): ConnectorHandle.Obj? { + return super.getObject(path) ?: catalog.find(path) + } + + @FnExperimental + override fun getFunction(path: BindingPath): ConnectorHandle.Fn? { + return super.getFunction(path) + } +}