├── .editorconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── feature-request.md ├── PULL_REQUEST_TEMPLATE.md ├── no-response.yml └── workflows │ ├── benchmark-main.yml │ ├── benchmark-manual.yml │ ├── build.yml │ ├── conformance-report.yml │ ├── docs-to-gh-wiki.yml │ └── gradle-wrapper-validation.yml ├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CODE_STYLE.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts └── src │ └── main │ ├── kotlin │ ├── org │ │ └── partiql │ │ │ └── gradle │ │ │ └── plugin │ │ │ └── publish │ │ │ └── PublishPlugin.kt │ ├── partiql.conventions.gradle.kts │ └── partiql.versions.kt │ └── resources │ └── META-INF │ └── gradle-plugins │ └── org.partiql.gradle.plugin.publish.properties ├── custom-ktlint-rules ├── build.gradle.kts └── src │ ├── main │ ├── kotlin │ │ └── org │ │ │ └── partiql │ │ │ └── ktlint │ │ │ ├── CustomRuleSetProvider.kt │ │ │ └── rule │ │ │ ├── TopLevelInternalRule.kt │ │ │ └── TopLevelPublicRule.kt │ └── resources │ │ └── META-INF │ │ └── services │ │ └── com.pinterest.ktlint.core.RuleSetProvider │ └── test │ └── kotlin │ └── org │ └── partiql │ └── ktlint │ └── rule │ ├── TopLevelInternalRuleTest.kt │ └── TopLevelPublicRuleTest.kt ├── detekt-config.yml ├── docs ├── upgrades │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── buildSrc │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ └── partiql.conventions.gradle.kts │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── v0.1-to-v0.2-upgrade │ │ ├── examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── test │ │ │ │ └── kotlin │ │ │ │ └── examples │ │ │ │ └── BreakingChanges.kt │ │ └── upgraded-examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── test │ │ │ └── kotlin │ │ │ └── examples │ │ │ └── BreakingChanges.kt │ ├── v0.14-to-v1-upgrade │ │ ├── examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── test │ │ │ │ └── kotlin │ │ │ │ └── examples │ │ │ │ ├── ASTChanges.kt │ │ │ │ ├── ErrorHandlingChanges.kt │ │ │ │ ├── EvaluationChanges.kt │ │ │ │ ├── FunctionChanges.kt │ │ │ │ ├── ParserChanges.kt │ │ │ │ └── TypeChanges.kt │ │ └── upgraded-examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── test │ │ │ └── kotlin │ │ │ └── examples │ │ │ ├── ASTChanges.kt │ │ │ ├── ErrorHandlingChanges.kt │ │ │ ├── EvaluationChanges.kt │ │ │ ├── FunctionChanges.kt │ │ │ ├── ParserChanges.kt │ │ │ └── TypeChanges.kt │ ├── v0.2-to-v0.3-upgrade │ │ ├── examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── test │ │ │ │ └── kotlin │ │ │ │ └── examples │ │ │ │ └── BreakingChanges.kt │ │ └── upgraded-examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── test │ │ │ └── kotlin │ │ │ └── examples │ │ │ └── BreakingChanges.kt │ ├── v0.3-to-v0.4-upgrade │ │ ├── examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── test │ │ │ │ └── kotlin │ │ │ │ └── examples │ │ │ │ └── BreakingChanges.kt │ │ └── upgraded-examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── test │ │ │ └── kotlin │ │ │ └── examples │ │ │ └── BreakingChanges.kt │ ├── v0.4-to-v0.5-upgrade │ │ ├── examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── test │ │ │ │ └── kotlin │ │ │ │ └── examples │ │ │ │ └── BreakingChanges.kt │ │ └── upgraded-examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── test │ │ │ └── kotlin │ │ │ └── examples │ │ │ └── BreakingChanges.kt │ ├── v0.5-to-v0.6-upgrade │ │ ├── examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── test │ │ │ │ └── kotlin │ │ │ │ └── examples │ │ │ │ └── BreakingChanges.kt │ │ └── upgraded-examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── test │ │ │ └── kotlin │ │ │ └── examples │ │ │ └── BreakingChanges.kt │ ├── v0.6-to-v0.7-upgrade │ │ ├── examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── test │ │ │ │ └── kotlin │ │ │ │ └── examples │ │ │ │ └── BreakingChanges.kt │ │ └── upgraded-examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── test │ │ │ └── kotlin │ │ │ └── examples │ │ │ └── BreakingChanges.kt │ ├── v0.7-to-v0.8-upgrade │ │ ├── examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── test │ │ │ │ └── kotlin │ │ │ │ └── examples │ │ │ │ └── BreakingChanges.kt │ │ └── upgraded-examples │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── test │ │ │ └── kotlin │ │ │ └── examples │ │ │ └── BreakingChanges.kt │ └── vA-to-vB-upgrade-template │ │ ├── examples │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── test │ │ │ └── kotlin │ │ │ └── examples │ │ │ └── BreakingChanges.kt │ │ └── upgraded-examples │ │ ├── build.gradle.kts │ │ └── src │ │ └── test │ │ └── kotlin │ │ └── examples │ │ └── BreakingChanges.kt └── wiki │ ├── _Sidebar.md │ ├── assets │ └── code │ │ ├── q1.env │ │ ├── q1.output │ │ ├── q1.sql │ │ ├── q10.env │ │ ├── q10.output │ │ ├── q10.sql │ │ ├── q11.env │ │ ├── q11.output │ │ ├── q11.sql │ │ ├── q12.env │ │ ├── q12.output │ │ ├── q12.sql │ │ ├── q13.env │ │ ├── q13.output │ │ ├── q13.sql │ │ ├── q14.env │ │ ├── q14.output │ │ ├── q14.sql │ │ ├── q15.env │ │ ├── q15.output │ │ ├── q15.sql │ │ ├── q16.env │ │ ├── q16.output │ │ ├── q16.sql │ │ ├── q17.env │ │ ├── q17.output │ │ ├── q17.sql │ │ ├── q18.env │ │ ├── q18.output │ │ ├── q18.sql │ │ ├── q2.env │ │ ├── q2.output │ │ ├── q2.sql │ │ ├── q3.env │ │ ├── q3.output │ │ ├── q3.sql │ │ ├── q4.env │ │ ├── q4.output │ │ ├── q4.sql │ │ ├── q5.env │ │ ├── q5.output │ │ ├── q5.sql │ │ ├── q6.env │ │ ├── q6.output │ │ ├── q6.sql │ │ ├── q7.env │ │ ├── q7.output │ │ ├── q7.sql │ │ ├── q8.env │ │ ├── q8.output │ │ ├── q8.sql │ │ ├── q9.env │ │ ├── q9.output │ │ ├── q9.sql │ │ └── tutorial-all-data.env │ ├── design │ └── CODE-STYLE.md │ ├── documentation │ ├── Aggregate Functions.md │ ├── Functions.md │ ├── Further Reading.md │ ├── Implementation & Specification Comparison.md │ ├── Numeric Data Type & Arithmetic Operations.md │ ├── PartiQL Code Coverage.md │ └── Window Functions.md │ ├── general │ └── Home.md │ ├── tutorials │ ├── Command Line Tutorial.md │ └── Tutorial.md │ ├── upgrades │ ├── cli-versions.md │ ├── upgrade-guide.md │ ├── v0.1-to-v0.2-upgrade.md │ ├── v0.2-to-v0.3-upgrade.md │ ├── v0.3-to-v0.4-upgrade.md │ ├── v0.4-to-v0.5-upgrade.md │ ├── v0.5-to-v0.6-upgrade.md │ ├── v0.6-to-v0.7-upgrade.md │ ├── v0.7-to-v0.8-upgrade.md │ ├── v0.8-to-v0.9-upgrade.md │ └── vA-to-vB-upgrade-template.md │ └── v1 │ ├── TODO.md │ └── compiler.md ├── examples ├── README.md ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── partiql │ │ │ └── examples │ │ │ ├── CSVJavaExample.java │ │ │ ├── EvaluationJavaExample.java │ │ │ ├── ParserJavaExample.java │ │ │ ├── PartiQLCompilerPipelineAsyncJavaExample.java │ │ │ └── S3JavaExample.java │ └── kotlin │ │ └── org │ │ └── partiql │ │ └── examples │ │ ├── CsvExprValueExample.kt │ │ ├── CustomFunctionsExample.kt │ │ ├── CustomProceduresExample.kt │ │ ├── EvaluationWithBindings.kt │ │ ├── EvaluationWithLazyBindings.kt │ │ ├── MergeKeyValues.kt │ │ ├── ParserErrorExample.kt │ │ ├── ParserExample.kt │ │ ├── PartiQLCompilerPipelineAsyncExample.kt │ │ ├── PartialEvaluationVisitorTransform.kt │ │ ├── PreventJoinVistor.kt │ │ ├── SimpleExpressionEvaluation.kt │ │ └── util │ │ ├── Example.kt │ │ └── Main.kt │ └── test │ ├── kotlin │ └── org │ │ └── partiql │ │ └── examples │ │ ├── BaseExampleTest.kt │ │ ├── CSVJavaExampleTest.kt │ │ ├── CsvExprValueExampleTest.kt │ │ ├── CustomFunctionsExampleTest.kt │ │ ├── CustomProceduresExampleTest.kt │ │ ├── Evaluation.kt │ │ ├── EvaluationJavaExampleTest.kt │ │ ├── EvaluationWithBindingsTest.kt │ │ ├── EvaluationWithLazyBindingsTest.kt │ │ ├── MergeKeyValuesTests.kt │ │ ├── ParseAndAstSerDe.kt │ │ ├── ParserErrorExampleTest.kt │ │ ├── ParserExampleTest.kt │ │ ├── ParserJavaExampleTest.kt │ │ ├── PartiQLCompilerPipelineAsyncExampleTest.kt │ │ ├── PartiQLCompilerPipelineAsyncJavaExampleTest.kt │ │ ├── PartialEvaluationVisitorTransformExampleTest.kt │ │ ├── PreventJoinVisitorExampleTest.kt │ │ └── SimpleExpressionEvaluationTest.kt │ └── resources │ └── junit-platform.properties ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib └── sprout │ ├── README.md │ ├── build.gradle.kts │ └── src │ ├── main │ └── kotlin │ │ └── org │ │ └── partiql │ │ └── sprout │ │ ├── Sprout.kt │ │ ├── generator │ │ ├── Generator.kt │ │ └── target │ │ │ └── kotlin │ │ │ ├── KotlinCommand.kt │ │ │ ├── KotlinGenerator.kt │ │ │ ├── KotlinOptions.kt │ │ │ ├── KotlinPoem.kt │ │ │ ├── KotlinResult.kt │ │ │ ├── KotlinSymbols.kt │ │ │ ├── poems │ │ │ ├── KotlinBuilderPoem.kt │ │ │ ├── KotlinFactoryPoem.kt │ │ │ ├── KotlinJacksonPoem.kt │ │ │ ├── KotlinListenerPoem.kt │ │ │ ├── KotlinUtilsPoem.kt │ │ │ └── KotlinVisitorPoem.kt │ │ │ ├── spec │ │ │ ├── KotlinFileSpec.kt │ │ │ ├── KotlinNodeSpec.kt │ │ │ ├── KotlinPackageSpec.kt │ │ │ └── KotlinUniverseSpec.kt │ │ │ └── types │ │ │ ├── Annotations.kt │ │ │ ├── JacksonTypes.kt │ │ │ └── Parameters.kt │ │ ├── model │ │ └── Model.kt │ │ └── parser │ │ ├── SproutParser.kt │ │ └── ion │ │ ├── IonExtensions.kt │ │ ├── IonImports.kt │ │ ├── IonSymbols.kt │ │ ├── IonTypeParser.kt │ │ ├── IonVisitor.kt │ │ └── note.txt │ └── test │ ├── kotlin │ └── org │ │ └── partiql │ │ └── sprout │ │ ├── generator │ │ └── target │ │ │ └── kotlin │ │ │ └── KotlinGeneratorTest.kt │ │ └── parser │ │ └── ion │ │ ├── IonExtensionsKtTest.kt │ │ ├── IonImportsTest.kt │ │ └── IonTypeParserTest.kt │ └── resources │ └── test.ion ├── partiql-ast ├── README.adoc ├── api │ └── partiql-ast.api ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── partiql │ │ │ └── ast │ │ │ ├── AstEnum.java │ │ │ ├── AstNode.java │ │ │ ├── AstVisitor.java │ │ │ ├── DataType.java │ │ │ ├── DatetimeField.java │ │ │ ├── Exclude.java │ │ │ ├── ExcludePath.java │ │ │ ├── ExcludeStep.java │ │ │ ├── Explain.java │ │ │ ├── From.java │ │ │ ├── FromExpr.java │ │ │ ├── FromJoin.java │ │ │ ├── FromTableRef.java │ │ │ ├── FromType.java │ │ │ ├── GroupBy.java │ │ │ ├── GroupByStrategy.java │ │ │ ├── Identifier.java │ │ │ ├── IntervalQualifier.java │ │ │ ├── JoinType.java │ │ │ ├── Let.java │ │ │ ├── Literal.java │ │ │ ├── Nulls.java │ │ │ ├── Order.java │ │ │ ├── OrderBy.java │ │ │ ├── Query.java │ │ │ ├── QueryBody.java │ │ │ ├── Select.java │ │ │ ├── SelectItem.java │ │ │ ├── SelectList.java │ │ │ ├── SelectPivot.java │ │ │ ├── SelectStar.java │ │ │ ├── SelectValue.java │ │ │ ├── SetOp.java │ │ │ ├── SetOpType.java │ │ │ ├── SetQuantifier.java │ │ │ ├── Sort.java │ │ │ ├── Statement.java │ │ │ ├── WindowClause.java │ │ │ ├── WindowFunctionNullTreatment.java │ │ │ ├── WindowFunctionType.java │ │ │ ├── WindowPartition.java │ │ │ ├── WindowSpecification.java │ │ │ ├── With.java │ │ │ ├── WithListElement.java │ │ │ ├── ddl │ │ │ ├── AttributeConstraint.java │ │ │ ├── ColumnDefinition.java │ │ │ ├── CreateTable.java │ │ │ ├── KeyValue.java │ │ │ ├── PartitionBy.java │ │ │ ├── TableConstraint.java │ │ │ └── package-info.java │ │ │ ├── dml │ │ │ ├── ConflictAction.java │ │ │ ├── ConflictTarget.java │ │ │ ├── Delete.java │ │ │ ├── DoReplaceAction.java │ │ │ ├── DoUpdateAction.java │ │ │ ├── Insert.java │ │ │ ├── InsertSource.java │ │ │ ├── OnConflict.java │ │ │ ├── Replace.java │ │ │ ├── SetClause.java │ │ │ ├── Update.java │ │ │ ├── UpdateTarget.java │ │ │ ├── UpdateTargetStep.java │ │ │ ├── Upsert.java │ │ │ └── package-info.java │ │ │ ├── expr │ │ │ ├── Expr.java │ │ │ ├── ExprAnd.java │ │ │ ├── ExprArray.java │ │ │ ├── ExprBag.java │ │ │ ├── ExprBetween.java │ │ │ ├── ExprBoolTest.java │ │ │ ├── ExprCall.java │ │ │ ├── ExprCase.java │ │ │ ├── ExprCast.java │ │ │ ├── ExprCoalesce.java │ │ │ ├── ExprExtract.java │ │ │ ├── ExprInCollection.java │ │ │ ├── ExprIsType.java │ │ │ ├── ExprLike.java │ │ │ ├── ExprLit.java │ │ │ ├── ExprMatch.java │ │ │ ├── ExprMissingPredicate.java │ │ │ ├── ExprNot.java │ │ │ ├── ExprNullIf.java │ │ │ ├── ExprNullPredicate.java │ │ │ ├── ExprOperator.java │ │ │ ├── ExprOr.java │ │ │ ├── ExprOverlaps.java │ │ │ ├── ExprOverlay.java │ │ │ ├── ExprParameter.java │ │ │ ├── ExprPath.java │ │ │ ├── ExprPosition.java │ │ │ ├── ExprQuerySet.java │ │ │ ├── ExprRowValue.java │ │ │ ├── ExprSessionAttribute.java │ │ │ ├── ExprStruct.java │ │ │ ├── ExprSubstring.java │ │ │ ├── ExprTrim.java │ │ │ ├── ExprValues.java │ │ │ ├── ExprVarRef.java │ │ │ ├── ExprVariant.java │ │ │ ├── ExprWindow.java │ │ │ ├── ExprWindowFunction.java │ │ │ ├── PathStep.java │ │ │ ├── SessionAttribute.java │ │ │ ├── TrimSpec.java │ │ │ ├── TruthValue.java │ │ │ ├── WindowFunction.java │ │ │ └── package-info.java │ │ │ ├── graph │ │ │ ├── GraphDirection.java │ │ │ ├── GraphLabel.java │ │ │ ├── GraphMatch.java │ │ │ ├── GraphPart.java │ │ │ ├── GraphPattern.java │ │ │ ├── GraphQuantifier.java │ │ │ ├── GraphRestrictor.java │ │ │ ├── GraphSelector.java │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ └── sql │ │ │ ├── Sql.kt │ │ │ ├── SqlBlock.kt │ │ │ ├── SqlDialect.kt │ │ │ ├── SqlLayout.kt │ │ │ └── package-info.java │ └── kotlin │ │ └── org │ │ └── partiql │ │ └── ast │ │ ├── Ast.kt │ │ └── AstRewriter.kt │ └── test │ └── kotlin │ └── org │ └── partiql │ └── ast │ └── sql │ └── SqlDialectTest.kt ├── partiql-cli ├── README.adoc ├── archive │ ├── README │ └── Tutorial │ │ └── code │ │ ├── q1.env │ │ ├── q1.output │ │ ├── q1.sql │ │ ├── q10.env │ │ ├── q10.output │ │ ├── q10.sql │ │ ├── q11.env │ │ ├── q11.output │ │ ├── q11.sql │ │ ├── q12.env │ │ ├── q12.output │ │ ├── q12.sql │ │ ├── q13.env │ │ ├── q13.output │ │ ├── q13.sql │ │ ├── q14.env │ │ ├── q14.output │ │ ├── q14.sql │ │ ├── q15.env │ │ ├── q15.output │ │ ├── q15.sql │ │ ├── q16.env │ │ ├── q16.output │ │ ├── q16.sql │ │ ├── q17.env │ │ ├── q17.output │ │ ├── q17.sql │ │ ├── q18.env │ │ ├── q18.output │ │ ├── q18.sql │ │ ├── q2.env │ │ ├── q2.output │ │ ├── q2.sql │ │ ├── q3.env │ │ ├── q3.output │ │ ├── q3.sql │ │ ├── q4.env │ │ ├── q4.output │ │ ├── q4.sql │ │ ├── q5.env │ │ ├── q5.output │ │ ├── q5.sql │ │ ├── q6.env │ │ ├── q6.output │ │ ├── q6.sql │ │ ├── q7.env │ │ ├── q7.output │ │ ├── q7.sql │ │ ├── q8.env │ │ ├── q8.out │ │ ├── q8.output │ │ ├── q8.sql │ │ ├── q9.env │ │ ├── q9.output │ │ ├── q9.sql │ │ └── tutorial-all-data.env ├── build.gradle.kts ├── examples │ ├── gpml-paper-example.ion │ ├── graph-bad-ion.ion │ ├── graph-bad-isl.ion │ ├── graph-empty.ion │ ├── graph-g1.ion │ ├── graph-g1L.ion │ ├── graph-g2.ion │ ├── graph-g3.ion │ └── rfc0025-example.ion ├── partiql.sh └── src │ ├── main │ └── kotlin │ │ └── org │ │ └── partiql │ │ └── cli │ │ ├── ErrorCodeString.kt │ │ ├── Main.kt │ │ ├── format │ │ ├── DotFormatter.kt │ │ ├── DotUrlFormatter.kt │ │ ├── ExplainFormatter.kt │ │ ├── NodeFormatter.kt │ │ ├── SexpFormatter.kt │ │ ├── TreeFormatter.kt │ │ ├── Utilities.kt │ │ └── dot │ │ │ └── Dot.kt │ │ ├── io │ │ ├── DatumWriterTextPretty.kt │ │ └── Format.kt │ │ ├── pipeline │ │ ├── AppPErrorListener.kt │ │ ├── ErrorMessageFormatter.kt │ │ └── Pipeline.kt │ │ └── shell │ │ ├── Shell.kt │ │ ├── ShellCompleter.kt │ │ ├── ShellHighlighter.kt │ │ └── ShellParser.kt │ └── test │ ├── kotlin │ └── org │ │ └── partiql │ │ └── cli │ │ └── io │ │ └── DatumWriterTextPrettyTests.kt │ └── resources │ ├── junit-platform.properties │ └── read_file_tests │ ├── csv_with_empty_lines.csv │ ├── customized.csv │ ├── customized_escape.csv │ ├── customized_ignore_empty.csv │ ├── customized_ignore_surrounding.csv │ ├── customized_line_breaker.csv │ ├── customized_quote.csv │ ├── data.csv │ ├── data.ion │ ├── data.tsv │ ├── data_list.ion │ ├── data_with_double_quotes_escape.csv │ ├── data_with_header_line.csv │ ├── data_with_header_line.tsv │ ├── data_with_ion_symbol_as_input.csv │ ├── simple_excel.csv │ ├── simple_mysql.csv │ ├── simple_postgresql.csv │ └── simple_postgresql.txt ├── partiql-coverage ├── README.md ├── api │ └── partiql-coverage.api ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── partiql │ │ │ └── coverage │ │ │ └── api │ │ │ └── PartiQLTest.java │ ├── kotlin │ │ └── org │ │ │ └── partiql │ │ │ └── coverage │ │ │ └── api │ │ │ ├── PartiQLTestCase.kt │ │ │ ├── PartiQLTestProvider.kt │ │ │ └── impl │ │ │ ├── ConfigurationParameter.kt │ │ │ ├── ConfigurationParameterExtractor.kt │ │ │ ├── ConfigurationParameterRetriever.kt │ │ │ ├── HtmlWriter.kt │ │ │ ├── LcovReportListener.kt │ │ │ ├── PartiQLTestExtension.kt │ │ │ ├── PartiQLTestInvocationContext.kt │ │ │ ├── PartiQLTestMethodContext.kt │ │ │ ├── PartiQLTestParameterResolver.kt │ │ │ ├── PostProcessor.kt │ │ │ ├── ReportKey.kt │ │ │ ├── ThresholdException.kt │ │ │ └── ThresholdExecutor.kt │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── org.junit.platform.launcher.LauncherSessionListener │ │ └── org.junit.platform.launcher.TestExecutionListener │ └── test │ ├── kotlin │ └── org │ │ └── partiql │ │ └── coverage │ │ └── api │ │ └── impl │ │ ├── PartiQLTestExtensionTest.kt │ │ └── ThresholdExecutorTest.kt │ └── resources │ └── lcov │ └── threshold.info ├── partiql-eval ├── api │ └── partiql-eval.api ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── partiql │ │ │ └── eval │ │ │ ├── Environment.java │ │ │ ├── Expr.java │ │ │ ├── ExprRelation.java │ │ │ ├── ExprValue.java │ │ │ ├── Mode.java │ │ │ ├── Row.java │ │ │ ├── Statement.java │ │ │ ├── WindowFunction.java │ │ │ ├── WindowPartition.java │ │ │ └── compiler │ │ │ ├── Match.java │ │ │ ├── PartiQLCompiler.java │ │ │ ├── Pattern.java │ │ │ └── Strategy.java │ └── kotlin │ │ └── org │ │ └── partiql │ │ └── eval │ │ └── internal │ │ ├── compiler │ │ └── StandardCompiler.kt │ │ ├── helpers │ │ ├── DatumArrayComparator.kt │ │ ├── DatumUtils.kt │ │ ├── IteratorChain.kt │ │ ├── IteratorPeeking.kt │ │ ├── IteratorSupplier.kt │ │ ├── PErrors.kt │ │ ├── RecordUtility.kt │ │ ├── RecordValueIterator.kt │ │ └── ValueUtility.kt │ │ ├── operator │ │ ├── Aggregate.kt │ │ ├── rel │ │ │ ├── Collation.kt │ │ │ ├── RelOpAggregate.kt │ │ │ ├── RelOpDistinct.kt │ │ │ ├── RelOpExceptAll.kt │ │ │ ├── RelOpExceptDistinct.kt │ │ │ ├── RelOpExclude.kt │ │ │ ├── RelOpFilter.kt │ │ │ ├── RelOpIntersectAll.kt │ │ │ ├── RelOpIntersectDistinct.kt │ │ │ ├── RelOpIterate.kt │ │ │ ├── RelOpIteratePermissive.kt │ │ │ ├── RelOpJoinInner.kt │ │ │ ├── RelOpJoinOuterFull.kt │ │ │ ├── RelOpJoinOuterLeft.kt │ │ │ ├── RelOpJoinOuterRight.kt │ │ │ ├── RelOpLimit.kt │ │ │ ├── RelOpOffset.kt │ │ │ ├── RelOpPeeking.kt │ │ │ ├── RelOpProject.kt │ │ │ ├── RelOpScan.kt │ │ │ ├── RelOpScanPermissive.kt │ │ │ ├── RelOpSort.kt │ │ │ ├── RelOpUnionAll.kt │ │ │ ├── RelOpUnionDistinct.kt │ │ │ ├── RelOpUnpivot.kt │ │ │ └── RelOpWindow.kt │ │ └── rex │ │ │ ├── CastTable.kt │ │ │ ├── ExprArray.kt │ │ │ ├── ExprBag.kt │ │ │ ├── ExprCall.kt │ │ │ ├── ExprCallDynamic.kt │ │ │ ├── ExprCase.kt │ │ │ ├── ExprCaseBranch.kt │ │ │ ├── ExprCaseSearched.kt │ │ │ ├── ExprCast.kt │ │ │ ├── ExprCoalesce.kt │ │ │ ├── ExprError.kt │ │ │ ├── ExprLit.kt │ │ │ ├── ExprMissing.kt │ │ │ ├── ExprNullIf.kt │ │ │ ├── ExprPathIndex.kt │ │ │ ├── ExprPathKey.kt │ │ │ ├── ExprPathSymbol.kt │ │ │ ├── ExprPermissive.kt │ │ │ ├── ExprPivot.kt │ │ │ ├── ExprPivotPermissive.kt │ │ │ ├── ExprSelect.kt │ │ │ ├── ExprSpread.kt │ │ │ ├── ExprStructField.kt │ │ │ ├── ExprStructPermissive.kt │ │ │ ├── ExprStructStrict.kt │ │ │ ├── ExprSubquery.kt │ │ │ ├── ExprSubqueryRow.kt │ │ │ ├── ExprTable.kt │ │ │ ├── ExprVar.kt │ │ │ └── IntervalUtils.kt │ │ └── window │ │ ├── DenseRankFunction.kt │ │ ├── LagFunction.kt │ │ ├── LeadFunction.kt │ │ ├── NavigationFunction.kt │ │ ├── RankFunction.kt │ │ ├── RowNumberFunction.kt │ │ └── WindowBuiltIns.kt │ └── test │ └── kotlin │ └── org │ └── partiql │ └── eval │ ├── CatalogTest.kt │ ├── PErrorCollector.kt │ ├── PTestCase.kt │ ├── compiler │ └── StrategyTest.kt │ └── internal │ ├── CteTests.kt │ ├── DataExceptionTest.kt │ ├── DatumMaterialize.kt │ ├── IntervalDivideTests.kt │ ├── IntervalMinusTests.kt │ ├── IntervalParseSignedTests.kt │ ├── IntervalPlusTests.kt │ ├── IntervalTimesTests.kt │ ├── LetTests.kt │ ├── LiteralIntervalTests.kt │ ├── PartiQLEvaluatorTest.kt │ ├── PlusTest.kt │ ├── TestCases.kt │ ├── TypingTestCase.kt │ ├── WindowTests.kt │ └── operator │ └── rex │ ├── CastTableTest.kt │ └── ExprCallDynamicTest.kt ├── partiql-lang ├── api │ └── partiql-lang.api └── build.gradle.kts ├── partiql-parser ├── README.adoc ├── api │ └── partiql-parser.api ├── build.gradle.kts └── src │ ├── main │ ├── antlr │ │ ├── PartiQLParser.g4 │ │ └── PartiQLTokens.g4 │ ├── java │ │ └── org │ │ │ └── partiql │ │ │ └── parser │ │ │ ├── PartiQLParser.java │ │ │ └── package-info.java │ └── kotlin │ │ └── org │ │ └── partiql │ │ └── parser │ │ ├── Exceptions.kt │ │ └── internal │ │ ├── PErrors.kt │ │ └── PartiQLParserDefault.kt │ └── test │ └── kotlin │ └── org │ └── partiql │ └── parser │ └── internal │ ├── ArgumentsProviderBase.kt │ ├── DeleteStatementTests.kt │ ├── InsertStatementTests.kt │ ├── PTestDef.kt │ ├── ParserTestCaseSimple.kt │ ├── PartiQLParserBagOpTests.kt │ ├── PartiQLParserDDLTests.kt │ ├── PartiQLParserFunctionCallTests.kt │ ├── PartiQLParserOperatorTests.kt │ ├── PartiQLParserSessionAttributeTests.kt │ ├── ReplaceStatementTests.kt │ ├── SemiColonTests.kt │ ├── UpdateStatementTests.kt │ ├── UpsertStatementTests.kt │ └── WithSelectTests.kt ├── partiql-plan ├── README.md ├── api │ └── partiql-plan.api ├── build.gradle.kts └── src │ └── main │ ├── java │ └── org │ │ └── partiql │ │ └── plan │ │ ├── Action.java │ │ ├── Collation.java │ │ ├── Exclusion.kt │ │ ├── JoinType.java │ │ ├── Operand.java │ │ ├── Operator.java │ │ ├── OperatorRewriter.java │ │ ├── OperatorVisitor.java │ │ ├── Plan.java │ │ ├── Version.java │ │ ├── WindowFunctionNode.java │ │ ├── WindowFunctionSignature.java │ │ ├── WithListElement.java │ │ ├── package-info.java │ │ ├── rel │ │ ├── Rel.java │ │ ├── RelAggregate.java │ │ ├── RelBase.java │ │ ├── RelCorrelate.java │ │ ├── RelDistinct.java │ │ ├── RelExcept.java │ │ ├── RelExclude.java │ │ ├── RelFilter.java │ │ ├── RelIntersect.java │ │ ├── RelIterate.java │ │ ├── RelJoin.java │ │ ├── RelLimit.java │ │ ├── RelOffset.java │ │ ├── RelProject.java │ │ ├── RelScan.java │ │ ├── RelSort.java │ │ ├── RelType.java │ │ ├── RelUnion.java │ │ ├── RelUnpivot.java │ │ ├── RelWindow.java │ │ ├── RelWith.java │ │ └── package-info.java │ │ └── rex │ │ ├── Rex.java │ │ ├── RexArray.java │ │ ├── RexBag.java │ │ ├── RexBase.java │ │ ├── RexCall.java │ │ ├── RexCase.java │ │ ├── RexCast.java │ │ ├── RexCoalesce.java │ │ ├── RexDispatch.java │ │ ├── RexError.java │ │ ├── RexLit.java │ │ ├── RexNullIf.java │ │ ├── RexPathIndex.java │ │ ├── RexPathKey.java │ │ ├── RexPathSymbol.java │ │ ├── RexPivot.java │ │ ├── RexSelect.java │ │ ├── RexSpread.java │ │ ├── RexStruct.java │ │ ├── RexSubquery.java │ │ ├── RexSubqueryComp.java │ │ ├── RexSubqueryIn.java │ │ ├── RexSubqueryTest.java │ │ ├── RexTable.java │ │ ├── RexType.java │ │ ├── RexVar.java │ │ └── package-info.java │ └── kotlin │ └── org │ └── partiql │ └── plan │ └── Operators.kt ├── partiql-planner ├── api │ └── partiql-planner.api ├── build.gradle.kts └── src │ ├── main │ ├── kotlin │ │ └── org │ │ │ └── partiql │ │ │ └── planner │ │ │ ├── PartiQLPlanner.kt │ │ │ ├── PartiQLPlannerPass.kt │ │ │ ├── builder │ │ │ └── PartiQLPlannerBuilder.kt │ │ │ └── internal │ │ │ ├── CoercionFamily.kt │ │ │ ├── Env.kt │ │ │ ├── FnComparator.kt │ │ │ ├── FnMatch.kt │ │ │ ├── FnResolver.kt │ │ │ ├── PErrors.kt │ │ │ ├── PlannerFlag.kt │ │ │ ├── SqlPlanner.kt │ │ │ ├── casts │ │ │ └── CastTable.kt │ │ │ ├── exclude │ │ │ └── Subsumption.kt │ │ │ ├── ir │ │ │ └── Nodes.kt │ │ │ ├── transforms │ │ │ ├── AggregationTransform.kt │ │ │ ├── AstPass.kt │ │ │ ├── AstToPlan.kt │ │ │ ├── NormalizeFromSource.kt │ │ │ ├── NormalizeGroupBy.kt │ │ │ ├── NormalizeSelect.kt │ │ │ ├── OrderByAliasSupport.kt │ │ │ ├── PlanTransform.kt │ │ │ ├── RelConverter.kt │ │ │ ├── RexConverter.kt │ │ │ ├── SubstitutionVisitor.kt │ │ │ └── WindowTransform.kt │ │ │ ├── typer │ │ │ ├── CompilerType.kt │ │ │ ├── DynamicTyper.kt │ │ │ ├── ExcludeUtils.kt │ │ │ ├── PlanTyper.kt │ │ │ ├── Scope.kt │ │ │ ├── Strategy.kt │ │ │ └── TypeEnv.kt │ │ │ ├── util │ │ │ ├── BinderUtils.kt │ │ │ ├── DateTimeUtils.kt │ │ │ ├── FunctionUtils.kt │ │ │ ├── IntervalUtils.kt │ │ │ └── TypeUtils.kt │ │ │ └── window │ │ │ └── WindowFunctionSignatureProvider.kt │ └── resources │ │ └── partiql_plan_internal.ion │ ├── test │ ├── kotlin │ │ └── org │ │ │ └── partiql │ │ │ └── planner │ │ │ ├── PlanEquivalenceOperatorVisitor.kt │ │ │ ├── PlanTest.kt │ │ │ ├── PlannerPErrorReportingTests.kt │ │ │ ├── internal │ │ │ ├── TestCatalog.kt │ │ │ ├── exclude │ │ │ │ └── SubsumptionTest.kt │ │ │ ├── transforms │ │ │ │ ├── NormalizeSelectTest.kt │ │ │ │ └── OrderByAliasSupportTest.kt │ │ │ └── typer │ │ │ │ ├── FnResolverTest.kt │ │ │ │ ├── InternalToPublicPlanTest.kt │ │ │ │ ├── PTypeMetaInPlan.kt │ │ │ │ ├── PartiQLTyperTestBase.kt │ │ │ │ ├── PlanTyperTest.kt │ │ │ │ ├── PlanTyperTestsPorted.kt │ │ │ │ ├── ScopeTest.kt │ │ │ │ ├── TypeLatticeTest.kt │ │ │ │ ├── Utils.kt │ │ │ │ ├── functions │ │ │ │ ├── ConcatTest.kt │ │ │ │ ├── FnTestUtils.kt │ │ │ │ ├── LowerTest.kt │ │ │ │ ├── NullIfTest.kt │ │ │ │ ├── TrimTest.kt │ │ │ │ └── UpperTest.kt │ │ │ │ ├── logical │ │ │ │ └── OpLogicalTest.kt │ │ │ │ ├── operator │ │ │ │ ├── OpArithmeticTest.kt │ │ │ │ ├── OpBitwiseAndTest.kt │ │ │ │ └── OpConcatTest.kt │ │ │ │ ├── path │ │ │ │ └── SanityTests.kt │ │ │ │ └── predicate │ │ │ │ ├── OpBetweenTest.kt │ │ │ │ ├── OpComparisonTest.kt │ │ │ │ ├── OpInTest.kt │ │ │ │ ├── OpIsMissingTest.kt │ │ │ │ ├── OpIsNullTest.kt │ │ │ │ ├── OpLikeTest.kt │ │ │ │ ├── OpOverlapsTest.kt │ │ │ │ └── OpTypeUnexpectedAssertionTest.kt │ │ │ ├── plugins │ │ │ └── local │ │ │ │ ├── LocalCatalog.kt │ │ │ │ ├── LocalConnector.kt │ │ │ │ ├── LocalSchema.kt │ │ │ │ └── LocalTable.kt │ │ │ └── util │ │ │ ├── PErrorAlwaysMissingCollector.kt │ │ │ ├── PErrorCollector.kt │ │ │ ├── PlanPrinter.kt │ │ │ └── Utils.kt │ └── resources │ │ └── outputs │ │ └── basics │ │ └── select.sql │ └── testFixtures │ ├── kotlin │ └── org │ │ └── partiql │ │ └── planner │ │ └── test │ │ ├── PartiQLTest.kt │ │ └── PartiQLTestProvider.kt │ └── resources │ ├── README.adoc │ ├── catalogs │ ├── default │ │ ├── aggregations │ │ │ ├── T.ion │ │ │ ├── T1.ion │ │ │ ├── T2.ion │ │ │ └── T3.ion │ │ ├── aws │ │ │ ├── b │ │ │ │ └── b.ion │ │ │ └── ddb │ │ │ │ ├── b.ion │ │ │ │ ├── persons.ion │ │ │ │ └── pets.ion │ │ ├── b │ │ │ ├── b │ │ │ │ ├── b.ion │ │ │ │ ├── b_open.ion │ │ │ │ ├── c.ion │ │ │ │ └── d.ion │ │ │ └── c │ │ │ │ └── c.ion │ │ ├── db │ │ │ └── markets │ │ │ │ ├── order_info.ion │ │ │ │ └── orders.ion │ │ ├── pql │ │ │ ├── main │ │ │ │ ├── T.ion │ │ │ │ ├── closed_duplicates_struct.ion │ │ │ │ ├── closed_ordered_duplicates_struct.ion │ │ │ │ ├── closed_union_duplicates_struct.ion │ │ │ │ ├── dogs.ion │ │ │ │ ├── employer.ion │ │ │ │ ├── item.ion │ │ │ │ ├── open_duplicates_struct.ion │ │ │ │ ├── os.ion │ │ │ │ └── person.ion │ │ │ ├── numbers.ion │ │ │ ├── points.ion │ │ │ └── t_item.ion │ │ └── subqueries │ │ │ ├── S.ion │ │ │ └── T.ion │ ├── tpc_ds │ │ ├── call_center.ion │ │ ├── catalog_page.ion │ │ ├── catalog_returns.ion │ │ ├── catalog_sales.ion │ │ ├── customer.ion │ │ ├── customer_address.ion │ │ ├── customer_demographics.ion │ │ ├── date_dim.ion │ │ ├── dbgen_version.ion │ │ ├── household_demographics.ion │ │ ├── income_band.ion │ │ ├── inventory.ion │ │ ├── item.ion │ │ ├── promotion.ion │ │ ├── reason.ion │ │ ├── ship_mode.ion │ │ ├── store.ion │ │ ├── store_returns.ion │ │ ├── store_sales.ion │ │ ├── time_dim.ion │ │ ├── warehouse.ion │ │ ├── web_page.ion │ │ ├── web_returns.ion │ │ ├── web_sales.ion │ │ └── web_site.ion │ └── tpc_h │ │ └── .gitkeep │ ├── inputs │ ├── basics │ │ ├── case.sql │ │ ├── coalesce.sql │ │ ├── functions.sql │ │ ├── nullif.sql │ │ ├── operator.sql │ │ ├── paths.sql │ │ ├── select.sql │ │ ├── simple.sql │ │ └── subquery.sql │ ├── schema_inferencer │ │ ├── aggregations.sql │ │ ├── casts.sql │ │ ├── collections.sql │ │ ├── exclude.sql │ │ ├── is_type.sql │ │ ├── joins.sql │ │ ├── order_by.sql │ │ ├── pivot.sql │ │ └── sanity.sql │ ├── subquery │ │ └── non_correlated.sql │ ├── tpc_ds │ │ ├── query01.sql │ │ ├── query02.sql │ │ ├── query03.sql │ │ ├── query04.sql │ │ ├── query05.sql │ │ ├── query06.sql │ │ ├── query07.sql │ │ ├── query08.sql │ │ ├── query09.sql │ │ ├── query10.sql │ │ ├── query11.sql │ │ ├── query12.sql │ │ ├── query13.sql │ │ ├── query14.sql │ │ ├── query15.sql │ │ ├── query16.sql │ │ ├── query17.sql │ │ ├── query18.sql │ │ ├── query19.sql │ │ ├── query20.sql │ │ ├── query21.sql │ │ ├── query22.sql │ │ ├── query23.sql │ │ ├── query24.sql │ │ ├── query25.sql │ │ ├── query26.sql │ │ ├── query27.sql │ │ ├── query28.sql │ │ ├── query29.sql │ │ ├── query30.sql │ │ ├── query31.sql │ │ ├── query32.sql │ │ ├── query33.sql │ │ ├── query34.sql │ │ ├── query35.sql │ │ ├── query36.sql │ │ ├── query37.sql │ │ ├── query38.sql │ │ ├── query39.sql │ │ ├── query40.sql │ │ ├── query41.sql │ │ ├── query42.sql │ │ ├── query43.sql │ │ ├── query44.sql │ │ ├── query45.sql │ │ ├── query46.sql │ │ ├── query47.sql │ │ ├── query48.sql │ │ ├── query49.sql │ │ ├── query50.sql │ │ ├── query51.sql │ │ ├── query52.sql │ │ ├── query53.sql │ │ ├── query54.sql │ │ ├── query55.sql │ │ ├── query56.sql │ │ ├── query57.sql │ │ ├── query58.sql │ │ ├── query59.sql │ │ ├── query60.sql │ │ ├── query61.sql │ │ ├── query62.sql │ │ ├── query63.sql │ │ ├── query64.sql │ │ ├── query65.sql │ │ ├── query66.sql │ │ ├── query67.sql │ │ ├── query68.sql │ │ ├── query69.sql │ │ ├── query70.sql │ │ ├── query71.sql │ │ ├── query72.sql │ │ ├── query73.sql │ │ ├── query74.sql │ │ ├── query75.sql │ │ ├── query76.sql │ │ ├── query77.sql │ │ ├── query78.sql │ │ ├── query79.sql │ │ ├── query80.sql │ │ ├── query81.sql │ │ ├── query82.sql │ │ ├── query83.sql │ │ ├── query84.sql │ │ ├── query85.sql │ │ ├── query86.sql │ │ ├── query87.sql │ │ ├── query88.sql │ │ ├── query89.sql │ │ ├── query90.sql │ │ ├── query91.sql │ │ ├── query92.sql │ │ ├── query93.sql │ │ ├── query94.sql │ │ ├── query95.sql │ │ ├── query96.sql │ │ ├── query97.sql │ │ ├── query98.sql │ │ └── query99.sql │ └── tpc_h │ │ ├── query01.sql │ │ ├── query02.sql │ │ ├── query03.sql │ │ ├── query04.sql │ │ ├── query05.sql │ │ ├── query06.sql │ │ ├── query07.sql │ │ ├── query08.sql │ │ ├── query09.sql │ │ ├── query10.sql │ │ ├── query11.sql │ │ ├── query12.sql │ │ ├── query13.sql │ │ ├── query14.sql │ │ ├── query15.sql │ │ ├── query16.sql │ │ ├── query17.sql │ │ ├── query18.sql │ │ ├── query19.sql │ │ ├── query20.sql │ │ ├── query21.sql │ │ └── query22.sql │ └── tests │ └── aggregations.ion ├── partiql-spi ├── api │ └── partiql-spi.api ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── partiql │ │ │ └── spi │ │ │ ├── Context.java │ │ │ ├── Enum.java │ │ │ ├── SourceLocation.java │ │ │ ├── SourceLocations.java │ │ │ ├── UnsupportedCodeException.java │ │ │ ├── catalog │ │ │ ├── System.java │ │ │ └── package-info.java │ │ │ ├── errors │ │ │ ├── PError.java │ │ │ ├── PErrorKind.java │ │ │ ├── PErrorListener.java │ │ │ ├── PRuntimeException.java │ │ │ ├── Severity.java │ │ │ └── package-info.java │ │ │ ├── function │ │ │ ├── Accumulator.java │ │ │ ├── Agg.java │ │ │ ├── AggOverload.java │ │ │ ├── Fn.java │ │ │ ├── FnOverload.java │ │ │ ├── Parameter.java │ │ │ ├── RoutineOverloadSignature.java │ │ │ ├── RoutineSignature.java │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── types │ │ │ ├── IntervalCode.java │ │ │ ├── PType.java │ │ │ ├── PTypeCollection.java │ │ │ ├── PTypeDecimal.java │ │ │ ├── PTypeField.java │ │ │ ├── PTypeIntervalDateTime.java │ │ │ ├── PTypeIntervalYearMonth.java │ │ │ ├── PTypePrimitive.java │ │ │ ├── PTypeRow.java │ │ │ ├── PTypeVariant.java │ │ │ ├── PTypeWithMaxLength.java │ │ │ ├── PTypeWithPrecisionOnly.java │ │ │ └── package-info.java │ │ │ └── value │ │ │ ├── Datum.java │ │ │ ├── DatumBoolean.java │ │ │ ├── DatumByte.java │ │ │ ├── DatumBytes.java │ │ │ ├── DatumChars.java │ │ │ ├── DatumCollection.java │ │ │ ├── DatumComparator.java │ │ │ ├── DatumDate.java │ │ │ ├── DatumDecimal.java │ │ │ ├── DatumDouble.java │ │ │ ├── DatumFloat.java │ │ │ ├── DatumInt.java │ │ │ ├── DatumIntervalDayTime.java │ │ │ ├── DatumIntervalHelpers.java │ │ │ ├── DatumIntervalYearMonth.java │ │ │ ├── DatumLong.java │ │ │ ├── DatumMissing.java │ │ │ ├── DatumNull.java │ │ │ ├── DatumReader.java │ │ │ ├── DatumRow.java │ │ │ ├── DatumShort.java │ │ │ ├── DatumString.java │ │ │ ├── DatumStruct.java │ │ │ ├── DatumTime.java │ │ │ ├── DatumTimestamp.java │ │ │ ├── DatumTimestampz.java │ │ │ ├── DatumTimez.java │ │ │ ├── DatumUtils.java │ │ │ ├── DatumWriter.java │ │ │ ├── Encoding.java │ │ │ ├── Field.java │ │ │ ├── InvalidOperationException.java │ │ │ ├── PErrors.java │ │ │ └── package-info.java │ └── kotlin │ │ └── org │ │ └── partiql │ │ └── spi │ │ ├── Connector.kt │ │ ├── catalog │ │ ├── Catalog.kt │ │ ├── Catalogs.kt │ │ ├── Identifier.kt │ │ ├── Name.kt │ │ ├── Namespace.kt │ │ ├── Path.kt │ │ ├── Session.kt │ │ ├── Table.kt │ │ └── impl │ │ │ ├── StandardCatalog.kt │ │ │ ├── StandardCatalogs.kt │ │ │ └── StandardTable.kt │ │ ├── function │ │ ├── Aggregation.kt │ │ ├── Builtins.kt │ │ ├── Function.kt │ │ └── builtins │ │ │ ├── AggAny.kt │ │ │ ├── AggAvg.kt │ │ │ ├── AggCount.kt │ │ │ ├── AggEvery.kt │ │ │ ├── AggGroupAs.kt │ │ │ ├── AggMax.kt │ │ │ ├── AggMin.kt │ │ │ ├── AggSome.kt │ │ │ ├── AggSum.kt │ │ │ ├── DefaultDecimal.kt │ │ │ ├── DefaultNumeric.kt │ │ │ ├── DiadicArithmeticOperator.kt │ │ │ ├── DiadicComparisonOperator.kt │ │ │ ├── DiadicOperator.kt │ │ │ ├── FnAbs.kt │ │ │ ├── FnAnd.kt │ │ │ ├── FnBetween.kt │ │ │ ├── FnBitLength.kt │ │ │ ├── FnBitwiseAnd.kt │ │ │ ├── FnCardinality.kt │ │ │ ├── FnCharLength.kt │ │ │ ├── FnCollAgg.kt │ │ │ ├── FnConcat.kt │ │ │ ├── FnCurrentDate.kt │ │ │ ├── FnCurrentUser.kt │ │ │ ├── FnDateDiffDay.kt │ │ │ ├── FnDateDiffHour.kt │ │ │ ├── FnDateDiffMinute.kt │ │ │ ├── FnDateDiffMonth.kt │ │ │ ├── FnDateDiffSecond.kt │ │ │ ├── FnDateDiffYear.kt │ │ │ ├── FnDivide.kt │ │ │ ├── FnEq.kt │ │ │ ├── FnExists.kt │ │ │ ├── FnExtract.kt │ │ │ ├── FnGt.kt │ │ │ ├── FnGte.kt │ │ │ ├── FnInCollection.kt │ │ │ ├── FnIsAny.kt │ │ │ ├── FnIsBag.kt │ │ │ ├── FnIsBinary.kt │ │ │ ├── FnIsBlob.kt │ │ │ ├── FnIsBool.kt │ │ │ ├── FnIsByte.kt │ │ │ ├── FnIsChar.kt │ │ │ ├── FnIsClob.kt │ │ │ ├── FnIsDate.kt │ │ │ ├── FnIsDecimal.kt │ │ │ ├── FnIsFalse.kt │ │ │ ├── FnIsFloat32.kt │ │ │ ├── FnIsFloat64.kt │ │ │ ├── FnIsInt.kt │ │ │ ├── FnIsInt16.kt │ │ │ ├── FnIsInt32.kt │ │ │ ├── FnIsInt64.kt │ │ │ ├── FnIsInt8.kt │ │ │ ├── FnIsInterval.kt │ │ │ ├── FnIsList.kt │ │ │ ├── FnIsMissing.kt │ │ │ ├── FnIsNull.kt │ │ │ ├── FnIsString.kt │ │ │ ├── FnIsStruct.kt │ │ │ ├── FnIsTime.kt │ │ │ ├── FnIsTimestamp.kt │ │ │ ├── FnIsTrue.kt │ │ │ ├── FnIsUnknown.kt │ │ │ ├── FnLike.kt │ │ │ ├── FnLikeEscape.kt │ │ │ ├── FnLower.kt │ │ │ ├── FnLt.kt │ │ │ ├── FnLte.kt │ │ │ ├── FnMinus.kt │ │ │ ├── FnModulo.kt │ │ │ ├── FnNeg.kt │ │ │ ├── FnNot.kt │ │ │ ├── FnOctetLength.kt │ │ │ ├── FnOr.kt │ │ │ ├── FnOverlaps.kt │ │ │ ├── FnPlus.kt │ │ │ ├── FnPos.kt │ │ │ ├── FnPosition.kt │ │ │ ├── FnSize.kt │ │ │ ├── FnSubstring.kt │ │ │ ├── FnTimes.kt │ │ │ ├── FnTrim.kt │ │ │ ├── FnTrimChars.kt │ │ │ ├── FnTrimLeading.kt │ │ │ ├── FnTrimLeadingChars.kt │ │ │ ├── FnTrimTrailing.kt │ │ │ ├── FnTrimTrailingChars.kt │ │ │ ├── FnUpper.kt │ │ │ ├── FnUtcnow.kt │ │ │ ├── FnUtils.kt │ │ │ ├── TypePrecedence.kt │ │ │ └── internal │ │ │ ├── Accumulator.kt │ │ │ ├── AccumulatorAnySome.kt │ │ │ ├── AccumulatorAvg.kt │ │ │ ├── AccumulatorCount.kt │ │ │ ├── AccumulatorDistinct.kt │ │ │ ├── AccumulatorEvery.kt │ │ │ ├── AccumulatorGroupAs.kt │ │ │ ├── AccumulatorMax.kt │ │ │ ├── AccumulatorMin.kt │ │ │ ├── AccumulatorSum.kt │ │ │ └── PErrors.kt │ │ ├── internal │ │ ├── SqlTypeFamily.kt │ │ ├── SqlTypes.kt │ │ └── value │ │ │ ├── ion │ │ │ ├── IonDatumException.kt │ │ │ ├── IonDatumReader.kt │ │ │ ├── IonDatumWriter.kt │ │ │ └── IonVariant.kt │ │ │ └── json │ │ │ └── .gitkeep │ │ └── utils │ │ ├── DatumUtils.kt │ │ ├── FunctionUtils.kt │ │ ├── IntervalUtils.kt │ │ ├── NumberUtils.kt │ │ ├── PatternUtils.kt │ │ └── StringUtils.kt │ ├── test │ ├── java │ │ └── org │ │ │ └── partiql │ │ │ └── spi │ │ │ └── value │ │ │ └── __snapshots__ │ │ │ └── DatumToStringTest.snap │ ├── kotlin │ │ └── org │ │ │ └── partiql │ │ │ ├── eval │ │ │ └── value │ │ │ │ └── DatumComparatorTest.kt │ │ │ ├── spi │ │ │ ├── errors │ │ │ │ └── PErrorCodeTests.kt │ │ │ └── value │ │ │ │ ├── DatumToStringTest.kt │ │ │ │ ├── ion │ │ │ │ ├── IonDatumReaderTest.kt │ │ │ │ └── IonDatumWriterTest.kt │ │ │ │ └── json │ │ │ │ └── .gitkeep │ │ │ ├── types │ │ │ ├── PTypeMetaTest.kt │ │ │ └── StaticTypeTest.kt │ │ │ └── value │ │ │ └── TimestampTest.kt │ └── resources │ │ ├── io │ │ ├── ion │ │ │ ├── kitchen_lower.ion │ │ │ ├── kitchen_typed.ion │ │ │ └── negatives.ion │ │ └── json │ │ │ └── .gitkeep │ │ └── snapshot.properties │ └── testFixtures │ └── kotlin │ └── org │ └── partiql │ ├── spi │ └── errors │ │ └── DataException.kt │ └── types │ ├── FromStaticType.kt │ └── StaticType.kt ├── settings.gradle.kts └── test ├── coverage-tests ├── README.md ├── build.gradle.kts └── src │ └── test │ └── kotlin │ └── org │ └── partiql │ └── test │ └── coverage │ ├── CaseWhenTests.kt │ ├── ConditionsWithoutBranchesTest.kt │ ├── CustomFunctionsTest.kt │ ├── ParametersTest.kt │ ├── RunnerTest.kt │ ├── TypingModeTest.kt │ ├── nested │ └── SimpleTest.kt │ └── utils │ └── PartiQLTestCaseDefault.kt ├── partiql-randomized-tests ├── build.gradle └── src │ └── test │ └── kotlin │ └── org │ └── partiql │ └── lang │ └── randomized │ ├── eval │ ├── DateTimeRandomizedTests.kt │ ├── IntOverflowRandomizedTest.kt │ └── Utils.kt │ └── syntax │ └── PartiQLParserDateTimeRandomizedTests.kt ├── partiql-tests-runner ├── README.md ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── partiql │ │ │ └── runner │ │ │ └── PartiQLTestsRunner.java │ ├── kotlin │ │ └── org │ │ │ └── partiql │ │ │ └── runner │ │ │ ├── ConformanceComparison.kt │ │ │ ├── Report.kt │ │ │ └── ReportAnalyzer.kt │ └── resources │ │ └── config │ │ └── legacy │ │ └── conformance_test_results.ion │ └── test │ ├── kotlin │ └── org │ │ └── partiql │ │ └── runner │ │ ├── CompileType.kt │ │ ├── ConformanceTestBase.kt │ │ ├── ConformanceTestEvalCore.kt │ │ ├── ConformanceTestEvalExtended.kt │ │ ├── Ion.kt │ │ ├── executor │ │ └── EvalExecutor.kt │ │ ├── io │ │ └── DatumIonReader.kt │ │ ├── report │ │ └── ReportGenerator.kt │ │ ├── schema │ │ ├── Assertion.kt │ │ ├── EquivalenceClass.kt │ │ ├── Namespace.kt │ │ ├── Parse.kt │ │ └── TestCase.kt │ │ ├── skip │ │ └── Failing.kt │ │ ├── test │ │ ├── TestExecutor.kt │ │ ├── TestLoader.kt │ │ ├── TestProvider.kt │ │ └── TestRunner.kt │ │ └── util │ │ └── DatumUtil.kt │ └── resources │ ├── config │ └── eval │ │ ├── skip-eval-core.txt │ │ ├── skip-eval-equiv-core.txt │ │ ├── skip-eval-extended.txt │ │ └── skip-eval-ported.txt │ └── ported │ ├── eval-equiv │ └── .gitkeep │ ├── eval │ ├── casts.ion │ ├── date-time-comparisons.ion │ ├── date-time-literals.ion │ ├── exclude.ion │ ├── from-let.ion │ ├── group-by-solo.ion │ ├── having.ion │ ├── in.ion │ ├── int.ion │ ├── ion-annotations.ion │ ├── like-predicate.ion │ ├── limit.ion │ ├── null-if.ion │ ├── offset.ion │ ├── order-by.ion │ ├── quoted-identifier.ion │ ├── unknown-propagation.ion │ └── unknown-values.ion │ └── syntax │ └── all.ion └── sprout-tests ├── build.gradle.kts └── src ├── main └── resources │ └── example.ion └── test └── kotlin └── org └── partiql └── sprout └── tests ├── ArgumentsProviderBase.kt └── example └── EqualityTests.kt /.editorconfig: -------------------------------------------------------------------------------- 1 | # Ignore custom ktlint rules for tests 2 | [**/test/**.kt] 3 | disabled_rules = custom-ktlint-rules:top-level-internal,custom-ktlint-rules:top-level-public 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.png binary 2 | *.ppt binary 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: An issue to track an existing bug in PartiQL 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Description 11 | - A clear and concise description of what the bug is. 12 | 13 | ## To Reproduce 14 | Steps to reproduce the behavior: 15 | 1. XXX 16 | 2. XXX 17 | 18 | ## Expected Behavior 19 | - < A clear and concise description of what you expected to happen. > 20 | 21 | ## Additional Context 22 | - Java version: XXX 23 | - PartiQL version: XXX 24 | - Add any other context about the problem here. 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Relevant Issue/Bug 11 | - Reference Issue #XXX -- how is it related? 12 | 13 | ## Requested Solution/Feature 14 | - A clear and concise description of what you want to happen. 15 | 16 | ## Describe Alternatives 17 | - A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | ## Additional Context 20 | Add any other context about the feature request here. 21 | 22 | ## DoD (Definition of Done) 23 | List set of criteria that characterize this issue as _DONE_ or _COMPLETED_. -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Relevant Issues 2 | - [Closes/Related To] Issue #XXX 3 | 4 | ## Description 5 | - < Explain > 6 | 7 | ## Other Information 8 | - Updated Unreleased Section in CHANGELOG: **[YES/NO]**: 9 | - Any backward-incompatible changes? **[YES/NO]**: 10 | - Any new external dependencies? **[YES/NO]**: 11 | - Do your changes comply with the [contributing][cg] and [code style][csg] guidelines? **[YES/NO]** 12 | 13 | ## License Information 14 | 15 | By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. 16 | 17 | 18 | 19 | [cg]: https://github.com/partiql/partiql-lang-kotlin/blob/main/CONTRIBUTING.md 20 | [csg]: https://github.com/partiql/partiql-lang-kotlin/blob/main/CODE_STYLE.md -------------------------------------------------------------------------------- /.github/no-response.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-no-response - https://github.com/probot/no-response 2 | 3 | # Number of days of inactivity before an Issue is closed for lack of response 4 | daysUntilClose: 14 5 | # Label requiring a response 6 | responseRequiredLabel: more-information-needed 7 | # Comment to post when closing an Issue for lack of response. Set to `false` to disable 8 | closeComment: > 9 | This issue has been automatically closed because there has been no response 10 | to our request for more information from the original author. With only the 11 | information that is currently in the issue, we don't have enough information 12 | to take action. Please reach out if you have or find the answers we need so 13 | that we can investigate further. 14 | -------------------------------------------------------------------------------- /.github/workflows/docs-to-gh-wiki.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Docs to GitHub Wiki 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'docs/wiki/**' 7 | branches: 8 | - main 9 | 10 | jobs: 11 | deploy-wiki: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Push Wiki Changes 16 | uses: Andrew-Chen-Wang/github-wiki-action@v3 17 | env: 18 | WIKI_DIR: docs/wiki/ 19 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | GH_NAME: ${{ github.event.commits[0].author.username }} 21 | GH_MAIL: ${{ github.event.commits[0].author.email }} 22 | -------------------------------------------------------------------------------- /.github/workflows/gradle-wrapper-validation.yml: -------------------------------------------------------------------------------- 1 | name: "Validate Gradle Wrapper" 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | validation: 6 | name: "Gradle wrapper validation" 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | - uses: gradle/actions/wrapper-validation@v4 11 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test/partiql-tests"] 2 | path = test/partiql-tests 3 | url = git@github.com:partiql/partiql-tests.git 4 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | PartiQL Lang Kotlin 2 | Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | -------------------------------------------------------------------------------- /buildSrc/src/main/resources/META-INF/gradle-plugins/org.partiql.gradle.plugin.publish.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | 16 | implementation-class=org.partiql.gradle.plugin.publish.PublishPlugin 17 | -------------------------------------------------------------------------------- /custom-ktlint-rules/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id(Plugins.conventions) 3 | `java-library` 4 | } 5 | 6 | dependencies { 7 | implementation(Deps.ktlint) 8 | 9 | testImplementation(Deps.assertj) 10 | testImplementation(Deps.ktlintTest) 11 | testImplementation(Deps.junitParams) 12 | } 13 | 14 | repositories { 15 | mavenCentral() 16 | } 17 | -------------------------------------------------------------------------------- /custom-ktlint-rules/src/main/kotlin/org/partiql/ktlint/CustomRuleSetProvider.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.ktlint 2 | 3 | import com.pinterest.ktlint.core.RuleSet 4 | import com.pinterest.ktlint.core.RuleSetProvider 5 | import org.partiql.ktlint.rule.TopLevelInternalRule 6 | import org.partiql.ktlint.rule.TopLevelPublicRule 7 | 8 | class CustomRuleSetProvider : RuleSetProvider { 9 | override fun get(): RuleSet = RuleSet("custom-ktlint-rules", TopLevelInternalRule(), TopLevelPublicRule()) 10 | } 11 | -------------------------------------------------------------------------------- /custom-ktlint-rules/src/main/resources/META-INF/services/com.pinterest.ktlint.core.RuleSetProvider: -------------------------------------------------------------------------------- 1 | org.partiql.ktlint.CustomRuleSetProvider 2 | -------------------------------------------------------------------------------- /detekt-config.yml: -------------------------------------------------------------------------------- 1 | console-reports: 2 | active: false 3 | exclude: 4 | # - 'ProjectStatisticsReport' 5 | # - 'ComplexityReport' 6 | # - 'NotificationReport' 7 | # - 'FindingsReport' 8 | # - 'FileBasedFindingsReport' 9 | # - 'BuildFailureReport' 10 | -------------------------------------------------------------------------------- /docs/upgrades/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf 9 | 10 | -------------------------------------------------------------------------------- /docs/upgrades/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /docs/upgrades/README.md: -------------------------------------------------------------------------------- 1 | ## `partiql-lang-kotlin` Version Upgrade 2 | Directory provides code examples of breaking changes between `partiql-lang-kotlin` major versions consumed through 3 | Maven. 4 | -------------------------------------------------------------------------------- /docs/upgrades/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /docs/upgrades/v0.1-to-v0.2-upgrade/examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.1.7") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.1-to-v0.2-upgrade/upgraded-examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.2.7") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.14-to-v1-upgrade/examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.14.9") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.14-to-v1-upgrade/upgraded-examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang:1.2.2") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.2-to-v0.3-upgrade/examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.2.7") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.2-to-v0.3-upgrade/upgraded-examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.3.4") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.3-to-v0.4-upgrade/examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.3.1") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.3-to-v0.4-upgrade/upgraded-examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.4.0") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.3-to-v0.4-upgrade/upgraded-examples/src/test/kotlin/examples/BreakingChanges.kt: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import com.amazon.ionelement.api.emptyMetaContainer 4 | import com.amazon.ionelement.api.ionInt 5 | import org.partiql.lang.domains.PartiqlAst 6 | import kotlin.test.Test 7 | 8 | class BreakingChanges { 9 | @Test 10 | fun `api change - PIG upgrade version disallowing imported builders`() { 11 | // Newer versions made this builder an interface with a private implementation, so users can no longer import 12 | // the TypeDomain's builders. The recommended way to create the objects is to use `.build { ... }` 13 | // pattern: 14 | PartiqlAst.build { 15 | lit(value = ionInt(1), emptyMetaContainer()) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docs/upgrades/v0.4-to-v0.5-upgrade/examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.4.0") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.4-to-v0.5-upgrade/upgraded-examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.5.0") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.5-to-v0.6-upgrade/examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.5.0") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.5-to-v0.6-upgrade/upgraded-examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.6.0") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.6-to-v0.7-upgrade/examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.6.0") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/v0.6-to-v0.7-upgrade/examples/src/test/kotlin/examples/BreakingChanges.kt: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import org.partiql.lang.errors.ErrorCode 4 | import kotlin.test.Test 5 | 6 | class BreakingChanges { 7 | // Breaking change -- `ErrorCode.EVALUATOR_SQL_EXCEPTION` removal. No equivalent `ErrorCode` and was only used 8 | // in testing 9 | // Breaking change -- `NodeMetadata` removal. Only used in testing. Not part of any public APIs. 10 | 11 | @Test 12 | fun `api change - renaming of field SEMANTIC_INFERENCER_ERROR`() { 13 | fun printOnSemanticInferencerError(someErrorCode: ErrorCode) { 14 | when (someErrorCode) { 15 | ErrorCode.SEMANTIC_INFERENCER_ERROR -> println("Semantic inferencer error occurred") 16 | else -> println("Some other error occurred") 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /docs/upgrades/v0.6-to-v0.7-upgrade/upgraded-examples/src/test/kotlin/examples/BreakingChanges.kt: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import org.partiql.lang.errors.ErrorCode 4 | import kotlin.test.Test 5 | 6 | class BreakingChanges { 7 | @Test 8 | fun `api change - renaming of field SEMANTIC_INFERENCER_ERROR`() { 9 | fun printOnSemanticProblem(someErrorCode: ErrorCode) { 10 | when (someErrorCode) { 11 | ErrorCode.SEMANTIC_PROBLEM -> println("Semantic inferencer problem occurred") 12 | else -> println("Some other error occurred") 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /docs/upgrades/v0.7-to-v0.8-upgrade/upgraded-examples/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at: 7 | * 8 | * http://aws.amazon.com/apache2.0/ 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 12 | * language governing permissions and limitations under the License. 13 | */ 14 | 15 | plugins { 16 | id("partiql.conventions") 17 | } 18 | 19 | dependencies { 20 | testImplementation("org.partiql:partiql-lang-kotlin:0.8.0") 21 | } 22 | -------------------------------------------------------------------------------- /docs/upgrades/vA-to-vB-upgrade-template/examples/src/test/kotlin/examples/BreakingChanges.kt: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import kotlin.test.Test 4 | 5 | class BreakingChanges { 6 | @Test 7 | fun `some change`() { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /docs/upgrades/vA-to-vB-upgrade-template/upgraded-examples/src/test/kotlin/examples/BreakingChanges.kt: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import kotlin.test.Test 4 | 5 | class BreakingChanges { 6 | @Test 7 | fun `some change`() { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q1.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employees': << 4 | -- a tuple is denoted by { ... } in the PartiQL data model 5 | { 'id': 3, 'name': 'Bob Smith', 'title': null }, 6 | { 'id': 4, 'name': 'Susan Smith', 'title': 'Dev Mgr' }, 7 | { 'id': 6, 'name': 'Jane Smith', 'title': 'Software Eng 2'} 8 | >> 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q1.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 4, 4 | 'employeeName': 'Susan Smith', 5 | 'title': 'Dev Mgr' 6 | } 7 | >> 8 | --- 9 | OK! 10 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q1.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id, 2 | e.name AS employeeName, 3 | e.title AS title 4 | FROM hr.employees e 5 | WHERE e.title = 'Dev Mgr' 6 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q10.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesWithMissing': << 4 | { 'id': 3, 'name': 'Bob Smith' }, -- no title in this tuple 5 | { 'id': 4, 'name': 'Susan Smith', 'title': 'Dev Mgr' }, 6 | { 'id': 6, 'name': 'Jane Smith', 'title': 'Software Eng 2'} 7 | >> 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q10.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 3, 4 | 'employeeName': 'Bob Smith', 5 | 'outputTitle': NULL 6 | }, 7 | { 8 | 'id': 4, 9 | 'employeeName': 'Susan Smith', 10 | 'outputTitle': 'DEV MGR' 11 | }, 12 | { 13 | 'id': 6, 14 | 'employeeName': 'Jane Smith', 15 | 'outputTitle': 'SOFTWARE ENG 2' 16 | } 17 | >> 18 | --- 19 | OK! 20 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q10.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id, 2 | e.name AS employeeName, 3 | UPPER(e.title) AS outputTitle 4 | FROM hr.employeesWithMissing AS e 5 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q11.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesMixed2': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ 9 | { 'name': 'AWS Redshift Spectrum querying' }, 10 | 'AWS Redshift security', 11 | { 'name': 'AWS Aurora security' } 12 | ] 13 | }, 14 | { 15 | 'id': 4, 16 | 'name': 'Susan Smith', 17 | 'title': 'Dev Mgr', 18 | 'projects': [] 19 | }, 20 | { 21 | 'id': 6, 22 | 'name': 'Jane Smith', 23 | 'projects': [ 'AWS Redshift security'] 24 | } 25 | >> 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q11.output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/partiql/partiql-lang-kotlin/8d556cad5c1fb17c453e7cb141ae08a31eb3dcd7/docs/wiki/assets/code/q11.output -------------------------------------------------------------------------------- /docs/wiki/assets/code/q11.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | CASE WHEN (p IS TUPLE) THEN p.name 3 | ELSE p END AS projectName 4 | FROM hr.employeesMixed2 AS e, 5 | e.projects AS p 6 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q12.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesNest': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ { 'name': 'AWS Redshift Spectrum querying' }, 9 | { 'name': 'AWS Redshift security' }, 10 | { 'name': 'AWS Aurora security' } 11 | ] 12 | }, 13 | { 14 | 'id': 4, 15 | 'name': 'Susan Smith', 16 | 'title': 'Dev Mgr', 17 | 'projects': [] 18 | }, 19 | { 20 | 'id': 6, 21 | 'name': 'Jane Smith', 22 | 'title': 'Software Eng 2', 23 | 'projects': [ { 'name': 'AWS Redshift security' } ] 24 | } 25 | >> 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q12.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'firstProjectName': 'AWS Redshift Spectrum querying' 5 | }, 6 | { 7 | 'employeeName': 'Susan Smith' 8 | }, 9 | { 10 | 'employeeName': 'Jane Smith', 11 | 'firstProjectName': 'AWS Redshift security' 12 | } 13 | >> 14 | --- 15 | OK! 16 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q12.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | e.projects[0].name AS firstProjectName 3 | FROM hr.employeesNest AS e 4 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q13.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesNest': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ { 'name': 'AWS Redshift Spectrum querying' }, 9 | { 'name': 'AWS Redshift security' }, 10 | { 'name': 'AWS Aurora security' } 11 | ] 12 | }, 13 | { 14 | 'id': 4, 15 | 'name': 'Susan Smith', 16 | 'title': 'Dev Mgr', 17 | 'projects': [] 18 | }, 19 | { 20 | 'id': 6, 21 | 'name': 'Jane Smith', 22 | 'title': 'Software Eng 2', 23 | 'projects': [ { 'name': 'AWS Redshift security' } ] 24 | } 25 | >> 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q13.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'projectName': 'AWS Redshift security', 5 | 'projectPriority': 1 6 | }, 7 | { 8 | 'employeeName': 'Bob Smith', 9 | 'projectName': 'AWS Aurora security', 10 | 'projectPriority': 2 11 | }, 12 | { 13 | 'employeeName': 'Jane Smith', 14 | 'projectName': 'AWS Redshift security', 15 | 'projectPriority': 0 16 | } 17 | >> 18 | --- 19 | OK! 20 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q13.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | p.name AS projectName, 3 | o AS projectPriority 4 | FROM hr.employeesNest AS e, 5 | e.projects AS p AT o 6 | WHERE p.name LIKE '%security%' 7 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q14.env: -------------------------------------------------------------------------------- 1 | { 2 | 'closingPrices': << 3 | { 'date': '4/1/2019', 'amzn': 1900, 'goog': 1120, 'fb': 180 }, 4 | { 'date': '4/2/2019', 'amzn': 1902, 'goog': 1119, 'fb': 183 } 5 | >> 6 | } 7 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q14.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'date': '4/1/2019', 4 | 'symbol': 'amzn', 5 | 'price': 1900 6 | }, 7 | { 8 | 'date': '4/1/2019', 9 | 'symbol': 'goog', 10 | 'price': 1120 11 | }, 12 | { 13 | 'date': '4/1/2019', 14 | 'symbol': 'fb', 15 | 'price': 180 16 | }, 17 | { 18 | 'date': '4/2/2019', 19 | 'symbol': 'amzn', 20 | 'price': 1902 21 | }, 22 | { 23 | 'date': '4/2/2019', 24 | 'symbol': 'goog', 25 | 'price': 1119 26 | }, 27 | { 28 | 'date': '4/2/2019', 29 | 'symbol': 'fb', 30 | 'price': 183 31 | } 32 | >> 33 | --- 34 | OK! 35 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q14.sql: -------------------------------------------------------------------------------- 1 | SELECT c."date" AS "date", 2 | sym AS "symbol", 3 | price AS price 4 | FROM closingPrices AS c, 5 | UNPIVOT c AS price AT sym 6 | WHERE NOT sym = 'date' 7 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q15.env: -------------------------------------------------------------------------------- 1 | { 2 | 'todaysStockPrices': << 3 | { 'symbol': 'amzn', 'price': 1900}, 4 | { 'symbol': 'goog', 'price': 1120}, 5 | { 'symbol': 'fb', 'price': 180 } 6 | >> 7 | } 8 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q15.output: -------------------------------------------------------------------------------- 1 | { 2 | 'amzn': 1900, 3 | 'goog': 1120, 4 | 'fb': 180 5 | } 6 | --- 7 | OK! 8 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q15.sql: -------------------------------------------------------------------------------- 1 | PIVOT sp.price AT sp."symbol" 2 | FROM todaysStockPrices sp 3 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q16.env: -------------------------------------------------------------------------------- 1 | { 2 | 'stockPrices':<< 3 | { 'date': '4/1/2019', 'symbol': 'amzn', 'price': 1900}, 4 | { 'date': '4/1/2019', 'symbol': 'goog', 'price': 1120}, 5 | { 'date': '4/1/2019', 'symbol': 'fb', 'price': 180 }, 6 | { 'date': '4/2/2019', 'symbol': 'amzn', 'price': 1902}, 7 | { 'date': '4/2/2019', 'symbol': 'goog', 'price': 1119}, 8 | { 'date': '4/2/2019', 'symbol': 'fb', 'price': 183 } 9 | >> 10 | } 11 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q16.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'date': date(4/1/2019), 4 | 'prices': {'amzn': 1900, 'goog': 1120, 'fb': 180} 5 | }, 6 | { 7 | 'date': date(4/2/2019), 8 | 'prices': {'amzn': 1902, 'goog': 1119, 'fb': 183} 9 | } 10 | >> 11 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q16.sql: -------------------------------------------------------------------------------- 1 | SELECT sp."date" AS "date", 2 | (PIVOT dp.sp.price AT dp.sp."symbol" 3 | FROM datesPrices as dp ) AS prices 4 | FROM StockPrices AS sp GROUP BY sp."date" GROUP AS datesPrices 5 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q17.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesNestScalars': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ 9 | 'AWS Redshift Spectrum querying', 10 | 'AWS Redshift security', 11 | 'AWS Aurora security' 12 | ] 13 | }, 14 | { 15 | 'id': 4, 16 | 'name': 'Susan Smith', 17 | 'title': 'Dev Mgr', 18 | 'projects': [] 19 | }, 20 | { 21 | 'id': 6, 22 | 'name': 'Jane Smith', 23 | 'title': 'Software Eng 2', 24 | 'projects': [ 'AWS Redshift security' ] 25 | } 26 | >> 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q17.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 3, 4 | 'name': 'Bob Smith', 5 | 'title': NULL, 6 | 'securityProjects': << 7 | 'AWS Redshift security', 8 | 'AWS Aurora security' 9 | >> 10 | }, 11 | { 12 | 'id': 4, 13 | 'name': 'Susan Smith', 14 | 'title': 'Dev Mgr', 15 | 'securityProjects': <<>> 16 | }, 17 | { 18 | 'id': 6, 19 | 'name': 'Jane Smith', 20 | 'title': 'Software Eng 2', 21 | 'securityProjects': << 22 | 'AWS Redshift security' 23 | >> 24 | } 25 | >> 26 | --- 27 | OK! 28 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q17.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id AS id, 2 | e.name AS name, 3 | e.title AS title, 4 | ( SELECT VALUE p 5 | FROM e.projects AS p 6 | WHERE p LIKE '%security%' 7 | ) AS securityProjects 8 | FROM hr.employeesNestScalars AS e 9 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q18.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesNestScalars': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ 9 | 'AWS Redshift Spectrum querying', 10 | 'AWS Redshift security', 11 | 'AWS Aurora security' 12 | ] 13 | }, 14 | { 15 | 'id': 4, 16 | 'name': 'Susan Smith', 17 | 'title': 'Dev Mgr', 18 | 'projects': [] 19 | }, 20 | { 21 | 'id': 6, 22 | 'name': 'Jane Smith', 23 | 'title': 'Software Eng 2', 24 | 'projects': [ 'AWS Redshift security' ] 25 | } 26 | >> 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q18.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'projectName': 'AWS Aurora security', 4 | 'employees': << 5 | 'Bob Smith' 6 | >> 7 | }, 8 | { 9 | 'projectName': 'AWS Redshift security', 10 | 'employees': << 11 | 'Bob Smith', 12 | 'Jane Smith' 13 | >> 14 | } 15 | >> 16 | --- 17 | OK! 18 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q18.sql: -------------------------------------------------------------------------------- 1 | SELECT p AS projectName, 2 | ( SELECT VALUE v.e.name 3 | FROM perProjectGroup AS v ) AS employees 4 | FROM hr.employeesNestScalars AS e JOIN e.projects AS p ON p LIKE '%security%' 5 | GROUP BY p GROUP AS perProjectGroup 6 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q2.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesNest': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ { 'name': 'AWS Redshift Spectrum querying' }, 9 | { 'name': 'AWS Redshift security' }, 10 | { 'name': 'AWS Aurora security' } 11 | ] 12 | }, 13 | { 14 | 'id': 4, 15 | 'name': 'Susan Smith', 16 | 'title': 'Dev Mgr', 17 | 'projects': [] 18 | }, 19 | { 20 | 'id': 6, 21 | 'name': 'Jane Smith', 22 | 'title': 'Software Eng 2', 23 | 'projects': [ { 'name': 'AWS Redshift security' } ] 24 | } 25 | >> 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q2.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'projectName': 'AWS Redshift security' 5 | }, 6 | { 7 | 'employeeName': 'Bob Smith', 8 | 'projectName': 'AWS Aurora security' 9 | }, 10 | { 11 | 'employeeName': 'Jane Smith', 12 | 'projectName': 'AWS Redshift security' 13 | } 14 | >> 15 | --- 16 | OK! 17 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q2.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | p.name AS projectName 3 | FROM hr.employeesNest AS e, 4 | e.projects AS p 5 | WHERE p.name LIKE '%security%' 6 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q3.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesNest': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ { 'name': 'AWS Redshift Spectrum querying' }, 9 | { 'name': 'AWS Redshift security' }, 10 | { 'name': 'AWS Aurora security' } 11 | ] 12 | }, 13 | { 14 | 'id': 4, 15 | 'name': 'Susan Smith', 16 | 'title': 'Dev Mgr', 17 | 'projects': [] 18 | }, 19 | { 20 | 'id': 6, 21 | 'name': 'Jane Smith', 22 | 'title': 'Software Eng 2', 23 | 'projects': [ { 'name': 'AWS Redshift security' } ] 24 | } 25 | >> 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q3.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 3, 4 | 'employeeName': 'Bob Smith', 5 | 'title': NULL, 6 | 'projectName': 'AWS Redshift Spectrum querying' 7 | }, 8 | { 9 | 'id': 3, 10 | 'employeeName': 'Bob Smith', 11 | 'title': NULL, 12 | 'projectName': 'AWS Redshift security' 13 | }, 14 | { 15 | 'id': 3, 16 | 'employeeName': 'Bob Smith', 17 | 'title': NULL, 18 | 'projectName': 'AWS Aurora security' 19 | }, 20 | { 21 | 'id': 4, 22 | 'employeeName': 'Susan Smith', 23 | 'title': 'Dev Mgr' 24 | }, 25 | { 26 | 'id': 6, 27 | 'employeeName': 'Jane Smith', 28 | 'title': 'Software Eng 2', 29 | 'projectName': 'AWS Redshift security' 30 | } 31 | >> 32 | --- 33 | OK! 34 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q3.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id AS id, 2 | e.name AS employeeName, 3 | e.title AS title, 4 | p.name AS projectName 5 | FROM hr.employeesNest AS e LEFT JOIN e.projects AS p ON true 6 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q4.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesNest': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ { 'name': 'AWS Redshift Spectrum querying' }, 9 | { 'name': 'AWS Redshift security' }, 10 | { 'name': 'AWS Aurora security' } 11 | ] 12 | }, 13 | { 14 | 'id': 4, 15 | 'name': 'Susan Smith', 16 | 'title': 'Dev Mgr', 17 | 'projects': [] 18 | }, 19 | { 20 | 'id': 6, 21 | 'name': 'Jane Smith', 22 | 'title': 'Software Eng 2', 23 | 'projects': [ { 'name': 'AWS Redshift security' } ] 24 | } 25 | >> 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q4.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'queryProjectsNum': 1 5 | }, 6 | { 7 | 'employeeName': 'Susan Smith', 8 | 'queryProjectsNum': 0 9 | }, 10 | { 11 | 'employeeName': 'Jane Smith', 12 | 'queryProjectsNum': 0 13 | } 14 | >> 15 | --- 16 | OK! 17 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q4.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | COUNT(p.name) AS queryProjectsNum 3 | FROM hr.employeesNest e LEFT JOIN e.projects AS p ON p.name LIKE '%querying%' 4 | GROUP BY e.id, e.name 5 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q5.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesWithTuples': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'project': { 9 | 'name': 'AWS Redshift Spectrum querying', 10 | 'org': 'AWS' 11 | } 12 | }, 13 | { 14 | 'id': 6, 15 | 'name': 'Jane Smith', 16 | 'title': 'Software Eng 2', 17 | 'project': { 18 | 'name': 'AWS Redshift security', 19 | 'org': 'AWS' 20 | } 21 | } 22 | >> 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q5.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'projectName': 'AWS Redshift Spectrum querying' 5 | }, 6 | { 7 | 'employeeName': 'Jane Smith', 8 | 'projectName': 'AWS Redshift security' 9 | } 10 | >> 11 | --- 12 | OK! 13 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q5.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | e.project.name AS projectName 3 | FROM hr.employeesWithTuples e 4 | WHERE e.project.org = 'AWS' 5 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q6.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesNestScalars': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ 9 | 'AWS Redshift Spectrum querying', 10 | 'AWS Redshift security', 11 | 'AWS Aurora security' 12 | ] 13 | }, 14 | { 15 | 'id': 4, 16 | 'name': 'Susan Smith', 17 | 'title': 'Dev Mgr', 18 | 'projects': [] 19 | }, 20 | { 21 | 'id': 6, 22 | 'name': 'Jane Smith', 23 | 'title': 'Software Eng 2', 24 | 'projects': [ 'AWS Redshift security' ] 25 | } 26 | >> 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q6.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'projectName': 'AWS Redshift security' 5 | }, 6 | { 7 | 'employeeName': 'Bob Smith', 8 | 'projectName': 'AWS Aurora security' 9 | }, 10 | { 11 | 'employeeName': 'Jane Smith', 12 | 'projectName': 'AWS Redshift security' 13 | } 14 | >> 15 | --- 16 | OK! 17 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q6.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | p AS projectName 3 | FROM hr.employeesNestScalars AS e, 4 | e.projects AS p 5 | WHERE p LIKE '%security%' 6 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q7.env: -------------------------------------------------------------------------------- 1 | { 2 | 'matrices': << 3 | { 4 | 'id': 3, 5 | 'matrix': [ 6 | [2, 4, 6], 7 | [1, 3, 5, 7], 8 | [9, 0] 9 | ] 10 | }, 11 | { 12 | 'id': 4, 13 | 'matrix': [ 14 | [5, 8], 15 | [ ] 16 | ] 17 | 18 | } 19 | >> 20 | } 21 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q7.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 3, 4 | 'even': 2 5 | }, 6 | { 7 | 'id': 3, 8 | 'even': 4 9 | }, 10 | { 11 | 'id': 3, 12 | 'even': 6 13 | }, 14 | { 15 | 'id': 3, 16 | 'even': 0 17 | }, 18 | { 19 | 'id': 4, 20 | 'even': 8 21 | } 22 | >> 23 | --- 24 | OK! 25 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q7.sql: -------------------------------------------------------------------------------- 1 | SELECT t.id AS id, 2 | x AS even 3 | FROM matrices AS t, 4 | t.matrix AS y, 5 | y AS x 6 | WHERE x % 2 = 0 7 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q8.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesWithMissing': << 4 | { 'id': 3, 'name': 'Bob Smith' }, -- no title in this tuple 5 | { 'id': 4, 'name': 'Susan Smith', 'title': 'Dev Mgr' }, 6 | { 'id': 6, 'name': 'Jane Smith', 'title': 'Software Eng 2'} 7 | >> 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q8.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 4, 4 | 'employeeName': 'Susan Smith', 5 | 'title': 'Dev Mgr' 6 | } 7 | >> 8 | --- 9 | OK! 10 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q8.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id, 2 | e.name AS employeeName, 3 | e.title AS title 4 | FROM hr.employeesWithMissing AS e 5 | WHERE e.title = 'Dev Mgr' 6 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q9.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesWithMissing': << 4 | { 'id': 3, 'name': 'Bob Smith' }, -- no title in this tuple 5 | { 'id': 4, 'name': 'Susan Smith', 'title': 'Dev Mgr' }, 6 | { 'id': 6, 'name': 'Jane Smith', 'title': 'Software Eng 2'} 7 | >> 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q9.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 3, 4 | 'employeeName': 'Bob Smith' 5 | }, 6 | { 7 | 'id': 4, 8 | 'employeeName': 'Susan Smith', 9 | 'outputTitle': 'Dev Mgr' 10 | }, 11 | { 12 | 'id': 6, 13 | 'employeeName': 'Jane Smith', 14 | 'outputTitle': 'Software Eng 2' 15 | } 16 | >> 17 | --- 18 | OK! 19 | -------------------------------------------------------------------------------- /docs/wiki/assets/code/q9.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id, 2 | e.name AS employeeName, 3 | e.title AS outputTitle 4 | FROM hr.employeesWithMissing AS e 5 | -------------------------------------------------------------------------------- /docs/wiki/documentation/Further Reading.md: -------------------------------------------------------------------------------- 1 | # Further Reading 2 | 3 | You can find valuable information in the links below: 4 | - [SQL++](http://db.ucsd.edu/wp-content/uploads/pdfs/375.pdf) 5 | - [Ion](http://amzn.github.io/ion-docs/) 6 | -------------------------------------------------------------------------------- /docs/wiki/upgrades/vA-to-vB-upgrade-template.md: -------------------------------------------------------------------------------- 1 | # vB (latest ) 2 | 3 | Fill in below sections with respect to most recent major version releases (e.g. if comparing v0.2.* with v0.3.*, list 4 | changes between v0.2.7 and v0.3.4). To keep consistency with other upgrade guides, 5 | * Omit commits related to tests and build-related changes 6 | * Move CLI/REPL changes to `cli-versions.md` document 7 | 8 | ## New features 9 | * 10 | 11 | ## Deprecated items 12 | * 13 | 14 | ## Misc/bug fixes 15 | * 16 | 17 | ## Breaking changes 18 | ### Breaking behavioral changes 19 | 1. 20 | 21 | ### Breaking API changes 22 | 1. -------------------------------------------------------------------------------- /docs/wiki/v1/TODO.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | 3 | This document has not yet been written. 4 | 5 | If you have a pressing need for the documentation you were looking for, please reach out by filing 6 | a GitHub Issue. Sorry for the inconvenience! 7 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/BaseExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | 3 | import org.junit.jupiter.api.Assertions.assertEquals 4 | import org.junit.jupiter.api.Test 5 | import org.partiql.examples.util.Example 6 | import java.io.ByteArrayOutputStream 7 | import java.io.PrintStream 8 | 9 | abstract class BaseExampleTest { 10 | abstract fun example(out: PrintStream): Example 11 | abstract val expected: String 12 | 13 | @Test 14 | fun test() { 15 | val outBuffer = ByteArrayOutputStream() 16 | 17 | example(PrintStream(outBuffer)).run() 18 | 19 | assertEquals(expected, outBuffer.toString("UTF-8")) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/CustomProceduresExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | 3 | import org.partiql.examples.util.Example 4 | import java.io.PrintStream 5 | 6 | class CustomProceduresExampleTest : BaseExampleTest() { 7 | override fun example(out: PrintStream): Example = CustomProceduresExample(out) 8 | 9 | override val expected = """ 10 | |Initial global session bindings: 11 | |Crew 1: 12 | | [{'name': 'Neil', 'mass': 80.5}, {'name': 'Buzz', 'mass': 72.3}, {'name': 'Michael', 'mass': 89.9}] 13 | |Crew 2: 14 | | [{'name': 'James', 'mass': 77.1}, {'name': 'Spock', 'mass': 81.6}] 15 | |Calculated moon weights: 16 | | [{'name': 'Neil', 'moonWeight': 13.3}, {'name': 'Buzz', 'moonWeight': 12.0}, {'name': 'Michael', 'moonWeight': 14.9}] 17 | | 18 | """.trimMargin() 19 | } 20 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/Evaluation.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/EvaluationWithBindingsTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | 3 | import org.partiql.examples.util.Example 4 | import java.io.PrintStream 5 | 6 | class EvaluationWithBindingsTest : BaseExampleTest() { 7 | override fun example(out: PrintStream): Example = EvaluationWithBindings(out) 8 | 9 | override val expected = """ 10 | |PartiQL query: 11 | | 'Hello, ' || user_name 12 | |global variables: 13 | | user_name => 'Homer Simpson' 14 | |result 15 | | 'Hello, Homer Simpson' 16 | | 17 | """.trimMargin() 18 | } 19 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/EvaluationWithLazyBindingsTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | 3 | import org.partiql.examples.util.Example 4 | import java.io.PrintStream 5 | 6 | class EvaluationWithLazyBindingsTest : BaseExampleTest() { 7 | override fun example(out: PrintStream): Example = EvaluationWithLazyBindings(out) 8 | 9 | override val expected = """ 10 | |PartiQL query: 11 | | SELECT p.name AS kitten_id FROM pets AS p WHERE age >= 4 12 | |global variables: 13 | | pets => [ { name: "Nibbler", age: 2 }, { name: "Hobbes", age: 6 } ] 14 | |result: 15 | | << 16 | | { 17 | | 'kitten_id': 'Hobbes' 18 | | } 19 | | >> 20 | | 21 | """.trimMargin() 22 | } 23 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/ParseAndAstSerDe.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/ParserErrorExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | 3 | import org.partiql.examples.util.Example 4 | import java.io.PrintStream 5 | 6 | class ParserErrorExampleTest : BaseExampleTest() { 7 | override fun example(out: PrintStream): Example = ParserErrorExample(out) 8 | 9 | override val expected = """ 10 | |Invalid PartiQL query: 11 | | SELECT 1 + 12 | |Error message: 13 | | Parser Error: at line 1, column 10: unexpected token found, PLUS : '+' 14 | |Error information: 15 | | errorCode: PARSE_UNEXPECTED_TOKEN 16 | | LINE_NUMBER: 1 17 | | COLUMN_NUMBER: 10 18 | | TOKEN_DESCRIPTION: PLUS 19 | | TOKEN_VALUE: 20 | | '+' 21 | | 22 | """.trimMargin() 23 | } 24 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/PartiQLCompilerPipelineAsyncExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | 3 | import org.partiql.examples.util.Example 4 | import java.io.PrintStream 5 | 6 | class PartiQLCompilerPipelineAsyncExampleTest : BaseExampleTest() { 7 | override fun example(out: PrintStream): Example = PartiQLCompilerPipelineAsyncExample(out) 8 | 9 | override val expected = """ 10 | |PartiQL query: 11 | | SELECT t.name FROM myTable AS t WHERE t.age > 20 12 | |result 13 | | << 14 | | { 15 | | 'name': 'tim' 16 | | } 17 | | >> 18 | | 19 | """.trimMargin() 20 | } 21 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/PartiQLCompilerPipelineAsyncJavaExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | 3 | import org.partiql.examples.util.Example 4 | import java.io.PrintStream 5 | 6 | class PartiQLCompilerPipelineAsyncJavaExampleTest : BaseExampleTest() { 7 | override fun example(out: PrintStream): Example = 8 | PartiQLCompilerPipelineAsyncJavaExample(out) 9 | 10 | override val expected = """ 11 | |PartiQL query: 12 | | SELECT t.name FROM myTable AS t WHERE t.age > 20 13 | |result 14 | | << 15 | | { 16 | | 'name': 'tim' 17 | | } 18 | | >> 19 | | 20 | """.trimMargin() 21 | } 22 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/PartialEvaluationVisitorTransformExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | 3 | import org.partiql.examples.util.Example 4 | import java.io.PrintStream 5 | 6 | class PartialEvaluationVisitorTransformExampleTest : BaseExampleTest() { 7 | override fun example(out: PrintStream): Example = PartialEvaluationVisitorTransformExample(out) 8 | 9 | override val expected = """ 10 | |Original AST: 11 | | (query (plus (lit 1) (lit 1))) 12 | |Transformed AST: 13 | | (query (lit 2)) 14 | | 15 | """.trimMargin() 16 | } 17 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/PreventJoinVisitorExampleTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | 3 | import org.partiql.examples.util.Example 4 | import java.io.PrintStream 5 | 6 | class PreventJoinVisitorExampleTest : BaseExampleTest() { 7 | override fun example(out: PrintStream): Example = PreventJoinVisitorExample(out) 8 | 9 | override val expected = """ 10 | |PartiQL query without JOINs: 11 | | SELECT foo FROM bar 12 | |Has joins: 13 | | false 14 | |PartiQL query with JOINs: 15 | | SELECT foo FROM bar CROSS JOIN bat 16 | |Has joins: 17 | | true 18 | | 19 | """.trimMargin() 20 | } 21 | -------------------------------------------------------------------------------- /examples/src/test/kotlin/org/partiql/examples/SimpleExpressionEvaluationTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.examples 2 | 3 | import org.partiql.examples.util.Example 4 | import java.io.PrintStream 5 | 6 | class SimpleExpressionEvaluationTest : BaseExampleTest() { 7 | override fun example(out: PrintStream): Example = SimpleExpressionEvaluation(out) 8 | 9 | override val expected = """ 10 | |PartiQL query: 11 | | 1 + 1 12 | |result 13 | | 2 14 | | 15 | """.trimMargin() 16 | } 17 | -------------------------------------------------------------------------------- /examples/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled = true 2 | junit.jupiter.execution.parallel.mode.default = concurrent 3 | junit.jupiter.execution.parallel.mode.classes.default = concurrent -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group=org.partiql 2 | version=1.3.1-SNAPSHOT 3 | 4 | ossrhUsername=EMPTY 5 | ossrhPassword=EMPTY 6 | 7 | org.gradle.parallel=true 8 | org.gradle.caching=true 9 | org.gradle.jvmargs=-Xmx4096M 10 | 11 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/partiql/partiql-lang-kotlin/8d556cad5c1fb17c453e7cb141ae08a31eb3dcd7/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /lib/sprout/src/main/kotlin/org/partiql/sprout/generator/target/kotlin/KotlinOptions.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.sprout.generator.target.kotlin 2 | 3 | /** 4 | * Generator options are entirely independent of the type definitions 5 | * 6 | * @property packageRoot 7 | */ 8 | class KotlinOptions( 9 | val packageRoot: String, 10 | val poems: List, 11 | val optIns: List = emptyList(), 12 | ) 13 | -------------------------------------------------------------------------------- /lib/sprout/src/main/kotlin/org/partiql/sprout/generator/target/kotlin/KotlinResult.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.sprout.generator.target.kotlin 2 | 3 | import org.partiql.sprout.generator.target.kotlin.spec.KotlinFileSpec 4 | 5 | class KotlinResult(private val specs: List) { 6 | 7 | fun write(action: (KotlinFileSpec) -> Unit) = specs.forEach(action) 8 | } 9 | -------------------------------------------------------------------------------- /lib/sprout/src/main/kotlin/org/partiql/sprout/parser/ion/note.txt: -------------------------------------------------------------------------------- 1 | This is the "ion" parser because it parses an Ion DSL. Developed but unpublished are parsers for other type modeling 2 | languages such as PIG's Ion DSL. So it's a bit funny now to have just this one internal `ion` package. 3 | -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/AstEnum.java: -------------------------------------------------------------------------------- 1 | package org.partiql.ast; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | /** 6 | * Abstract base class representing enums in the AST. 7 | */ 8 | public abstract class AstEnum extends AstNode { 9 | /** 10 | * The code of the enum. 11 | * @return the code of the enum. 12 | */ 13 | public abstract int code(); 14 | 15 | /** 16 | * String representation for the enum variant. 17 | * @return string representation for the enum variant. 18 | */ 19 | @NotNull 20 | public abstract String name(); 21 | } 22 | -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/FromTableRef.java: -------------------------------------------------------------------------------- 1 | package org.partiql.ast; 2 | 3 | /** 4 | * Base class for clauses within a FROM source. 5 | */ 6 | public abstract class FromTableRef extends AstNode {} 7 | -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/Select.java: -------------------------------------------------------------------------------- 1 | package org.partiql.ast; 2 | 3 | /** 4 | * Abstract base class for the SELECT clause. 5 | */ 6 | public abstract class Select extends AstNode {} 7 | -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/Statement.java: -------------------------------------------------------------------------------- 1 | package org.partiql.ast; 2 | 3 | /** 4 | * Abstract base class for PartiQL statements. 5 | */ 6 | public abstract class Statement extends AstNode {} 7 | -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/ddl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Data definition language (DDL) AST nodes. 3 | */ 4 | package org.partiql.ast.ddl; -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/dml/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Data manipulation language AST nodes. 3 | */ 4 | package org.partiql.ast.dml; -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/expr/Expr.java: -------------------------------------------------------------------------------- 1 | package org.partiql.ast.expr; 2 | 3 | import org.partiql.ast.AstNode; 4 | 5 | /** 6 | * This is the base class for all PartiQL expressions. 7 | */ 8 | public abstract class Expr extends AstNode {} 9 | -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/expr/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * AST nodes for PartiQL expressions. 3 | */ 4 | package org.partiql.ast.expr; -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/graph/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Graph query (GPML) AST nodes. 3 | *

