Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merges 0.14 main into partiql-eval #1314

Merged
merged 31 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8a37a9a
Adds support for EXCLUDE in the SqlDialect
johnedquinn Dec 7, 2023
a07b6aa
fix typer/transfomrer
yliuuuu Dec 8, 2023
6ba5a12
Merge pull request #1288 from partiql/path-navi-with-function
yliuuuu Dec 8, 2023
124e87f
Fix Timestamp Type Parsing Issue. (#1284)
yliuuuu Dec 8, 2023
7c9cc9a
Merge pull request #1285 from partiql/exclude-dialect
johnedquinn Dec 8, 2023
1c3c79a
Refactors partiql-tests-runner for multiple engines (#1289)
rchowell Dec 8, 2023
ddd642d
Adds int32 and int64 variants of date_add (#1291)
rchowell Dec 8, 2023
f505d29
Adds support for DISTINCT in the Planner
johnedquinn Dec 8, 2023
55c7a2a
Merge pull request #1293 from partiql/add-distinct-to-planner
johnedquinn Dec 11, 2023
54990be
Fix PlanCompiler output type for DISTINCT + ORDER BY (#1298)
alancai98 Dec 12, 2023
ebfc93f
Fixes scan_indexed and adds PIVOT (#1297)
rchowell Dec 12, 2023
6ab6f27
Fixes parsing of PIVOT, replicates the bug in legacy conversion (#1304)
rchowell Dec 13, 2023
8076e6c
Inferencer removal (#1302)
yliuuuu Dec 14, 2023
e8622ee
Structures globals within plan to lie within catalogs
johnedquinn Dec 14, 2023
0d72dfb
Updates CHANGELOG
johnedquinn Dec 14, 2023
79ee005
Use Iterable for PartiQLValue collections rather than Sequence (#1305)
rchowell Dec 14, 2023
5c1240c
Replace plugins PartiQLPlanner with ConnectorMetadata (#1309)
rchowell Dec 15, 2023
b6137a3
Updates naming of value to symbol
johnedquinn Dec 15, 2023
f31fffe
Updates internal IRs to match public API
johnedquinn Dec 15, 2023
0a75bd3
Adds PartiQLFunction.Aggregation and updates Plugin interface (#1310)
rchowell Dec 15, 2023
99a514c
Merge remote-tracking branch 'origin/main' into remodel-globals
johnedquinn Dec 15, 2023
7b9a469
Merge remote-tracking branch 'origin/main' into remodel-globals
johnedquinn Dec 15, 2023
3d877f8
Re-adds the imports removed from merge
johnedquinn Dec 15, 2023
dafdac5
Refactor modeling of EXCLUDE in partiql-ast and partiql-plan (#1311)
alancai98 Dec 15, 2023
22d3c33
Updates CHANGELOG
johnedquinn Dec 15, 2023
c489057
Fix jmh benchmark after #1309 (#1312)
alancai98 Dec 15, 2023
c7c7972
Merge pull request #1308 from partiql/remodel-globals
johnedquinn Dec 15, 2023
7dcdaac
Simplifies logical model of the path expression (#1306)
johnedquinn Dec 15, 2023
67bb008
Prepare v0.14.0 release (#1276)
yliuuuu Dec 15, 2023
2176d21
Prepare v0.14.1-SNAPSHOT; remove duplicate dependencies (#1313)
alancai98 Dec 16, 2023
6e1d7fe
Merges 0.14 main into partiql-eval
rchowell Dec 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ Thank you to all who have contributed!

## [Unreleased]

### Added

### Changed

### Deprecated

### Fixed

### Removed

### Security

### Contributors
Thank you to all who have contributed!
- @<your-username>

## [0.14.0-alpha] - 2023-12-15

### Added
- Adds top-level IR node creation functions.
- Adds `componentN` functions (destructuring) to IR nodes via Kotlin data classes
Expand All @@ -43,29 +61,38 @@ Thank you to all who have contributed!
- **Breaking** The default integer literal type is now 32-bit; if the literal can not fit in a 32-bit integer, it overflows to 64-bit.
- **BREAKING** `PartiQLValueType` now distinguishes between Arbitrary Precision Decimal and Fixed Precision Decimal.
- **BREAKING** Function Signature Changes. Now Function signature has two subclasses, `Scalar` and `Aggregation`.
- **BREAKING** Plugin Changes. Only return one Connector.Factory, use Kotlin fields. JVM signature remains the same.
- **BREAKING** In the produced plan:
- The new plan is fully resolved and typed.
- Operators will be converted to function call.
- Changes the return type of `filter_distinct` to a list if input collection is list
- Changes the `PartiQLValue` collections to implement Iterable rather than Sequence, allowing for multiple consumption.
- **BREAKING** Moves PartiQLParserBuilder.standard().build() to be PartiQLParser.default().
- **BREAKING** Changed modeling of `EXCLUDE` in `partiql-ast`

### Deprecated

### Fixed
- Fixes the CLI hanging on invalid queries. See issue #1230.
- Fixes Timestamp Type parsing issue. Previously Timestamp Type would get parsed to a Time type.
- Fixes PIVOT parsing to assign the key and value as defined by spec section 14.
- Fixes the physical plan compiler to return list when `DISTINCT` used with `ORDER BY`

### Removed
- **Breaking** Removed IR factory in favor of static top-level functions. Change `Ast.foo()`
to `foo()`
- **Breaking** Removed `org.partiql.lang.planner.transforms.AstToPlan`. Use `org.partiql.planner.PartiQLPlanner`.
- **Breaking** Removed `org.partiql.lang.planner.transforms.PartiQLSchemaInferencer`. In order to achieve the same functionality, one would need to use the `org.partiql.planner.PartiQLPlanner`.
- To get the inferred type of the query result, one can do: `(plan.statement as Statement.Query).root.type`

### Security

### Contributors
Thank you to all who have contributed!
- @rchowell
- @johnedquinn
- @yliuuuu
- @alancai98

## [0.13.2-alpha] - 2023-09-29

Expand Down Expand Up @@ -920,6 +947,7 @@ breaking changes if migrating from v0.9.2. The breaking changes accidentally int
Initial alpha release of PartiQL.

[Unreleased]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.13.2-alpha...HEAD
[0.14.0-alpha]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.13.2-alpha...v0.14.0-alpha
[0.13.2-alpha]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.13.1-alpha...v0.13.2-alpha
[0.13.1-alpha]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.13.0-alpha...v0.13.1-alpha
[0.13.0-alpha]: https://github.com/partiql/partiql-lang-kotlin/compare/v0.12.0-alpha...v0.13.0-alpha
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This project is published to [Maven Central](https://search.maven.org/artifact/o

| Group ID | Artifact ID | Recommended Version |
|---------------|-----------------------|---------------------|
| `org.partiql` | `partiql-lang-kotlin` | `0.13.2` |
| `org.partiql` | `partiql-lang-kotlin` | `0.14.0` |


For Maven builds, add the following to your `pom.xml`:
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=0.14.0-SNAPSHOT
version=0.14.1-SNAPSHOT

ossrhUsername=EMPTY
ossrhPassword=EMPTY
Expand Down
29 changes: 16 additions & 13 deletions partiql-ast/src/main/kotlin/org/partiql/ast/helpers/ToLegacyAst.kt
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,12 @@ private class AstTranslator(val metas: Map<String, MetaContainer>) : AstBaseVisi
projectExpr(expr, alias, metas)
}

// !!
// Legacy AST mislabels key and value in PIVOT, swapping the order here to recreate bug for compatibility.
// !!
override fun visitSelectPivot(node: Select.Pivot, ctx: Ctx) = translate(node) { metas ->
val value = visitExpr(node.value, ctx)
val key = visitExpr(node.key, ctx)
val key = visitExpr(node.value, ctx) // SWAP val -> key
val value = visitExpr(node.key, ctx) // SWAP key -> val
projectPivot(value, key, metas)
}

Expand Down Expand Up @@ -753,42 +756,42 @@ private class AstTranslator(val metas: Map<String, MetaContainer>) : AstBaseVisi
}

override fun visitExclude(node: Exclude, ctx: Ctx): PartiqlAst.ExcludeOp = translate(node) { metas ->
val excludeExprs = node.exprs.translate<PartiqlAst.ExcludeExpr>(ctx)
val excludeExprs = node.items.translate<PartiqlAst.ExcludeExpr>(ctx)
excludeOp(excludeExprs, metas)
}

override fun visitExcludeExcludeExpr(node: Exclude.ExcludeExpr, ctx: Ctx) = translate(node) { metas ->
val root = visitIdentifierSymbol(node.root, ctx)
override fun visitExcludeItem(node: Exclude.Item, ctx: Ctx) = translate(node) { metas ->
val root = visitExprVar(node.root, ctx)
val steps = node.steps.translate<PartiqlAst.ExcludeStep>(ctx)
excludeExpr(root = root, steps = steps, metas)
excludeExpr(root = identifier_(root.name, root.case), steps = steps, metas)
}

override fun visitExcludeStep(node: Exclude.Step, ctx: Ctx) =
super.visitExcludeStep(node, ctx) as PartiqlAst.ExcludeStep

override fun visitExcludeStepExcludeTupleAttr(node: Exclude.Step.ExcludeTupleAttr, ctx: Ctx) = translate(node) { metas ->
override fun visitExcludeStepStructField(node: Exclude.Step.StructField, ctx: Ctx) = translate(node) { metas ->
val attr = node.symbol.symbol
val case = node.symbol.caseSensitivity.toLegacyCaseSensitivity()
excludeTupleAttr(identifier(attr, case), metas)
}

override fun visitExcludeStepExcludeCollectionIndex(
node: Exclude.Step.ExcludeCollectionIndex,
override fun visitExcludeStepCollIndex(
node: Exclude.Step.CollIndex,
ctx: Ctx
) = translate(node) { metas ->
val index = node.index.toLong()
excludeCollectionIndex(index, metas)
}

override fun visitExcludeStepExcludeTupleWildcard(
node: Exclude.Step.ExcludeTupleWildcard,
override fun visitExcludeStepStructWildcard(
node: Exclude.Step.StructWildcard,
ctx: Ctx
) = translate(node) { metas ->
excludeTupleWildcard(metas)
}

override fun visitExcludeStepExcludeCollectionWildcard(
node: Exclude.Step.ExcludeCollectionWildcard,
override fun visitExcludeStepCollWildcard(
node: Exclude.Step.CollWildcard,
ctx: Ctx
) = translate(node) { metas ->
excludeCollectionWildcard(metas)
Expand Down
14 changes: 7 additions & 7 deletions partiql-ast/src/main/kotlin/org/partiql/ast/sql/SqlDialect.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,32 +86,32 @@ public abstract class SqlDialect : AstBaseVisitor<SqlBlock, SqlBlock>() {
override fun visitExclude(node: Exclude, head: SqlBlock): SqlBlock {
var h = head
h = h concat " EXCLUDE "
h = h concat list(start = null, end = null) { node.exprs }
h = h concat list(start = null, end = null) { node.items }
return h
}

override fun visitExcludeExcludeExpr(node: Exclude.ExcludeExpr, head: SqlBlock): SqlBlock {
override fun visitExcludeItem(node: Exclude.Item, head: SqlBlock): SqlBlock {
var h = head
h = h concat visitIdentifierSymbol(node.root, SqlBlock.Nil)
h = h concat visitExprVar(node.root, SqlBlock.Nil)
h = h concat list(delimiter = null, start = null, end = null) { node.steps }
return h
}

override fun visitExcludeStepExcludeCollectionIndex(node: Exclude.Step.ExcludeCollectionIndex, head: SqlBlock): SqlBlock {
override fun visitExcludeStepCollIndex(node: Exclude.Step.CollIndex, head: SqlBlock): SqlBlock {
return head concat r("[${node.index}]")
}

override fun visitExcludeStepExcludeTupleWildcard(node: Exclude.Step.ExcludeTupleWildcard, head: SqlBlock): SqlBlock {
override fun visitExcludeStepStructWildcard(node: Exclude.Step.StructWildcard, head: SqlBlock): SqlBlock {
return head concat r(".*")
}

override fun visitExcludeStepExcludeTupleAttr(node: Exclude.Step.ExcludeTupleAttr, head: SqlBlock): SqlBlock {
override fun visitExcludeStepStructField(node: Exclude.Step.StructField, head: SqlBlock): SqlBlock {
var h = head concat r(".")
h = h concat visitIdentifierSymbol(node.symbol, SqlBlock.Nil)
return h
}

override fun visitExcludeStepExcludeCollectionWildcard(node: Exclude.Step.ExcludeCollectionWildcard, head: SqlBlock): SqlBlock {
override fun visitExcludeStepCollWildcard(node: Exclude.Step.CollWildcard, head: SqlBlock): SqlBlock {
return head concat r("[*]")
}

Expand Down
14 changes: 7 additions & 7 deletions partiql-ast/src/main/resources/partiql_ast.ion
Original file line number Diff line number Diff line change
Expand Up @@ -563,17 +563,17 @@ select::[
]

exclude::{
exprs: list::[exclude_expr],
items: list::[item],
_: [
exclude_expr::{
root: '.identifier.symbol',
item::{
root: '.expr.var',
steps: list::[step],
},
step::[
exclude_tuple_attr::{ symbol: '.identifier.symbol' },
exclude_collection_index::{ index: int },
exclude_tuple_wildcard::{},
exclude_collection_wildcard::{},
struct_field::{ symbol: '.identifier.symbol' },
coll_index::{ index: int },
struct_wildcard::{},
coll_wildcard::{},
]
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,14 @@ class ToLegacyAstTest {
}
}
},
expect("(project_pivot (lit 1) (lit 2))") {
expect("(project_pivot (lit 2) (lit 1))") {
selectPivot {
value = exprLit(int32Value(1))
// PIVOT 1 AT 2
// - 1 is the VALUE
// - 2 is the KEY
// In the legacy implementation these were accidentally flipped
key = exprLit(int32Value(2))
value = exprLit(int32Value(1))
}
},
expect("(project_value (lit null))") {
Expand Down
66 changes: 32 additions & 34 deletions partiql-ast/src/test/kotlin/org/partiql/ast/sql/SqlDialectTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1073,11 +1073,9 @@ class SqlDialectTest {
type = From.Value.Type.SCAN
}
exclude = exclude {
exprs += excludeExcludeExpr {
root = id("t", Identifier.CaseSensitivity.INSENSITIVE)
steps += excludeStepExcludeTupleAttr {
symbol = id("a", Identifier.CaseSensitivity.INSENSITIVE)
}
items += excludeItem {
root = v("t")
steps += insensitiveExcludeStructField("a")
}
}
}
Expand All @@ -1090,21 +1088,21 @@ class SqlDialectTest {
type = From.Value.Type.SCAN
}
exclude = exclude {
exprs += excludeExcludeExpr {
root = id("a", Identifier.CaseSensitivity.INSENSITIVE)
steps += insensitiveExcludeTupleAttr("b")
items += excludeItem {
root = v("a")
steps += insensitiveExcludeStructField("b")
}
exprs += excludeExcludeExpr {
root = id("c", Identifier.CaseSensitivity.INSENSITIVE)
steps += insensitiveExcludeTupleAttr("d")
items += excludeItem {
root = v("c")
steps += insensitiveExcludeStructField("d")
}
exprs += excludeExcludeExpr {
root = id("e", Identifier.CaseSensitivity.INSENSITIVE)
steps += insensitiveExcludeTupleAttr("f")
items += excludeItem {
root = v("e")
steps += insensitiveExcludeStructField("f")
}
exprs += excludeExcludeExpr {
root = id("g", Identifier.CaseSensitivity.INSENSITIVE)
steps += insensitiveExcludeTupleAttr("h")
items += excludeItem {
root = v("g")
steps += insensitiveExcludeStructField("h")
}
}
}
Expand All @@ -1117,37 +1115,37 @@ class SqlDialectTest {
type = From.Value.Type.SCAN
}
exclude = exclude {
exprs += excludeExcludeExpr {
root = id("t", Identifier.CaseSensitivity.INSENSITIVE)
items += excludeItem {
root = v("t")
steps += mutableListOf(
insensitiveExcludeTupleAttr("a"),
sensitiveExcludeTupleAttr("b"),
excludeStepExcludeTupleWildcard(),
excludeStepExcludeCollectionWildcard(),
insensitiveExcludeTupleAttr("c"),
insensitiveExcludeStructField("a"),
sensitiveExcludeStructField("b"),
excludeStepStructWildcard(),
excludeStepCollWildcard(),
insensitiveExcludeStructField("c"),
)
}
exprs += excludeExcludeExpr {
root = id("s", Identifier.CaseSensitivity.SENSITIVE)
items += excludeItem {
root = exprVar(id("s", Identifier.CaseSensitivity.SENSITIVE), Expr.Var.Scope.DEFAULT)
steps += mutableListOf(
excludeStepExcludeCollectionIndex(0),
insensitiveExcludeTupleAttr("d"),
sensitiveExcludeTupleAttr("e"),
excludeStepExcludeCollectionWildcard(),
insensitiveExcludeTupleAttr("f"),
excludeStepExcludeTupleWildcard(),
excludeStepCollIndex(0),
insensitiveExcludeStructField("d"),
sensitiveExcludeStructField("e"),
excludeStepCollWildcard(),
insensitiveExcludeStructField("f"),
excludeStepStructWildcard(),
)
}
}
}
},
)

private fun AstBuilder.insensitiveExcludeTupleAttr(str: String) = excludeStepExcludeTupleAttr {
private fun AstBuilder.insensitiveExcludeStructField(str: String) = excludeStepStructField {
symbol = id(str, Identifier.CaseSensitivity.INSENSITIVE)
}

private fun AstBuilder.sensitiveExcludeTupleAttr(str: String) = excludeStepExcludeTupleAttr {
private fun AstBuilder.sensitiveExcludeStructField(str: String) = excludeStepStructField {
symbol = id(str, Identifier.CaseSensitivity.SENSITIVE)
}

Expand Down
25 changes: 10 additions & 15 deletions partiql-cli/src/main/kotlin/org/partiql/cli/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@ package org.partiql.cli

import AstPrinter
import com.amazon.ion.system.IonSystemBuilder
import com.amazon.ionelement.api.field
import com.amazon.ionelement.api.ionString
import com.amazon.ionelement.api.ionStructOf
import org.partiql.cli.pico.PartiQLCommand
import org.partiql.cli.shell.info
import org.partiql.lang.eval.EvaluationSession
import org.partiql.parser.PartiQLParserBuilder
import org.partiql.parser.PartiQLParser
import org.partiql.plan.debug.PlanPrinter
import org.partiql.planner.PartiQLPlanner
import org.partiql.planner.PartiQLPlannerBuilder
import org.partiql.plugins.local.LocalPlugin
import org.partiql.plugins.local.LocalConnector
import picocli.CommandLine
import java.io.PrintStream
import java.nio.file.Paths
import java.util.UUID
import kotlin.system.exitProcess

Expand All @@ -53,15 +50,14 @@ object Debug {

private const val USER_ID = "DEBUG_USER_ID"

private val plugins = listOf(LocalPlugin())
private val catalogs = mapOf(
"local" to ionStructOf(
field("connector_name", ionString("local")),
)
)
private val root = Paths.get(System.getProperty("user.home")).resolve(".partiql/local")

private val planner = PartiQLPlannerBuilder().plugins(plugins).build()
private val parser = PartiQLParserBuilder.standard().build()
private val planner = PartiQLPlanner.builder()
.catalogs(
"local" to LocalConnector.Metadata(root)
)
.build()
private val parser = PartiQLParser.default()

// !!
// IMPLEMENT DEBUG BEHAVIOR HERE
Expand All @@ -80,7 +76,6 @@ object Debug {
val sess = PartiQLPlanner.Session(
queryId = UUID.randomUUID().toString(),
userId = "debug",
catalogConfig = catalogs,
)
val result = planner.plan(statement, sess).plan
out.info("-- Plan ----------")
Expand Down
Loading