Skip to content

Commit

Permalink
Adds initial v1 rels to evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
rchowell committed Aug 20, 2024
1 parent e786d49 commit 01ce0a0
Show file tree
Hide file tree
Showing 52 changed files with 1,144 additions and 331 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ internal class Pipeline private constructor(
fun default(): Pipeline {
val parser = PartiQLParser.default()
val planner = PartiQLPlanner.standard()
val engine = PartiQLEngine.default()
val engine = PartiQLEngine.standard()
return Pipeline(parser, planner, engine)
}

fun strict(): Pipeline {
val parser = PartiQLParser.default()
val planner = PartiQLPlanner.builder().signal().build()
val engine = PartiQLEngine.default()
val engine = PartiQLEngine.standard()
return Pipeline(parser, planner, engine)
}
}
Expand Down
1 change: 0 additions & 1 deletion partiql-eval/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ dependencies {
testImplementation(Deps.junitVintage) // Enables JUnit4
}

// Disabled for partiql-eval project at initialization.
kotlin {
explicitApi = null
}
Expand Down
23 changes: 11 additions & 12 deletions partiql-eval/src/main/kotlin/org/partiql/eval/PartiQLEngine.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.partiql.eval

import org.partiql.plan.PartiQLPlan
import org.partiql.spi.connector.Connector
import org.partiql.eval.builder.PartiQLEngineBuilder
import org.partiql.plan.v1.PartiQLPlan
import org.partiql.planner.catalog.Session

/**
* PartiQL's Experimental Engine.
Expand All @@ -17,28 +18,26 @@ import org.partiql.spi.connector.Connector
* This engine also internalizes the mechanics of the engine itself. Internally, it creates a physical plan to operate on,
* and it executes directly on that plan. The limited number of APIs exposed in this library is intentional to allow for
* under-the-hood experimentation by the PartiQL Community.
*
*
* TODO rename PartiQLEngine to PartiQLCompiler as it produces the statement (statement holds its own execution logic).
*/
public interface PartiQLEngine {

public fun prepare(plan: PartiQLPlan, session: Session): PartiQLStatement<*>

// TODO: Pass session variable during statement execution once we finalize data structure for session.
public fun execute(statement: PartiQLStatement<*>): PartiQLResult
public fun prepare(plan: PartiQLPlan, mode: Mode, session: Session): PartiQLStatement

companion object {

@JvmStatic
public fun builder(): PartiQLEngineBuilder = PartiQLEngineBuilder()

@JvmStatic
fun default() = PartiQLEngineBuilder().build()
fun standard() = PartiQLEngineBuilder().build()
}

public class Session(
val catalogs: Map<String, Connector> = mapOf(),
val mode: Mode = Mode.PERMISSIVE
)

/**
* TODO move mode to the session ??
*/
public enum class Mode {
PERMISSIVE,
STRICT // AKA, Type Checking Mode in the PartiQL Specification
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.partiql.eval

import org.partiql.value.PartiQLValue
import org.partiql.value.PartiQLValueExperimental
import org.partiql.eval.value.Datum

public sealed interface PartiQLResult {

@OptIn(PartiQLValueExperimental::class)
public data class Value(public val value: PartiQLValue) : PartiQLResult
public data class Value(public val value: Datum) : PartiQLResult

public data class Error(public val cause: Throwable) : PartiQLResult
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package org.partiql.eval

import org.partiql.value.PartiQLValue
import org.partiql.value.PartiQLValueExperimental
import org.partiql.planner.catalog.Session

/**
* Represents a compiled PartiQL Plan ready for execution.
* Represents a compiled PartiQL statement ready for execution.
*/
sealed interface PartiQLStatement<T> {
public interface PartiQLStatement {

public fun execute(): T

@OptIn(PartiQLValueExperimental::class)
interface Query : PartiQLStatement<PartiQLValue>
public fun execute(session: Session): PartiQLResult
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.partiql.eval.builder

import org.partiql.eval.PartiQLEngine
import org.partiql.eval.internal.SqlCompiler

class PartiQLEngineBuilder {

/**
* Build the builder, return an implementation of a [PartiQLEngine]
*
* @return
*/
public fun build(): PartiQLEngine = SqlCompiler()
}
Loading

0 comments on commit 01ce0a0

Please sign in to comment.