diff --git a/partiql-cli/build.gradle.kts b/partiql-cli/build.gradle.kts index ed163fa5a..e1584e5e4 100644 --- a/partiql-cli/build.gradle.kts +++ b/partiql-cli/build.gradle.kts @@ -26,6 +26,7 @@ dependencies { implementation(project(":partiql-planner")) implementation(project(":partiql-types")) implementation(project(":partiql-spi")) + implementation(project(":partiql-system")) implementation(Deps.csv) implementation(Deps.awsSdkBom) implementation(Deps.awsSdkDynamodb) 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 878409a77..403cdd3bb 100644 --- a/partiql-cli/src/main/kotlin/org/partiql/cli/Main.kt +++ b/partiql-cli/src/main/kotlin/org/partiql/cli/Main.kt @@ -20,10 +20,10 @@ import org.partiql.cli.pipeline.Pipeline import org.partiql.cli.shell.Shell import org.partiql.spi.catalog.Catalog import org.partiql.spi.catalog.Name -import org.partiql.spi.catalog.Session import org.partiql.spi.catalog.Table import org.partiql.spi.value.Datum import org.partiql.spi.value.DatumReader +import org.partiql.system.PartiQLSessionBuilder import org.partiql.value.PartiQLValueExperimental import org.partiql.value.io.PartiQLValueTextWriter import picocli.CommandLine @@ -210,7 +210,7 @@ internal class MainCommand : Runnable { println() } - private fun session() = Session.builder() + private fun session() = PartiQLSessionBuilder() .identity(System.getProperty("user.name")) .namespace(emptyList()) .catalog("default") diff --git a/partiql-eval/build.gradle.kts b/partiql-eval/build.gradle.kts index 17f013af7..d8642a856 100644 --- a/partiql-eval/build.gradle.kts +++ b/partiql-eval/build.gradle.kts @@ -33,6 +33,7 @@ dependencies { annotationProcessor(Deps.lombok) // Test testImplementation(project(":partiql-parser")) + testImplementation(project(":partiql-system")) testImplementation(testFixtures(project(":partiql-types"))) // TODO: Remove use of StaticType testImplementation(Deps.junit4) testImplementation(Deps.junit4Params) diff --git a/partiql-eval/src/test/kotlin/org/partiql/eval/compiler/StrategyTest.kt b/partiql-eval/src/test/kotlin/org/partiql/eval/compiler/StrategyTest.kt index 912b57887..e571378ed 100644 --- a/partiql-eval/src/test/kotlin/org/partiql/eval/compiler/StrategyTest.kt +++ b/partiql-eval/src/test/kotlin/org/partiql/eval/compiler/StrategyTest.kt @@ -9,7 +9,7 @@ import org.partiql.eval.Statement import org.partiql.parser.PartiQLParser import org.partiql.plan.rel.RelLimit import org.partiql.planner.PartiQLPlanner -import org.partiql.spi.catalog.Session +import org.partiql.system.PartiQLSession import kotlin.test.Test import kotlin.test.assertTrue @@ -20,7 +20,7 @@ public class StrategyTest { private val parser = PartiQLParser.standard() private val planner = PartiQLPlanner.standard() - private val session = Session.empty() + private val session = PartiQLSession.empty() private class MyLimit : ExprRelation { override fun open(env: Environment) = error("open") diff --git a/partiql-eval/src/test/kotlin/org/partiql/eval/internal/SuccessTestCase.kt b/partiql-eval/src/test/kotlin/org/partiql/eval/internal/SuccessTestCase.kt index 32bd8d72b..5042435a1 100644 --- a/partiql-eval/src/test/kotlin/org/partiql/eval/internal/SuccessTestCase.kt +++ b/partiql-eval/src/test/kotlin/org/partiql/eval/internal/SuccessTestCase.kt @@ -8,10 +8,10 @@ import org.partiql.plan.Plan import org.partiql.planner.PartiQLPlanner import org.partiql.spi.catalog.Catalog import org.partiql.spi.catalog.Name -import org.partiql.spi.catalog.Session import org.partiql.spi.catalog.Table import org.partiql.spi.value.Datum import org.partiql.spi.value.DatumReader +import org.partiql.system.PartiQLSessionBuilder import org.partiql.types.StaticType import org.partiql.types.fromStaticType import org.partiql.value.PartiQLValue @@ -64,7 +64,7 @@ public class SuccessTestCase( } } .build() - val session = Session.builder() + val session = PartiQLSessionBuilder() .catalog("memory") .catalogs(catalog) .build() diff --git a/partiql-eval/src/test/kotlin/org/partiql/eval/internal/TypingTestCase.kt b/partiql-eval/src/test/kotlin/org/partiql/eval/internal/TypingTestCase.kt index dda974399..de7f5ba4d 100644 --- a/partiql-eval/src/test/kotlin/org/partiql/eval/internal/TypingTestCase.kt +++ b/partiql-eval/src/test/kotlin/org/partiql/eval/internal/TypingTestCase.kt @@ -7,8 +7,8 @@ import org.partiql.parser.PartiQLParser import org.partiql.plan.Plan import org.partiql.planner.PartiQLPlanner import org.partiql.spi.catalog.Catalog -import org.partiql.spi.catalog.Session import org.partiql.spi.value.Datum +import org.partiql.system.PartiQLSessionBuilder import org.partiql.types.PType import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -62,7 +62,7 @@ public class TypingTestCase @OptIn(PartiQLValueExperimental::class) constructor( assertEquals(1, parseResult.statements.size) val statement = parseResult.statements[0] val catalog = Catalog.builder().name("memory").build() - val session = Session.builder() + val session = PartiQLSessionBuilder() .catalog("memory") .catalogs(catalog) .build() diff --git a/partiql-planner/build.gradle.kts b/partiql-planner/build.gradle.kts index 88a0586b8..c54b040c1 100644 --- a/partiql-planner/build.gradle.kts +++ b/partiql-planner/build.gradle.kts @@ -37,6 +37,7 @@ dependencies { annotationProcessor(Deps.lombok) // Test testImplementation(project(":partiql-parser")) + testImplementation(project(":partiql-system")) testImplementation(testFixtures(project(":partiql-types"))) // TODO: Remove use of StaticType testImplementation(Deps.kotlinReflect) // Test Fixtures 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 da8e6ed8f..86c5ed70c 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 @@ -102,8 +102,25 @@ internal class Env(private val session: Session) { error("Qualified functions are not supported.") } - // 1. Search in the current catalog and namespace. - val catalog = default + // Search in SQL Path + session.getPath().forEach { catalogName -> + // TODO: Allow for referencing schemas within a catalog. For now, only allow top-level functions in a catalog. + if (catalogName.getLength() != 1) { + return@forEach + } + val catalog = catalogs.getCatalog(catalogName.first()) ?: return@forEach + val candidates = getCandidates(catalog, identifier, args) + if (candidates.isNotEmpty()) { + return candidates + } + } + return emptyList() + } + + /** + * Given a [catalog], searches for candidate functions. + */ + private fun getCandidates(catalog: Catalog, identifier: Identifier, args: List): List { val name = identifier.getIdentifier().getText().lowercase() // CASE-NORMALIZED LOWER val variants = catalog.getFunctions(session, name).toList() val candidates = variants.filter { it.getParameters().size == args.size } @@ -118,14 +135,35 @@ internal class Env(private val session: Session) { * @return */ fun resolveFn(identifier: Identifier, args: List): Rex? { - // Reject qualified routine names. if (identifier.hasQualifier()) { error("Qualified functions are not supported.") } + // Search in SQL Path + session.getPath().forEach { catalogName -> + // TODO: Allow for referencing schemas within a catalog. For now, only allow top-level functions in a catalog. + if (catalogName.getLength() != 1) { + return@forEach + } + val catalog = catalogs.getCatalog(catalogName.first()) ?: return@forEach + val candidates = resolveFn(catalog, identifier, args) + if (candidates != null) { + return candidates + } + } + return null + } + + /** + * TODO leverage session PATH. + * + * @param identifier + * @param args + * @return + */ + private fun resolveFn(catalog: Catalog, identifier: Identifier, args: List): Rex? { // 1. Search in the current catalog and namespace. - val catalog = default val name = identifier.getIdentifier().getText().lowercase() // CASE-NORMALIZED LOWER val variants = catalog.getFunctions(session, name).toList() if (variants.isEmpty()) { @@ -170,10 +208,25 @@ internal class Env(private val session: Session) { } fun resolveAgg(path: String, setQuantifier: SetQuantifier, args: List): Rel.Op.Aggregate.Call.Resolved? { + // Search in SQL Path + session.getPath().forEach { catalogName -> + // TODO: Allow for referencing schemas within a catalog. For now, only allow top-level functions in a catalog. + if (catalogName.getLength() != 1) { + return@forEach + } + val catalog = catalogs.getCatalog(catalogName.first()) ?: return@forEach + val agg = resolveAgg(catalog, path, setQuantifier, args) + if (agg != null) { + return agg + } + } + return null + } + + private fun resolveAgg(catalog: Catalog, path: String, setQuantifier: SetQuantifier, args: List): Rel.Op.Aggregate.Call.Resolved? { // TODO: Eventually, do we want to support sensitive lookup? With a path? // 1. Search in the current catalog and namespace. - val catalog = default val name = path.lowercase() val candidates = catalog.getAggregations(session, name).toList() if (candidates.isEmpty()) { 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 edf5f02d1..355c154b8 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/PlanTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/PlanTest.kt @@ -11,7 +11,7 @@ import org.partiql.planner.internal.TestCatalog import org.partiql.planner.test.PartiQLTest import org.partiql.planner.test.PartiQLTestProvider import org.partiql.spi.catalog.Name -import org.partiql.spi.catalog.Session +import org.partiql.system.PartiQLSessionBuilder import org.partiql.types.BagType import org.partiql.types.StaticType import org.partiql.types.StructType @@ -66,7 +66,7 @@ class PlanTest { ) private val pipeline: (PartiQLTest, Boolean) -> PartiQLPlanner.Result = { test, isSignalMode -> - val session = Session.builder() + val session = PartiQLSessionBuilder() .catalog("default") .catalogs( TestCatalog.builder() diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/PlannerPErrorReportingTests.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/PlannerPErrorReportingTests.kt index b426325d6..4740ce545 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/PlannerPErrorReportingTests.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/PlannerPErrorReportingTests.kt @@ -12,8 +12,8 @@ import org.partiql.planner.util.PErrorCollector import org.partiql.planner.util.PlanPrinter import org.partiql.spi.Context import org.partiql.spi.catalog.Catalog -import org.partiql.spi.catalog.Session import org.partiql.spi.catalog.Table +import org.partiql.system.PartiQLSessionBuilder import org.partiql.types.BagType import org.partiql.types.Field import org.partiql.types.PType @@ -38,7 +38,7 @@ internal class PlannerPErrorReportingTests { .define(Table.empty("struct_with_missing", PType.row(listOf(Field.of("f1", PType.smallint()))))) .build() - private val session = Session.builder() + private val session = PartiQLSessionBuilder() .catalog(catalogName) .catalogs(catalog) .build() diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/exclude/SubsumptionTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/exclude/SubsumptionTest.kt index 191ccf921..6e4d04461 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/exclude/SubsumptionTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/exclude/SubsumptionTest.kt @@ -17,7 +17,7 @@ import org.partiql.plan.rex.RexSelect import org.partiql.plan.rex.RexVar import org.partiql.planner.PartiQLPlanner import org.partiql.spi.catalog.Catalog -import org.partiql.spi.catalog.Session +import org.partiql.system.PartiQLSessionBuilder import java.util.stream.Stream import kotlin.test.assertEquals @@ -41,7 +41,7 @@ class SubsumptionTest { val parseResult = parser.parse(text) assertEquals(1, parseResult.statements.size) val statement = parseResult.statements[0] - val session = Session.builder().catalog("default").catalogs(catalog).build() + val session = PartiQLSessionBuilder().catalog("default").catalogs(catalog).build() val plan = planner.plan(statement, session).plan val excludeClause = getExcludeClause(plan.getOperation()).getExclusions() assertEquals(tc.expectedExcludeExprs, excludeClause) 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 42d534ebd..decb32594 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 @@ -16,6 +16,7 @@ import org.partiql.spi.catalog.Session import org.partiql.spi.catalog.Table import org.partiql.spi.errors.PError import org.partiql.spi.errors.PErrorListener +import org.partiql.system.PartiQLSessionBuilder import org.partiql.types.PType import org.partiql.types.StaticType import org.partiql.types.fromStaticType @@ -42,7 +43,7 @@ abstract class PartiQLTyperTestBase { public val planner = PartiQLPlanner.standard() internal val session: ((String, Catalog) -> Session) = { catalog, metadata -> - Session.builder() + PartiQLSessionBuilder() .catalog(catalog) .catalogs(metadata) .build() 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 6d6d12f03..bc8ff98f5 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 @@ -21,8 +21,8 @@ import org.partiql.planner.util.PErrorCollector import org.partiql.spi.Context import org.partiql.spi.catalog.Identifier import org.partiql.spi.catalog.Name -import org.partiql.spi.catalog.Session import org.partiql.spi.catalog.Table +import org.partiql.system.PartiQLSessionBuilder import org.partiql.types.PType import org.partiql.value.PartiQLValueExperimental import org.partiql.value.int32Value @@ -120,7 +120,7 @@ class PlanTyperTest { private fun getTyper(): PlanTyperWrapper { val config = Context.of(PErrorCollector()) val env = Env( - Session.builder() + PartiQLSessionBuilder() .catalog("pql") .namespace("main") .catalogs( 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 13d06bd03..04b4f0c73 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 @@ -32,6 +32,7 @@ import org.partiql.spi.catalog.Name import org.partiql.spi.catalog.Session import org.partiql.spi.errors.PError import org.partiql.spi.errors.PErrorListener +import org.partiql.system.PartiQLSessionBuilder import org.partiql.types.BagType import org.partiql.types.DecimalType import org.partiql.types.Field @@ -3824,7 +3825,7 @@ internal class PlanTyperTestsPorted { } private fun runTest(tc: SuccessTestCase) { - val session = Session.builder() + val session = PartiQLSessionBuilder() .catalog(tc.catalog) .catalogs(*catalogs.toTypedArray()) .namespace(tc.catalogPath) @@ -3867,7 +3868,7 @@ internal class PlanTyperTestsPorted { } private fun runTest(tc: ErrorTestCase) { - val session = Session.builder() + val session = PartiQLSessionBuilder() .catalog(tc.catalog) .catalogs(*catalogs.toTypedArray()) .namespace(tc.catalogPath) @@ -3911,7 +3912,7 @@ internal class PlanTyperTestsPorted { } private fun runTest(tc: ThrowingExceptionTestCase) { - val session = Session.builder() + val session = PartiQLSessionBuilder() .catalog(tc.catalog) .catalogs(*catalogs.toTypedArray()) .namespace(tc.catalogPath) diff --git a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/ScopeTest.kt b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/ScopeTest.kt index 276bda5cf..2d32bf9b5 100644 --- a/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/ScopeTest.kt +++ b/partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/ScopeTest.kt @@ -10,7 +10,7 @@ import org.partiql.planner.internal.ir.relBinding import org.partiql.planner.internal.typer.PlanTyper.Companion.toCType import org.partiql.spi.catalog.Catalog import org.partiql.spi.catalog.Identifier -import org.partiql.spi.catalog.Session +import org.partiql.system.PartiQLSessionBuilder import org.partiql.types.PType import kotlin.test.assertEquals import kotlin.test.fail @@ -36,7 +36,7 @@ internal class ScopeTest { @JvmStatic val locals = TypeEnv( Env( - Session.builder() + PartiQLSessionBuilder() .catalog("currentCatalog") .catalogs(catalog) .build() diff --git a/partiql-spi/api/partiql-spi.api b/partiql-spi/api/partiql-spi.api index 7b9571a09..020f1dabf 100644 --- a/partiql-spi/api/partiql-spi.api +++ b/partiql-spi/api/partiql-spi.api @@ -202,6 +202,7 @@ public final class org/partiql/spi/catalog/Namespace : java/lang/Iterable, kotli public synthetic fun ([Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun append ([Ljava/lang/String;)Lorg/partiql/spi/catalog/Namespace; public final fun asIdentifier ()Lorg/partiql/spi/catalog/Identifier; + public static final fun empty ()Lorg/partiql/spi/catalog/Namespace; public fun equals (Ljava/lang/Object;)Z public fun forEach (Ljava/util/function/Consumer;)V public final fun get (I)Ljava/lang/String; diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Catalog.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Catalog.kt index d7233390b..7f358a223 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Catalog.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Catalog.kt @@ -2,7 +2,6 @@ package org.partiql.spi.catalog import org.partiql.spi.catalog.impl.StandardCatalog import org.partiql.spi.function.Aggregation -import org.partiql.spi.function.Builtins import org.partiql.spi.function.Function /** @@ -22,7 +21,9 @@ public interface Catalog { /** * Get a table by name. */ - public fun getTable(session: Session, name: Name): Table? = null + public fun getTable(session: Session, name: Name): Table? { + return null + } /** * Get a table by identifier. @@ -41,17 +42,23 @@ public interface Catalog { * 2. Invoke getTable("a"."b"."c"."Example"."x") * 3. The implementation MUST match "a"."b"."c"."Example" to a.b.c.Example (note "x" does not match a table) */ - public fun getTable(session: Session, identifier: Identifier): Table? = null + public fun getTable(session: Session, identifier: Identifier): Table? { + return null + } /** * Returns a collection of scalar functions in this catalog with the given name, or an empty list if none. */ - public fun getFunctions(session: Session, name: String): Collection = Builtins.getFunctions(name) + public fun getFunctions(session: Session, name: String): Collection { + return emptyList() + } /** * Returns a collection of aggregation functions in this catalog with the given name, or an empty list if none. */ - public fun getAggregations(session: Session, name: String): Collection = Builtins.getAggregations(name) + public fun getAggregations(session: Session, name: String): Collection { + return emptyList() + } public companion object { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Namespace.kt b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Namespace.kt index 170bf5b98..a597dba25 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Namespace.kt +++ b/partiql-spi/src/main/kotlin/org/partiql/spi/catalog/Namespace.kt @@ -81,6 +81,7 @@ public class Namespace private constructor( private val EMPTY = Namespace(emptyArray()) + @JvmStatic public fun empty(): Namespace = EMPTY @JvmStatic diff --git a/partiql-system/api/partiql-system.api b/partiql-system/api/partiql-system.api new file mode 100644 index 000000000..53162b793 --- /dev/null +++ b/partiql-system/api/partiql-system.api @@ -0,0 +1,28 @@ +public final class org/partiql/system/PartiQLSession : org/partiql/spi/catalog/Session { + public static fun empty ()Lorg/partiql/spi/catalog/Session; + public fun getCatalog ()Ljava/lang/String; + public fun getCatalogs ()Lorg/partiql/spi/catalog/Catalogs; + public fun getIdentity ()Ljava/lang/String; + public fun getNamespace ()Lorg/partiql/spi/catalog/Namespace; + public fun getPath ()Lorg/partiql/spi/catalog/Path; + public fun getProperties ()Ljava/util/Map; +} + +public final class org/partiql/system/PartiQLSessionBuilder { + public fun ()V + public fun build ()Lorg/partiql/spi/catalog/Session; + public fun catalog (Ljava/lang/String;)Lorg/partiql/system/PartiQLSessionBuilder; + public fun catalogs ([Lorg/partiql/spi/catalog/Catalog;)Lorg/partiql/system/PartiQLSessionBuilder; + public fun identity (Ljava/lang/String;)Lorg/partiql/system/PartiQLSessionBuilder; + public fun namespace (Ljava/util/Collection;)Lorg/partiql/system/PartiQLSessionBuilder; + public fun namespace (Lorg/partiql/spi/catalog/Namespace;)Lorg/partiql/system/PartiQLSessionBuilder; + public fun namespace ([Ljava/lang/String;)Lorg/partiql/system/PartiQLSessionBuilder; + public fun noSystemCatalog ()Lorg/partiql/system/PartiQLSessionBuilder; + public fun property (Ljava/lang/String;Ljava/lang/String;)Lorg/partiql/system/PartiQLSessionBuilder; + public fun systemCatalogName (Ljava/lang/String;)Lorg/partiql/system/PartiQLSessionBuilder; +} + +public final class org/partiql/system/internal/NumberExtensionsKt { + public static final fun coerceNumbers (Ljava/lang/Number;Ljava/lang/Number;)Lkotlin/Pair; +} + diff --git a/partiql-system/build.gradle.kts b/partiql-system/build.gradle.kts new file mode 100644 index 000000000..86ff4b227 --- /dev/null +++ b/partiql-system/build.gradle.kts @@ -0,0 +1,43 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +plugins { + id(Plugins.conventions) + id(Plugins.publish) +} + +dependencies { + api(project(":partiql-spi")) + api(project(":partiql-types")) + compileOnly(Deps.lombok) + annotationProcessor(Deps.lombok) +} + +// TODO: Once we move to only public Java APIs, we can use Javadoc. +// Need to add this as we have both Java and Kotlin sources. Dokka already handles multi-language projects. If +// Javadoc is enabled, we end up overwriting index.html (causing compilation errors). +tasks.withType { + enabled = false +} + +tasks.withType { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} + +publish { + artifactId = "partiql-catalog" + name = "PartiQL Catalog" + description = "Contains all of the PartiQL System's functions and operators." +} diff --git a/partiql-system/src/main/java/org/partiql/system/PartiQLSession.java b/partiql-system/src/main/java/org/partiql/system/PartiQLSession.java new file mode 100644 index 000000000..9ef1d96d9 --- /dev/null +++ b/partiql-system/src/main/java/org/partiql/system/PartiQLSession.java @@ -0,0 +1,101 @@ +package org.partiql.system; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.partiql.spi.catalog.Catalogs; +import org.partiql.spi.catalog.Namespace; +import org.partiql.spi.catalog.Path; +import org.partiql.spi.catalog.Session; + +import java.util.HashMap; +import java.util.Map; + +/** + * This is a package-private implementation of {@link Session}. + * @see PartiQLSessionBuilder + */ +public final class PartiQLSession implements Session { + + @NotNull + private final Catalogs _catalogs; + + @NotNull + private final String identity; + + @Nullable + private final Namespace systemCatalogNamespace; + + @NotNull + private final String currentCatalog; + + @NotNull + private final Namespace namespace; + + @NotNull + private final Map properties; + + PartiQLSession(boolean usesSystemCatalog, @NotNull String systemCatalogName, @NotNull String identity, @NotNull String catalog, @NotNull Namespace namespace, @NotNull Catalogs.Builder catalogs, @NotNull Map properties) { + this.systemCatalogNamespace = usesSystemCatalog ? Namespace.of(systemCatalogName) : null; + this.identity = identity; + this.currentCatalog = catalog; + this.namespace = namespace; + this.properties = properties; + if (usesSystemCatalog) { + catalogs.add(new PartiQLSystemCatalog(systemCatalogName)); + } + this._catalogs = catalogs.build(); + } + + @NotNull + @Override + public Map getProperties() { + return properties; + } + + @NotNull + @Override + public Path getPath() { + return Path.of(getNamespace(), systemCatalogNamespace); + } + + @NotNull + @Override + public String getIdentity() { + return identity; + } + + @NotNull + @Override + public String getCatalog() { + return currentCatalog; + } + + @NotNull + @Override + public Catalogs getCatalogs() { + return _catalogs; + } + + @NotNull + @Override + public Namespace getNamespace() { + return namespace; + } + + /** + * + * @return a session only holding the system catalog. + */ + @NotNull + public static Session empty() { + return new PartiQLSession( + true, + "$pql_system", + "unknown", + "$pql_system", + Namespace.of(), + Catalogs.builder(), + new HashMap<>() + ); + } +} diff --git a/partiql-system/src/main/java/org/partiql/system/PartiQLSessionBuilder.java b/partiql-system/src/main/java/org/partiql/system/PartiQLSessionBuilder.java new file mode 100644 index 000000000..515672fcd --- /dev/null +++ b/partiql-system/src/main/java/org/partiql/system/PartiQLSessionBuilder.java @@ -0,0 +1,139 @@ +package org.partiql.system; + +import org.jetbrains.annotations.NotNull; +import org.partiql.spi.catalog.Catalog; +import org.partiql.spi.catalog.Catalogs; +import org.partiql.spi.catalog.Namespace; +import org.partiql.spi.catalog.Session; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + * This creates a {@link Session} while also installing the PartiQL System Catalog by default (unless + * {@link PartiQLSessionBuilder#noSystemCatalog()} is specified). The resulting {@link Session} will append the System + * Catalog to the end of the {@link Session#getPath()}. + * @see PartiQLSessionBuilder#noSystemCatalog() + * @see PartiQLSessionBuilder#systemCatalogName(String) + */ +public final class PartiQLSessionBuilder { + + private String identity = "unknown"; + private String catalog = null; + private final Catalogs.Builder catalogs = Catalogs.builder(); + private Namespace namespace = Namespace.empty(); + private final Map properties = new HashMap<>(); + private boolean usesSystemCatalog = true; + private String systemCatalogName = "$partiql_system"; + + /** + * TODO + * @param identity TODO + * @return TODO + */ + @NotNull + public PartiQLSessionBuilder identity(String identity) { + this.identity = identity; + return this; + } + + /** + * Removes the system catalog from the session. + * @return the builder + */ + @NotNull + public PartiQLSessionBuilder noSystemCatalog() { + this.usesSystemCatalog = false; + return this; + } + + /** + * Sets the name of the system catalog. + * @param name the desired name + * @return the builder + */ + @NotNull + public PartiQLSessionBuilder systemCatalogName(@NotNull String name) { + this.systemCatalogName = name; + return this; + } + + /** + * TODO + * @param catalog TODO + * @return TODO + */ + @NotNull + public PartiQLSessionBuilder catalog(String catalog) { + this.catalog = catalog; + return this; + } + + /** + * TODO + * @param namespace TODO + * @return TODO + */ + @NotNull + public PartiQLSessionBuilder namespace(Namespace namespace) { + this.namespace = namespace; + return this; + } + + /** + * TODO + * @param levels TODO + * @return TODO + */ + @NotNull + public PartiQLSessionBuilder namespace(String... levels) { + this.namespace = Namespace.of(levels); + return this; + } + + /** + * TODO + * @param levels TODO + * @return TODO + */ + @NotNull + public PartiQLSessionBuilder namespace(Collection levels) { + this.namespace = Namespace.of(levels); + return this; + } + + /** + * TODO + * @param name TODO + * @param value TODO + * @return TODO + */ + @NotNull + public PartiQLSessionBuilder property(String name, String value) { + this.properties.put(name, value); + return this; + } + + /** + * TODO + * @param catalogs TODO + * @return TODO + */ + @NotNull + public PartiQLSessionBuilder catalogs(Catalog... catalogs) { + for (Catalog catalog : catalogs) { + this.catalogs.add(catalog); + } + return this; + } + + /** + * TODO + * @return TODO + */ + @NotNull + public Session build() { + return new PartiQLSession(usesSystemCatalog, systemCatalogName, identity, catalog, namespace, catalogs, properties); + } +} diff --git a/partiql-system/src/main/java/org/partiql/system/PartiQLSystemCatalog.java b/partiql-system/src/main/java/org/partiql/system/PartiQLSystemCatalog.java new file mode 100644 index 000000000..980a78737 --- /dev/null +++ b/partiql-system/src/main/java/org/partiql/system/PartiQLSystemCatalog.java @@ -0,0 +1,67 @@ +package org.partiql.system; + +import lombok.EqualsAndHashCode; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.partiql.spi.catalog.Catalog; +import org.partiql.spi.catalog.Identifier; +import org.partiql.spi.catalog.Name; +import org.partiql.spi.catalog.Session; +import org.partiql.spi.catalog.Table; +import org.partiql.spi.function.Aggregation; +import org.partiql.spi.function.Function; + +import java.util.Collection; + +/** + * This is a package-private class that implements the PartiQL System Catalog. + * It provides the implementation for the PartiQL System Catalog, which is a built-in catalog + * that provides access to the PartiQL language and its built-in functions and aggregations. + * @see PartiQLSessionBuilder + */ +final class PartiQLSystemCatalog implements Catalog { + + /** + * TODO + */ + @NotNull + private final String name; + + /** + * Creates a new PartiQL System Catalog with the given name. + * @param name the name of the PartiQL System Catalog + */ + PartiQLSystemCatalog(@NotNull String name) { + this.name = name; + } + + @NotNull + @Override + public String getName() { + return this.name; + } + + @Nullable + @Override + public Table getTable(@NotNull Session session, @NotNull Name name) { + return null; + } + + @Nullable + @Override + public Table getTable(@NotNull Session session, @NotNull Identifier identifier) { + return null; + } + + @NotNull + @Override + public Collection getFunctions(@NotNull Session session, @NotNull String name) { + return Builtins.INSTANCE.getFunctions(name); + } + + @NotNull + @Override + public Collection getAggregations(@NotNull Session session, @NotNull String name) { + return Builtins.INSTANCE.getAggregations(name); + } +} diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/utils/PatternUtils.kt b/partiql-system/src/main/kotlin/org/partiql/spi/function/utils/PatternUtils.kt similarity index 100% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/utils/PatternUtils.kt rename to partiql-system/src/main/kotlin/org/partiql/spi/function/utils/PatternUtils.kt diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/utils/StringUtils.kt b/partiql-system/src/main/kotlin/org/partiql/spi/function/utils/StringUtils.kt similarity index 100% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/utils/StringUtils.kt rename to partiql-system/src/main/kotlin/org/partiql/spi/function/utils/StringUtils.kt diff --git a/partiql-system/src/main/kotlin/org/partiql/spi/internal/SqlTypeFamily.kt b/partiql-system/src/main/kotlin/org/partiql/spi/internal/SqlTypeFamily.kt new file mode 100644 index 000000000..cc2dabd86 --- /dev/null +++ b/partiql-system/src/main/kotlin/org/partiql/spi/internal/SqlTypeFamily.kt @@ -0,0 +1,75 @@ +package org.partiql.spi.internal + +import org.partiql.types.PType + +/** + * A basic "set" representation for type categorization; perhaps we optimize later.. + * + * From Calcite, + * > SqlTypeFamily provides SQL type categorization. + * > Primary Families + * > CHARACTER, + * > BINARY, + * > NUMERIC, + * > DATE, + * > TIME, + * > TIMESTAMP, + * > BOOLEAN, + * > https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFamily.java + * + * + * From Postgres, + * > Data types are divided into several basic type categories, including boolean, numeric, string, bitstring, datetime, + * > timespan, geometric, network, and user-defined. Within each category there can be one or more preferred types, + * > which are preferred when there is a choice of possible types. + */ +internal class SqlTypeFamily private constructor( + @JvmField val preferred: PType, + @JvmField val members: Set, +) { + + /** + * Constructor a singleton [SqlTypeFamily]. + */ + constructor(preferred: PType) : this(preferred, setOf(preferred.code())) + + operator fun contains(type: PType) = type.code() in members + + companion object { + + @JvmStatic + val TEXT = SqlTypeFamily( + preferred = PType.string(), + members = setOf( + PType.CHAR, + PType.VARCHAR, + PType.STRING, + PType.CLOB, + ) + ) + + @JvmStatic + val COLLECTION = SqlTypeFamily( + preferred = PType.bag(), + members = setOf( + PType.ARRAY, + PType.BAG + ) + ) + + @JvmStatic + val NUMBER = SqlTypeFamily( + preferred = PType.decimal(38, 19), + members = setOf( + PType.TINYINT, + PType.SMALLINT, + PType.INTEGER, + PType.BIGINT, + PType.NUMERIC, + PType.REAL, + PType.DOUBLE, + PType.DECIMAL, + ) + ) + } +} diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/Builtins.kt b/partiql-system/src/main/kotlin/org/partiql/system/Builtins.kt similarity index 97% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/Builtins.kt rename to partiql-system/src/main/kotlin/org/partiql/system/Builtins.kt index cdd7f2f47..5dec5232f 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/Builtins.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/Builtins.kt @@ -1,7 +1,9 @@ -package org.partiql.spi.function +package org.partiql.system /* ktlint-disable no-wildcard-imports */ -import org.partiql.spi.function.builtins.* +import org.partiql.spi.function.Aggregation +import org.partiql.spi.function.Function +import org.partiql.system.builtins.* /** * This is where we will register all SQL builtins; consider raising a "library" interface. @@ -182,8 +184,8 @@ internal object Builtins { Fn_LIKE_ESCAPE__STRING_STRING_STRING__BOOL, Fn_LIKE_ESCAPE__CLOB_CLOB_CLOB__BOOL, - Fn_LOWER__STRING__STRING, - Fn_LOWER__CLOB__CLOB, + org.partiql.system.builtins.Fn_LOWER__STRING__STRING, + org.partiql.system.builtins.Fn_LOWER__CLOB__CLOB, FnLt, FnLte, diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAny.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggAny.kt similarity index 83% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAny.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/AggAny.kt index cadee2aaa..105bb3f59 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAny.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggAny.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Aggregation import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.internal.AccumulatorAnySome +import org.partiql.system.builtins.internal.AccumulatorAnySome import org.partiql.types.PType internal val Agg_ANY__BOOL__BOOL = Aggregation.static( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAvg.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggAvg.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAvg.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/AggAvg.kt index d78de2bd4..96c4e4331 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAvg.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggAvg.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Aggregation import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.internal.AccumulatorAvg +import org.partiql.system.builtins.internal.AccumulatorAvg import org.partiql.types.PType // TODO: This needs to be formalized. See https://github.com/partiql/partiql-lang-kotlin/issues/1659 diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggCount.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggCount.kt similarity index 77% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggCount.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/AggCount.kt index 50abf3861..04967cc12 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggCount.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggCount.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Aggregation import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.internal.AccumulatorCount +import org.partiql.system.builtins.internal.AccumulatorCount import org.partiql.types.PType internal val Agg_COUNT__ANY__INT64 = Aggregation.static( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggEvery.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggEvery.kt similarity index 85% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggEvery.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/AggEvery.kt index 6973374d0..f009d8d6a 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggEvery.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggEvery.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Aggregation import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.internal.AccumulatorEvery +import org.partiql.system.builtins.internal.AccumulatorEvery import org.partiql.types.PType internal val Agg_EVERY__BOOL__BOOL = Aggregation.static( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggGroupAs.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggGroupAs.kt similarity index 78% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggGroupAs.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/AggGroupAs.kt index 90630e8cf..11cff8fc9 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggGroupAs.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggGroupAs.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Aggregation import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.internal.AccumulatorGroupAs +import org.partiql.system.builtins.internal.AccumulatorGroupAs import org.partiql.types.PType internal val Agg_GROUP_AS__ANY__ANY = Aggregation.static( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMax.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggMax.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMax.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/AggMax.kt index de8831d7b..9d4ac8ad5 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMax.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggMax.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Aggregation import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.internal.AccumulatorMax +import org.partiql.system.builtins.internal.AccumulatorMax import org.partiql.types.PType internal val Agg_MAX__INT8__INT8 = Aggregation.static( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMin.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggMin.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMin.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/AggMin.kt index 140f569fe..8ceddf8b1 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggMin.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggMin.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Aggregation import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.internal.AccumulatorMin +import org.partiql.system.builtins.internal.AccumulatorMin import org.partiql.types.PType internal val Agg_MIN__INT8__INT8 = Aggregation.static( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggSome.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggSome.kt similarity index 84% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggSome.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/AggSome.kt index 6b28cfaee..32dad874d 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggSome.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggSome.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Aggregation import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.internal.AccumulatorAnySome +import org.partiql.system.builtins.internal.AccumulatorAnySome import org.partiql.types.PType internal val Agg_SOME__BOOL__BOOL = Aggregation.static( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggSum.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggSum.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggSum.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/AggSum.kt index b661e6dc7..af22fe007 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggSum.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/AggSum.kt @@ -1,11 +1,11 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Aggregation import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.internal.AccumulatorSum +import org.partiql.system.builtins.internal.AccumulatorSum import org.partiql.types.PType internal val Agg_SUM__INT8__INT8 = Aggregation.static( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DefaultNumeric.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/DefaultNumeric.kt similarity index 83% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DefaultNumeric.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/DefaultNumeric.kt index cb9d44a30..5bdd8c291 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DefaultNumeric.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/DefaultNumeric.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.types.PType diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DiadicArithmeticOperator.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/DiadicArithmeticOperator.kt similarity index 88% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DiadicArithmeticOperator.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/DiadicArithmeticOperator.kt index ff5ac52a6..920fb0518 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DiadicArithmeticOperator.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/DiadicArithmeticOperator.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DiadicComparisonOperator.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/DiadicComparisonOperator.kt similarity index 97% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DiadicComparisonOperator.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/DiadicComparisonOperator.kt index 948d5af29..880c4cfcd 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DiadicComparisonOperator.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/DiadicComparisonOperator.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DiadicOperator.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/DiadicOperator.kt similarity index 99% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DiadicOperator.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/DiadicOperator.kt index bd233083c..824340421 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DiadicOperator.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/DiadicOperator.kt @@ -1,10 +1,10 @@ -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.TypePrecedence.TYPE_PRECEDENCE import org.partiql.spi.internal.SqlTypeFamily import org.partiql.spi.value.Datum +import org.partiql.system.builtins.TypePrecedence.TYPE_PRECEDENCE import org.partiql.types.PType /** diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAbs.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnAbs.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAbs.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnAbs.kt index d97538786..caefef2f2 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAbs.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnAbs.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAnd.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnAnd.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAnd.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnAnd.kt index 07399b386..c5e16aacb 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAnd.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnAnd.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBetween.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnBetween.kt similarity index 99% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBetween.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnBetween.kt index 3df72bc16..161b21ec7 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBetween.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnBetween.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBitLength.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnBitLength.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBitLength.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnBitLength.kt index ba477cdbf..897314947 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBitLength.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnBitLength.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBitwiseAnd.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnBitwiseAnd.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBitwiseAnd.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnBitwiseAnd.kt index f2e1db52b..379ae624a 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnBitwiseAnd.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnBitwiseAnd.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.value.Datum diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCardinality.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCardinality.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCardinality.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCardinality.kt index 8a37a7ea1..a4a620dcf 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCardinality.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCardinality.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCharLength.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCharLength.kt similarity index 94% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCharLength.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCharLength.kt index ebb7b550c..b92b0475e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCharLength.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCharLength.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCollAgg.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCollAgg.kt similarity index 81% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCollAgg.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCollAgg.kt index 09a09f782..d571c6b94 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCollAgg.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCollAgg.kt @@ -1,20 +1,20 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter -import org.partiql.spi.function.builtins.internal.Accumulator -import org.partiql.spi.function.builtins.internal.AccumulatorAnySome -import org.partiql.spi.function.builtins.internal.AccumulatorAvg -import org.partiql.spi.function.builtins.internal.AccumulatorCount -import org.partiql.spi.function.builtins.internal.AccumulatorDistinct -import org.partiql.spi.function.builtins.internal.AccumulatorEvery -import org.partiql.spi.function.builtins.internal.AccumulatorMax -import org.partiql.spi.function.builtins.internal.AccumulatorMin -import org.partiql.spi.function.builtins.internal.AccumulatorSum import org.partiql.spi.value.Datum +import org.partiql.system.builtins.internal.Accumulator +import org.partiql.system.builtins.internal.AccumulatorAnySome +import org.partiql.system.builtins.internal.AccumulatorAvg +import org.partiql.system.builtins.internal.AccumulatorCount +import org.partiql.system.builtins.internal.AccumulatorDistinct +import org.partiql.system.builtins.internal.AccumulatorEvery +import org.partiql.system.builtins.internal.AccumulatorMax +import org.partiql.system.builtins.internal.AccumulatorMin +import org.partiql.system.builtins.internal.AccumulatorSum import org.partiql.types.PType internal abstract class Fn_COLL_AGG__BAG__ANY( diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnConcat.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnConcat.kt similarity index 97% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnConcat.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnConcat.kt index d8e90d651..33e3226d9 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnConcat.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnConcat.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCurrentDate.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCurrentDate.kt similarity index 88% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCurrentDate.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCurrentDate.kt index 3fe9cc2ae..4551bb3c6 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCurrentDate.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCurrentDate.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.types.PType diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCurrentUser.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCurrentUser.kt similarity index 88% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCurrentUser.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCurrentUser.kt index 4b234ecec..20c9554a7 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCurrentUser.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnCurrentUser.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.types.PType diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddDay.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddDay.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddDay.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddDay.kt index 98f9e4f5a..8a67a8e16 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddDay.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddDay.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.errors.DataException import org.partiql.errors.TypeCheckException diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddHour.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddHour.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddHour.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddHour.kt index be21e3c08..96ca62229 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddHour.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddHour.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.errors.DataException import org.partiql.errors.TypeCheckException diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMinute.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddMinute.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMinute.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddMinute.kt index 9811538a9..2aec5b557 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMinute.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddMinute.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.errors.DataException import org.partiql.errors.TypeCheckException diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddMonth.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddMonth.kt index 5a61e31c5..3a30bb309 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddMonth.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddMonth.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.errors.DataException import org.partiql.errors.TypeCheckException diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddSecond.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddSecond.kt index 53c3415e5..fc19f32c8 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddSecond.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddSecond.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.errors.DataException import org.partiql.errors.TypeCheckException diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddYear.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddYear.kt index 4beae8cbb..64256e509 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateAddYear.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateAddYear.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.errors.DataException import org.partiql.errors.TypeCheckException diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffDay.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffDay.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffDay.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffDay.kt index 9b3ce54b0..d48c5d6c9 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffDay.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffDay.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffHour.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffHour.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffHour.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffHour.kt index f8bd4bada..759063645 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffHour.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffHour.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffMinute.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffMinute.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffMinute.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffMinute.kt index 3ec423190..b938f39ed 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffMinute.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffMinute.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffMonth.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffMonth.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffMonth.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffMonth.kt index 634bb52e4..33b9c79e1 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffMonth.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffMonth.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffSecond.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffSecond.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffSecond.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffSecond.kt index e2cedd215..377577842 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffSecond.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffSecond.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffYear.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffYear.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffYear.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffYear.kt index 483f59e7d..d37cf0ab3 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDateDiffYear.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDateDiffYear.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDivide.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDivide.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDivide.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDivide.kt index cc1f6f1a2..4577294f3 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnDivide.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnDivide.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.value.Datum diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnEq.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnEq.kt similarity index 97% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnEq.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnEq.kt index 22d8582bb..b5372e0fe 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnEq.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnEq.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnExists.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnExists.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnExists.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnExists.kt index 09c2b06f8..455489b15 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnExists.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnExists.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnExtract.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnExtract.kt similarity index 99% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnExtract.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnExtract.kt index dfe6db4cb..22cb3d0fc 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnExtract.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnExtract.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGt.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnGt.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGt.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnGt.kt index c0077be00..677029538 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGt.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnGt.kt @@ -1,12 +1,12 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.value.Datum +import org.partiql.system.internal.compareTo import org.partiql.types.PType -import org.partiql.value.util.compareTo internal object FnGt : DiadicComparisonOperator("gt") { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnGte.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnGte.kt index 9a581b5c2..dd3d0c775 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnGte.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnGte.kt @@ -1,12 +1,12 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.value.Datum +import org.partiql.system.internal.compareTo import org.partiql.types.PType -import org.partiql.value.util.compareTo internal object FnGte : DiadicComparisonOperator("gte") { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnInCollection.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnInCollection.kt similarity index 97% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnInCollection.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnInCollection.kt index c54fe8f12..0c926afc2 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnInCollection.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnInCollection.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName", "DEPRECATION") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsAny.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsAny.kt similarity index 90% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsAny.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsAny.kt index c9ebf47aa..b2b100e8e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsAny.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsAny.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBag.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBag.kt similarity index 91% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBag.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBag.kt index e35758ea2..4628f8e0d 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBag.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBag.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBinary.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBinary.kt similarity index 90% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBinary.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBinary.kt index c92e3a3a6..e4cf405c8 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBinary.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBinary.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBlob.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBlob.kt similarity index 91% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBlob.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBlob.kt index abefbf0bb..3134c4a5f 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBlob.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBlob.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBool.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBool.kt similarity index 91% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBool.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBool.kt index 2ca7040c4..cc20b069f 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBool.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsBool.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsByte.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsByte.kt similarity index 90% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsByte.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsByte.kt index 45a710121..fed6c6e66 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsByte.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsByte.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsChar.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsChar.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsChar.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsChar.kt index ae1da6b8f..4f7f21b9e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsChar.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsChar.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.errors.TypeCheckException import org.partiql.spi.function.Function diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsClob.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsClob.kt similarity index 91% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsClob.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsClob.kt index d88d0849e..7672c439b 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsClob.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsClob.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsDate.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsDate.kt similarity index 91% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsDate.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsDate.kt index adf281acd..8cd774a50 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsDate.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsDate.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsDecimal.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsDecimal.kt similarity index 97% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsDecimal.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsDecimal.kt index 3cc07bb7e..b3590fb99 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsDecimal.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsDecimal.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsFloat32.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsFloat32.kt similarity index 94% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsFloat32.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsFloat32.kt index 0f873d9f8..e83b10cf6 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsFloat32.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsFloat32.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsFloat64.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsFloat64.kt similarity index 92% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsFloat64.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsFloat64.kt index 424c0a86d..63721bdea 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsFloat64.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsFloat64.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt.kt similarity index 93% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt.kt index 09bdf95c6..194783dee 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt16.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt16.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt16.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt16.kt index 8bf34170e..0b5621131 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt16.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt16.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt32.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt32.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt32.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt32.kt index 3c16b7383..fc0790124 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt32.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt32.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt64.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt64.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt64.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt64.kt index 1a55a5155..b49b0ca64 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt64.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt64.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt8.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt8.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt8.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt8.kt index 46379417b..bb5b9c680 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt8.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInt8.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInterval.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInterval.kt similarity index 90% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInterval.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInterval.kt index 2141027c1..04a3e565e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInterval.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsInterval.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsList.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsList.kt similarity index 91% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsList.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsList.kt index 0bf3d3819..3201bdfa0 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsList.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsList.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsMissing.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsMissing.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsMissing.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsMissing.kt index 7acb5188c..2b4d903e3 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsMissing.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsMissing.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsNull.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsNull.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsNull.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsNull.kt index d3d258db8..678c0a8e4 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsNull.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsNull.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsString.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsString.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsString.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsString.kt index 2d6c98133..5ca9d51af 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsString.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsString.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.errors.TypeCheckException import org.partiql.spi.function.Function diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsStruct.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsStruct.kt similarity index 91% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsStruct.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsStruct.kt index e83155c0c..73a6fcdfc 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsStruct.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsStruct.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsTime.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsTime.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsTime.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsTime.kt index ae3f6b36c..1776e1ef7 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsTime.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsTime.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsTimestamp.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsTimestamp.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsTimestamp.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsTimestamp.kt index 63f798281..46fe11abd 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsTimestamp.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnIsTimestamp.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLike.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLike.kt similarity index 97% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLike.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLike.kt index 7d2801dd0..3b56081df 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLike.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLike.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLikeEscape.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLikeEscape.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLikeEscape.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLikeEscape.kt index 88093f28a..6efcdd42e 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLikeEscape.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLikeEscape.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.errors.TypeCheckException import org.partiql.spi.function.Function diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLower.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLower.kt similarity index 94% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLower.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLower.kt index ebca15aee..e06a919cd 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLower.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLower.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLt.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLt.kt index 8e526a2be..a9065acce 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLt.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLt.kt @@ -1,12 +1,12 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.value.Datum +import org.partiql.system.internal.compareTo import org.partiql.types.PType -import org.partiql.value.util.compareTo internal object FnLt : DiadicComparisonOperator("lt") { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLte.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLte.kt index 35d6cba0e..6ce9316bb 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnLte.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnLte.kt @@ -1,12 +1,12 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.value.Datum +import org.partiql.system.internal.compareTo import org.partiql.types.PType -import org.partiql.value.util.compareTo internal object FnLte : DiadicComparisonOperator("lte") { diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnMinus.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnMinus.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnMinus.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnMinus.kt index df7de273c..fef010eaf 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnMinus.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnMinus.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnModulo.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnModulo.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnModulo.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnModulo.kt index a785a020e..a40fcf8eb 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnModulo.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnModulo.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.value.Datum diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNeg.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnNeg.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNeg.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnNeg.kt index 0ebc9380c..9f7c0f40a 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNeg.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnNeg.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNot.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnNot.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNot.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnNot.kt index c605f7800..4f6b1437f 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNot.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnNot.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnOctetLength.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnOctetLength.kt similarity index 94% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnOctetLength.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnOctetLength.kt index b4ea074e9..ba630fa70 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnOctetLength.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnOctetLength.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnOr.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnOr.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnOr.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnOr.kt index e643d9eb1..c200a8cdf 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnOr.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnOr.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPlus.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnPlus.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPlus.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnPlus.kt index 576951390..ed88a8bd0 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPlus.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnPlus.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPos.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnPos.kt similarity index 97% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPos.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnPos.kt index bb0ab5085..3ecf26782 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPos.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnPos.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPosition.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnPosition.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPosition.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnPosition.kt index 27992ebc8..f6ae1e29d 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnPosition.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnPosition.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnSize.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnSize.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnSize.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnSize.kt index 554dbd253..f8e60c581 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnSize.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnSize.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnSubstring.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnSubstring.kt similarity index 99% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnSubstring.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnSubstring.kt index 1872b9ef5..b9ca5c041 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnSubstring.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnSubstring.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.errors.TypeCheckException import org.partiql.spi.function.Function diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTimes.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTimes.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTimes.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTimes.kt index 9e3b00f64..a2490e0eb 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTimes.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTimes.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.value.Datum diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrim.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrim.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrim.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrim.kt index 6da1ea25f..cdf0fc367 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrim.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrim.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimChars.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimChars.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimChars.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimChars.kt index 1a57fc043..48620b725 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimChars.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimChars.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimLeading.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimLeading.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimLeading.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimLeading.kt index c1452755a..9dcad5894 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimLeading.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimLeading.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimLeadingChars.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimLeadingChars.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimLeadingChars.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimLeadingChars.kt index 600e6003d..c9ae36ae2 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimLeadingChars.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimLeadingChars.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimTrailing.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimTrailing.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimTrailing.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimTrailing.kt index 2431ea54e..b5c5fc306 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimTrailing.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimTrailing.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimTrailingChars.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimTrailingChars.kt similarity index 96% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimTrailingChars.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimTrailingChars.kt index d6895e14e..d74a659e9 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnTrimTrailingChars.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnTrimTrailingChars.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnUpper.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnUpper.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnUpper.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnUpper.kt index f5a118a13..0fa40694b 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnUpper.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnUpper.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.function.Parameter diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnUtcnow.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnUtcnow.kt similarity index 91% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnUtcnow.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/FnUtcnow.kt index 988724510..7632c8753 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnUtcnow.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/FnUtcnow.kt @@ -1,7 +1,7 @@ // ktlint-disable filename @file:Suppress("ClassName") -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.spi.function.Function import org.partiql.spi.value.Datum diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/TypePrecedence.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/TypePrecedence.kt similarity index 95% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/TypePrecedence.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/TypePrecedence.kt index 3cfc527e6..193ff04a4 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/TypePrecedence.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/TypePrecedence.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins +package org.partiql.system.builtins import org.partiql.types.PType diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/Accumulator.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/Accumulator.kt similarity index 98% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/Accumulator.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/Accumulator.kt index 6e8ae0082..e22f21dbd 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/Accumulator.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/Accumulator.kt @@ -12,14 +12,14 @@ * language governing permissions and limitations under the License. */ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import com.amazon.ion.Decimal import org.partiql.errors.TypeCheckException import org.partiql.spi.function.Aggregation import org.partiql.spi.value.Datum +import org.partiql.system.internal.coerceNumbers import org.partiql.types.PType -import org.partiql.value.util.coerceNumbers import java.math.BigDecimal import java.math.BigInteger import java.math.MathContext diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorAnySome.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorAnySome.kt similarity index 89% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorAnySome.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorAnySome.kt index 8e6c8ca29..2768062fb 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorAnySome.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorAnySome.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import org.partiql.spi.value.Datum import org.partiql.types.PType diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorAvg.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorAvg.kt similarity index 91% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorAvg.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorAvg.kt index 1b5b6a462..b170d72f2 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorAvg.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorAvg.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import org.partiql.spi.value.Datum import org.partiql.types.PType diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorCount.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorCount.kt similarity index 82% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorCount.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorCount.kt index fd18cbcc6..d19bc28f7 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorCount.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorCount.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import org.partiql.spi.value.Datum diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorCountStar.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorCountStar.kt similarity index 85% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorCountStar.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorCountStar.kt index d45a9240f..a98795cf1 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorCountStar.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorCountStar.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import org.partiql.spi.function.Aggregation import org.partiql.spi.value.Datum diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorDistinct.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorDistinct.kt similarity index 89% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorDistinct.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorDistinct.kt index 330b4858b..a314b01f2 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorDistinct.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorDistinct.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import org.partiql.spi.value.Datum import java.util.TreeSet diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorEvery.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorEvery.kt similarity index 88% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorEvery.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorEvery.kt index d7cb1d35a..88ca5454b 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorEvery.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorEvery.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import org.partiql.spi.value.Datum import org.partiql.types.PType diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorGroupAs.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorGroupAs.kt similarity index 83% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorGroupAs.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorGroupAs.kt index 32da479b3..fb7791ee8 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorGroupAs.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorGroupAs.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import org.partiql.spi.value.Datum diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorMax.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorMax.kt similarity index 86% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorMax.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorMax.kt index c1a147041..73ca296ec 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorMax.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorMax.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import org.partiql.spi.value.Datum diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorMin.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorMin.kt similarity index 86% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorMin.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorMin.kt index dbaf42801..580e75834 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorMin.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorMin.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import org.partiql.spi.value.Datum diff --git a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorSum.kt b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorSum.kt similarity index 91% rename from partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorSum.kt rename to partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorSum.kt index c293a66d3..7f555e76c 100644 --- a/partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorSum.kt +++ b/partiql-system/src/main/kotlin/org/partiql/system/builtins/internal/AccumulatorSum.kt @@ -1,4 +1,4 @@ -package org.partiql.spi.function.builtins.internal +package org.partiql.system.builtins.internal import org.partiql.spi.value.Datum import org.partiql.types.PType diff --git a/partiql-system/src/main/kotlin/org/partiql/system/internal/NumberExtensions.kt b/partiql-system/src/main/kotlin/org/partiql/system/internal/NumberExtensions.kt new file mode 100644 index 000000000..811fa680d --- /dev/null +++ b/partiql-system/src/main/kotlin/org/partiql/system/internal/NumberExtensions.kt @@ -0,0 +1,202 @@ +package org.partiql.system.internal + +/* + * Copyright 2019 Amazon.com, Inc. or its affiliates. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at: + * + * http://aws.amazon.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + */ + +import com.amazon.ion.Decimal +import java.math.BigDecimal +import java.math.BigInteger +import java.math.MathContext +import java.math.RoundingMode + +/** + * Essentially the same as partiql-lang's NumberExtensions.kt. Key differences are the following: + * - Adding [Int] and [Float] branch when casing on the [Number] + * - TODO support for integer types smaller than [Int] + */ + +// TODO should this be configurable? +private val MATH_CONTEXT = MathContext(38, RoundingMode.HALF_EVEN) + +/** + * Factory function to create a [BigDecimal] using correct precision, use it in favor of native BigDecimal constructors + * and factory methods + */ +internal fun bigDecimalOf(num: Number, mc: MathContext = MATH_CONTEXT): BigDecimal = when (num) { + is Decimal -> num + is Int -> BigDecimal(num, mc) + is Long -> BigDecimal(num, mc) + is Float -> BigDecimal(num.toDouble(), mc) + is Double -> BigDecimal(num, mc) + is BigInteger -> BigDecimal(num, mc) + is BigDecimal -> num + is BigInteger -> num.toBigDecimal() + else -> throw IllegalArgumentException("Unsupported number type: $num, ${num.javaClass}") +} + +/** + * This should handle Byte, Short, Int, Long, BigInteger, Float, Double, BigDecimal + */ +private val CONVERSION_MAP = mapOf>, Class>( + // BYTE + setOf(Byte::class.javaObjectType, Byte::class.javaObjectType) to Byte::class.javaObjectType, + setOf(Byte::class.javaObjectType, Short::class.javaObjectType) to Short::class.javaObjectType, + setOf(Byte::class.javaObjectType, Int::class.javaObjectType) to Int::class.javaObjectType, + setOf(Byte::class.javaObjectType, Long::class.javaObjectType) to Long::class.javaObjectType, + setOf(Byte::class.javaObjectType, BigInteger::class.javaObjectType) to BigInteger::class.javaObjectType, + setOf(Byte::class.javaObjectType, Float::class.javaObjectType) to Float::class.javaObjectType, + setOf(Byte::class.javaObjectType, Double::class.javaObjectType) to Double::class.javaObjectType, + setOf(Byte::class.javaObjectType, BigDecimal::class.javaObjectType) to BigDecimal::class.javaObjectType, + // SHORT + setOf(Short::class.javaObjectType, Byte::class.javaObjectType) to Short::class.javaObjectType, + setOf(Short::class.javaObjectType, Short::class.javaObjectType) to Short::class.javaObjectType, + setOf(Short::class.javaObjectType, Int::class.javaObjectType) to Int::class.javaObjectType, + setOf(Short::class.javaObjectType, Long::class.javaObjectType) to Long::class.javaObjectType, + setOf(Short::class.javaObjectType, BigInteger::class.javaObjectType) to BigInteger::class.javaObjectType, + setOf(Short::class.javaObjectType, Float::class.javaObjectType) to Float::class.javaObjectType, + setOf(Short::class.javaObjectType, Double::class.javaObjectType) to Double::class.javaObjectType, + setOf(Short::class.javaObjectType, BigDecimal::class.javaObjectType) to BigDecimal::class.javaObjectType, + // INT + setOf(Int::class.javaObjectType, Byte::class.javaObjectType) to Int::class.javaObjectType, + setOf(Int::class.javaObjectType, Short::class.javaObjectType) to Int::class.javaObjectType, + setOf(Int::class.javaObjectType, Int::class.javaObjectType) to Int::class.javaObjectType, + setOf(Int::class.javaObjectType, Long::class.javaObjectType) to Long::class.javaObjectType, + setOf(Int::class.javaObjectType, BigInteger::class.javaObjectType) to BigInteger::class.javaObjectType, + setOf(Int::class.javaObjectType, Float::class.javaObjectType) to Double::class.javaObjectType, + setOf(Int::class.javaObjectType, Double::class.javaObjectType) to Double::class.javaObjectType, + setOf(Int::class.javaObjectType, BigDecimal::class.javaObjectType) to BigDecimal::class.javaObjectType, + // LONG + setOf(Long::class.javaObjectType, Byte::class.javaObjectType) to Long::class.javaObjectType, + setOf(Long::class.javaObjectType, Short::class.javaObjectType) to Long::class.javaObjectType, + setOf(Long::class.javaObjectType, Int::class.javaObjectType) to Long::class.javaObjectType, + setOf(Long::class.javaObjectType, Long::class.javaObjectType) to Long::class.javaObjectType, + setOf(Long::class.javaObjectType, BigInteger::class.javaObjectType) to BigInteger::class.javaObjectType, + setOf(Long::class.javaObjectType, Float::class.javaObjectType) to Double::class.javaObjectType, + setOf(Long::class.javaObjectType, Double::class.javaObjectType) to Double::class.javaObjectType, + setOf(Long::class.javaObjectType, BigDecimal::class.javaObjectType) to BigDecimal::class.javaObjectType, + // FLOAT + setOf(Float::class.javaObjectType, Byte::class.javaObjectType) to Float::class.javaObjectType, + setOf(Float::class.javaObjectType, Short::class.javaObjectType) to Float::class.javaObjectType, + setOf(Float::class.javaObjectType, Int::class.javaObjectType) to Float::class.javaObjectType, + setOf(Float::class.javaObjectType, Long::class.javaObjectType) to Double::class.javaObjectType, + setOf(Float::class.javaObjectType, BigInteger::class.javaObjectType) to Double::class.javaObjectType, + setOf(Float::class.javaObjectType, Float::class.javaObjectType) to Float::class.javaObjectType, + setOf(Float::class.javaObjectType, Double::class.javaObjectType) to Double::class.javaObjectType, + setOf(Float::class.javaObjectType, BigDecimal::class.javaObjectType) to BigDecimal::class.javaObjectType, + // DOUBLE + setOf(Double::class.javaObjectType, Byte::class.javaObjectType) to Double::class.javaObjectType, + setOf(Double::class.javaObjectType, Short::class.javaObjectType) to Double::class.javaObjectType, + setOf(Double::class.javaObjectType, Int::class.javaObjectType) to Double::class.javaObjectType, + setOf(Double::class.javaObjectType, Long::class.javaObjectType) to Double::class.javaObjectType, + setOf(Double::class.javaObjectType, BigInteger::class.javaObjectType) to Double::class.javaObjectType, + setOf(Double::class.javaObjectType, Float::class.javaObjectType) to Double::class.javaObjectType, + setOf(Double::class.javaObjectType, Double::class.javaObjectType) to Double::class.javaObjectType, + setOf(Double::class.javaObjectType, BigDecimal::class.javaObjectType) to BigDecimal::class.javaObjectType, + // BIG INTEGER + setOf(BigInteger::class.javaObjectType, Byte::class.javaObjectType) to BigInteger::class.javaObjectType, + setOf(BigInteger::class.javaObjectType, Short::class.javaObjectType) to BigInteger::class.javaObjectType, + setOf(BigInteger::class.javaObjectType, Int::class.javaObjectType) to BigInteger::class.javaObjectType, + setOf(BigInteger::class.javaObjectType, Long::class.javaObjectType) to BigInteger::class.javaObjectType, + setOf(BigInteger::class.javaObjectType, BigInteger::class.javaObjectType) to BigInteger::class.javaObjectType, + setOf(BigInteger::class.javaObjectType, Float::class.javaObjectType) to Double::class.javaObjectType, + setOf(BigInteger::class.javaObjectType, Double::class.javaObjectType) to Double::class.javaObjectType, + setOf(BigInteger::class.javaObjectType, BigDecimal::class.javaObjectType) to BigDecimal::class.javaObjectType, + // BIG DECIMAL + setOf(BigDecimal::class.javaObjectType, Byte::class.javaObjectType) to BigDecimal::class.javaObjectType, + setOf(BigDecimal::class.javaObjectType, Short::class.javaObjectType) to BigDecimal::class.javaObjectType, + setOf(BigDecimal::class.javaObjectType, Int::class.javaObjectType) to BigDecimal::class.javaObjectType, + setOf(BigDecimal::class.javaObjectType, Long::class.javaObjectType) to BigDecimal::class.javaObjectType, + setOf(BigDecimal::class.javaObjectType, BigInteger::class.javaObjectType) to BigDecimal::class.javaObjectType, + setOf(BigDecimal::class.javaObjectType, Float::class.javaObjectType) to BigDecimal::class.javaObjectType, + setOf(BigDecimal::class.javaObjectType, Double::class.javaObjectType) to BigDecimal::class.javaObjectType, + setOf(BigDecimal::class.javaObjectType, BigDecimal::class.javaObjectType) to BigDecimal::class.javaObjectType, +) + +private val CONVERTERS = mapOf, (Number) -> Number>( + Byte::class.javaObjectType to Number::toByte, + Short::class.javaObjectType to Number::toShort, + Int::class.javaObjectType to Number::toInt, + Long::class.javaObjectType to Number::toLong, + Float::class.javaObjectType to Number::toFloat, + Double::class.javaObjectType to Number::toDouble, + BigInteger::class.javaObjectType to { num -> + when (num) { + is Byte -> num.toInt().toBigInteger() + is Short -> num.toInt().toBigInteger() + is Int -> num.toBigInteger() + is Long -> num.toBigInteger() + is BigInteger -> num + else -> throw IllegalArgumentException( + "Unsupported number for BigInteger conversion: $num" + ) + } + }, + BigDecimal::class.java to { num -> + when (num) { + is Byte -> bigDecimalOf(num) + is Short -> bigDecimalOf(num) + is Int -> bigDecimalOf(num) + is Long -> bigDecimalOf(num) + is Float -> bigDecimalOf(num) + is Double -> bigDecimalOf(num) + is BigDecimal -> bigDecimalOf(num) + is BigInteger -> bigDecimalOf(num) + else -> throw IllegalArgumentException( + "Unsupported number for decimal conversion: $num (${num.javaClass.simpleName})" + ) + } + } +) + +@Suppress("UNCHECKED_CAST") +/** Provides a narrowing or widening operator on supported numbers. */ +internal fun Number.coerce(type: Class): T where T : Number { + val conv = CONVERTERS[type] ?: throw IllegalArgumentException("No converter for $type") + return conv(this) as T +} + +/** + * Implements a very simple number tower to convert two numbers to their arithmetic + * compatible type. + * + * This is only supported on limited types needed by the expression system. + * TODO: Make no longer public. + */ +public fun coerceNumbers(first: Number, second: Number): Pair { + fun typeFor(n: Number): Class<*> = if (n is Decimal) { + BigDecimal::class.javaObjectType + } else { + n.javaClass + } + + val type = CONVERSION_MAP[setOf(typeFor(first), typeFor(second))] + ?: throw IllegalArgumentException("No coercion support for ${typeFor(first)} to ${typeFor(second)}") + + return Pair(first.coerce(type), second.coerce(type)) +} + +internal operator fun Number.compareTo(other: Number): Int { + val (first, second) = coerceNumbers(this, other) + return when (first) { + is Byte -> first.compareTo(second as Byte) + is Short -> first.compareTo(second as Short) + is Int -> first.compareTo(second as Int) + is Long -> first.compareTo(second as Long) + is Float -> first.compareTo(second as Float) + is Double -> first.compareTo(second as Double) + is BigDecimal -> first.compareTo(second as BigDecimal) + is BigInteger -> first.compareTo(second as BigInteger) + else -> throw IllegalStateException() + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 82f037527..88c7f09c7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,3 +1,6 @@ +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" +} /* * Copyright Amazon.com, Inc. or its affiliates. All rights reserved. * @@ -25,6 +28,7 @@ include( "partiql-plan", "partiql-planner", "partiql-spi", + "partiql-system", "partiql-types", "lib:sprout", "test:coverage-tests", diff --git a/test/partiql-randomized-tests/build.gradle b/test/partiql-randomized-tests/build.gradle index dba6bb42c..4434bd78f 100644 --- a/test/partiql-randomized-tests/build.gradle +++ b/test/partiql-randomized-tests/build.gradle @@ -23,6 +23,7 @@ dependencies { testImplementation project(':partiql-parser') testImplementation project(':partiql-plan') testImplementation project(':partiql-planner') + testImplementation project(':partiql-system') testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5' testImplementation 'pl.pragmatists:JUnitParams:[1.0.0,1.1.0)' diff --git a/test/partiql-randomized-tests/src/test/kotlin/org/partiql/lang/randomized/eval/Utils.kt b/test/partiql-randomized-tests/src/test/kotlin/org/partiql/lang/randomized/eval/Utils.kt index 432b7531a..604825bbf 100644 --- a/test/partiql-randomized-tests/src/test/kotlin/org/partiql/lang/randomized/eval/Utils.kt +++ b/test/partiql-randomized-tests/src/test/kotlin/org/partiql/lang/randomized/eval/Utils.kt @@ -4,8 +4,8 @@ import org.partiql.eval.compiler.PartiQLCompiler import org.partiql.parser.PartiQLParser import org.partiql.planner.PartiQLPlanner import org.partiql.spi.catalog.Catalog -import org.partiql.spi.catalog.Session import org.partiql.spi.value.Datum +import org.partiql.system.PartiQLSessionBuilder import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental import kotlin.test.assertEquals @@ -27,7 +27,7 @@ private fun execute(query: String): PartiQLValue { val catalog = object : Catalog { override fun getName(): String = "default" } - val session = Session.builder().catalog("default").catalogs(catalog).build() + val session = PartiQLSessionBuilder().catalog("default").catalogs(catalog).build() val engine = PartiQLCompiler.builder().build() // Execute diff --git a/test/partiql-tests-runner/build.gradle.kts b/test/partiql-tests-runner/build.gradle.kts index 0755f4ccc..5ffb99c09 100644 --- a/test/partiql-tests-runner/build.gradle.kts +++ b/test/partiql-tests-runner/build.gradle.kts @@ -29,6 +29,7 @@ dependencies { testImplementation(project(":partiql-eval")) testImplementation(project(":partiql-parser", configuration = "shadow")) testImplementation(project(":partiql-planner")) + testImplementation(project(":partiql-system")) } val tests = System.getenv()["PARTIQL_TESTS_DATA"] ?: "../partiql-tests/partiql-tests-data" diff --git a/test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/executor/EvalExecutor.kt b/test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/executor/EvalExecutor.kt index f17b322a6..603c5093f 100644 --- a/test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/executor/EvalExecutor.kt +++ b/test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/executor/EvalExecutor.kt @@ -26,6 +26,7 @@ import org.partiql.spi.errors.PErrorException import org.partiql.spi.errors.PErrorListener import org.partiql.spi.errors.Severity import org.partiql.spi.value.Datum +import org.partiql.system.PartiQLSessionBuilder import org.partiql.types.PType import org.partiql.value.PartiQLValue import org.partiql.value.PartiQLValueExperimental @@ -152,7 +153,7 @@ class EvalExecutor( override fun create(env: IonStruct, options: CompileType): TestExecutor { // infer catalog from conformance test `env` val catalog = infer(env.toIonElement() as StructElement) - val session = Session.builder() + val session = PartiQLSessionBuilder() .catalog("default") .catalogs(catalog) .build() @@ -185,7 +186,7 @@ class EvalExecutor( */ private fun inferEnv(env: AnyElement): PType { val catalog = Catalog.builder().name("default").build() - val session = Session.builder() + val session = PartiQLSessionBuilder() .catalog("default") .catalogs(catalog) .build()