-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Remove tableLayoutHandle #12674
Remove tableLayoutHandle #12674
Conversation
Is this ready for review? |
I thought it was ok but it seems like there is merge conflict now... Let me rebase it first. |
945d64f
to
9c9a07d
Compare
presto-hive/src/test/java/com/facebook/presto/hive/TestHiveIntegrationSmokeTest.java
Outdated
Show resolved
Hide resolved
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.
-
"Rename listTableLayouts method" . Looks good (see also trinodb/trino@d7cde8c )
Why rename topushPredicateIntoTableScan
instead ofpushFilterIntoTableScan
? -
"Add missing null checks on TableLayoutResult constructor" . Looks good. (See also trinodb/trino@c68109c)
-
"Remove support for multiple layouts" . Looks good. (See also trinodb/trino@801423b).
Please remove unrelated changes inHiveIntegrationSmokeTest
.
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.
This is a nice a patch. Reviewed the first 10 commits and skimmed through the rest. There are some api change needs more discussion.
presto-hive/src/test/java/com/facebook/presto/hive/TestHiveIntegrationSmokeTest.java
Outdated
Show resolved
Hide resolved
presto-hive/src/test/java/com/facebook/presto/hive/TestHiveIntegrationSmokeTest.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/optimizations/AddExchanges.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/optimizations/BeginTableWrite.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/PickTableLayout.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/split/SplitManager.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/split/SplitManager.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/plan/TableWriterNode.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/Metadata.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/com/facebook/presto/spi/connector/ConnectorSplitManager.java
Outdated
Show resolved
Hide resolved
Might worth splitting everything related 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.
-
"Simplify unconditional PickLayout" and "Inline pushPredicateIntoTableScan" Looks good.
-
"Add tableLayoutHandle and transactionHandle to tableHandle"
Generally looks good. This looks like part of trinodb/trino@47ce7e6 but get split and only adding TableLayoutHandle
and TransactionHandle
to TableHandle
.
Now since we don't remove TableLayoutHandle
from TableScanNode
and other places, there is an interesting question that for object can both holds TableHandle
and TableLayoutHandle
, should we check their layout is the same? -- Or maybe we can squash these split commits before merge so this is no longer a problem ? :)
Also, I would use "TableLayoutHandle", "TransactionHandle" and "TableHandle"
presto-main/src/main/java/com/facebook/presto/metadata/MetadataManager.java
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/TableHandle.java
Outdated
Show resolved
Hide resolved
presto-main/src/test/java/com/facebook/presto/cost/TestCostCalculator.java
Outdated
Show resolved
Hide resolved
presto-main/src/test/java/com/facebook/presto/cost/TestCostCalculator.java
Outdated
Show resolved
Hide resolved
...ook/presto/sql/planner/iterative/rule/TestTransformCorrelatedSingleRowSubqueryToProject.java
Show resolved
Hide resolved
presto-main/src/test/java/com/facebook/presto/sql/planner/iterative/rule/test/PlanBuilder.java
Show resolved
Hide resolved
presto-main/src/test/java/com/facebook/presto/sql/planner/iterative/rule/test/PlanBuilder.java
Outdated
Show resolved
Hide resolved
...t/java/com/facebook/presto/sql/planner/sanity/TestValidateAggregationsWithDefaultValues.java
Outdated
Show resolved
Hide resolved
.../src/test/java/com/facebook/presto/sql/planner/sanity/TestValidateStreamingAggregations.java
Outdated
Show resolved
Hide resolved
Looks reasonable. I have a question though.
which uses the following connector API:
Is it correct to assume that pushed down predicate is encoded in |
We generally should hide But it is discussible if we want to go that far since what we gain is only code cleanness. If we allow connector to participate query planning, all these getLayout calls won't be necessary. Connector basically just needs a rule (or a default rule for connectors that does want to implement itself) to take in a subtree + constrained trait set and return a subtree + provided trait set. However, we need to come up with a plan to support both old connector API and new connector rule based planning. Today, we used a lot of specific data structure to bypass the problem connector cannot rewrite query plan ( |
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.
For now I skip "Use tableHandle in getInfo" to "Remove TableLayoutHandle in TableScanNode" since it looks like continues to backport trinodb/trino@47ce7e6
The following 3 commits looks reasonable:
- "Rename TableLayout to TableProperties"
- "Rename ConnectorTableLayout to ConnectoLayoutProperties"
- "Rename TableLayout to TableProperties in metadata"
Although I feel the third commit should be squashed to the first commit :)
I also agree with @highker 's comment on #12674 (comment) (do we really need to alter the name?) -- or maybe rename it as TableLayoutProperties
?
presto-accumulo/src/main/java/com/facebook/presto/accumulo/AccumuloMetadata.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/TableProperties.java
Outdated
Show resolved
Hide resolved
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.
Thanks for reviewing, I will address these comments and as synced offline, will remove the renaming part.
presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/PickTableLayout.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/MetadataManager.java
Show resolved
Hide resolved
presto-main/src/test/java/com/facebook/presto/execution/TaskTestUtils.java
Outdated
Show resolved
Hide resolved
...-main/src/test/java/com/facebook/presto/execution/scheduler/TestPhasedExecutionSchedule.java
Outdated
Show resolved
Hide resolved
presto-main/src/test/java/com/facebook/presto/sql/planner/TestTypeValidator.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/InputExtractor.java
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/MetadataManager.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/com/facebook/presto/spi/connector/ConnectorSplitManager.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/com/facebook/presto/spi/connector/ConnectorSplitManager.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/Metadata.java
Outdated
Show resolved
Hide resolved
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.
"Use tableHandle in getInfo"
Looks good. Note the semantic is now interesting:
- What does
TableHandle.getLayout
is empty mean? - Should
MetadataManager.getLayout
always return a layout?
Let's discuss in person and add necessary comments. Otherwise it will be difficult for us to maintain the code (and the open source community :) )
Update:
What does TableHandle.getLayout
is empty mean?
Now ......
In the future empty should mean the default access path.
presto-main/src/main/java/com/facebook/presto/metadata/MetadataManager.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/MetadataManager.java
Outdated
Show resolved
Hide resolved
d990f5e
to
4e1a6c2
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.
"Use tableHandle in metadataDelete" Looks good % one nit.
...ain/src/main/java/com/facebook/presto/sql/planner/optimizations/MetadataDeleteOptimizer.java
Outdated
Show resolved
Hide resolved
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.
"Use tableHandle in getLayout" . Looks good with a few small questions.
presto-main/src/main/java/com/facebook/presto/metadata/TableHandle.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/PickTableLayout.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/MetadataManager.java
Outdated
Show resolved
Hide resolved
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.
(Removed since the comment somehow not published, see next comment instead)
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.
"Use tableHandle in getAlternativeTableHandle". Looks good.
presto-main/src/main/java/com/facebook/presto/sql/planner/PlanFragmenter.java
Outdated
Show resolved
Hide resolved
|
Per offline discussion, let's try to squash from "Add tableLayoutHandle and transactionHandle to tableHandle" to "Remove TableLayoutHandle in TableScanNode". Remember to have a backup before squash :) |
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.
Thanks for reviewing, comments has been addressed.
...o-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/ExtractSpatialJoins.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/MetadataManager.java
Show resolved
Hide resolved
...ain/src/main/java/com/facebook/presto/sql/planner/optimizations/MetadataDeleteOptimizer.java
Outdated
Show resolved
Hide resolved
@@ -74,7 +74,7 @@ | |||
|
|||
Optional<TableHandle> getTableHandleForStatisticsCollection(Session session, QualifiedObjectName tableName, Map<String, Object> analyzeProperties); | |||
|
|||
List<TableLayoutResult> getLayouts(Session session, TableHandle tableHandle, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns); | |||
Optional<TableLayoutResult> getLayout(Session session, TableHandle tableHandle, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns); |
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.
Updated in previous commit ("Remove support for multiple layouts").
presto-main/src/main/java/com/facebook/presto/metadata/TableHandle.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/PickTableLayout.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/PlanFragmenter.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/PlanFragmenter.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/plan/TableScanNode.java
Outdated
Show resolved
Hide resolved
210128f
to
fc1261b
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.
Some nits. Will continue review.
presto-main/src/main/java/com/facebook/presto/metadata/Metadata.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/MetadataManager.java
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/MetadataManager.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/optimizations/AddExchanges.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/optimizations/BeginTableWrite.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/TableHandle.java
Outdated
Show resolved
Hide resolved
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.
Looks great. All comments are minor. Thanks for clean it up!
Let's quickly go through the comments marked with "talk in person".
Minor comments about commit message:
-
"Hide TableLayout from engine"
Remember to wrap the commit message to 72 characters :) -
"Use TableHandle in TableLayout"
TechnicallyTableHandle
is not used inTableLayout
--TableLayout
now contains the information to construct aTableHandle
, but it doesn't storeTableHandle
as a field.
So what about "Remove TableLayoutHandle from TableLayout" ?
presto-main/src/main/java/com/facebook/presto/sql/planner/PlanFragmenter.java
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/PickTableLayout.java
Show resolved
Hide resolved
session, | ||
node.getTable(), | ||
constraint, | ||
Optional.of(node.getOutputSymbols().stream() | ||
.map(node.getAssignments()::get) | ||
.collect(toImmutableSet()))); | ||
|
||
if (layouts.isEmpty()) { | ||
return ImmutableList.of(new ValuesNode(idAllocator.getNextId(), node.getOutputSymbols(), ImmutableList.of())); | ||
if (layout.getLayout().getPredicate().isNone()) { |
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 am a bit confused about the logic from line 301-303, although I understand the semantic is correct since it's doing the same thing as before. Let's quickly discuss in person :)
Looks like TableLayout. getPredicate.isNone()
somewhat indicates the scan result is empty? (So use an empty ValuesNode
to replace TableScanNode
)
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, before we even pushdown, we will eliminate unnecessary table Scan node. An example is if we are reading from a view where intersect of predicate from the view and from the query will yield empty result.
return context.defaultRewrite(node); | ||
} | ||
return new MetadataDeleteNode(idAllocator.getNextId(), delete.get().getTarget(), Iterables.getOnlyElement(node.getOutputSymbols()), tableScanNode.getLayout().get()); | ||
// delete target is always the table in source tableScanNode, see BeginTableWrite for details. |
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 thought i understand the code but I don't quite understand this comment. Let's quickly discuss in person :)
fc1261b
to
8cad186
Compare
More accurately, constructs a set of alternate plans with the filter pushed into the table scan based on available table layouts.
Currently multiple layout is used for streaming aggregation/pre-sorted layout selection for connector that supported it. We should have better way to support this functionality once we start to allow connector participate planning. We now expects connector to return at least one layout.
It's just selecting a layout for the raw table scan, so no need to go through the logic for pushing a predicate etc.
5d4b78f
to
2f22bff
Compare
This commit hide tableLayout from engine. Since connector will rewrite the sub plan and use an new TableHandle to represent the current provided view of the data set, layout is no longer a useful concept.
2f22bff
to
58ac906
Compare
This PR is to remove tableLayoutHandle completely from PlanNodes and metadata APIs.
For background and future works, see the following comments: