From 0830de53aa98704c38a65b1f9e1e40212c9cbb8a Mon Sep 17 00:00:00 2001 From: "R. C. Howell" Date: Mon, 15 Jul 2024 09:56:55 -0700 Subject: [PATCH] Fix plugins --- .../org/partiql/plugins/local/LocalCatalog.kt | 30 ++----------------- .../org/partiql/plugins/local/LocalTable.kt | 7 ++--- .../partiql/plugins/memory/MemoryConnector.kt | 16 +--------- .../org/partiql/plugins/memory/MemoryTable.kt | 3 +- 4 files changed, 8 insertions(+), 48 deletions(-) diff --git a/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalCatalog.kt b/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalCatalog.kt index b4e996f11..ff412fb55 100644 --- a/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalCatalog.kt +++ b/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalCatalog.kt @@ -4,10 +4,7 @@ import org.partiql.planner.catalog.Catalog import org.partiql.planner.catalog.Name import org.partiql.planner.catalog.Namespace import org.partiql.planner.catalog.Routine -<<<<<<< HEAD import org.partiql.planner.catalog.Session -======= ->>>>>>> v1-metadata-catalog import org.partiql.planner.catalog.Table import java.nio.file.Path import kotlin.io.path.isDirectory @@ -33,43 +30,24 @@ internal class LocalCatalog( return name } -<<<<<<< HEAD override fun getTable(session: Session, name: Name): Table? { - val path = toPath(name.getNamespace()).resolve(name.getText() + EXT) - if (path.notExists() || !path.isDirectory()) { - return null - } - return LocalTable(name.getText(), path) - } - - override fun listTables(session: Session, namespace: Namespace): Collection { -======= - override fun getTable(name: Name): Table? { val path = toPath(name.getNamespace()).resolve(name.getName() + EXT) if (path.notExists() || !path.isDirectory()) { return null } - return LocalTable(name.getName(), path) + return LocalTable(name, path) } - override fun listTables(namespace: Namespace): Collection { ->>>>>>> v1-metadata-catalog + override fun listTables(session: Session, namespace: Namespace): Collection { val path = toPath(namespace) if (path.notExists()) { // throw exception? return emptyList() } -<<<<<<< HEAD return super.listTables(session, namespace) } override fun listNamespaces(session: Session, namespace: Namespace): Collection { -======= - return super.listTables(namespace) - } - - override fun listNamespaces(namespace: Namespace): Collection { ->>>>>>> v1-metadata-catalog val path = toPath(namespace) if (path.notExists() || path.isDirectory()) { // throw exception? @@ -82,11 +60,7 @@ internal class LocalCatalog( .map { toNamespace(it.toPath()) } } -<<<<<<< HEAD override fun getRoutines(session: Session, name: Name): Collection = emptyList() -======= - override fun getRoutines(name: Name): Collection = emptyList() ->>>>>>> v1-metadata-catalog private fun toPath(namespace: Namespace): Path { var curr = root diff --git a/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalTable.kt b/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalTable.kt index fa589265c..06f5ad68c 100644 --- a/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalTable.kt +++ b/plugins/partiql-local/src/main/kotlin/org/partiql/plugins/local/LocalTable.kt @@ -18,6 +18,7 @@ import com.amazon.ion.system.IonReaderBuilder import com.amazon.ionelement.api.loadSingleElement import org.partiql.eval.bindings.Binding import org.partiql.eval.value.Datum +import org.partiql.planner.catalog.Name import org.partiql.planner.catalog.Table import org.partiql.types.PType import org.partiql.types.StaticType @@ -29,7 +30,7 @@ import kotlin.io.path.reader * Associate a resolved path with a [StaticType] */ internal class LocalTable( - private val name: String, + private val name: Name, private val path: Path, ) : Table, Binding { @@ -37,9 +38,7 @@ internal class LocalTable( assert(!path.isDirectory()) { "LocalTable path must be a file." } } - override fun getName(): String { - return name - } + override fun getName(): Name = name override fun getSchema(): PType { val reader = IonReaderBuilder.standard().build(path.reader()) diff --git a/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryConnector.kt b/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryConnector.kt index ab348dbbc..571026dad 100644 --- a/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryConnector.kt +++ b/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryConnector.kt @@ -20,10 +20,7 @@ import org.partiql.eval.bindings.Binding import org.partiql.eval.bindings.Bindings import org.partiql.planner.catalog.Catalog import org.partiql.planner.catalog.Name -<<<<<<< HEAD import org.partiql.planner.catalog.Session -======= ->>>>>>> v1-metadata-catalog import org.partiql.planner.catalog.Table import org.partiql.spi.connector.Connector @@ -84,25 +81,14 @@ public class MemoryConnector private constructor( override fun getName(): String = name -<<<<<<< HEAD override fun getTable(session: Session, name: Name): Table? { - if (name.hasNamespace()) { - error("MemoryCatalog does not support namespaces") - } - return tables[name.getText()] - } - - override fun listTables(session: Session): Collection { -======= - override fun getTable(name: Name): Table? { if (name.hasNamespace()) { error("MemoryCatalog does not support namespaces") } return tables[name.getName()] } - override fun listTables(): Collection { ->>>>>>> v1-metadata-catalog + override fun listTables(session: Session): Collection { return tables.keys.map { Name.of(it) } } } diff --git a/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryTable.kt b/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryTable.kt index 6872cc3c5..278a582e0 100644 --- a/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryTable.kt +++ b/plugins/partiql-memory/src/main/kotlin/org/partiql/plugins/memory/MemoryTable.kt @@ -2,6 +2,7 @@ package org.partiql.plugins.memory import org.partiql.eval.bindings.Binding import org.partiql.eval.value.Datum +import org.partiql.planner.catalog.Name import org.partiql.planner.catalog.Table import org.partiql.types.PType @@ -11,7 +12,7 @@ public class MemoryTable private constructor( private val datum: Datum, ) : Table, Binding { - override fun getName(): String = name + override fun getName(): Name = Name.of(name) override fun getSchema(): PType = type override fun getDatum(): Datum = datum