Skip to content

Commit

Permalink
Audits the SPI & types packages (#1703)
Browse files Browse the repository at this point in the history
* Moves SPI classes under org.partiql.spi
* Updates Javadocs
* Removes partiql-types and moves org.partiql.types sources into org.partiql.spi
* Removes the partiql-types version of Enum in favor of SPI's enum
* Removes all UNKNOWN variants within partiql-spi of org.partiql.spi.Enum
* Adds an UnsupportedCodeException to org.partiql.spi.Enum#name()
  • Loading branch information
johnedquinn authored Jan 10, 2025
1 parent 4bf549b commit cb0276c
Show file tree
Hide file tree
Showing 289 changed files with 808 additions and 1,133 deletions.
4 changes: 2 additions & 2 deletions CODE_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ codebase.

See an example below:
```text
⚬ partiql-types
└── src/main/kotlin/org/partiql/types
⚬ partiql-spi
└── src/main/kotlin/org/partiql/spi/types
├── impl
| ├── StructElement.kt (internal)
| ├── StructType.kt (internal)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ $ tree -d -L 2 -I build -I src`
├── partiql-parser PartiQL parser
├── partiql-plan PartiQL plan data structures and utilities
├── partiql-planner PartiQL planner
├── partiql-spi Service provider interface
├── partiql-types PartiQL types
├── partiql-spi Common interfaces: types, values, catalogs, functions, etc.
├── plugins PartiQL plugins used in testing
│   ├── partiql-local
│   └── partiql-memory
Expand Down
1 change: 0 additions & 1 deletion docs/wiki/tutorials/Pluggable Functions Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ To build your module, you can use build automation tools like Maven or Gradle. T
```Kotlin
dependencies {
implementation("org.partiql:partiql-spi:<latest_version>")
implementation("org.partiql:partiql-types:<latest_version>")
}
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=org.partiql
version=1.0.0-rc.4-SNAPSHOT
version=1.0.0-rc.4

ossrhUsername=EMPTY
ossrhPassword=EMPTY
Expand Down
1 change: 0 additions & 1 deletion partiql-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies {
implementation(project(":partiql-parser", configuration = "shadow"))
implementation(project(":partiql-plan"))
implementation(project(":partiql-planner"))
implementation(project(":partiql-types"))
implementation(project(":partiql-spi"))
implementation(testFixtures(project(":partiql-spi")))
implementation(Deps.csv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.partiql.spi.errors.PError
*/
enum class ErrorCodeString(val code: Int) {
ALL(-1),
UNKNOWN(PError.UNKNOWN),
INTERNAL_ERROR(PError.INTERNAL_ERROR),
UNRECOGNIZED_TOKEN(PError.UNRECOGNIZED_TOKEN),
UNEXPECTED_TOKEN(PError.UNEXPECTED_TOKEN),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.partiql.spi.errors.PError
import org.partiql.spi.errors.PErrorKind
import org.partiql.spi.errors.Severity
import org.partiql.spi.function.Function
import org.partiql.types.PType
import org.partiql.spi.types.PType
import java.io.PrintWriter
import java.io.Writer

Expand All @@ -29,21 +29,19 @@ object ErrorMessageFormatter {
ErrorCodeString.VAR_REF_AMBIGUOUS -> varRefAmbiguous(error)
ErrorCodeString.VAR_REF_NOT_FOUND -> varRefNotFound(error)
ErrorCodeString.ALL -> "INTERNAL ERROR: This should never have occurred."
ErrorCodeString.UNKNOWN, null -> "Unrecognized error code received: ${error.code()}"
null -> "Unrecognized error code received: ${error.code()}"
}
return buildString {
val type = when (error.severity.code()) {
Severity.ERROR -> "e"
Severity.WARNING -> "w"
Severity.UNKNOWN -> "UNKNOWN"
else -> "UNKNOWN"
}
val classification = when (error.kind.code()) {
PErrorKind.SYNTAX -> "syntax"
PErrorKind.SEMANTIC -> "semantic"
PErrorKind.COMPILATION -> "compile"
PErrorKind.EXECUTION -> "runtime"
PErrorKind.UNKNOWN -> "unknown"
else -> "unknown"
}
val loc = error.location
Expand Down
2 changes: 0 additions & 2 deletions partiql-eval/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ dependencies {
api(project(":partiql-plan"))
api(project(":partiql-planner"))
api(project(":partiql-spi"))
api(project(":partiql-types"))
compileOnly(Deps.lombok)
annotationProcessor(Deps.lombok)
// Test
testImplementation(project(":partiql-parser"))
testImplementation(testFixtures(project(":partiql-types"))) // TODO: Remove use of StaticType
testImplementation(testFixtures(project(":partiql-spi")))
testImplementation(Deps.junit4)
testImplementation(Deps.junit4Params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ import org.partiql.spi.Context
import org.partiql.spi.errors.PError
import org.partiql.spi.errors.PErrorKind
import org.partiql.spi.errors.PErrorListenerException
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

/**
* This class is responsible for producing an executable statement from logical operators.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.partiql.eval.internal.helpers

import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

internal object DatumUtils {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.partiql.eval.internal.helpers

import org.partiql.errors.TypeCheckException
import org.partiql.spi.errors.TypeCheckException
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType
import java.math.BigInteger

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import org.partiql.eval.Row
import org.partiql.eval.internal.helpers.DatumArrayComparator
import org.partiql.eval.internal.operator.Aggregate
import org.partiql.spi.function.Aggregation
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType
import java.util.TreeMap
import java.util.TreeSet

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import org.partiql.eval.Environment
import org.partiql.eval.ExprRelation
import org.partiql.eval.Row
import org.partiql.plan.Exclusion
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.spi.value.Field
import org.partiql.types.PType

/**
* Implementation of the EXCLUDE clause; there are good opportunities to tune/optimize this.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.partiql.eval.internal.operator.rel

import org.partiql.errors.TypeCheckException
import org.partiql.eval.Environment
import org.partiql.eval.ExprRelation
import org.partiql.eval.ExprValue
import org.partiql.eval.Row
import org.partiql.eval.internal.helpers.DatumUtils.lowerSafe
import org.partiql.spi.errors.TypeCheckException
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

internal class RelOpIterate(
private val expr: ExprValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import org.partiql.eval.ExprRelation
import org.partiql.eval.ExprValue
import org.partiql.eval.Row
import org.partiql.eval.internal.helpers.DatumUtils.lowerSafe
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

internal class RelOpIteratePermissive(
private val expr: ExprValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.partiql.eval.internal.operator.rel

import org.partiql.errors.TypeCheckException
import org.partiql.eval.Environment
import org.partiql.eval.ExprRelation
import org.partiql.eval.ExprValue
import org.partiql.eval.Row
import org.partiql.eval.internal.helpers.DatumUtils.lowerSafe
import org.partiql.eval.internal.helpers.RecordValueIterator
import org.partiql.types.PType
import org.partiql.spi.errors.TypeCheckException
import org.partiql.spi.types.PType

internal class RelOpScan(
private val expr: ExprValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.partiql.eval.ExprValue
import org.partiql.eval.Row
import org.partiql.eval.internal.helpers.DatumUtils.lowerSafe
import org.partiql.eval.internal.helpers.RecordValueIterator
import org.partiql.types.PType
import org.partiql.spi.types.PType

internal class RelOpScanPermissive(
private val expr: ExprValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.partiql.eval.internal.operator.rel

import org.partiql.errors.TypeCheckException
import org.partiql.eval.Environment
import org.partiql.eval.ExprRelation
import org.partiql.eval.ExprValue
import org.partiql.eval.Row
import org.partiql.eval.internal.helpers.DatumUtils.lowerSafe
import org.partiql.spi.errors.TypeCheckException
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.spi.value.Field
import org.partiql.types.PType

/**
* The unpivot operator produces a bag of records from a struct.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ package org.partiql.eval.internal.operator.rex
import com.amazon.ionelement.api.ElementType
import com.amazon.ionelement.api.IonElementException
import com.amazon.ionelement.api.createIonElementLoader
import org.partiql.errors.DataException
import org.partiql.errors.TypeCheckException
import org.partiql.spi.errors.DataException
import org.partiql.spi.errors.TypeCheckException
import org.partiql.spi.types.PType
import org.partiql.spi.types.PType.ARRAY
import org.partiql.spi.types.PType.BAG
import org.partiql.spi.types.PType.BIGINT
import org.partiql.spi.types.PType.BOOL
import org.partiql.spi.types.PType.CHAR
import org.partiql.spi.types.PType.CLOB
import org.partiql.spi.types.PType.DATE
import org.partiql.spi.types.PType.DECIMAL
import org.partiql.spi.types.PType.DOUBLE
import org.partiql.spi.types.PType.DYNAMIC
import org.partiql.spi.types.PType.INTEGER
import org.partiql.spi.types.PType.NUMERIC
import org.partiql.spi.types.PType.REAL
import org.partiql.spi.types.PType.SMALLINT
import org.partiql.spi.types.PType.STRING
import org.partiql.spi.types.PType.STRUCT
import org.partiql.spi.types.PType.TIME
import org.partiql.spi.types.PType.TIMESTAMP
import org.partiql.spi.types.PType.TIMESTAMPZ
import org.partiql.spi.types.PType.TIMEZ
import org.partiql.spi.types.PType.TINYINT
import org.partiql.spi.types.PType.VARCHAR
import org.partiql.spi.types.PType.VARIANT
import org.partiql.spi.value.Datum
import org.partiql.types.PType
import org.partiql.types.PType.ARRAY
import org.partiql.types.PType.BAG
import org.partiql.types.PType.BIGINT
import org.partiql.types.PType.BOOL
import org.partiql.types.PType.CHAR
import org.partiql.types.PType.CLOB
import org.partiql.types.PType.DATE
import org.partiql.types.PType.DECIMAL
import org.partiql.types.PType.DOUBLE
import org.partiql.types.PType.DYNAMIC
import org.partiql.types.PType.INTEGER
import org.partiql.types.PType.NUMERIC
import org.partiql.types.PType.REAL
import org.partiql.types.PType.SMALLINT
import org.partiql.types.PType.STRING
import org.partiql.types.PType.STRUCT
import org.partiql.types.PType.TIME
import org.partiql.types.PType.TIMESTAMP
import org.partiql.types.PType.TIMESTAMPZ
import org.partiql.types.PType.TIMEZ
import org.partiql.types.PType.TINYINT
import org.partiql.types.PType.VARCHAR
import org.partiql.types.PType.VARIANT
import java.math.BigDecimal
import java.math.BigInteger
import java.math.RoundingMode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package org.partiql.eval.internal.operator.rex

import org.partiql.errors.TypeCheckException
import org.partiql.eval.Environment
import org.partiql.eval.ExprValue
import org.partiql.eval.Row
import org.partiql.eval.internal.helpers.DatumUtils.lowerSafe
import org.partiql.eval.internal.operator.rex.ExprCallDynamic.Candidate
import org.partiql.eval.internal.operator.rex.ExprCallDynamic.CoercionFamily.DYNAMIC
import org.partiql.eval.internal.operator.rex.ExprCallDynamic.CoercionFamily.UNKNOWN
import org.partiql.spi.errors.TypeCheckException
import org.partiql.spi.function.Function
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

/**
* Implementation of Dynamic Dispatch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package org.partiql.eval.internal.operator.rex

import org.partiql.eval.Environment
import org.partiql.eval.ExprValue
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

internal class ExprCase(
private val branches: List<Pair<ExprValue, ExprValue>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package org.partiql.eval.internal.operator.rex

import org.partiql.eval.Environment
import org.partiql.eval.ExprValue
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

/**
* Represents a single branch of a <case> or <searched case> expression.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package org.partiql.eval.internal.operator.rex

import org.partiql.eval.Environment
import org.partiql.eval.ExprValue
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

/**
* Implementation of a CAST expression.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package org.partiql.eval.internal.operator.rex

import org.partiql.eval.Environment
import org.partiql.eval.ExprValue
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

internal class ExprMissing(
private val type: PType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.partiql.eval.internal.operator.rex

import org.partiql.errors.TypeCheckException
import org.partiql.eval.Environment
import org.partiql.eval.ExprValue
import org.partiql.eval.internal.helpers.ValueUtility.getInt32Coerced
import org.partiql.spi.errors.TypeCheckException
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

internal class ExprPathIndex(
@JvmField val root: ExprValue,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.partiql.eval.internal.operator.rex

import org.partiql.errors.TypeCheckException
import org.partiql.eval.Environment
import org.partiql.eval.ExprValue
import org.partiql.eval.internal.helpers.ValueUtility.check
import org.partiql.spi.errors.TypeCheckException
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

internal class ExprPathKey(
@JvmField val root: ExprValue,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.partiql.eval.internal.operator.rex

import org.partiql.errors.TypeCheckException
import org.partiql.eval.Environment
import org.partiql.eval.ExprValue
import org.partiql.eval.internal.helpers.ValueUtility.check
import org.partiql.spi.errors.TypeCheckException
import org.partiql.spi.types.PType
import org.partiql.spi.value.Datum
import org.partiql.types.PType

internal class ExprPathSymbol(
@JvmField val root: ExprValue,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.partiql.eval.internal.operator.rex

import org.partiql.errors.CardinalityViolation
import org.partiql.errors.DataException
import org.partiql.errors.TypeCheckException
import org.partiql.eval.Environment
import org.partiql.eval.ExprValue
import org.partiql.spi.errors.CardinalityViolation
import org.partiql.spi.errors.DataException
import org.partiql.spi.errors.TypeCheckException
import org.partiql.spi.value.Datum

internal class ExprPermissive(private var expr: ExprValue) :
Expand Down
Loading

0 comments on commit cb0276c

Please sign in to comment.