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 applyFilter equivalent to Constraint-based table layout selection #541
Conversation
3187f86
to
b4fd791
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.
Just skimmed. Generally it looks ok, I need to take another pass.
@@ -602,4 +602,23 @@ default ConnectorTableProperties getTableProperties(ConnectorSession session, Co | |||
{ | |||
return Optional.empty(); | |||
} | |||
|
|||
/** | |||
* Attempt to push down the provided constraint into the table. This method is provided as an alternative to |
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.
it is not alternative, but a replacement.
return Optional.of(new ValuesNode(idAllocator.getNextId(), node.getOutputSymbols(), ImmutableList.of())); | ||
TableHandle newTable; | ||
TupleDomain<ColumnHandle> remainingFilter; | ||
if (metadata.usesLegacyTableLayouts(session, node.getTable())) { |
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: I would put legacy branch into the else
branch.
* <p> | ||
* <b>Note</b>: it's critical for connectors to return Optional.empty() if calling this method has no effect for that | ||
* invocation, even if the connector generally supports pushdown. Doing otherwise can cause the optimizer | ||
* to loop indefinitely. |
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 could also check if the were no change. For example:
- checking if the remaining predicate is empty
- seeing that remaining predicate is equal to constraint that we are trying to push down.
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'm not sure that is possible. The connector could be applying the constraint internally by updating its handle, but it may not be able to enforce the change completely. This means that there would be no external change visible, but big improvements should be happening internally.
@@ -265,7 +265,7 @@ public ConnectorTableLayout getTableLayout(ConnectorSession session, ConnectorTa | |||
TpchTableLayoutHandle layout = (TpchTableLayoutHandle) handle; | |||
|
|||
// tables in this connector have a single layout | |||
return getTableLayouts(session, layout.getTable(), Constraint.alwaysTrue(), Optional.empty()) | |||
return getTableLayouts(session, layout.getTable(), new Constraint<>(layout.getPredicate()), Optional.empty()) |
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.
Commit message has a typo
* <p> | ||
* <b>Note</b>: it's critical for connectors to return Optional.empty() if calling this method has no effect for that | ||
* invocation, even if the connector generally supports pushdown. Doing otherwise can cause the optimizer | ||
* to loop indefinitely. |
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'm not sure that is possible. The connector could be applying the constraint internally by updating its handle, but it may not be able to enforce the change completely. This means that there would be no external change visible, but big improvements should be happening internally.
getLayout(LayoutHandle) was picking a new predicate and ignoring the previously pushed-down predicate.
c7e6765
to
55824f4
Compare
Current constraint is effectively a cache of the predicate that describes the data the connector will produce. It is unnecessary, as the engine can obtain it by calling getTableProperties and retrieving it directly.
The ability to push down a Constraint (TupleDomain + opaque predicate evaluator) is the last piece needed to fully deprecate Table Layouts. The new applyFilter function introduces a specialized API that connectors can implement to obtain the same behavior without having to deal with Table Layouts, TableLayoutHandle, etc. It is meant as a transitional API until the fully-feature applyFilter with generalized predicates is implemented.
55824f4
to
21fd923
Compare
The ability to push down a Constraint (TupleDomain + opaque predicate evaluator) is the last piece needed to fully deprecate Table Layouts. The new applyFilter function introduces a specialized API that connectors can implement to obtain the same behavior without having to deal with Table Layouts, TableLayoutHandle, etc. It is meant as a transitional API until the fully-feature applyFilter with generalized predicates is implemented.