-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PlannerPipeline #590
Add PlannerPipeline #590
Conversation
8ba7305
to
53f6bda
Compare
- AST->logical - logical->resolved - lesolved->physical. Not yet integrated with anything--that will come in a future commit.
405ae74
to
befac52
Compare
cf7f832
to
c20b466
Compare
c20b466
to
10ebc0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted a few places where I need to rename "global bindings" to "unique id resolver".
…plan-staging-planner-pipeline
…plan-staging-planner-pipeline
@@ -34,12 +34,10 @@ import org.partiql.lang.util.propertyValueMapOf | |||
* | |||
* @param message the message for this exception | |||
* @param errorCode the error code for this exception | |||
* @param errorContextArg context for this error, contains details like line & column number among other attributes. | |||
* @param errorContext context for this error, includes details like line & character offsets, among others. | |||
* @param internal True to indicate that this exception a bug in ParitQL itself. False to indicate it was caused by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit.: is a bug
.
|
||
/* | ||
|
||
Differences between CompilerOptions and PlannerOptions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EvaluatorOptions
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks. Fixing...
Differences between CompilerOptions and PlannerOptions: | ||
|
||
- There is no EvaluatorOptions equivalent for CompileOptions.visitorTransformMode since the planner always runs some basic | ||
normalization and variable resolution passes *before* the customer can inject their own transforms. | ||
- There is no EvaluatorOptions equivalent for CompileOptions.thunkReturnTypeAssertions since PlannerPipeline does not | ||
support the static type inferencer (yet). | ||
- PlannerOptions.allowUndefinedVariables is new. | ||
- PlannerOptions has no equivalent for CompileOptions.undefinedVariableBehavior -- this was added for backward |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EvaluatorOptions
?
Differences between CompilerOptions and PlannerOptions: | ||
|
||
- There is no EvaluatorOptions equivalent for CompileOptions.visitorTransformMode since the planner always runs some basic | ||
normalization and variable resolution passes *before* the customer can inject their own transforms. | ||
- There is no EvaluatorOptions equivalent for CompileOptions.thunkReturnTypeAssertions since PlannerPipeline does not | ||
support the static type inferencer (yet). | ||
- PlannerOptions.allowUndefinedVariables is new. | ||
- PlannerOptions has no equivalent for CompileOptions.undefinedVariableBehavior -- this was added for backward |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EvaluatorOptions
?
* - Parses the specified SQL string, producing an AST. | ||
* - Converts the AST to a logical plan. | ||
* - Resolves all global and local variables in the logical plan, assigning unique indexes to local variables | ||
* and calling [MetadataResolver.resolveVariable] to obtain PartiQL-service specific unique identifiers of global |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have an in place definition of PartiQL service here?
/** | ||
* Add a custom function which will be callable by the compiled queries. | ||
* | ||
* Functions added here will replace any built-in function with the same name. | ||
*/ | ||
fun addFunction(function: ExprFunction): Builder = this.apply { | ||
customFunctions[function.signature.name] = function | ||
} | ||
|
||
/** | ||
* Add custom types to CAST/IS operators to. | ||
* | ||
* Built-in types will take precedence over custom types in case of a name collision. | ||
*/ | ||
fun customDataTypes(customTypes: List<CustomType>) = this.apply { | ||
customDataTypes = customTypes | ||
} | ||
|
||
/** | ||
* Add a custom stored procedure which will be callable by the compiled queries. | ||
* | ||
* Stored procedures added here will replace any built-in procedure with the same name. | ||
*/ | ||
fun addProcedure(procedure: StoredProcedure): Builder = this.apply { | ||
customProcedures[procedure.signature.name] = procedure | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the decisions that we're making here for custom functions, types, and procedures make future debugging or understanding the expected behavior difficult. I'd be more inclined to not to support them at this stage to leave the room open. If going with supporting them, wouldn't it make sense to disallow any name collisions with built-ins at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the decisions that we're making here for custom functions, types, and procedures make future debugging or understanding the expected behavior difficult.
I don't understand this statement--there are no decisions being made--their behavior and the behavior of this API is 100% identical to CompilerPipeline
and the AST evaluator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had an offline discussion about this and—considering the open type system work that is started—current agreement is to be more restrictive w/ not introducing the custom function and type interfaces to the API at this stage and revisit once there is a defined use-case. If at that stage we don't have the impl from open type system we'll decide on incorporating the use-case with the least throw away work in this API.
/** | ||
* Add a custom function which will be callable by the compiled queries. | ||
* | ||
* Functions added here will replace any built-in function with the same name. | ||
*/ | ||
fun addFunction(function: ExprFunction): Builder = this.apply { | ||
customFunctions[function.signature.name] = function | ||
} | ||
|
||
/** | ||
* Add custom types to CAST/IS operators to. | ||
* | ||
* Built-in types will take precedence over custom types in case of a name collision. | ||
*/ | ||
fun customDataTypes(customTypes: List<CustomType>) = this.apply { | ||
customDataTypes = customTypes | ||
} | ||
|
||
/** | ||
* Add a custom stored procedure which will be callable by the compiled queries. | ||
* | ||
* Stored procedures added here will replace any built-in procedure with the same name. | ||
*/ | ||
fun addProcedure(procedure: StoredProcedure): Builder = this.apply { | ||
customProcedures[procedure.signature.name] = procedure | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the decisions that we're making here for custom functions, types, and procedures make future debugging or understanding the expected behavior difficult. I'd be more inclined to not to support them at this stage to leave the room open. If going with supporting them, wouldn't it make sense to disallow any name collisions with built-ins at all?
val compileOptionsToUse = evaluatorOptions ?: EvaluatorOptions.standard() | ||
|
||
when (compileOptionsToUse.thunkOptions.thunkReturnTypeAssertions) { | ||
ThunkReturnTypeAssertions.DISABLED -> { /* intentionally blank */ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great to add the why in the comment.
val compileOptionsToUse = evaluatorOptions ?: EvaluatorOptions.standard() | ||
|
||
when (compileOptionsToUse.thunkOptions.thunkReturnTypeAssertions) { | ||
ThunkReturnTypeAssertions.DISABLED -> { /* intentionally blank */ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great to add the why in the comment.
Merges the following PRs to `main`: - #583 - #584 - #587 - #588 - #589 - #609 - #590 - #592 Also, this adds a TODO comment (ea40e4a, requested by @am357 in offline chat) and excludes `PlannerPipeline` from the new aggregate tests which were pulled in when merging from `main` and were not part of the other PRs (34025b3). By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Merges the following PRs to `main`: - #583 - #584 - #587 - #588 - #589 - #609 - #590 - #592 Also, this adds a TODO comment (ea40e4a, requested by @am357 in offline chat) and excludes `PlannerPipeline` from the new aggregate tests which were pulled in when merging from `main` and were not part of the other PRs (34025b3). By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Merges the following PRs to `main`: - #583 - #584 - #587 - #588 - #589 - #609 - #590 - #592 Also, this adds a TODO comment (ea40e4a, requested by @am357 in offline chat) and excludes `PlannerPipeline` from the new aggregate tests which were pulled in when merging from `main` and were not part of the other PRs (34025b3). By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Merges the following PRs to `main`: - #583 - #584 - #587 - #588 - #589 - #609 - #590 - #592 Also, this adds a TODO comment (ea40e4a, requested by @am357 in offline chat) and excludes `PlannerPipeline` from the new aggregate tests which were pulled in when merging from `main` and were not part of the other PRs (34025b3). By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
This PR was originally part of #582, and is based on #589, which must be merged first.
This PR adds
PlannerPipeline
andEvaluatorOptions
, which are analagous to the AST evaluator'sCompilerPipeline
andCompileOptions
, respectively. The difference is that the passes introduced in #588 are executed, after parsing the AST is converted into a logcial plan, variables are resolved, then its converted to a physical plan.There is no ability to do so yet, however,
PlannerPipeline
will eventually house the APIs needed to make the planner user-extensible.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.