Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add PlannerPipeline #590

Merged
merged 15 commits into from
May 24, 2022

Conversation

dlurton
Copy link
Member

@dlurton dlurton commented Apr 30, 2022

This PR was originally part of #582, and is based on #589, which must be merged first.

This PR adds PlannerPipeline and EvaluatorOptions, which are analagous to the AST evaluator's CompilerPipeline and CompileOptions, 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.

@dlurton dlurton changed the title Physical plan staging planner pipeline Add PlannerPipeline Apr 30, 2022
@dlurton dlurton changed the base branch from main to physical-plan-staging-filter-distinct April 30, 2022 02:38
@dlurton dlurton force-pushed the physical-plan-staging-planner-pipeline branch from 8ba7305 to 53f6bda Compare April 30, 2022 02:39
@dlurton dlurton mentioned this pull request May 4, 2022
- AST->logical
- logical->resolved
- lesolved->physical.

Not yet integrated with anything--that will come in a future commit.
@dlurton dlurton force-pushed the physical-plan-staging-filter-distinct branch from 405ae74 to befac52 Compare May 11, 2022 00:14
@dlurton dlurton force-pushed the physical-plan-staging-planner-pipeline branch from cf7f832 to c20b466 Compare May 11, 2022 00:44
@dlurton dlurton force-pushed the physical-plan-staging-planner-pipeline branch from c20b466 to 10ebc0e Compare May 11, 2022 00:47
@dlurton dlurton requested a review from alancai98 May 11, 2022 16:19
Base automatically changed from physical-plan-staging-filter-distinct to physical-plan-staging May 19, 2022 21:35
@dlurton dlurton requested a review from jpschorr May 19, 2022 22:09
Copy link
Member Author

@dlurton dlurton left a 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".

lang/src/org/partiql/lang/planner/PlannerPipeline.kt Outdated Show resolved Hide resolved
lang/src/org/partiql/lang/planner/PlannerPipeline.kt Outdated Show resolved Hide resolved
lang/src/org/partiql/lang/planner/PlannerPipeline.kt Outdated Show resolved Hide resolved
lang/src/org/partiql/lang/planner/PlannerPipeline.kt Outdated Show resolved Hide resolved
@dlurton dlurton changed the base branch from physical-plan-staging to physical-plan-staging-metadata-resolver May 23, 2022 18:47
@dlurton dlurton requested a review from am357 May 23, 2022 18:49
@dlurton dlurton self-assigned this May 23, 2022
Base automatically changed from physical-plan-staging-metadata-resolver to physical-plan-staging May 23, 2022 18:55
@@ -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
Copy link
Contributor

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EvaluatorOptions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks. Fixing...

Comment on lines 11 to 18
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EvaluatorOptions?

Comment on lines 11 to 18
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
Copy link
Contributor

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
Copy link
Contributor

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?

Comment on lines 196 to 221
/**
* 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
}
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

Comment on lines 196 to 221
/**
* 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
}
Copy link
Contributor

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 */ }
Copy link
Contributor

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 */ }
Copy link
Contributor

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.

@dlurton dlurton merged commit 694b660 into physical-plan-staging May 24, 2022
@dlurton dlurton deleted the physical-plan-staging-planner-pipeline branch May 26, 2022 16:28
dlurton added a commit that referenced this pull request May 27, 2022
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.
RCHowell pushed a commit that referenced this pull request Jun 1, 2022
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.
RCHowell pushed a commit that referenced this pull request Jun 1, 2022
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.
RCHowell pushed a commit that referenced this pull request Jun 1, 2022
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants