Skip to content

Commit

Permalink
Fix plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
RCHowell committed Jul 15, 2024
1 parent ab3413b commit 0830de5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Name> {
=======
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<Name> {
>>>>>>> v1-metadata-catalog
override fun listTables(session: Session, namespace: Namespace): Collection<Name> {
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<Namespace> {
=======
return super.listTables(namespace)
}

override fun listNamespaces(namespace: Namespace): Collection<Namespace> {
>>>>>>> v1-metadata-catalog
val path = toPath(namespace)
if (path.notExists() || path.isDirectory()) {
// throw exception?
Expand All @@ -82,11 +60,7 @@ internal class LocalCatalog(
.map { toNamespace(it.toPath()) }
}

<<<<<<< HEAD
override fun getRoutines(session: Session, name: Name): Collection<Routine> = emptyList()
=======
override fun getRoutines(name: Name): Collection<Routine> = emptyList()
>>>>>>> v1-metadata-catalog

private fun toPath(namespace: Namespace): Path {
var curr = root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,17 +30,15 @@ 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 {

init {
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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<Name> {
=======
override fun getTable(name: Name): Table? {
if (name.hasNamespace()) {
error("MemoryCatalog does not support namespaces")
}
return tables[name.getName()]
}

override fun listTables(): Collection<Name> {
>>>>>>> v1-metadata-catalog
override fun listTables(session: Session): Collection<Name> {
return tables.keys.map { Name.of(it) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 0830de5

Please sign in to comment.