4 | * Note: the public APIs in this package are experimental and subject to change without prior notice. 5 | *

6 | */ 7 | package org.partiql.ast.graph; -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Abstract syntax tree (AST) object model for PartiQL statements. 3 | */ 4 | package org.partiql.ast; -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/sql/Sql.kt: -------------------------------------------------------------------------------- 1 | @file:JvmName("Sql") 2 | package org.partiql.ast.sql 3 | 4 | import org.partiql.ast.AstNode 5 | 6 | /** 7 | * Pretty-print this [AstNode] as SQL text with the given (or standard) [SqlLayout] and [SqlDialect]. 8 | * 9 | * @see SqlLayout 10 | * @see SqlDialect 11 | */ 12 | @JvmOverloads 13 | public fun AstNode.sql( 14 | layout: SqlLayout = SqlLayout.STANDARD, 15 | dialect: SqlDialect = SqlDialect.STANDARD, 16 | ): String = dialect.transform(this).sql(layout) 17 | 18 | /** 19 | * Write this [SqlBlock] tree as SQL text with the given [SqlLayout]. 20 | */ 21 | public fun SqlBlock.sql(layout: SqlLayout = SqlLayout.STANDARD): String = layout.print(this) 22 | -------------------------------------------------------------------------------- /partiql-ast/src/main/java/org/partiql/ast/sql/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Defines classes and interfaces relevant for AST pretty-printing. 3 | */ 4 | package org.partiql.ast.sql; -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q1.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employees': << 4 | -- a tuple is denoted by { ... } in the PartiQL data model 5 | { 'id': 3, 'name': 'Bob Smith', 'title': null }, 6 | { 'id': 4, 'name': 'Susan Smith', 'title': 'Dev Mgr' }, 7 | { 'id': 6, 'name': 'Jane Smith', 'title': 'Software Eng 2'} 8 | >> 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q1.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 4, 4 | 'employeeName': 'Susan Smith', 5 | 'title': 'Dev Mgr' 6 | } 7 | >> 8 | --- 9 | OK! 10 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q1.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id, 2 | e.name AS employeeName, 3 | e.title AS title 4 | FROM hr.employees e 5 | WHERE e.title = 'Dev Mgr' 6 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q10.env: -------------------------------------------------------------------------------- 1 | q8.env -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q10.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 3, 4 | 'employeeName': 'Bob Smith', 5 | 'outputTitle': NULL 6 | }, 7 | { 8 | 'id': 4, 9 | 'employeeName': 'Susan Smith', 10 | 'outputTitle': 'DEV MGR' 11 | }, 12 | { 13 | 'id': 6, 14 | 'employeeName': 'Jane Smith', 15 | 'outputTitle': 'SOFTWARE ENG 2' 16 | } 17 | >> 18 | --- 19 | OK! 20 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q10.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id, 2 | e.name AS employeeName, 3 | UPPER(e.title) AS outputTitle 4 | FROM hr.employeesWithMissing AS e 5 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q11.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesMixed2': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ 9 | { 'name': 'AWS Redshift Spectrum querying' }, 10 | 'AWS Redshift security', 11 | { 'name': 'AWS Aurora security' } 12 | ] 13 | }, 14 | { 15 | 'id': 4, 16 | 'name': 'Susan Smith', 17 | 'title': 'Dev Mgr', 18 | 'projects': [] 19 | }, 20 | { 21 | 'id': 6, 22 | 'name': 'Jane Smith', 23 | 'projects': [ 'AWS Redshift security'] 24 | } 25 | >> 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q11.output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/partiql/partiql-lang-kotlin/8d556cad5c1fb17c453e7cb141ae08a31eb3dcd7/partiql-cli/archive/Tutorial/code/q11.output -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q11.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | CASE WHEN (p IS TUPLE) THEN p.name 3 | ELSE p END AS projectName 4 | FROM hr.employeesMixed2 AS e, 5 | e.projects AS p 6 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q12.env: -------------------------------------------------------------------------------- 1 | q2.env -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q12.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'firstProjectName': 'AWS Redshift Spectrum querying' 5 | }, 6 | { 7 | 'employeeName': 'Susan Smith' 8 | }, 9 | { 10 | 'employeeName': 'Jane Smith', 11 | 'firstProjectName': 'AWS Redshift security' 12 | } 13 | >> 14 | --- 15 | OK! 16 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q12.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | e.projects[0].name AS firstProjectName 3 | FROM hr.employeesNest AS e 4 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q13.env: -------------------------------------------------------------------------------- 1 | q2.env -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q13.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'projectName': 'AWS Redshift security', 5 | 'projectPriority': 1 6 | }, 7 | { 8 | 'employeeName': 'Bob Smith', 9 | 'projectName': 'AWS Aurora security', 10 | 'projectPriority': 2 11 | }, 12 | { 13 | 'employeeName': 'Jane Smith', 14 | 'projectName': 'AWS Redshift security', 15 | 'projectPriority': 0 16 | } 17 | >> 18 | --- 19 | OK! 20 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q13.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | p.name AS projectName, 3 | o AS projectPriority 4 | FROM hr.employeesNest AS e, 5 | e.projects AS p AT o 6 | WHERE p.name LIKE '%security%' 7 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q14.env: -------------------------------------------------------------------------------- 1 | { 2 | 'closingPrices': << 3 | { 'date': '4/1/2019', 'amzn': 1900, 'goog': 1120, 'fb': 180 }, 4 | { 'date': '4/2/2019', 'amzn': 1902, 'goog': 1119, 'fb': 183 } 5 | >> 6 | } 7 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q14.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'date': '4/1/2019', 4 | 'symbol': 'amzn', 5 | 'price': 1900 6 | }, 7 | { 8 | 'date': '4/1/2019', 9 | 'symbol': 'goog', 10 | 'price': 1120 11 | }, 12 | { 13 | 'date': '4/1/2019', 14 | 'symbol': 'fb', 15 | 'price': 180 16 | }, 17 | { 18 | 'date': '4/2/2019', 19 | 'symbol': 'amzn', 20 | 'price': 1902 21 | }, 22 | { 23 | 'date': '4/2/2019', 24 | 'symbol': 'goog', 25 | 'price': 1119 26 | }, 27 | { 28 | 'date': '4/2/2019', 29 | 'symbol': 'fb', 30 | 'price': 183 31 | } 32 | >> 33 | --- 34 | OK! 35 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q14.sql: -------------------------------------------------------------------------------- 1 | SELECT c."date" AS "date", 2 | sym AS "symbol", 3 | price AS price 4 | FROM closingPrices AS c, 5 | UNPIVOT c AS price AT sym 6 | WHERE NOT sym = 'date' 7 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q15.env: -------------------------------------------------------------------------------- 1 | { 2 | 'todaysStockPrices': << 3 | { 'symbol': 'amzn', 'price': 1900}, 4 | { 'symbol': 'goog', 'price': 1120}, 5 | { 'symbol': 'fb', 'price': 180 } 6 | >> 7 | } 8 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q15.output: -------------------------------------------------------------------------------- 1 | { 2 | 'amzn': 1900, 3 | 'goog': 1120, 4 | 'fb': 180 5 | } 6 | --- 7 | OK! 8 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q15.sql: -------------------------------------------------------------------------------- 1 | PIVOT sp.price AT sp."symbol" 2 | FROM todaysStockPrices sp 3 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q16.env: -------------------------------------------------------------------------------- 1 | { 2 | 'stockPrices':<< 3 | { 'date': '4/1/2019', 'symbol': 'amzn', 'price': 1900}, 4 | { 'date': '4/1/2019', 'symbol': 'goog', 'price': 1120}, 5 | { 'date': '4/1/2019', 'symbol': 'fb', 'price': 180 }, 6 | { 'date': '4/2/2019', 'symbol': 'amzn', 'price': 1902}, 7 | { 'date': '4/2/2019', 'symbol': 'goog', 'price': 1119}, 8 | { 'date': '4/2/2019', 'symbol': 'fb', 'price': 183 } 9 | >> 10 | } 11 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q16.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'date': date(4/1/2019), 4 | 'prices': {'amzn': 1900, 'goog': 1120, 'fb': 180} 5 | }, 6 | { 7 | 'date': date(4/2/2019), 8 | 'prices': {'amzn': 1902, 'goog': 1119, 'fb': 183} 9 | } 10 | >> 11 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q16.sql: -------------------------------------------------------------------------------- 1 | SELECT sp."date" AS "date", 2 | (PIVOT dp.sp.price AT dp.sp."symbol" 3 | FROM datesPrices as dp ) AS prices 4 | FROM StockPrices AS sp GROUP BY sp."date" GROUP AS datesPrices 5 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q17.env: -------------------------------------------------------------------------------- 1 | q6.env -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q17.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 3, 4 | 'name': 'Bob Smith', 5 | 'title': NULL, 6 | 'securityProjects': << 7 | 'AWS Redshift security', 8 | 'AWS Aurora security' 9 | >> 10 | }, 11 | { 12 | 'id': 4, 13 | 'name': 'Susan Smith', 14 | 'title': 'Dev Mgr', 15 | 'securityProjects': <<>> 16 | }, 17 | { 18 | 'id': 6, 19 | 'name': 'Jane Smith', 20 | 'title': 'Software Eng 2', 21 | 'securityProjects': << 22 | 'AWS Redshift security' 23 | >> 24 | } 25 | >> 26 | --- 27 | OK! 28 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q17.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id AS id, 2 | e.name AS name, 3 | e.title AS title, 4 | ( SELECT VALUE p 5 | FROM e.projects AS p 6 | WHERE p LIKE '%security%' 7 | ) AS securityProjects 8 | FROM hr.employeesNestScalars AS e 9 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q18.env: -------------------------------------------------------------------------------- 1 | q6.env -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q18.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'projectName': 'AWS Aurora security', 4 | 'employees': << 5 | 'Bob Smith' 6 | >> 7 | }, 8 | { 9 | 'projectName': 'AWS Redshift security', 10 | 'employees': << 11 | 'Bob Smith', 12 | 'Jane Smith' 13 | >> 14 | } 15 | >> 16 | --- 17 | OK! 18 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q18.sql: -------------------------------------------------------------------------------- 1 | SELECT p AS projectName, 2 | ( SELECT VALUE v.e.name 3 | FROM perProjectGroup AS v ) AS employees 4 | FROM hr.employeesNestScalars AS e JOIN e.projects AS p ON p LIKE '%security%' 5 | GROUP BY p GROUP AS perProjectGroup 6 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q2.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesNest': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ { 'name': 'AWS Redshift Spectrum querying' }, 9 | { 'name': 'AWS Redshift security' }, 10 | { 'name': 'AWS Aurora security' } 11 | ] 12 | }, 13 | { 14 | 'id': 4, 15 | 'name': 'Susan Smith', 16 | 'title': 'Dev Mgr', 17 | 'projects': [] 18 | }, 19 | { 20 | 'id': 6, 21 | 'name': 'Jane Smith', 22 | 'title': 'Software Eng 2', 23 | 'projects': [ { 'name': 'AWS Redshift security' } ] 24 | } 25 | >> 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q2.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'projectName': 'AWS Redshift security' 5 | }, 6 | { 7 | 'employeeName': 'Bob Smith', 8 | 'projectName': 'AWS Aurora security' 9 | }, 10 | { 11 | 'employeeName': 'Jane Smith', 12 | 'projectName': 'AWS Redshift security' 13 | } 14 | >> 15 | --- 16 | OK! 17 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q2.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | p.name AS projectName 3 | FROM hr.employeesNest AS e, 4 | e.projects AS p 5 | WHERE p.name LIKE '%security%' 6 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q3.env: -------------------------------------------------------------------------------- 1 | q2.env -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q3.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 3, 4 | 'employeeName': 'Bob Smith', 5 | 'title': NULL, 6 | 'projectName': 'AWS Redshift Spectrum querying' 7 | }, 8 | { 9 | 'id': 3, 10 | 'employeeName': 'Bob Smith', 11 | 'title': NULL, 12 | 'projectName': 'AWS Redshift security' 13 | }, 14 | { 15 | 'id': 3, 16 | 'employeeName': 'Bob Smith', 17 | 'title': NULL, 18 | 'projectName': 'AWS Aurora security' 19 | }, 20 | { 21 | 'id': 4, 22 | 'employeeName': 'Susan Smith', 23 | 'title': 'Dev Mgr' 24 | }, 25 | { 26 | 'id': 6, 27 | 'employeeName': 'Jane Smith', 28 | 'title': 'Software Eng 2', 29 | 'projectName': 'AWS Redshift security' 30 | } 31 | >> 32 | --- 33 | OK! 34 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q3.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id AS id, 2 | e.name AS employeeName, 3 | e.title AS title, 4 | p.name AS projectName 5 | FROM hr.employeesNest AS e LEFT JOIN e.projects AS p ON true 6 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q4.env: -------------------------------------------------------------------------------- 1 | q2.env -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q4.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'queryProjectsNum': 1 5 | }, 6 | { 7 | 'employeeName': 'Susan Smith', 8 | 'queryProjectsNum': 0 9 | }, 10 | { 11 | 'employeeName': 'Jane Smith', 12 | 'queryProjectsNum': 0 13 | } 14 | >> 15 | --- 16 | OK! 17 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q4.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | COUNT(p.name) AS queryProjectsNum 3 | FROM hr.employeesNest e LEFT JOIN e.projects AS p ON p.name LIKE '%querying%' 4 | GROUP BY e.id, e.name 5 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q5.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesWithTuples': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'project': { 9 | 'name': 'AWS Redshift Spectrum querying', 10 | 'org': 'AWS' 11 | } 12 | }, 13 | { 14 | 'id': 6, 15 | 'name': 'Jane Smith', 16 | 'title': 'Software Eng 2', 17 | 'project': { 18 | 'name': 'AWS Redshift security', 19 | 'org': 'AWS' 20 | } 21 | } 22 | >> 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q5.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'projectName': 'AWS Redshift Spectrum querying' 5 | }, 6 | { 7 | 'employeeName': 'Jane Smith', 8 | 'projectName': 'AWS Redshift security' 9 | } 10 | >> 11 | --- 12 | OK! 13 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q5.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | e.project.name AS projectName 3 | FROM hr.employeesWithTuples e 4 | WHERE e.project.org = 'AWS' 5 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q6.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesNestScalars': << 4 | { 5 | 'id': 3, 6 | 'name': 'Bob Smith', 7 | 'title': null, 8 | 'projects': [ 9 | 'AWS Redshift Spectrum querying', 10 | 'AWS Redshift security', 11 | 'AWS Aurora security' 12 | ] 13 | }, 14 | { 15 | 'id': 4, 16 | 'name': 'Susan Smith', 17 | 'title': 'Dev Mgr', 18 | 'projects': [] 19 | }, 20 | { 21 | 'id': 6, 22 | 'name': 'Jane Smith', 23 | 'title': 'Software Eng 2', 24 | 'projects': [ 'AWS Redshift security' ] 25 | } 26 | >> 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q6.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'employeeName': 'Bob Smith', 4 | 'projectName': 'AWS Redshift security' 5 | }, 6 | { 7 | 'employeeName': 'Bob Smith', 8 | 'projectName': 'AWS Aurora security' 9 | }, 10 | { 11 | 'employeeName': 'Jane Smith', 12 | 'projectName': 'AWS Redshift security' 13 | } 14 | >> 15 | --- 16 | OK! 17 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q6.sql: -------------------------------------------------------------------------------- 1 | SELECT e.name AS employeeName, 2 | p AS projectName 3 | FROM hr.employeesNestScalars AS e, 4 | e.projects AS p 5 | WHERE p LIKE '%security%' 6 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q7.env: -------------------------------------------------------------------------------- 1 | { 2 | 'matrices': << 3 | { 4 | 'id': 3, 5 | 'matrix': [ 6 | [2, 4, 6], 7 | [1, 3, 5, 7], 8 | [9, 0] 9 | ] 10 | }, 11 | { 12 | 'id': 4, 13 | 'matrix': [ 14 | [5, 8], 15 | [ ] 16 | ] 17 | 18 | } 19 | >> 20 | } 21 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q7.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 3, 4 | 'even': 2 5 | }, 6 | { 7 | 'id': 3, 8 | 'even': 4 9 | }, 10 | { 11 | 'id': 3, 12 | 'even': 6 13 | }, 14 | { 15 | 'id': 3, 16 | 'even': 0 17 | }, 18 | { 19 | 'id': 4, 20 | 'even': 8 21 | } 22 | >> 23 | --- 24 | OK! 25 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q7.sql: -------------------------------------------------------------------------------- 1 | SELECT t.id AS id, 2 | x AS even 3 | FROM matrices AS t, 4 | t.matrix AS y, 5 | y AS x 6 | WHERE x % 2 = 0 7 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q8.env: -------------------------------------------------------------------------------- 1 | { 2 | 'hr': { 3 | 'employeesWithMissing': << 4 | { 'id': 3, 'name': 'Bob Smith' }, -- no title in this tuple 5 | { 'id': 4, 'name': 'Susan Smith', 'title': 'Dev Mgr' }, 6 | { 'id': 6, 'name': 'Jane Smith', 'title': 'Software Eng 2'} 7 | >> 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q8.out: -------------------------------------------------------------------------------- 1 | << 2 | { 'id': 4, 'employeeName': 'Susan Smith', 'title': 'Dev Mgr' }, 3 | { 'id': 6, 'employeeName': 'Jane Smith', 'title': 'Software Eng 2'} 4 | >> 5 | 6 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q8.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 4, 4 | 'employeeName': 'Susan Smith', 5 | 'title': 'Dev Mgr' 6 | } 7 | >> 8 | --- 9 | OK! 10 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q8.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id, 2 | e.name AS employeeName, 3 | e.title AS title 4 | FROM hr.employeesWithMissing AS e 5 | WHERE e.title = 'Dev Mgr' 6 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q9.env: -------------------------------------------------------------------------------- 1 | q8.env -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q9.output: -------------------------------------------------------------------------------- 1 | << 2 | { 3 | 'id': 3, 4 | 'employeeName': 'Bob Smith' 5 | }, 6 | { 7 | 'id': 4, 8 | 'employeeName': 'Susan Smith', 9 | 'outputTitle': 'Dev Mgr' 10 | }, 11 | { 12 | 'id': 6, 13 | 'employeeName': 'Jane Smith', 14 | 'outputTitle': 'Software Eng 2' 15 | } 16 | >> 17 | --- 18 | OK! 19 | -------------------------------------------------------------------------------- /partiql-cli/archive/Tutorial/code/q9.sql: -------------------------------------------------------------------------------- 1 | SELECT e.id, 2 | e.name AS employeeName, 3 | e.title AS outputTitle 4 | FROM hr.employeesWithMissing AS e 5 | -------------------------------------------------------------------------------- /partiql-cli/examples/graph-bad-ion.ion: -------------------------------------------------------------------------------- 1 | { ( } 2 | -------------------------------------------------------------------------------- /partiql-cli/examples/graph-bad-isl.ion: -------------------------------------------------------------------------------- 1 | { nodes: [] } 2 | -------------------------------------------------------------------------------- /partiql-cli/examples/graph-empty.ion: -------------------------------------------------------------------------------- 1 | { nodes: [], edges: [] } 2 | -------------------------------------------------------------------------------- /partiql-cli/examples/graph-g1.ion: -------------------------------------------------------------------------------- 1 | // single-node no-edges graph: n1 2 | 3 | { nodes: [ {id: n1, labels: ["a"], payload: 1} ], 4 | edges: [] } 5 | -------------------------------------------------------------------------------- /partiql-cli/examples/graph-g1L.ion: -------------------------------------------------------------------------------- 1 | // single-node self-loop graph: --> n1 --[e11]-- 2 | // |---------------| 3 | 4 | { nodes: [ {id: n1, labels: ["a"], payload: 1} ], 5 | edges: [ {id: e11, labels: ["e"], payload: 1.1, ends: (n1 -> n1) } ] } 6 | 7 | -------------------------------------------------------------------------------- /partiql-cli/examples/graph-g2.ion: -------------------------------------------------------------------------------- 1 | // n1 ---[e12]--> n2 2 | 3 | { nodes: [ {id: n1, labels: ["a"], payload: 1}, 4 | {id: n2, labels: ["b"], payload: 2} ], 5 | edges: [ {id: e12, labels: ["e"], payload: 1.2, ends: (n1 -> n2) } ] } 6 | -------------------------------------------------------------------------------- /partiql-cli/examples/graph-g3.ion: -------------------------------------------------------------------------------- 1 | // a triangle: n2 ~~[e23]~~ n3 2 | // \ / 3 | // [e21] [e31] 4 | // \ / 5 | // v v 6 | // n1 7 | 8 | { nodes: [ {id: n1, labels: ["a"], payload: 1}, 9 | {id: n2, labels: ["b"], payload: 2}, 10 | {id: n3, labels: ["a", "b"], payload: 3} ], 11 | edges: [ {id: e21, labels: ["d"], payload: 2.1, ends: (n2 -> n1) }, 12 | {id: e31, labels: ["e"], payload: 3.1, ends: (n3 -> n1) }, 13 | {id: e23, labels: ["e"], payload: 2.3, ends: (n2 -- n3) } ] } 14 | -------------------------------------------------------------------------------- /partiql-cli/examples/rfc0025-example.ion: -------------------------------------------------------------------------------- 1 | // This is the graph that appears as an example in PartiQL RFC-0025 2 | // https://github.com/partiql/partiql-docs/blob/main/RFCs/0025-graph-data-model.md 3 | 4 | graph::{ 5 | nodes: [ 6 | { id: n1, labels: ["a"] }, 7 | { id: n2, labels: ["a"] }, 8 | { id: n3, labels: ["b"] } 9 | ], 10 | 11 | edges: [ 12 | { id: e1, labels: ["x"], ends: (n2 -> n1) }, 13 | { id: e2, labels: ["y"], ends: (n1 -> n3) }, 14 | { id: e3, labels: ["y"], ends: (n2 -> n3) } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /partiql-cli/partiql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2022 Amazon.com, Inc. or its affiliates. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"). 6 | # You may not use this file except in compliance with the License. 7 | # A copy of the License is located at: 8 | # 9 | # http://aws.amazon.com/apache2.0/ 10 | # 11 | # or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 13 | # language governing permissions and limitations under the License. 14 | # 15 | 16 | cli_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) 17 | 18 | cd "$cli_path" 19 | ../gradlew :partiql-cli:install 20 | ../partiql-cli/build/install/partiql-cli/bin/partiql "$@" 21 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/junit-platform.properties: -------------------------------------------------------------------------------- 1 | junit.jupiter.execution.parallel.enabled = true 2 | junit.jupiter.execution.parallel.mode.default = concurrent 3 | junit.jupiter.execution.parallel.mode.classes.default = concurrent -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/csv_with_empty_lines.csv: -------------------------------------------------------------------------------- 1 | 1,2 2 | 3 | 3 4 | 5 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/customized.csv: -------------------------------------------------------------------------------- 1 | id name balance 2 | 1 Bob 10000.00 3 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/customized_escape.csv: -------------------------------------------------------------------------------- 1 | id,name,balance 2 | "/"1",Bob,10000.00 3 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/customized_ignore_empty.csv: -------------------------------------------------------------------------------- 1 | id,name,balance 2 | 3 | 1,Bob,10000.00 4 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/customized_ignore_surrounding.csv: -------------------------------------------------------------------------------- 1 | id,name,balance 2 | 1 , Bob , 10000.00 -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/customized_line_breaker.csv: -------------------------------------------------------------------------------- 1 | id,name,balance 2 | 1,Bob,10000.00 3 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/customized_quote.csv: -------------------------------------------------------------------------------- 1 | id,name,balance 2 | '1,',Bob,10000.00 3 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/data.csv: -------------------------------------------------------------------------------- 1 | 1,2 2 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/data.ion: -------------------------------------------------------------------------------- 1 | 1 2 2 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/data.tsv: -------------------------------------------------------------------------------- 1 | 1 2 2 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/data_list.ion: -------------------------------------------------------------------------------- 1 | [1, 2] 2 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/data_with_double_quotes_escape.csv: -------------------------------------------------------------------------------- 1 | "1,2",2 2 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/data_with_header_line.csv: -------------------------------------------------------------------------------- 1 | col1,col2 2 | 1,2 3 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/data_with_header_line.tsv: -------------------------------------------------------------------------------- 1 | col1 col2 2 | 1 2 3 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/data_with_ion_symbol_as_input.csv: -------------------------------------------------------------------------------- 1 | 1,2 2 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/simple_excel.csv: -------------------------------------------------------------------------------- 1 | title,category,price 2 | harry potter,book,7.99 3 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/simple_mysql.csv: -------------------------------------------------------------------------------- 1 | id name balance 2 | 1 B"ob 10000.00 3 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/simple_postgresql.csv: -------------------------------------------------------------------------------- 1 | id,name,balance 2 | 1,B""ob,10000.00 3 | -------------------------------------------------------------------------------- /partiql-cli/src/test/resources/read_file_tests/simple_postgresql.txt: -------------------------------------------------------------------------------- 1 | id name balance 2 | 1 Bob 10000.00 3 | -------------------------------------------------------------------------------- /partiql-coverage/api/partiql-coverage.api: -------------------------------------------------------------------------------- 1 | public abstract interface annotation class org/partiql/coverage/api/PartiQLTest : java/lang/annotation/Annotation { 2 | public abstract fun provider ()Ljava/lang/Class; 3 | } 4 | 5 | public abstract interface class org/partiql/coverage/api/PartiQLTestCase { 6 | public abstract fun getSession ()Lorg/partiql/lang/eval/EvaluationSession; 7 | } 8 | 9 | public abstract interface class org/partiql/coverage/api/PartiQLTestProvider { 10 | public abstract fun getPipelineBuilder ()Lorg/partiql/lang/CompilerPipeline$Builder; 11 | public abstract fun getStatement ()Ljava/lang/String; 12 | public abstract fun getTestCases ()Ljava/lang/Iterable; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /partiql-coverage/src/main/resources/META-INF/services/org.junit.platform.launcher.LauncherSessionListener: -------------------------------------------------------------------------------- 1 | org.partiql.coverage.api.impl.PostProcessor 2 | -------------------------------------------------------------------------------- /partiql-coverage/src/main/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener: -------------------------------------------------------------------------------- 1 | org.partiql.coverage.api.impl.LcovReportListener$LcovReportBranchListener 2 | org.partiql.coverage.api.impl.LcovReportListener$LcovReportConditionListener 3 | -------------------------------------------------------------------------------- /partiql-eval/src/main/java/org/partiql/eval/Expr.java: -------------------------------------------------------------------------------- 1 | package org.partiql.eval; 2 | 3 | /** 4 | * Physical operators are implementations for one (or more) logical operators. 5 | */ 6 | public interface Expr {} 7 | -------------------------------------------------------------------------------- /partiql-eval/src/main/java/org/partiql/eval/ExprValue.java: -------------------------------------------------------------------------------- 1 | package org.partiql.eval; 2 | 3 | import org.partiql.spi.value.Datum; 4 | 5 | /** 6 | * ExprValue is the interface for an expression (physical operator) that returns a value. 7 | */ 8 | public interface ExprValue extends Expr { 9 | 10 | /** 11 | * Evaluate the expression for the given environment. 12 | * 13 | * @param env The current environment. 14 | * @return The expression result. 15 | */ 16 | public Datum eval(Environment env); 17 | } 18 | -------------------------------------------------------------------------------- /partiql-eval/src/main/java/org/partiql/eval/WindowPartition.java: -------------------------------------------------------------------------------- 1 | package org.partiql.eval; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | /** 6 | * Represents a partition of rows within a window. 7 | * @deprecated This feature is experimental and is subject to change. 8 | */ 9 | @Deprecated 10 | public interface WindowPartition { 11 | 12 | /** 13 | * Returns the number of rows in this partition. 14 | * @return the number of rows in this partition. 15 | */ 16 | long size(); 17 | 18 | /** 19 | * Retrieves the row at the given index. 20 | * @param index the index of the row to retrieve. Partitions are 0-indexed. 21 | * @throws RuntimeException if index is out of bounds 22 | * @return the row at the given index 23 | */ 24 | @NotNull 25 | Row get(long index) throws RuntimeException; 26 | } 27 | -------------------------------------------------------------------------------- /partiql-eval/src/main/java/org/partiql/eval/compiler/Match.java: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.compiler; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.partiql.plan.Operand; 5 | 6 | /** 7 | * Match represents a subtree match to be sent to the {@link Strategy}. 8 | */ 9 | public class Match { 10 | 11 | private final Operand[] operands; 12 | 13 | /** 14 | * Single operand match with zero-or-more inputs. 15 | * 16 | * @param operand matched logical operand. 17 | */ 18 | public Match(@NotNull Operand operand) { 19 | this.operands = new Operand[]{operand}; 20 | } 21 | 22 | /** 23 | * Get the first (or only) operand 24 | * 25 | * @return Operand 26 | */ 27 | @NotNull 28 | public Operand getOperand() { 29 | return operands[0]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/DatumArrayComparator.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.helpers 2 | 3 | import org.partiql.spi.value.Datum 4 | 5 | internal object DatumArrayComparator : Comparator> { 6 | private val delegate = Datum.comparator(false) 7 | override fun compare(o1: Array, o2: Array): Int { 8 | if (o1.size < o2.size) { 9 | return -1 10 | } 11 | if (o1.size > o2.size) { 12 | return 1 13 | } 14 | for (index in 0..o2.lastIndex) { 15 | val element1 = o1[index] 16 | val element2 = o2[index] 17 | val compared = delegate.compare(element1, element2) 18 | if (compared != 0) { 19 | return compared 20 | } 21 | } 22 | return 0 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/IteratorSupplier.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.helpers 2 | 3 | internal class IteratorSupplier(private val supplier: () -> Iterator) : Iterable { 4 | override fun iterator(): Iterator { 5 | return supplier.invoke() 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/RecordUtility.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.helpers 2 | 3 | import org.partiql.spi.value.Datum 4 | 5 | internal object RecordUtility { 6 | /** 7 | * Coerces missing values into null values. Currently used when the [Datum.comparator] is used in a TreeSet/TreeMap 8 | * (treats null and missing as the same value) and we need to deterministically return a value. Here we use coerce 9 | * to null to follow the PartiQL spec's grouping function. 10 | */ 11 | fun Array.coerceMissing() { 12 | for (i in indices) { 13 | if (this[i].isMissing) { 14 | this[i] = Datum.nullValue() 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/helpers/RecordValueIterator.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.helpers 2 | 3 | import org.partiql.eval.Row 4 | import org.partiql.spi.value.Datum 5 | 6 | /** 7 | * An [Iterator] over an [Iterator] lazily producing [Row]s as you call [next]. 8 | */ 9 | internal class RecordValueIterator( 10 | collectionValue: Iterator 11 | ) : Iterator { 12 | 13 | private val collectionIter = collectionValue.iterator() 14 | 15 | override fun hasNext(): Boolean = collectionIter.hasNext() 16 | 17 | override fun next(): Row = 18 | Row(Array(1) { collectionIter.next() }) 19 | } 20 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/Aggregate.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator 2 | 3 | import org.partiql.eval.ExprValue 4 | import org.partiql.spi.function.Agg 5 | 6 | /** 7 | * Simple data class to hold a compile aggregation call. 8 | */ 9 | internal class Aggregate( 10 | val agg: Agg, 11 | val args: List, 12 | val distinct: Boolean 13 | ) 14 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/Collation.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rel 2 | 3 | import org.partiql.eval.ExprValue 4 | 5 | /** 6 | * DO NOT USE FINAL. 7 | * 8 | * @property expr The expression to sort by.. 9 | * @property desc True iff DESC sort, otherwise ASC. 10 | * @property last True iff NULLS LAST sort, otherwise NULLS FIRST. 11 | */ 12 | internal class Collation( 13 | @JvmField var expr: ExprValue, 14 | @JvmField var desc: Boolean, 15 | @JvmField var last: Boolean, 16 | ) 17 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprArray.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.spi.value.Datum 6 | 7 | /** 8 | * Creates an array by evaluating each input value expression. 9 | */ 10 | internal class ExprArray(values: List) : 11 | ExprValue { 12 | 13 | // DO NOT USE FINAL 14 | private var _values = values 15 | 16 | override fun eval(env: Environment): Datum = Datum.array(_values.map { it.eval(env) }) 17 | } 18 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprBag.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.spi.value.Datum 6 | 7 | /** 8 | * Creates a bag by evaluating each input value expression. 9 | */ 10 | internal class ExprBag(values: List) : 11 | ExprValue { 12 | 13 | // DO NOT USE FINAL 14 | private var _values = values 15 | 16 | override fun eval(env: Environment): Datum = Datum.bag(_values.map { it.eval(env) }) 17 | } 18 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprCast.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.spi.types.PType 6 | import org.partiql.spi.value.Datum 7 | 8 | /** 9 | * Implementation of a CAST expression. 10 | * 11 | * @constructor 12 | * TODO 13 | * 14 | * @param operand 15 | * @param target 16 | */ 17 | internal class ExprCast(operand: ExprValue, target: PType) : 18 | ExprValue { 19 | 20 | // DO NOT USE FINAL 21 | private var _operand = operand 22 | private var _target = target 23 | 24 | override fun eval(env: Environment): Datum { 25 | return CastTable.cast(_operand.eval(env), _target) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprCoalesce.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.spi.value.Datum 6 | 7 | internal class ExprCoalesce( 8 | private val args: Array 9 | ) : ExprValue { 10 | 11 | override fun eval(env: Environment): Datum { 12 | for (arg in args) { 13 | val result = arg.eval(env) 14 | if (!result.isNull && !result.isMissing) { 15 | return result 16 | } 17 | } 18 | return Datum.nullValue() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprError.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.eval.internal.helpers.PErrors 6 | import org.partiql.spi.value.Datum 7 | 8 | internal class ExprError : ExprValue { 9 | override fun eval(env: Environment): Datum { 10 | // TODO: Add error to ExprError 11 | throw PErrors.internalErrorException(IllegalStateException("A warning has been converted into an error.")) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprLit.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.spi.value.Datum 6 | 7 | /** 8 | * Literal expression. 9 | */ 10 | internal class ExprLit(value: Datum) : ExprValue { 11 | 12 | // DO NOT USE FINAL 13 | private var _value = value 14 | 15 | override fun eval(env: Environment): Datum = _value 16 | } 17 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprMissing.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.spi.types.PType 6 | import org.partiql.spi.value.Datum 7 | 8 | internal class ExprMissing( 9 | private val type: PType 10 | ) : ExprValue { 11 | 12 | override fun eval(env: Environment): Datum { 13 | return Datum.missing(type) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprNullIf.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.spi.value.Datum 6 | 7 | internal class ExprNullIf( 8 | private val valueExpr: ExprValue, 9 | private val nullifierExpr: ExprValue 10 | ) : ExprValue { 11 | 12 | private val comparator = Datum.comparator() 13 | 14 | override fun eval(env: Environment): Datum { 15 | val value = valueExpr.eval(env) 16 | val nullifier = nullifierExpr.eval(env) 17 | return when (comparator.compare(value, nullifier)) { 18 | 0 -> if (value.isMissing || nullifier.isMissing) Datum.missing() else Datum.nullValue() 19 | else -> value 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprPathSymbol.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.eval.internal.helpers.PErrors 6 | import org.partiql.eval.internal.helpers.ValueUtility.checkStruct 7 | import org.partiql.spi.value.Datum 8 | 9 | internal class ExprPathSymbol( 10 | @JvmField val root: ExprValue, 11 | @JvmField val symbol: String, 12 | ) : ExprValue { 13 | 14 | override fun eval(env: Environment): Datum { 15 | val struct = root.eval(env).checkStruct() 16 | if (struct.isNull) { 17 | return Datum.nullValue() 18 | } 19 | return struct.getInsensitive(symbol) ?: throw PErrors.pathSymbolFailureException() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprStructField.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.ExprValue 4 | 5 | internal class ExprStructField(val key: ExprValue, val value: ExprValue) 6 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprTable.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.spi.catalog.Table 6 | import org.partiql.spi.value.Datum 7 | 8 | /** 9 | * Wrap a [Table] as an expression operator. 10 | * 11 | * @constructor 12 | * 13 | * @param table 14 | */ 15 | internal class ExprTable(table: Table) : ExprValue { 16 | 17 | // DO NOT USE FINAL 18 | private var _table = table 19 | 20 | override fun eval(env: Environment): Datum = _table.getDatum() 21 | } 22 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rex/ExprVar.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.ExprValue 5 | import org.partiql.spi.value.Datum 6 | 7 | /** 8 | * Implementation for variable lookup; walks up environments if necessary, otherwise lookup using tuple offset. 9 | */ 10 | internal class ExprVar( 11 | private var depth: Int, 12 | private var offset: Int, 13 | ) : ExprValue { 14 | 15 | override fun eval(env: Environment): Datum = env.get(depth, offset) 16 | } 17 | -------------------------------------------------------------------------------- /partiql-eval/src/main/kotlin/org/partiql/eval/internal/window/RowNumberFunction.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.window 2 | 3 | import org.partiql.eval.Environment 4 | import org.partiql.eval.WindowFunction 5 | import org.partiql.eval.WindowPartition 6 | import org.partiql.spi.value.Datum 7 | 8 | internal class RowNumberFunction : WindowFunction { 9 | 10 | private var _index: Long = 0 11 | 12 | override fun reset(partition: WindowPartition) { 13 | _index = 0 14 | } 15 | 16 | override fun eval(env: Environment, orderingGroupStart: Long, orderingGroupEnd: Long): Datum { 17 | return Datum.bigint(++_index) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /partiql-eval/src/test/kotlin/org/partiql/eval/PTestCase.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval 2 | 3 | interface PTestCase : Runnable { 4 | /** 5 | * Executes the test case 6 | */ 7 | override fun run() 8 | } 9 | -------------------------------------------------------------------------------- /partiql-eval/src/test/kotlin/org/partiql/eval/internal/operator/rex/CastTableTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.eval.internal.operator.rex 2 | 3 | import org.junit.jupiter.api.Test 4 | 5 | class CastTableTest { 6 | @Test 7 | fun printCastTable() { 8 | println(CastTable) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /partiql-lang/api/partiql-lang.api: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/partiql/partiql-lang-kotlin/8d556cad5c1fb17c453e7cb141ae08a31eb3dcd7/partiql-lang/api/partiql-lang.api -------------------------------------------------------------------------------- /partiql-parser/api/partiql-parser.api: -------------------------------------------------------------------------------- 1 | public abstract interface class org/partiql/parser/PartiQLParser { 2 | public static fun builder ()Lorg/partiql/parser/PartiQLParser$Builder; 3 | public fun parse (Ljava/lang/String;)Lorg/partiql/parser/PartiQLParser$Result; 4 | public abstract fun parse (Ljava/lang/String;Lorg/partiql/spi/Context;)Lorg/partiql/parser/PartiQLParser$Result; 5 | public static fun standard ()Lorg/partiql/parser/PartiQLParser; 6 | } 7 | 8 | public class org/partiql/parser/PartiQLParser$Builder { 9 | public fun ()V 10 | public fun build ()Lorg/partiql/parser/PartiQLParser; 11 | } 12 | 13 | public final class org/partiql/parser/PartiQLParser$Result { 14 | public field locations Lorg/partiql/spi/SourceLocations; 15 | public field statements Ljava/util/List; 16 | public fun (Ljava/util/List;Lorg/partiql/spi/SourceLocations;)V 17 | } 18 | 19 | -------------------------------------------------------------------------------- /partiql-parser/src/main/java/org/partiql/parser/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains classes and interfaces related to converting PartiQL text into an abstract syntax tree (AST). 3 | * 4 | * @see org.partiql.parser.PartiQLParser 5 | */ 6 | package org.partiql.parser; 7 | -------------------------------------------------------------------------------- /partiql-parser/src/test/kotlin/org/partiql/parser/internal/PTestDef.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.parser.internal 2 | 3 | interface PTestDef { 4 | /** 5 | * Returns the name of the test 6 | */ 7 | fun name(): String 8 | 9 | /** 10 | * Runs the test case. 11 | */ 12 | fun assert() 13 | } 14 | -------------------------------------------------------------------------------- /partiql-plan/src/main/java/org/partiql/plan/Action.java: -------------------------------------------------------------------------------- 1 | package org.partiql.plan; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.partiql.plan.rex.Rex; 5 | 6 | /** 7 | * A PartiQL statement action within a plan. 8 | */ 9 | public interface Action { 10 | 11 | /** 12 | * PartiQL Query Statement — i.e. SELECT-FROM 13 | */ 14 | interface Query extends Action { 15 | 16 | /** 17 | * Returns the root expression of the query. 18 | */ 19 | @NotNull 20 | Rex getRex(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /partiql-plan/src/main/java/org/partiql/plan/Plan.java: -------------------------------------------------------------------------------- 1 | package org.partiql.plan; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | /** 6 | * A plan holds operations that can be executed. 7 | */ 8 | public interface Plan { 9 | 10 | /** 11 | * Returns the version of this plan. 12 | * @return version for serialization and debugging. 13 | */ 14 | @NotNull 15 | default Version getVersion() { 16 | return Version.V1(); 17 | } 18 | 19 | /** 20 | * Returns the statement action to execute. 21 | * @return statement action to execute. 22 | */ 23 | @NotNull 24 | Action getAction(); 25 | } 26 | -------------------------------------------------------------------------------- /partiql-plan/src/main/java/org/partiql/plan/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * PartiQL logical plan data structures. 3 | */ 4 | package org.partiql.plan; -------------------------------------------------------------------------------- /partiql-plan/src/main/java/org/partiql/plan/rel/Rel.java: -------------------------------------------------------------------------------- 1 | package org.partiql.plan.rel; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.partiql.plan.Operator; 5 | 6 | /** 7 | * A Rel is an {@link Operator} that produces a collection of tuples. 8 | */ 9 | public interface Rel extends Operator { 10 | 11 | /** 12 | * Returns the type of the rows produced by this rel. 13 | * @return type for rows produced by this rel. 14 | */ 15 | @NotNull 16 | RelType getType(); 17 | 18 | /** 19 | * Sets the type of the rows produced by this rel. 20 | * @param type the new type of the rows produced by this Rel. 21 | */ 22 | void setType(@NotNull RelType type); 23 | } 24 | -------------------------------------------------------------------------------- /partiql-plan/src/main/java/org/partiql/plan/rel/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * PartiQL plan relational operators. 3 | */ 4 | package org.partiql.plan.rel; -------------------------------------------------------------------------------- /partiql-plan/src/main/java/org/partiql/plan/rex/Rex.java: -------------------------------------------------------------------------------- 1 | package org.partiql.plan.rex; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.partiql.plan.Operator; 5 | 6 | /** 7 | * A {@link Rex} is an {@link Operator} that produces a value. 8 | */ 9 | public interface Rex extends Operator { 10 | 11 | /** 12 | * Gets the type of the value produced by this rex. 13 | * @return the type of the value produced by this rex. 14 | */ 15 | @NotNull 16 | RexType getType(); 17 | 18 | /** 19 | * Sets the type of the value produced by this rex. 20 | * @param type the new type of the value produced by this rex. 21 | */ 22 | void setType(RexType type); 23 | } 24 | -------------------------------------------------------------------------------- /partiql-plan/src/main/java/org/partiql/plan/rex/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * PartiQL logical plan relation expressions. 3 | */ 4 | package org.partiql.plan.rex; -------------------------------------------------------------------------------- /partiql-planner/src/main/kotlin/org/partiql/planner/PartiQLPlannerPass.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.planner 2 | 3 | import org.partiql.plan.Plan 4 | import org.partiql.spi.Context 5 | 6 | /** 7 | * Interface specifies a pass that can be applied to a [Plan] by the [PartiQLPlanner]. 8 | */ 9 | public interface PartiQLPlannerPass { 10 | /** 11 | * Applies this pass to the given [Plan] and returns the resulting [Plan]. 12 | * 13 | * @param plan The [Plan] to apply this pass to. 14 | * @param ctx The [Context] to use for this pass. 15 | * @return The resulting [Plan] after applying this pass. 16 | */ 17 | public fun apply(plan: Plan, ctx: Context): Plan 18 | } 19 | -------------------------------------------------------------------------------- /partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/SubstitutionVisitor.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.planner.internal.transforms 2 | 3 | import org.partiql.ast.AstNode 4 | import org.partiql.ast.AstRewriter 5 | import org.partiql.ast.expr.Expr 6 | 7 | internal object SubstitutionVisitor : AstRewriter>() { 8 | override fun visitExpr(node: Expr, ctx: Map<*, AstNode>): AstNode { 9 | val visited = super.visitExpr(node, ctx) 10 | if (ctx.containsKey(visited)) { 11 | return ctx[visited]!! 12 | } 13 | return visited 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /partiql-planner/src/main/kotlin/org/partiql/planner/internal/typer/Strategy.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.planner.internal.typer 2 | 3 | /** 4 | * Variable resolution strategies — https://partiql.org/assets/PartiQL-Specification.pdf#page=35 5 | * 6 | * | Value | Strategy | Scoping Rules | 7 | * |------------+-----------------------+---------------| 8 | * | LOCAL | local-first lookup | Rules 1, 2 | 9 | * | GLOBAL | global-first lookup | Rule 3 | 10 | */ 11 | internal enum class Strategy { 12 | LOCAL, 13 | GLOBAL, 14 | } 15 | -------------------------------------------------------------------------------- /partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/TypeLatticeTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.planner.internal.typer 2 | 3 | import org.junit.jupiter.api.Disabled 4 | import org.junit.jupiter.api.Test 5 | import org.partiql.planner.internal.casts.CastTable 6 | 7 | class TypeLatticeTest { 8 | 9 | @Test 10 | @Disabled 11 | fun latticeAsciidocDump() { 12 | // this test only exists for dumping the type lattice as Asciidoc 13 | println(CastTable.partiql) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/aggregations/T.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | constraints: [ closed, ordered, unique ], 6 | fields: [ 7 | { 8 | name: "a", 9 | type: "bool", 10 | }, 11 | { 12 | name: "b", 13 | type: "int32", 14 | }, 15 | { 16 | name: "c", 17 | type: "string", 18 | }, 19 | { 20 | name: "d", 21 | type: { 22 | type: "struct", 23 | constraints: [ closed, ordered, unique ], 24 | fields: [ 25 | { 26 | name: "e", 27 | type: "string" 28 | } 29 | ] 30 | }, 31 | } 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/aggregations/T1.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | constraints: [ closed ], 6 | fields: [ 7 | { 8 | name: "a", 9 | type: "bool", 10 | }, 11 | { 12 | name: "b", 13 | type: "int32", 14 | }, 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/aggregations/T2.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | constraints: [ closed ], 6 | fields: [ 7 | { 8 | name: "c", 9 | type: "bool", 10 | }, 11 | { 12 | name: "d", 13 | type: "int32", 14 | }, 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/aggregations/T3.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | constraints: [ closed ], 6 | fields: [ 7 | { 8 | name: "e", 9 | type: "bool", 10 | }, 11 | { 12 | name: "f", 13 | type: "int32", 14 | }, 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/aws/b/b.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | constraints: [ closed, unique, ordered ], 6 | fields: [ 7 | { 8 | name: "identifier", 9 | type: "int32", 10 | } 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/aws/ddb/b.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | constraints: [ closed, unique, ordered ], 6 | fields: [ 7 | { 8 | name: "identifier", 9 | type: "string", 10 | } 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/aws/ddb/pets.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | constraints: [ closed, unique, ordered ], 6 | fields: [ 7 | { 8 | name: "id", 9 | type: "int32", 10 | }, 11 | { 12 | name: "breed", 13 | type: "string", 14 | } 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/b/b/b.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "struct", 3 | constraints: [ closed, unique, ordered ], 4 | fields: [ 5 | { 6 | name: "b", 7 | type: { 8 | type: "struct", 9 | constraints: [ closed, unique, ordered ], 10 | fields: [ 11 | { 12 | name: "b", 13 | type: "int32", 14 | } 15 | ] 16 | } 17 | }, 18 | { 19 | name: "c", 20 | type: "int32", 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/b/b/b_open.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "struct", 3 | constraints: [ unique, ordered ], // open struct 4 | fields: [ 5 | { 6 | name: "b", 7 | type: { 8 | type: "struct", 9 | constraints: [ unique, ordered ], // open struct 10 | fields: [ 11 | { 12 | name: "b", 13 | type: "int32", 14 | } 15 | ] 16 | } 17 | }, 18 | { 19 | name: "c", 20 | type: "int32", 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/b/b/c.ion: -------------------------------------------------------------------------------- 1 | "int32" 2 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/b/b/d.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "struct", 3 | constraints: [ closed, ordered ], 4 | fields: [ 5 | { 6 | name: "e", 7 | type: "int32", 8 | }, 9 | { 10 | name: "e", 11 | type: { 12 | type: "struct", 13 | fields: [ 14 | { 15 | name: "f", 16 | type: "int32", 17 | } 18 | ] 19 | } 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/b/c/c.ion: -------------------------------------------------------------------------------- 1 | "decimal" 2 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/db/markets/order_info.ion: -------------------------------------------------------------------------------- 1 | { 2 | name: "order_info", 3 | constraints: [ closed, unique, ordered ], 4 | type: "struct", 5 | fields: [ 6 | { 7 | name: "customer_id", 8 | type: "int32", 9 | }, 10 | { 11 | name: "marketplace_id", 12 | type: "int32", 13 | }, 14 | { 15 | name: "ship_option", 16 | type: "string", 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/db/markets/orders.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | constraints: [ closed, unique, ordered ], 6 | fields: [ 7 | { 8 | name: "customer_id", 9 | type: "int32", 10 | }, 11 | { 12 | name: "marketplace_id", 13 | type: "int32", 14 | }, 15 | { 16 | name: "ship_option", 17 | type: "string", 18 | } 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/pql/main/closed_duplicates_struct.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "struct", 3 | constraints: [ 4 | closed 5 | ], 6 | fields: [ 7 | { 8 | name: "definition", 9 | type: "string", 10 | }, 11 | { 12 | name: "definition", 13 | type: "float32", 14 | }, 15 | { 16 | name: "DEFINITION", 17 | type: "decimal" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/pql/main/closed_ordered_duplicates_struct.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "struct", 3 | constraints: [ 4 | closed, 5 | ordered 6 | ], 7 | fields: [ 8 | { 9 | name: "definition", 10 | type: "string", 11 | }, 12 | { 13 | name: "definition", 14 | type: "float32", 15 | }, 16 | { 17 | name: "DEFINITION", 18 | type: "decimal" 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/pql/main/closed_union_duplicates_struct.ion: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | type: "struct", 4 | constraints: [ 5 | closed 6 | ], 7 | fields: [ 8 | { 9 | name: "definition", 10 | type: "string", 11 | }, 12 | { 13 | name: "definition", 14 | type: "float32", 15 | }, 16 | { 17 | name: "DEFINITION", 18 | type: "decimal" 19 | } 20 | ] 21 | }, 22 | { 23 | type: "struct", 24 | constraints: [ 25 | closed, 26 | ordered 27 | ], 28 | fields: [ 29 | { 30 | name: "definition", 31 | type: "int16", 32 | }, 33 | { 34 | name: "definition", 35 | type: "int32", 36 | }, 37 | { 38 | name: "DEFINITION", 39 | type: "int64" 40 | } 41 | ] 42 | }, 43 | ] 44 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/pql/main/dogs.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "list", 3 | items: { 4 | type: "struct", 5 | constraints: [closed], 6 | fields: [ 7 | { 8 | name: "breed", 9 | type: "string", 10 | }, 11 | { 12 | name: "avg_height", 13 | type: "float32", 14 | }, 15 | { 16 | name: "typical_allergies", 17 | type: { 18 | type: "list", 19 | items: "string" 20 | } 21 | } 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/pql/main/employer.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "struct", 3 | name: "employer", 4 | constraints: [ closed, unique, ordered ], 5 | fields: [ 6 | { 7 | name: "name", 8 | type: "string" 9 | }, 10 | { 11 | name: "tax_id", 12 | type: "int64" 13 | }, 14 | { 15 | name: "address", 16 | type: { 17 | type: "struct", 18 | constraints: [ closed, unique, ordered ], 19 | fields: [ 20 | { 21 | name: "street", 22 | type: "string" 23 | }, 24 | { 25 | name: "zip", 26 | type: "int32" 27 | }, 28 | ] 29 | }, 30 | }, 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/pql/main/open_duplicates_struct.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "struct", 3 | fields: [ 4 | { 5 | name: "definition", 6 | type: "string", 7 | }, 8 | { 9 | name: "definition", 10 | type: "float32", 11 | }, 12 | { 13 | name: "DEFINITION", 14 | type: "decimal" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/pql/main/os.ion: -------------------------------------------------------------------------------- 1 | // String representing the current operating system 2 | "string" 3 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/pql/main/person.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "struct", 3 | name: "person", 4 | constraints: [ closed, unique, ordered ], 5 | fields: [ 6 | { 7 | name: "name", 8 | type: { 9 | type: "struct", 10 | constraints: [ closed, unique, ordered ], 11 | fields: [ 12 | { 13 | name: "first", 14 | type: "string" 15 | }, 16 | { 17 | name: "last", 18 | type: "string" 19 | }, 20 | ] 21 | }, 22 | }, 23 | { 24 | name: "ssn", 25 | type: "string" 26 | }, 27 | { 28 | name: "employer", 29 | type: "string" 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/pql/points.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | constraints: [closed], 6 | fields: [ 7 | { 8 | name: "x", 9 | type: "float32", 10 | }, 11 | { 12 | name: "y", 13 | type: "float32", 14 | }, 15 | { 16 | name: "z", 17 | type: "float32", 18 | }, 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/subqueries/S.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "list", 3 | items: { 4 | type: "struct", 5 | constraints: [ closed, unique ], 6 | fields: [ 7 | { 8 | name: "a", 9 | type: "int32" 10 | }, 11 | { 12 | name: "b", 13 | type: "int32" 14 | }, 15 | { 16 | name: "c", 17 | type: "int32" 18 | }, 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/default/subqueries/T.ion: -------------------------------------------------------------------------------- 1 | { 2 | type: "list", 3 | items: { 4 | type: "struct", 5 | constraints: [ closed, unique ], 6 | fields: [ 7 | { 8 | name: "x", 9 | type: "int32" 10 | }, 11 | { 12 | name: "y", 13 | type: "int32" 14 | }, 15 | { 16 | name: "z", 17 | type: "int32" 18 | }, 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/tpc_ds/dbgen_version.ion: -------------------------------------------------------------------------------- 1 | dbgen_version::{ 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | fields: [ 6 | { 7 | name: "dv_version", 8 | type: "string" 9 | }, 10 | { 11 | name: "dv_create_date", 12 | type: "int64" 13 | }, 14 | { 15 | name: "dv_create_time", 16 | type: "int64" 17 | }, 18 | { 19 | name: "dv_cmdline_args", 20 | type: "string" 21 | } 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/tpc_ds/household_demographics.ion: -------------------------------------------------------------------------------- 1 | household_demographics::{ 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | fields: [ 6 | { 7 | name: "hd_demo_sk", 8 | type: "string" 9 | }, 10 | { 11 | name: "hd_income_band_sk", 12 | type: "string" 13 | }, 14 | { 15 | name: "hd_buy_potential", 16 | type: "string" 17 | }, 18 | { 19 | name: "hd_dep_count", 20 | type: "int32" 21 | }, 22 | { 23 | name: "hd_vehicle_count", 24 | type: "int32" 25 | } 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/tpc_ds/income_band.ion: -------------------------------------------------------------------------------- 1 | income_band::{ 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | fields: [ 6 | { 7 | name: "ib_income_band_sk", 8 | type: "string" 9 | }, 10 | { 11 | name: "ib_lower_bound", 12 | type: "int32" 13 | }, 14 | { 15 | name: "ib_upper_bound", 16 | type: "int32" 17 | } 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/tpc_ds/inventory.ion: -------------------------------------------------------------------------------- 1 | inventory::{ 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | fields: [ 6 | { 7 | name: "inv_date_sk", 8 | type: "string" 9 | }, 10 | { 11 | name: "inv_item_sk", 12 | type: "string" 13 | }, 14 | { 15 | name: "inv_warehouse_sk", 16 | type: "string" 17 | }, 18 | { 19 | name: "inv_quantity_on_hand", 20 | type: "int32" 21 | } 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/tpc_ds/reason.ion: -------------------------------------------------------------------------------- 1 | reason::{ 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | fields: [ 6 | { 7 | name: "r_reason_sk", 8 | type: "string" 9 | }, 10 | { 11 | name: "r_reason_id", 12 | type: "string" 13 | }, 14 | { 15 | name: "r_reason_desc", 16 | type: "string" 17 | } 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/tpc_ds/ship_mode.ion: -------------------------------------------------------------------------------- 1 | ship_mode::{ 2 | type: "bag", 3 | items: { 4 | type: "struct", 5 | fields: [ 6 | { 7 | name: "sm_ship_mode_sk", 8 | type: "string" 9 | }, 10 | { 11 | name: "sm_ship_mode_id", 12 | type: "string" 13 | }, 14 | { 15 | name: "sm_type", 16 | type: "string" 17 | }, 18 | { 19 | name: "sm_code", 20 | type: "string" 21 | }, 22 | { 23 | name: "sm_carrier", 24 | type: "string" 25 | }, 26 | { 27 | name: "sm_contract", 28 | type: "string" 29 | } 30 | ] 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/catalogs/tpc_h/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/partiql/partiql-lang-kotlin/8d556cad5c1fb17c453e7cb141ae08a31eb3dcd7/partiql-planner/src/testFixtures/resources/catalogs/tpc_h/.gitkeep -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/basics/functions.sql: -------------------------------------------------------------------------------- 1 | --#[func-00] 2 | nullIf(t1, t2); -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/basics/simple.sql: -------------------------------------------------------------------------------- 1 | -- ------------------ 2 | -- Globals 3 | -- ------------------ 4 | 5 | --#[global-00] 6 | my_global; 7 | 8 | -- ------------------ 9 | -- Literals 10 | -- ------------------ 11 | 12 | --#[sanity-lit-00] 13 | true; 14 | 15 | --#[sanity-lit-01] 16 | 1; 17 | 18 | --#[sanity-lit-02] 19 | 1.0; 20 | 21 | --#[sanity-lit-03] 22 | 'hello'; 23 | 24 | --#[sanity-lit-04] 25 | [ 'a', 'b', 'c' ]; 26 | 27 | --#[sanity-lit-05] 28 | << 'a', 'b', 'c' >>; 29 | 30 | --#[sanity-lit-06] 31 | { 'a': 1, 'b': 2, 'c': 3 }; -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/basics/subquery.sql: -------------------------------------------------------------------------------- 1 | -- Scalar subquery coercion 2 | --#[subquery-00] 3 | 1 = (SELECT b FROM T); 4 | 5 | -- Row value subquery coercion 6 | --#[subquery-01] 7 | (false, 1) = (SELECT a, b FROM T); 8 | 9 | -- IN collection subquery 10 | --#[subquery-02] 11 | SELECT UPPER(v) FROM T 12 | WHERE b IN (SELECT b FROM T WHERE a); 13 | 14 | -- Scalar subquery coercion with aggregation 15 | --#[subquery-03] 16 | -- 100 = (SELECT MAX(t.b) FROM T as t) 17 | 100 = (SELECT COUNT(*) FROM T); 18 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/casts.sql: -------------------------------------------------------------------------------- 1 | --#[cast-00] 2 | CAST(numbers.d AS INT2); 3 | 4 | --#[cast-01] 5 | CAST(numbers.d AS INT4); 6 | 7 | --#[cast-02] 8 | CAST(numbers.d AS INT8); 9 | 10 | --#[cast-03] 11 | CAST(numbers.d AS INT); 12 | 13 | --#[cast-04] 14 | CAST(numbers.d AS BIGINT); 15 | 16 | --#[cast-05] 17 | CAST(numbers.d AS DECIMAL); 18 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/collections.sql: -------------------------------------------------------------------------------- 1 | --#[collections-01] 2 | -- Collection BAG 3 | << 1, 2, 3 >>; 4 | 5 | --#[collections-02] 6 | -- Collection LIST 7 | [ 1, 2, 3 ]; 8 | 9 | --#[collections-03] 10 | -- Collection LIST 11 | ( 1, 2, 3 ); 12 | 13 | --#[collections-05] 14 | --SELECT VALUE from array 15 | SELECT VALUE x FROM [ 1, 2, 3 ] as x; 16 | 17 | --#[collections-06] 18 | --SELECT from array 19 | SELECT x FROM [ 1, 2, 3 ] as x; 20 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/is_type.sql: -------------------------------------------------------------------------------- 1 | --#[is-type-00] 2 | false IS BOOL; 3 | 4 | --#[is-type-01] 5 | item.i_class_id IS INT; 6 | 7 | --#[is-type-02] 8 | item.i_brand IS STRING; 9 | 10 | --#[is-type-03] 11 | 1 IS NULL; 12 | 13 | --#[is-type-04] 14 | MISSING IS NULL; 15 | 16 | --#[is-type-05] 17 | NULL IS NULL; 18 | 19 | --#[is-type-06] 20 | MISSING IS MISSING; 21 | 22 | --#[is-type-07] 23 | NULL IS MISSING; 24 | 25 | --#[is-type-08] 26 | -- ERROR! always MISSING 27 | MISSING IS BOOL; 28 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/joins.sql: -------------------------------------------------------------------------------- 1 | --#[join-01] 2 | SELECT * FROM <<{ 'a': 1 }>> AS t1, <<{ 'b': 2.0 }>> AS t2; 3 | 4 | --#[join-02] 5 | SELECT * FROM <<{ 'a': 1 }>> AS t1 LEFT JOIN <<{ 'b': 2.0 }>> AS t2 ON TRUE; 6 | 7 | --#[join-03] 8 | SELECT b, a FROM <<{ 'a': 1 }>> AS t1 LEFT JOIN <<{ 'b': 2.0 }>> AS t2 ON TRUE; 9 | 10 | --#[join-04] 11 | SELECT t1.a, t2.a FROM <<{ 'a': 1 }>> AS t1 LEFT JOIN <<{ 'a': 2.0 }>> AS t2 ON t1.a = t2.a; 12 | 13 | --#[join-05] 14 | SELECT * FROM <<{ 'a': 1 }>> AS t1 LEFT JOIN <<{ 'a': 2.0 }>> AS t2 ON t1.a = t2.a; 15 | 16 | --#[join-06] 17 | SELECT * FROM 18 | <<{ 'a': 1 }>> AS t1 19 | LEFT JOIN 20 | <<{ 'a': 2.0 }>> AS t2 21 | ON t1.a = t2.a 22 | LEFT JOIN 23 | <<{ 'a': 'hello, world' }>> AS t3 24 | ON t3.a = 'hello'; 25 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/order_by.sql: -------------------------------------------------------------------------------- 1 | --#[order_by-01] 2 | SELECT * FROM pets ORDER BY id; 3 | 4 | --#[order_by-02] 5 | SELECT * FROM pets ORDER BY breed; 6 | 7 | --#[order_by-03] 8 | SELECT * FROM pets ORDER BY unknown_col; 9 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/schema_inferencer/pivot.sql: -------------------------------------------------------------------------------- 1 | --#[pivot-00] 2 | PIVOT t.a AT t.c FROM main.T AS t; 3 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/subquery/non_correlated.sql: -------------------------------------------------------------------------------- 1 | --#[subquery-00] 2 | SELECT x 3 | FROM T 4 | WHERE x IN (SELECT a FROM S); 5 | 6 | --#[subquery-01] 7 | SELECT x 8 | FROM T 9 | WHERE x > (SELECT MAX(a) FROM S); 10 | 11 | --#[subquery-02] 12 | SELECT t.*, s.* 13 | FROM T AS t 14 | JOIN (SELECT * FROM S) AS s 15 | ON t.x = s.a; 16 | 17 | --#[subquery-03] 18 | 1 = (SELECT COUNT(*) FROM T); 19 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_ds/query03.sql: -------------------------------------------------------------------------------- 1 | -- start query 3 in stream 0 using template query3.tpl 2 | SELECT dt.d_year, 3 | item.i_brand_id brand_id, 4 | item.i_brand brand, 5 | Sum(ss_ext_discount_amt) sum_agg 6 | FROM date_dim dt, 7 | store_sales, 8 | item 9 | WHERE dt.d_date_sk = store_sales.ss_sold_date_sk 10 | AND store_sales.ss_item_sk = item.i_item_sk 11 | AND item.i_manufact_id = 427 12 | AND dt.d_moy = 11 13 | GROUP BY dt.d_year, 14 | item.i_brand, 15 | item.i_brand_id 16 | ORDER BY dt.d_year, 17 | sum_agg DESC, 18 | brand_id 19 | LIMIT 100; 20 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_ds/query15.sql: -------------------------------------------------------------------------------- 1 | -- start query 15 in stream 0 using template query15.tpl 2 | SELECT ca_zip, 3 | Sum(cs_sales_price) 4 | FROM catalog_sales, 5 | customer, 6 | customer_address, 7 | date_dim 8 | WHERE cs_bill_customer_sk = c_customer_sk 9 | AND c_current_addr_sk = ca_address_sk 10 | AND ( Substr(ca_zip, 1, 5) IN ( '85669', '86197', '88274', '83405', 11 | '86475', '85392', '85460', '80348', 12 | '81792' ) 13 | OR ca_state IN ( 'CA', 'WA', 'GA' ) 14 | OR cs_sales_price > 500 ) 15 | AND cs_sold_date_sk = d_date_sk 16 | AND d_qoy = 1 17 | AND d_year = 1998 18 | GROUP BY ca_zip 19 | ORDER BY ca_zip 20 | LIMIT 100; 21 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_ds/query22.sql: -------------------------------------------------------------------------------- 1 | -- start query 22 in stream 0 using template query22.tpl 2 | SELECT i_product_name, 3 | i_brand, 4 | i_class, 5 | i_category, 6 | Avg(inv_quantity_on_hand) qoh 7 | FROM inventory, 8 | date_dim, 9 | item, 10 | warehouse 11 | WHERE inv_date_sk = d_date_sk 12 | AND inv_item_sk = i_item_sk 13 | AND inv_warehouse_sk = w_warehouse_sk 14 | AND d_month_seq BETWEEN 1205 AND 1205 + 11 15 | GROUP BY rollup( i_product_name, i_brand, i_class, i_category ) 16 | ORDER BY qoh, 17 | i_product_name, 18 | i_brand, 19 | i_class, 20 | i_category 21 | LIMIT 100; 22 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_ds/query37.sql: -------------------------------------------------------------------------------- 1 | -- start query 37 in stream 0 using template query37.tpl 2 | SELECT 3 | i_item_id , 4 | i_item_desc , 5 | i_current_price 6 | FROM item, 7 | inventory, 8 | date_dim, 9 | catalog_sales 10 | WHERE i_current_price BETWEEN 20 AND 20 + 30 11 | AND inv_item_sk = i_item_sk 12 | AND d_date_sk=inv_date_sk 13 | AND d_date BETWEEN Cast('1999-03-06' AS DATE) AND ( 14 | Cast('1999-03-06' AS DATE) + INTERVAL '60' day) 15 | AND i_manufact_id IN (843,815,850,840) 16 | AND inv_quantity_on_hand BETWEEN 100 AND 500 17 | AND cs_item_sk = i_item_sk 18 | GROUP BY i_item_id, 19 | i_item_desc, 20 | i_current_price 21 | ORDER BY i_item_id 22 | LIMIT 100; 23 | 24 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_ds/query42.sql: -------------------------------------------------------------------------------- 1 | -- start query 42 in stream 0 using template query42.tpl 2 | SELECT dt.d_year, 3 | item.i_category_id, 4 | item.i_category, 5 | Sum(ss_ext_sales_price) 6 | FROM date_dim dt, 7 | store_sales, 8 | item 9 | WHERE dt.d_date_sk = store_sales.ss_sold_date_sk 10 | AND store_sales.ss_item_sk = item.i_item_sk 11 | AND item.i_manager_id = 1 12 | AND dt.d_moy = 12 13 | AND dt.d_year = 2000 14 | GROUP BY dt.d_year, 15 | item.i_category_id, 16 | item.i_category 17 | ORDER BY Sum(ss_ext_sales_price) DESC, 18 | dt.d_year, 19 | item.i_category_id, 20 | item.i_category 21 | LIMIT 100; 22 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_ds/query52.sql: -------------------------------------------------------------------------------- 1 | -- start query 52 in stream 0 using template query52.tpl 2 | SELECT dt.d_year, 3 | item.i_brand_id brand_id, 4 | item.i_brand brand, 5 | Sum(ss_ext_sales_price) ext_price 6 | FROM date_dim dt, 7 | store_sales, 8 | item 9 | WHERE dt.d_date_sk = store_sales.ss_sold_date_sk 10 | AND store_sales.ss_item_sk = item.i_item_sk 11 | AND item.i_manager_id = 1 12 | AND dt.d_moy = 11 13 | AND dt.d_year = 1999 14 | GROUP BY dt.d_year, 15 | item.i_brand, 16 | item.i_brand_id 17 | ORDER BY dt.d_year, 18 | ext_price DESC, 19 | brand_id 20 | LIMIT 100; 21 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_ds/query55.sql: -------------------------------------------------------------------------------- 1 | -- start query 55 in stream 0 using template query55.tpl 2 | SELECT i_brand_id brand_id, 3 | i_brand brand, 4 | Sum(ss_ext_sales_price) ext_price 5 | FROM date_dim, 6 | store_sales, 7 | item 8 | WHERE d_date_sk = ss_sold_date_sk 9 | AND ss_item_sk = i_item_sk 10 | AND i_manager_id = 33 11 | AND d_moy = 12 12 | AND d_year = 1998 13 | GROUP BY i_brand, 14 | i_brand_id 15 | ORDER BY ext_price DESC, 16 | i_brand_id 17 | LIMIT 100; 18 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_ds/query82.sql: -------------------------------------------------------------------------------- 1 | 2 | -- start query 82 in stream 0 using template query82.tpl 3 | SELECT 4 | i_item_id , 5 | i_item_desc , 6 | i_current_price 7 | FROM item, 8 | inventory, 9 | date_dim, 10 | store_sales 11 | WHERE i_current_price BETWEEN 63 AND 63+30 12 | AND inv_item_sk = i_item_sk 13 | AND d_date_sk=inv_date_sk 14 | AND d_date BETWEEN Cast('1998-04-27' AS DATE) AND ( 15 | Cast('1998-04-27' AS DATE) + INTERVAL '60' day) 16 | AND i_manufact_id IN (57,293,427,320) 17 | AND inv_quantity_on_hand BETWEEN 100 AND 500 18 | AND ss_item_sk = i_item_sk 19 | GROUP BY i_item_id, 20 | i_item_desc, 21 | i_current_price 22 | ORDER BY i_item_id 23 | LIMIT 100; 24 | 25 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_ds/query84.sql: -------------------------------------------------------------------------------- 1 | -- start query 84 in stream 0 using template query84.tpl 2 | SELECT c_customer_id AS customer_id, 3 | c_last_name 4 | || ', ' 5 | || c_first_name AS customername 6 | FROM customer, 7 | customer_address, 8 | customer_demographics, 9 | household_demographics, 10 | income_band, 11 | store_returns 12 | WHERE ca_city = 'Green Acres' 13 | AND c_current_addr_sk = ca_address_sk 14 | AND ib_lower_bound >= 54986 15 | AND ib_upper_bound <= 54986 + 50000 16 | AND ib_income_band_sk = hd_income_band_sk 17 | AND cd_demo_sk = c_current_cdemo_sk 18 | AND hd_demo_sk = c_current_hdemo_sk 19 | AND sr_cdemo_sk = cd_demo_sk 20 | ORDER BY c_customer_id 21 | LIMIT 100; 22 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_ds/query96.sql: -------------------------------------------------------------------------------- 1 | -- start query 96 in stream 0 using template query96.tpl 2 | SELECT Count(*) 3 | FROM store_sales, 4 | household_demographics, 5 | time_dim, 6 | store 7 | WHERE ss_sold_time_sk = time_dim.t_time_sk 8 | AND ss_hdemo_sk = household_demographics.hd_demo_sk 9 | AND ss_store_sk = s_store_sk 10 | AND time_dim.t_hour = 15 11 | AND time_dim.t_minute >= 30 12 | AND household_demographics.hd_dep_count = 7 13 | AND store.s_store_name = 'ese' 14 | ORDER BY Count(*) 15 | LIMIT 100; 16 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query01.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-01] 2 | select 3 | l_returnflag, 4 | l_linestatus, 5 | sum(l_quantity) as sum_qty, 6 | sum(l_extendedprice) as sum_base_price, 7 | sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, 8 | sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, 9 | avg(l_quantity) as avg_qty, 10 | avg(l_extendedprice) as avg_price, 11 | avg(l_discount) as avg_disc, 12 | count(*) as count_order 13 | from 14 | lineitem 15 | where 16 | l_shipdate <= date '1998-12-01' - interval ':1' day (3) 17 | group by 18 | l_returnflag, 19 | l_linestatus 20 | order by 21 | l_returnflag, 22 | l_linestatus; 23 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query03.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-03] 2 | select 3 | l_orderkey, 4 | sum(l_extendedprice * (1 - l_discount)) as revenue, 5 | o_orderdate, 6 | o_shippriority 7 | from 8 | customer, 9 | orders, 10 | lineitem 11 | where 12 | c_mktsegment = ':1' 13 | and c_custkey = o_custkey 14 | and l_orderkey = o_orderkey 15 | and o_orderdate < date ':2' 16 | and l_shipdate > date ':2' 17 | group by 18 | l_orderkey, 19 | o_orderdate, 20 | o_shippriority 21 | order by 22 | revenue desc, 23 | o_orderdate; 24 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query04.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-04] 2 | select 3 | o_orderpriority, 4 | count(*) as order_count 5 | from 6 | orders 7 | where 8 | o_orderdate >= date ':1' 9 | and o_orderdate < date ':1' + interval '3' month 10 | and exists ( 11 | select 12 | * 13 | from 14 | lineitem 15 | where 16 | l_orderkey = o_orderkey 17 | and l_commitdate < l_receiptdate 18 | ) 19 | group by 20 | o_orderpriority 21 | order by 22 | o_orderpriority; 23 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query05.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-05] 2 | select 3 | n_name, 4 | sum(l_extendedprice * (1 - l_discount)) as revenue 5 | from 6 | customer, 7 | orders, 8 | lineitem, 9 | supplier, 10 | nation, 11 | region 12 | where 13 | c_custkey = o_custkey 14 | and l_orderkey = o_orderkey 15 | and l_suppkey = s_suppkey 16 | and c_nationkey = s_nationkey 17 | and s_nationkey = n_nationkey 18 | and n_regionkey = r_regionkey 19 | and r_name = ':1' 20 | and o_orderdate >= date ':2' 21 | and o_orderdate < date ':2' + interval '1' year 22 | group by 23 | n_name 24 | order by 25 | revenue desc; 26 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query06.sql: -------------------------------------------------------------------------------- 1 | -- $ID$ 2 | -- TPC-H/TPC-R Forecasting Revenue Change Query (Q6) 3 | -- Functional Query Definition 4 | -- Approved February 1998 5 | :x 6 | :o 7 | select 8 | sum(l_extendedprice * l_discount) as revenue 9 | from 10 | lineitem 11 | where 12 | l_shipdate >= date ':1' 13 | and l_shipdate < date ':1' + interval '1' year 14 | and l_discount between :2 - 0.01 and :2 + 0.01 15 | and l_quantity < :3; 16 | :n -1 17 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query09.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-09] 2 | select 3 | nation, 4 | o_year, 5 | sum(amount) as sum_profit 6 | from 7 | ( 8 | select 9 | n_name as nation, 10 | extract(year from o_orderdate) as o_year, 11 | l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount 12 | from 13 | part, 14 | supplier, 15 | lineitem, 16 | partsupp, 17 | orders, 18 | nation 19 | where 20 | s_suppkey = l_suppkey 21 | and ps_suppkey = l_suppkey 22 | and ps_partkey = l_partkey 23 | and p_partkey = l_partkey 24 | and o_orderkey = l_orderkey 25 | and s_nationkey = n_nationkey 26 | and p_name like '%:1%' 27 | ) as profit 28 | group by 29 | nation, 30 | o_year 31 | order by 32 | nation, 33 | o_year desc; 34 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query10.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-10] 2 | select 3 | c_custkey, 4 | c_name, 5 | sum(l_extendedprice * (1 - l_discount)) as revenue, 6 | c_acctbal, 7 | n_name, 8 | c_address, 9 | c_phone, 10 | c_comment 11 | from 12 | customer, 13 | orders, 14 | lineitem, 15 | nation 16 | where 17 | c_custkey = o_custkey 18 | and l_orderkey = o_orderkey 19 | and o_orderdate >= date ':1' 20 | and o_orderdate < date ':1' + interval '3' month 21 | and l_returnflag = 'R' 22 | and c_nationkey = n_nationkey 23 | group by 24 | c_custkey, 25 | c_name, 26 | c_acctbal, 27 | c_phone, 28 | n_name, 29 | c_address, 30 | c_comment 31 | order by 32 | revenue desc; 33 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query11.sql: -------------------------------------------------------------------------------- 1 | --#[tpch-h-11] 2 | select 3 | ps_partkey, 4 | sum(ps_supplycost * ps_availqty) as value 5 | from 6 | partsupp, 7 | supplier, 8 | nation 9 | where 10 | ps_suppkey = s_suppkey 11 | and s_nationkey = n_nationkey 12 | and n_name = ':1' 13 | group by 14 | ps_partkey having 15 | sum(ps_supplycost * ps_availqty) > ( 16 | select 17 | sum(ps_supplycost * ps_availqty) * :2 18 | from 19 | partsupp, 20 | supplier, 21 | nation 22 | where 23 | ps_suppkey = s_suppkey 24 | and s_nationkey = n_nationkey 25 | and n_name = ':1' 26 | ) 27 | order by 28 | value desc; 29 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query12.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-12] 2 | select 3 | l_shipmode, 4 | sum(case 5 | when o_orderpriority = '1-URGENT' 6 | or o_orderpriority = '2-HIGH' 7 | then 1 8 | else 0 9 | end) as high_line_count, 10 | sum(case 11 | when o_orderpriority <> '1-URGENT' 12 | and o_orderpriority <> '2-HIGH' 13 | then 1 14 | else 0 15 | end) as low_line_count 16 | from 17 | orders, 18 | lineitem 19 | where 20 | o_orderkey = l_orderkey 21 | and l_shipmode in (':1', ':2') 22 | and l_commitdate < l_receiptdate 23 | and l_shipdate < l_commitdate 24 | and l_receiptdate >= date ':3' 25 | and l_receiptdate < date ':3' + interval '1' year 26 | group by 27 | l_shipmode 28 | order by 29 | l_shipmode; 30 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query13.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-13] 2 | select 3 | c_count, 4 | count(*) as custdist 5 | from 6 | ( 7 | select 8 | c_custkey, 9 | count(o_orderkey) 10 | from 11 | customer left outer join orders on 12 | c_custkey = o_custkey 13 | and o_comment not like '%:1%:2%' 14 | group by 15 | c_custkey 16 | ) as c_orders (c_custkey, c_count) 17 | group by 18 | c_count 19 | order by 20 | custdist desc, 21 | c_count desc; 22 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query14.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-14] 2 | select 3 | 100.00 * sum(case 4 | when p_type like 'PROMO%' 5 | then l_extendedprice * (1 - l_discount) 6 | else 0 7 | end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue 8 | from 9 | lineitem, 10 | part 11 | where 12 | l_partkey = p_partkey 13 | and l_shipdate >= date ':1' 14 | and l_shipdate < date ':1' + interval '1' month; 15 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query15.sql: -------------------------------------------------------------------------------- 1 | --#[tpch-h-15] 2 | create view revenue:s (supplier_no, total_revenue) as 3 | select 4 | l_suppkey, 5 | sum(l_extendedprice * (1 - l_discount)) 6 | from 7 | lineitem 8 | where 9 | l_shipdate >= date ':1' 10 | and l_shipdate < date ':1' + interval '3' month 11 | group by 12 | l_suppkey; 13 | 14 | :o 15 | select 16 | s_suppkey, 17 | s_name, 18 | s_address, 19 | s_phone, 20 | total_revenue 21 | from 22 | supplier, 23 | revenue:s 24 | where 25 | s_suppkey = supplier_no 26 | and total_revenue = ( 27 | select 28 | max(total_revenue) 29 | from 30 | revenue:s 31 | ) 32 | order by 33 | s_suppkey; 34 | 35 | drop view revenue:s; 36 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query16.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-16] 2 | select 3 | p_brand, 4 | p_type, 5 | p_size, 6 | count(distinct ps_suppkey) as supplier_cnt 7 | from 8 | partsupp, 9 | part 10 | where 11 | p_partkey = ps_partkey 12 | and p_brand <> ':1' 13 | and p_type not like ':2%' 14 | and p_size in (:3, :4, :5, :6, :7, :8, :9, :10) 15 | and ps_suppkey not in ( 16 | select 17 | s_suppkey 18 | from 19 | supplier 20 | where 21 | s_comment like '%Customer%Complaints%' 22 | ) 23 | group by 24 | p_brand, 25 | p_type, 26 | p_size 27 | order by 28 | supplier_cnt desc, 29 | p_brand, 30 | p_type, 31 | p_size; 32 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query17.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-17] 2 | select 3 | sum(l_extendedprice) / 7.0 as avg_yearly 4 | from 5 | lineitem, 6 | part 7 | where 8 | p_partkey = l_partkey 9 | and p_brand = ':1' 10 | and p_container = ':2' 11 | and l_quantity < ( 12 | select 13 | 0.2 * avg(l_quantity) 14 | from 15 | lineitem 16 | where 17 | l_partkey = p_partkey 18 | ); 19 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query18.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-18] 2 | select 3 | c_name, 4 | c_custkey, 5 | o_orderkey, 6 | o_orderdate, 7 | o_totalprice, 8 | sum(l_quantity) 9 | from 10 | customer, 11 | orders, 12 | lineitem 13 | where 14 | o_orderkey in ( 15 | select 16 | l_orderkey 17 | from 18 | lineitem 19 | group by 20 | l_orderkey having 21 | sum(l_quantity) > :1 22 | ) 23 | and c_custkey = o_custkey 24 | and o_orderkey = l_orderkey 25 | group by 26 | c_name, 27 | c_custkey, 28 | o_orderkey, 29 | o_orderdate, 30 | o_totalprice 31 | order by 32 | o_totalprice desc, 33 | o_orderdate; 34 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query20.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-20] 2 | select 3 | s_name, 4 | s_address 5 | from 6 | supplier, 7 | nation 8 | where 9 | s_suppkey in ( 10 | select 11 | ps_suppkey 12 | from 13 | partsupp 14 | where 15 | ps_partkey in ( 16 | select 17 | p_partkey 18 | from 19 | part 20 | where 21 | p_name like ':1%' 22 | ) 23 | and ps_availqty > ( 24 | select 25 | 0.5 * sum(l_quantity) 26 | from 27 | lineitem 28 | where 29 | l_partkey = ps_partkey 30 | and l_suppkey = ps_suppkey 31 | and l_shipdate >= date ':2' 32 | and l_shipdate < date ':2' + interval '1' year 33 | ) 34 | ) 35 | and s_nationkey = n_nationkey 36 | and n_name = ':3' 37 | order by 38 | s_name; 39 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query21.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-21] 2 | select 3 | s_name, 4 | count(*) as numwait 5 | from 6 | supplier, 7 | lineitem l1, 8 | orders, 9 | nation 10 | where 11 | s_suppkey = l1.l_suppkey 12 | and o_orderkey = l1.l_orderkey 13 | and o_orderstatus = 'F' 14 | and l1.l_receiptdate > l1.l_commitdate 15 | and exists ( 16 | select 17 | * 18 | from 19 | lineitem l2 20 | where 21 | l2.l_orderkey = l1.l_orderkey 22 | and l2.l_suppkey <> l1.l_suppkey 23 | ) 24 | and not exists ( 25 | select 26 | * 27 | from 28 | lineitem l3 29 | where 30 | l3.l_orderkey = l1.l_orderkey 31 | and l3.l_suppkey <> l1.l_suppkey 32 | and l3.l_receiptdate > l3.l_commitdate 33 | ) 34 | and s_nationkey = n_nationkey 35 | and n_name = ':1' 36 | group by 37 | s_name 38 | order by 39 | numwait desc, 40 | s_name; 41 | -------------------------------------------------------------------------------- /partiql-planner/src/testFixtures/resources/inputs/tpc_h/query22.sql: -------------------------------------------------------------------------------- 1 | --#[tpc-h-22] 2 | select 3 | cntrycode, 4 | count(*) as numcust, 5 | sum(c_acctbal) as totacctbal 6 | from 7 | ( 8 | select 9 | substring(c_phone from 1 for 2) as cntrycode, 10 | c_acctbal 11 | from 12 | customer 13 | where 14 | substring(c_phone from 1 for 2) in 15 | (':1', ':2', ':3', ':4', ':5', ':6', ':7') 16 | and c_acctbal > ( 17 | select 18 | avg(c_acctbal) 19 | from 20 | customer 21 | where 22 | c_acctbal > 0.00 23 | and substring(c_phone from 1 for 2) in 24 | (':1', ':2', ':3', ':4', ':5', ':6', ':7') 25 | ) 26 | and not exists ( 27 | select 28 | * 29 | from 30 | orders 31 | where 32 | o_custkey = c_custkey 33 | ) 34 | ) as custsale 35 | group by 36 | cntrycode 37 | order by 38 | cntrycode; 39 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/UnsupportedCodeException.java: -------------------------------------------------------------------------------- 1 | package org.partiql.spi; 2 | 3 | /** 4 | * This is specifically thrown when an operation is not implemented for a particular {@link Enum#code()}. 5 | * @see Enum#name() 6 | */ 7 | public class UnsupportedCodeException extends RuntimeException { 8 | public UnsupportedCodeException(int code) { 9 | super("Code not supported: " + code + "."); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/catalog/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

3 | * Holds interfaces that represent different aspects of a PartiQL Catalog. 4 | *

5 | * @see org.partiql.spi.catalog.Catalog 6 | * @see org.partiql.spi.catalog.Identifier 7 | * @see org.partiql.spi.catalog.Session 8 | * @see org.partiql.spi.catalog.Table 9 | */ 10 | package org.partiql.spi.catalog; 11 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/errors/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

3 | * This package contains the core interfaces for PartiQL's error reporting mechanism. 4 | *

5 | * @see org.partiql.spi.errors.PError 6 | * @see org.partiql.spi.errors.PErrorListener 7 | */ 8 | package org.partiql.spi.errors; 9 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/function/Accumulator.java: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.partiql.spi.value.Datum; 5 | 6 | /** 7 | * Represents the accumulator for an aggregation function. 8 | * @see AggOverload 9 | * @see Agg 10 | */ 11 | public interface Accumulator { 12 | 13 | /** 14 | * Receives the next set of arguments, and updates the accumulator's state. 15 | * @param args the next set of arguments. 16 | */ 17 | public void next(Datum[] args); 18 | 19 | /** 20 | * Computes the final value of the accumulator. 21 | * @return the computed final value of the accumulator. 22 | */ 23 | @NotNull 24 | public Datum value(); 25 | } 26 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/function/Agg.java: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | 5 | /** 6 | * Represents an aggregate function (e.g. SUM, AVG, etc.) and its implementation. 7 | * @see AggOverload 8 | */ 9 | public abstract class Agg { 10 | 11 | /** 12 | * Returns an accumulator for the aggregate function. 13 | * @return an accumulator for the aggregate function. 14 | */ 15 | @NotNull 16 | public abstract Accumulator getAccumulator(); 17 | 18 | /** 19 | * Returns the signature of the aggregate function. 20 | * @return the signature of the aggregate function. 21 | */ 22 | @NotNull 23 | public abstract RoutineSignature getSignature(); 24 | } 25 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/function/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

3 | * This packages holds the core interfaces for scalar and aggregate functions. 4 | *

5 | * @see org.partiql.spi.function.FnOverload 6 | * @see org.partiql.spi.function.Fn 7 | * @see org.partiql.spi.function.AggOverload 8 | * @see org.partiql.spi.function.Agg 9 | */ 10 | package org.partiql.spi.function; 11 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

3 | * This package is the root of the SPI module, which provides APIs that are used across PartiQL's libraries. 4 | *

5 | * @see org.partiql.spi.errors 6 | * @see org.partiql.spi.value 7 | * @see org.partiql.types 8 | */ 9 | package org.partiql.spi; 10 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/types/PTypePrimitive.java: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.types; 2 | 3 | import java.util.Objects; 4 | 5 | class PTypePrimitive extends PType { 6 | 7 | PTypePrimitive(int code) { 8 | super(code); 9 | } 10 | 11 | @Override 12 | public boolean equals(Object o) { 13 | if (this == o) return true; 14 | if (!(o instanceof PType)) return false; 15 | return code() == ((PType) o).code(); 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return name(); 21 | } 22 | 23 | @Override 24 | public int hashCode() { 25 | return Objects.hashCode(code()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/types/PTypeVariant.java: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.types; 2 | 3 | class PTypeVariant extends PType { 4 | 5 | // TODO: Use this somehow 6 | private final String encoding; 7 | 8 | public PTypeVariant(String encoding) { 9 | super(VARIANT); 10 | this.encoding = encoding; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/types/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains all of PartiQL's types. 3 | * @see org.partiql.spi.types.PType 4 | * @see org.partiql.spi.types.PType.Kind 5 | */ 6 | package org.partiql.spi.types; 7 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/value/DatumInt.java: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.value; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.partiql.spi.types.PType; 5 | 6 | /** 7 | * This shall always be package-private (internal). 8 | */ 9 | class DatumInt implements Datum { 10 | 11 | private final int _value; 12 | 13 | private final static PType _type = PType.integer(); 14 | 15 | DatumInt(int value) { 16 | _value = value; 17 | } 18 | 19 | @Override 20 | public int getInt() { 21 | return _value; 22 | } 23 | 24 | @NotNull 25 | @Override 26 | public PType getType() { 27 | return _type; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "DatumInt{" + 33 | "_type=" + _type + 34 | ", _value=" + _value + 35 | '}'; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/value/DatumWriter.java: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.value; 2 | 3 | /** 4 | * The {@link DatumWriter} interface is a low-level writer interface for writing streams of PartiQL data. 5 | *
6 | * @see java.io.Writer 7 | */ 8 | public interface DatumWriter extends AutoCloseable { 9 | 10 | /** 11 | * Like java.io.Reader with combined `append` and `write` since this does not implement Appendable. 12 | * 13 | * @param datum to write. 14 | */ 15 | public DatumWriter write(Datum datum); 16 | } 17 | -------------------------------------------------------------------------------- /partiql-spi/src/main/java/org/partiql/spi/value/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

3 | * This package provides the core representation of PartiQL runtime values, {@link org.partiql.spi.value.Datum}. 4 | *

5 | * @see org.partiql.spi.value.Datum 6 | * @see org.partiql.types 7 | */ 8 | package org.partiql.spi.value; 9 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/Aggregation.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function 2 | 3 | import org.partiql.spi.types.PType 4 | 5 | /** 6 | * Represents a SQL aggregation function, such as MAX, MIN, SUM, etc. 7 | */ 8 | internal object Aggregation { 9 | 10 | /** 11 | * @param name 12 | * @param parameters 13 | * @param returns 14 | * @param accumulator 15 | * @return 16 | */ 17 | @JvmStatic 18 | fun overload( 19 | name: String, 20 | parameters: Array, 21 | returns: PType, 22 | accumulator: () -> Accumulator, 23 | ): AggOverload { 24 | return AggOverload.Builder(name) 25 | .returns(returns) 26 | .addParameters(*parameters.map { it.getType() }.toTypedArray()) 27 | .body(accumulator) 28 | .build() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggAny.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Aggregation 7 | import org.partiql.spi.function.Parameter 8 | import org.partiql.spi.function.builtins.internal.AccumulatorAnySome 9 | import org.partiql.spi.types.PType 10 | 11 | internal val Agg_ANY__BOOL__BOOL = Aggregation.overload( 12 | name = "any", 13 | returns = PType.bool(), 14 | parameters = arrayOf(Parameter("value", PType.bool())), 15 | accumulator = ::AccumulatorAnySome 16 | ) 17 | 18 | internal val Agg_ANY__ANY__BOOL = Aggregation.overload( 19 | name = "any", 20 | returns = PType.bool(), 21 | parameters = arrayOf(Parameter("value", PType.dynamic())), 22 | accumulator = ::AccumulatorAnySome 23 | ) 24 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggCount.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Aggregation 7 | import org.partiql.spi.function.Parameter 8 | import org.partiql.spi.function.builtins.internal.AccumulatorCount 9 | import org.partiql.spi.types.PType 10 | 11 | internal val Agg_COUNT__ANY__INT64 = Aggregation.overload( 12 | name = "count", 13 | returns = PType.bigint(), 14 | parameters = arrayOf(Parameter("value", PType.dynamic())), 15 | accumulator = ::AccumulatorCount, 16 | ) 17 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/AggGroupAs.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Aggregation 7 | import org.partiql.spi.function.Parameter 8 | import org.partiql.spi.function.builtins.internal.AccumulatorGroupAs 9 | import org.partiql.spi.types.PType 10 | 11 | internal val Agg_GROUP_AS__ANY__ANY = Aggregation.overload( 12 | name = "group_as", 13 | returns = PType.dynamic(), 14 | parameters = arrayOf( 15 | Parameter("value", PType.dynamic()), 16 | ), 17 | accumulator = ::AccumulatorGroupAs, 18 | ) 19 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DefaultDecimal.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function.builtins 2 | 3 | import org.partiql.spi.types.PType 4 | 5 | internal object DefaultDecimal { 6 | // TODO: Once all functions are converted to use the new function modeling, this can be removed. 7 | val DECIMAL: PType = PType.decimal(38, 19) 8 | } 9 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/DefaultNumeric.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function.builtins 2 | 3 | import org.partiql.spi.types.PType 4 | 5 | internal object DefaultNumeric { 6 | // TODO: Once all functions are converted to use the new function modeling, this can be removed. 7 | val NUMERIC: PType = PType.numeric(38, 19) 8 | } 9 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnAnd.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.utils.FunctionUtils.logicalAnd 10 | 11 | internal val Fn_AND__BOOL_BOOL__BOOL = FunctionUtils.hidden( 12 | name = "and", 13 | returns = PType.bool(), 14 | parameters = arrayOf( 15 | Parameter("lhs", PType.bool()), 16 | Parameter("rhs", PType.bool()), 17 | ), 18 | isNullCall = false, 19 | isMissingCall = false, 20 | ) { args -> 21 | logicalAnd(args[0], args[1]) 22 | } 23 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCurrentDate.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.types.PType 7 | import org.partiql.spi.utils.FunctionUtils 8 | 9 | internal val Fn_CURRENT_DATE____DATE = FunctionUtils.hidden( 10 | 11 | name = "current_date", 12 | returns = PType.date(), 13 | parameters = arrayOf(), 14 | 15 | ) { args -> 16 | TODO("Function current_date not implemented") 17 | } 18 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnCurrentUser.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.types.PType 7 | import org.partiql.spi.utils.FunctionUtils 8 | 9 | internal val Fn_CURRENT_USER____STRING = FunctionUtils.hidden( 10 | 11 | name = "current_user", 12 | returns = PType.string(), 13 | parameters = arrayOf(), 14 | 15 | ) { args -> 16 | TODO("Function current_user not implemented") 17 | } 18 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsAny.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | 10 | internal val Fn_IS_ANY__ANY__BOOL = FunctionUtils.hidden( 11 | name = "is_any", 12 | returns = PType.bool(), 13 | parameters = arrayOf(Parameter("value", PType.dynamic())), 14 | isNullCall = true, 15 | ) { _ -> 16 | TODO("Function is_any not implemented") 17 | } 18 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBag.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | internal val Fn_IS_BAG__ANY__BOOL = FunctionUtils.hidden( 12 | name = "is_bag", 13 | returns = PType.bool(), 14 | parameters = arrayOf(Parameter("value", PType.dynamic())), 15 | ) { args -> 16 | Datum.bool(args[0].type.code() == PType.BAG) 17 | } 18 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBinary.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | 10 | internal val Fn_IS_BINARY__ANY__BOOL = FunctionUtils.hidden( 11 | name = "is_binary", 12 | returns = PType.bool(), 13 | parameters = arrayOf(Parameter("value", PType.dynamic())), 14 | ) { _ -> 15 | TODO("BINARY NOT SUPPORTED RIGHT NOW.") 16 | } 17 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBlob.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | internal val Fn_IS_BLOB__ANY__BOOL = FunctionUtils.hidden( 12 | name = "is_blob", 13 | returns = PType.bool(), 14 | parameters = arrayOf(Parameter("value", PType.dynamic())), 15 | ) { args -> 16 | Datum.bool(args[0].type.code() == PType.BLOB) 17 | } 18 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsBool.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | internal val Fn_IS_BOOL__ANY__BOOL = FunctionUtils.hidden( 12 | name = "is_bool", 13 | returns = PType.bool(), 14 | parameters = arrayOf(Parameter("value", PType.dynamic())), 15 | ) { args -> 16 | Datum.bool(args[0].type.code() == PType.BOOL) 17 | } 18 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsByte.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | 10 | internal val Fn_IS_BYTE__ANY__BOOL = FunctionUtils.hidden( 11 | 12 | name = "is_byte", 13 | returns = PType.bool(), 14 | parameters = arrayOf(Parameter("value", PType.dynamic())), 15 | 16 | ) { args -> 17 | TODO("BYTE NOT SUPPORTED YET.") 18 | } 19 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsClob.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | internal val Fn_IS_CLOB__ANY__BOOL = FunctionUtils.hidden( 12 | 13 | name = "is_clob", 14 | returns = PType.bool(), 15 | parameters = arrayOf(Parameter("value", PType.dynamic())), 16 | 17 | ) { args -> 18 | Datum.bool(args[0].type.code() == PType.CLOB) 19 | } 20 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsDate.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | internal val Fn_IS_DATE__ANY__BOOL = FunctionUtils.hidden( 12 | 13 | name = "is_date", 14 | returns = PType.bool(), 15 | parameters = arrayOf(Parameter("value", PType.dynamic())), 16 | 17 | ) { args -> 18 | Datum.bool(args[0].type.code() == PType.DATE) 19 | } 20 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsFloat32.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | internal val Fn_IS_FLOAT32__ANY__BOOL = FunctionUtils.hidden( 12 | 13 | name = "is_float32", 14 | returns = PType.bool(), 15 | parameters = arrayOf(Parameter("value", PType.dynamic())), 16 | 17 | ) { args -> 18 | val arg = args[0] 19 | when (arg.type.code()) { 20 | PType.REAL -> Datum.bool(true) 21 | PType.DOUBLE -> { 22 | val v = arg.double 23 | Datum.bool(Float.MIN_VALUE <= v && v <= Float.MAX_VALUE) 24 | } 25 | else -> Datum.bool(false) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsFloat64.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | internal val Fn_IS_FLOAT64__ANY__BOOL = FunctionUtils.hidden( 12 | 13 | name = "is_float64", 14 | returns = PType.bool(), 15 | parameters = arrayOf(Parameter("value", PType.dynamic())), 16 | 17 | ) { args -> 18 | when (args[0].type.code()) { 19 | PType.REAL, 20 | PType.DOUBLE, 21 | -> Datum.bool(true) 22 | else -> Datum.bool(false) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInt.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | private val INT_TYPES = setOf( 12 | PType.TINYINT, 13 | PType.SMALLINT, 14 | PType.INTEGER, 15 | PType.BIGINT, 16 | PType.NUMERIC 17 | ) 18 | 19 | internal val Fn_IS_INT__ANY__BOOL = FunctionUtils.hidden( 20 | name = "is_int", 21 | returns = PType.bool(), 22 | parameters = arrayOf(Parameter("value", PType.dynamic())) 23 | ) { args -> 24 | val arg = args[0] 25 | Datum.bool(arg.type.code() in INT_TYPES) 26 | } 27 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsInterval.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | 10 | internal val Fn_IS_INTERVAL__ANY__BOOL = FunctionUtils.hidden( 11 | 12 | name = "is_interval", 13 | returns = PType.bool(), 14 | parameters = arrayOf(Parameter("value", PType.dynamic())), 15 | 16 | ) { args -> 17 | TODO("INTERVAL NOT SUPPORTED YET") 18 | } 19 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsList.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | internal val Fn_IS_LIST__ANY__BOOL = FunctionUtils.hidden( 12 | 13 | name = "is_list", 14 | returns = PType.bool(), 15 | parameters = arrayOf(Parameter("value", PType.dynamic())), 16 | 17 | ) { args -> 18 | Datum.bool(args[0].type.code() == PType.ARRAY) 19 | } 20 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsMissing.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.FnOverload 7 | import org.partiql.spi.function.Parameter 8 | import org.partiql.spi.types.PType 9 | import org.partiql.spi.utils.FunctionUtils 10 | import org.partiql.spi.value.Datum 11 | 12 | /** 13 | * Function (operator) for the `IS MISSING` special form. Its name is hidden via [FunctionUtils.hide]. 14 | */ 15 | private val name = FunctionUtils.hide("is_missing") 16 | internal val Fn_IS_MISSING__ANY__BOOL = FnOverload.Builder(name) 17 | .returns(PType.bool()) 18 | .addParameter(Parameter("value", PType.dynamic())) 19 | .isNullCall(false) 20 | .isMissingCall(false) 21 | .body { args -> 22 | Datum.bool(args[0].isMissing) 23 | } 24 | .build() 25 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsStruct.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | internal val Fn_IS_STRUCT__ANY__BOOL = FunctionUtils.hidden( 12 | 13 | name = "is_struct", 14 | returns = PType.bool(), 15 | parameters = arrayOf(Parameter("value", PType.dynamic())), 16 | 17 | ) { args -> 18 | Datum.bool(args[0].type.code() == PType.STRUCT) 19 | } 20 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnIsUnknown.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.value.Datum 10 | 11 | /** 12 | * Function (operator) for the `IS UNKNOWN` special form. 13 | */ 14 | internal val Fn_IS_UNKNOWN__ANY__BOOL = FunctionUtils.hidden( 15 | name = "is_unknown", 16 | returns = PType.bool(), 17 | parameters = arrayOf(Parameter("value", PType.bool())), 18 | isNullCall = false, 19 | isMissingCall = false 20 | ) { args -> 21 | val arg = args[0] 22 | if (arg.isNull || arg.isMissing) { 23 | Datum.bool(true) 24 | } else { 25 | Datum.bool(false) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnNot.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.FnOverload 7 | import org.partiql.spi.function.Parameter 8 | import org.partiql.spi.types.PType 9 | import org.partiql.spi.utils.FunctionUtils 10 | import org.partiql.spi.utils.FunctionUtils.logicalNot 11 | 12 | /** 13 | * This is the boolean NOT predicate. Its name is hidden via the use of [FunctionUtils.hide]. 14 | */ 15 | private val name = FunctionUtils.hide("not") 16 | internal val Fn_NOT__BOOL__BOOL = FnOverload.Builder(name) 17 | .isNullCall(true) 18 | .isMissingCall(false) 19 | .addParameter(Parameter("value", PType.dynamic())) 20 | .returns(PType.bool()) 21 | .body { args -> 22 | logicalNot(args[0]) 23 | } 24 | .build() 25 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnOr.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Parameter 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.utils.FunctionUtils 9 | import org.partiql.spi.utils.FunctionUtils.logicalOr 10 | 11 | internal val Fn_OR__BOOL_BOOL__BOOL = FunctionUtils.hidden( 12 | name = "or", 13 | returns = PType.bool(), 14 | parameters = arrayOf( 15 | Parameter("lhs", PType.bool()), 16 | Parameter("rhs", PType.bool()), 17 | ), 18 | isNullCall = false, 19 | isMissingCall = false, 20 | ) { args -> 21 | logicalOr(args[0], args[1]) 22 | } 23 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/FnUtcnow.kt: -------------------------------------------------------------------------------- 1 | // ktlint-disable filename 2 | @file:Suppress("ClassName") 3 | 4 | package org.partiql.spi.function.builtins 5 | 6 | import org.partiql.spi.function.Function 7 | import org.partiql.spi.types.PType 8 | import org.partiql.spi.value.Datum 9 | import java.time.OffsetDateTime 10 | import java.time.ZoneOffset 11 | 12 | internal val Fn_UTCNOW____TIMESTAMP = Function.overload( 13 | name = "utcnow", 14 | returns = PType.timestampz(6), 15 | parameters = arrayOf(), 16 | ) { 17 | val now = OffsetDateTime.now(ZoneOffset.UTC) 18 | Datum.timestampz(now, 6) 19 | } 20 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorAnySome.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function.builtins.internal 2 | 3 | import org.partiql.spi.types.PType 4 | import org.partiql.spi.utils.FunctionUtils.booleanValue 5 | import org.partiql.spi.utils.FunctionUtils.checkIsBooleanType 6 | import org.partiql.spi.value.Datum 7 | 8 | internal class AccumulatorAnySome : Accumulator() { 9 | 10 | private var res: Datum? = null 11 | 12 | override fun nextValue(value: Datum) { 13 | checkIsBooleanType("ANY/SOME", value) 14 | res = res?.let { Datum.bool(it.booleanValue() || value.booleanValue()) } ?: value 15 | } 16 | 17 | override fun value(): Datum = res ?: Datum.nullValue(PType.bool()) 18 | } 19 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorCount.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function.builtins.internal 2 | 3 | import org.partiql.spi.value.Datum 4 | 5 | internal class AccumulatorCount : Accumulator() { 6 | 7 | var count: Long = 0L 8 | 9 | override fun nextValue(value: Datum) { 10 | this.count += 1L 11 | } 12 | 13 | override fun value(): Datum = Datum.bigint(count) 14 | } 15 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorDistinct.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function.builtins.internal 2 | 3 | import org.partiql.spi.value.Datum 4 | import java.util.TreeSet 5 | 6 | internal class AccumulatorDistinct( 7 | private val _delegate: Accumulator, 8 | ) : Accumulator() { 9 | 10 | private val seen = TreeSet(Datum.comparator()) 11 | 12 | override fun nextValue(value: Datum) { 13 | if (!seen.contains(value)) { 14 | seen.add(value) 15 | _delegate.nextValue(value) 16 | } 17 | } 18 | 19 | override fun value(): Datum { 20 | return _delegate.value() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorEvery.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function.builtins.internal 2 | 3 | import org.partiql.spi.types.PType 4 | import org.partiql.spi.utils.FunctionUtils.checkIsBooleanType 5 | import org.partiql.spi.value.Datum 6 | 7 | internal class AccumulatorEvery : Accumulator() { 8 | 9 | private var res: Datum? = null 10 | 11 | override fun nextValue(value: Datum) { 12 | checkIsBooleanType("EVERY", value) 13 | res = res?.let { Datum.bool(it.boolean && value.boolean) } ?: value 14 | } 15 | 16 | override fun value(): Datum = res ?: Datum.nullValue(PType.bool()) 17 | } 18 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorGroupAs.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function.builtins.internal 2 | 3 | import org.partiql.spi.value.Datum 4 | 5 | internal class AccumulatorGroupAs : Accumulator() { 6 | 7 | val values = mutableListOf() 8 | 9 | override fun nextValue(value: Datum) { 10 | values.add(value) 11 | } 12 | 13 | override fun value(): Datum = Datum.bag(values) 14 | } 15 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorMax.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function.builtins.internal 2 | 3 | import org.partiql.spi.utils.FunctionUtils.comparisonAccumulator 4 | import org.partiql.spi.value.Datum 5 | 6 | internal class AccumulatorMax : Accumulator() { 7 | 8 | var max: Datum = Datum.nullValue() 9 | private val comparator = Datum.comparator(true).reversed() 10 | 11 | override fun nextValue(value: Datum) { 12 | max = comparisonAccumulator(comparator)(max, value) 13 | } 14 | 15 | override fun value(): Datum = max 16 | } 17 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/function/builtins/internal/AccumulatorMin.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.function.builtins.internal 2 | 3 | import org.partiql.spi.utils.FunctionUtils.comparisonAccumulator 4 | import org.partiql.spi.value.Datum 5 | 6 | internal class AccumulatorMin : Accumulator() { 7 | 8 | var min: Datum = Datum.nullValue() 9 | private val comparator = Datum.comparator(false) 10 | 11 | override fun nextValue(value: Datum) { 12 | min = comparisonAccumulator(comparator)(min, value) 13 | } 14 | 15 | override fun value(): Datum = min 16 | } 17 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/internal/value/ion/IonDatumWriter.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.internal.value.ion 2 | 3 | import org.partiql.spi.value.Datum 4 | import org.partiql.spi.value.DatumWriter 5 | 6 | internal class IonDatumWriter : DatumWriter { 7 | 8 | override fun close() { 9 | TODO("Not yet implemented") 10 | } 11 | 12 | override fun write(datum: Datum?): DatumWriter { 13 | TODO("Not yet implemented") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/internal/value/json/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/partiql/partiql-lang-kotlin/8d556cad5c1fb17c453e7cb141ae08a31eb3dcd7/partiql-spi/src/main/kotlin/org/partiql/spi/internal/value/json/.gitkeep -------------------------------------------------------------------------------- /partiql-spi/src/main/kotlin/org/partiql/spi/utils/DatumUtils.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.utils 2 | 3 | import org.partiql.spi.types.PType 4 | import org.partiql.spi.value.Datum 5 | 6 | internal fun Datum.getNumber(): Number { 7 | return when (this.type.code()) { 8 | PType.TINYINT -> this.byte 9 | PType.INTEGER -> this.int 10 | PType.SMALLINT -> this.short 11 | PType.BIGINT -> this.long 12 | PType.REAL -> this.float 13 | PType.DOUBLE -> this.double 14 | PType.DECIMAL -> this.bigDecimal 15 | PType.NUMERIC -> this.bigDecimal 16 | else -> error("Unexpected type: ${this.type}") 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /partiql-spi/src/test/kotlin/org/partiql/spi/value/ion/IonDatumReaderTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.value.ion 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.partiql.spi.value.DatumReader 5 | 6 | class IonDatumReaderTest { 7 | 8 | /** 9 | * Test we can parse all inputs with no errors. 10 | */ 11 | @Test 12 | fun acceptance() { 13 | readAll("/io/ion/kitchen_lower.ion") 14 | // TODO re-enable after types with arguments are supported 15 | // readAll("/io/ion/kitchen_typed.ion") 16 | } 17 | 18 | private fun readAll(resource: String) { 19 | val input = this::class.java.getResourceAsStream(resource)!! 20 | val reader = DatumReader.ion(input) 21 | while (reader.next() != null) { 22 | // do nothing 23 | } 24 | reader.close() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /partiql-spi/src/test/kotlin/org/partiql/spi/value/ion/IonDatumWriterTest.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.spi.value.ion 2 | 3 | class IonDatumWriterTest 4 | -------------------------------------------------------------------------------- /partiql-spi/src/test/kotlin/org/partiql/spi/value/json/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/partiql/partiql-lang-kotlin/8d556cad5c1fb17c453e7cb141ae08a31eb3dcd7/partiql-spi/src/test/kotlin/org/partiql/spi/value/json/.gitkeep -------------------------------------------------------------------------------- /partiql-spi/src/test/resources/io/ion/kitchen_lower.ion: -------------------------------------------------------------------------------- 1 | null 2 | missing 3 | true 4 | false 5 | 1 // int 6 | 1e23 // float 7 | 1.23 // double 8 | "abc" 9 | {{ "This is a CLOB of text." }} 10 | {{ VG8gaW5maW5pdHkuLi4gYW5kIGJleW9uZCE= }} 11 | { x: 1, y: 2, z: 3 } 12 | [ "a", "b", "c" ] 13 | -------------------------------------------------------------------------------- /partiql-spi/src/test/resources/io/json/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/partiql/partiql-lang-kotlin/8d556cad5c1fb17c453e7cb141ae08a31eb3dcd7/partiql-spi/src/test/resources/io/json/.gitkeep -------------------------------------------------------------------------------- /partiql-spi/src/test/resources/snapshot.properties: -------------------------------------------------------------------------------- 1 | serializer=au.com.origin.snapshots.serializers.v1.ToStringSnapshotSerializer 2 | comparator=au.com.origin.snapshots.comparators.v1.PlainTextEqualsComparator 3 | reporters=au.com.origin.snapshots.reporters.v1.PlainTextSnapshotReporter 4 | snapshot-dir=__snapshots__ 5 | output-dir=src/test/java 6 | ci-env-var=CI 7 | update-snapshot=none -------------------------------------------------------------------------------- /test/coverage-tests/README.md: -------------------------------------------------------------------------------- 1 | # PartiQL Code Coverage Tests 2 | 3 | While there are some unit tests in `partiql-coverage`, this repository aims to simultaneously create integration tests 4 | as well as expose examples for users on how to create PartiQL Code Coverage tests. 5 | -------------------------------------------------------------------------------- /test/coverage-tests/src/test/kotlin/org/partiql/test/coverage/utils/PartiQLTestCaseDefault.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.test.coverage.utils 2 | 3 | import org.partiql.coverage.api.PartiQLTestCase 4 | import org.partiql.lang.eval.EvaluationSession 5 | 6 | /** 7 | * [PartiQLTestCase] with nothing to assert. Uses the default [EvaluationSession]. 8 | */ 9 | class PartiQLTestCaseDefault : PartiQLTestCase { 10 | override val session: EvaluationSession = EvaluationSession.standard() 11 | } 12 | -------------------------------------------------------------------------------- /test/partiql-tests-runner/src/main/kotlin/org/partiql/runner/Report.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.runner 2 | 3 | data class Report( 4 | val dataSet: DataSet, 5 | val commitId: String, 6 | val passingSet: Set, 7 | val failingSet: Set, 8 | val ignoredSet: Set 9 | ) { 10 | // The short hash 11 | val commitIdShort = commitId.substring(0..6) 12 | } 13 | 14 | enum class DataSet { 15 | PartiQLCore, 16 | PartiQLExtended 17 | } 18 | -------------------------------------------------------------------------------- /test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/CompileType.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.runner 2 | 3 | enum class CompileType { 4 | PERMISSIVE, 5 | STRICT 6 | } 7 | -------------------------------------------------------------------------------- /test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/Ion.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.runner 2 | 3 | import com.amazon.ion.system.IonSystemBuilder 4 | 5 | /** 6 | * IonSystem for legacy pipelines and value comparison. 7 | */ 8 | public val ION = IonSystemBuilder.standard().build() 9 | -------------------------------------------------------------------------------- /test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/schema/Assertion.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.runner.schema 2 | 3 | import com.amazon.ion.IonValue 4 | 5 | sealed class Assertion { 6 | data class EvaluationSuccess(val expectedResult: IonValue) : Assertion() 7 | object EvaluationFailure : Assertion() 8 | // TODO: other assertion and test categories: https://github.com/partiql/partiql-tests/issues/35 9 | } 10 | -------------------------------------------------------------------------------- /test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/schema/EquivalenceClass.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.runner.schema 2 | 3 | data class EquivalenceClass( 4 | val id: String, 5 | val statements: List, 6 | ) 7 | -------------------------------------------------------------------------------- /test/partiql-tests-runner/src/test/kotlin/org/partiql/runner/schema/Namespace.kt: -------------------------------------------------------------------------------- 1 | package org.partiql.runner.schema 2 | 3 | import com.amazon.ion.IonStruct 4 | 5 | data class Namespace( 6 | var env: IonStruct, 7 | val namespaces: MutableList, 8 | val testCases: MutableList, 9 | val equivClasses: MutableMap> 10 | ) 11 | -------------------------------------------------------------------------------- /test/partiql-tests-runner/src/test/resources/config/eval/skip-eval-extended.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/partiql/partiql-lang-kotlin/8d556cad5c1fb17c453e7cb141ae08a31eb3dcd7/test/partiql-tests-runner/src/test/resources/config/eval/skip-eval-extended.txt -------------------------------------------------------------------------------- /test/partiql-tests-runner/src/test/resources/ported/eval-equiv/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/partiql/partiql-lang-kotlin/8d556cad5c1fb17c453e7cb141ae08a31eb3dcd7/test/partiql-tests-runner/src/test/resources/ported/eval-equiv/.gitkeep --------------------------------------------------------------------------------