feat(native): Add index source plan conversion with connector extensibility (#27596)#27596
Merged
zacw7 merged 1 commit intoprestodb:masterfrom Apr 16, 2026
Merged
feat(native): Add index source plan conversion with connector extensibility (#27596)#27596zacw7 merged 1 commit intoprestodb:masterfrom
zacw7 merged 1 commit intoprestodb:masterfrom
Conversation
Contributor
Reviewer's GuideAdds an extensibility point for connector-specific IndexSourceNode-to-ConnectorTableHandle conversion and wires IndexSourceNode plan conversion to use it, plus a regression test ensuring default behavior remains equivalent to a normal table scan producing a HiveTableHandle. Sequence diagram for IndexSourceNode to ConnectorTableHandle conversion with index handlesequenceDiagram
participant PlanConverter as VeloxQueryPlanConverterBase
participant IndexNode as protocol_IndexSourceNode
participant Helper as toConnectorTableHandleForIndexSource
participant ConnectorRegistry as PrestoToVeloxConnectorRegistry
participant Connector as PrestoToVeloxConnector
participant TableScan as core_TableScanNode
PlanConverter->>PlanConverter: VELOX_CHECK_NOT_NULL(node)
PlanConverter->>IndexNode: read outputVariables, assignments, tableHandle, indexHandle
PlanConverter->>Helper: toConnectorTableHandleForIndexSource(tableHandle, indexHandle, exprConverter, typeParser)
Helper->>ConnectorRegistry: getPrestoToVeloxConnector(tableHandle.connectorHandle._type)
ConnectorRegistry-->>Helper: connector
Helper->>Connector: toVeloxTableHandleForIndexSource(tableHandle, indexHandle, exprConverter, typeParser)
alt default_implementation
Connector-->>Helper: toVeloxTableHandle(tableHandle, exprConverter, typeParser)
else index_aware_connector
Connector-->>Helper: index_aware ConnectorTableHandle
end
Helper-->>PlanConverter: connectorTableHandle
PlanConverter->>TableScan: create core_TableScanNode(id, rowType, connectorTableHandle, assignments)
TableScan-->>PlanConverter: TableScanNode instance
Updated class diagram for PrestoToVeloxConnector and IndexSourceNode plan conversionclassDiagram
class PrestoToVeloxConnector {
<<interface>>
+toVeloxTableHandle(tableHandle: protocol_TableHandle, exprConverter: VeloxExprConverter, typeParser: TypeParser) ConnectorTableHandle
+toVeloxTableHandleForIndexSource(tableHandle: protocol_TableHandle, indexHandle: protocol_IndexHandle, exprConverter: VeloxExprConverter, typeParser: TypeParser) ConnectorTableHandle
+toVeloxInsertTableHandle(tableHandle: protocol_TableHandle, exprConverter: VeloxExprConverter, typeParser: TypeParser) ConnectorInsertTableHandle
}
class VeloxQueryPlanConverterBase {
-exprConverter_: VeloxExprConverter
-typeParser_: TypeParser
+toVeloxQueryPlan(node: protocol_IndexSourceNode, tableWriteInfo: TableWriteInfo, taskId: TaskId) core_PlanNode
}
class PlanConversionHelpers {
+toConnectorTableHandle(tableHandle: protocol_TableHandle, exprConverter: VeloxExprConverter, typeParser: TypeParser) ConnectorTableHandle
+toConnectorTableHandleForIndexSource(tableHandle: protocol_TableHandle, indexHandle: protocol_IndexHandle, exprConverter: VeloxExprConverter, typeParser: TypeParser) ConnectorTableHandle
}
class protocol_IndexSourceNode {
+id: string
+outputVariables: VariableList
+assignments: AssignmentMap
+tableHandle: protocol_TableHandle
+indexHandle: protocol_IndexHandle
}
class protocol_TableHandle {
+connectorHandle: ConnectorHandle
}
class protocol_IndexHandle {
+indexColumns: ColumnList
}
class core_TableScanNode {
+id: string
+rowType: RowType
+tableHandle: ConnectorTableHandle
+assignments: ColumnHandleMap
}
class ConnectorTableHandle
class ConnectorInsertTableHandle
class VeloxExprConverter
class TypeParser
class TableWriteInfo
class TaskId
class core_PlanNode
class ConcreteConnector {
+toVeloxTableHandleForIndexSource(tableHandle: protocol_TableHandle, indexHandle: protocol_IndexHandle, exprConverter: VeloxExprConverter, typeParser: TypeParser) ConnectorTableHandle
}
VeloxQueryPlanConverterBase --> PlanConversionHelpers : calls
PlanConversionHelpers --> PrestoToVeloxConnector : calls
protocol_IndexSourceNode --> protocol_TableHandle : has
protocol_IndexSourceNode --> protocol_IndexHandle : has
core_TableScanNode --> ConnectorTableHandle : has
PrestoToVeloxConnector <|.. ConcreteConnector
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
zacw7
added a commit
to zacw7/presto
that referenced
this pull request
Apr 15, 2026
…bility (prestodb#27596) Summary: Add a virtual method `toVeloxTableHandleForIndexSource` to `PrestoToVeloxConnector` that allows connectors to customize how an `IndexSourceNode` is converted into a Velox `ConnectorTableHandle`. The default implementation delegates to `toVeloxTableHandle`, ignoring the `IndexHandle`. Connectors that support index lookup can override this to incorporate the `IndexHandle` into the resulting table handle, enabling index-aware table scan creation. Without this extensibility point, the `IndexHandle` (carrying index column names resolved by the coordinator) would be silently dropped during worker-side plan conversion, and the worker would have no way to know which columns are indexed. Also updates `PrestoToVeloxQueryPlan::toVeloxQueryPlan(IndexSourceNode)` to call the new method, passing the `IndexHandle` through from the plan node. **Changes:** - `PrestoToVeloxConnector.h`: Add `toVeloxTableHandleForIndexSource()` virtual method with default delegation to `toVeloxTableHandle()`. - `PrestoToVeloxQueryPlan.cpp`: Add `toConnectorTableHandleForIndexSource()` free function and update `IndexSourceNode` conversion to use it. Add `VELOX_CHECK_NOT_NULL` guard. Differential Revision: D101022019
05855d5 to
f5cc241
Compare
f5cc241 to
87bdf7a
Compare
tanjialiang
previously approved these changes
Apr 16, 2026
…bility (prestodb#27596) Summary: Add a virtual method `toVeloxTableHandleForIndexSource` to `PrestoToVeloxConnector` that allows connectors to customize how an `IndexSourceNode` is converted into a Velox `ConnectorTableHandle`. The default implementation delegates to `toVeloxTableHandle`, ignoring the `IndexHandle`. Connectors that support index lookup can override this to incorporate the `IndexHandle` into the resulting table handle, enabling index-aware table scan creation. Without this extensibility point, the `IndexHandle` (carrying index column names resolved by the coordinator) would be silently dropped during worker-side plan conversion, and the worker would have no way to know which columns are indexed. Also handles the case where `IndexJoinOptimizer` inserts a `FilterNode` between `IndexJoinNode` and `IndexSourceNode` for non-domain-expressible predicates. The `FilterNode` is unwrapped and its filter is merged into the join's remaining filter. **Changes:** - `PrestoToVeloxConnector.h`: Add `toVeloxTableHandleForIndexSource()` virtual method with default delegation to `toVeloxTableHandle()`. - `PrestoToVeloxQueryPlan.cpp`: Add `toConnectorTableHandleForIndexSource()` free function, update `IndexSourceNode` conversion to use it, add `VELOX_CHECK_NOT_NULL` guard, and add `FilterNode` unwrapping for `IndexJoinNode`. - `PlanConverterTest.cpp`: Add `indexSource` test covering `IndexSourceNode` to `TableScanNode` conversion. Differential Revision: D101022019
87bdf7a to
91023c0
Compare
tanjialiang
approved these changes
Apr 16, 2026
Copilot AI
pushed a commit
to Joe-Abraham/presto
that referenced
this pull request
Apr 23, 2026
…bility (prestodb#27596) (prestodb#27596) Summary: Add a virtual method `toVeloxTableHandleForIndexSource` to `PrestoToVeloxConnector` that allows connectors to customize how an `IndexSourceNode` is converted into a Velox `ConnectorTableHandle`. The default implementation delegates to `toVeloxTableHandle`, ignoring the `IndexHandle`. Connectors that support index lookup can override this to incorporate the `IndexHandle` into the resulting table handle, enabling index-aware table scan creation. Without this extensibility point, the `IndexHandle` (carrying index column names resolved by the coordinator) would be silently dropped during worker-side plan conversion, and the worker would have no way to know which columns are indexed. Also handles the case where `IndexJoinOptimizer` inserts a `FilterNode` between `IndexJoinNode` and `IndexSourceNode` for non-domain-expressible predicates. The `FilterNode` is unwrapped and its filter is merged into the join's remaining filter. **Changes:** - `PrestoToVeloxConnector.h`: Add `toVeloxTableHandleForIndexSource()` virtual method with default delegation to `toVeloxTableHandle()`. - `PrestoToVeloxQueryPlan.cpp`: Add `toConnectorTableHandleForIndexSource()` free function, update `IndexSourceNode` conversion to use it, add `VELOX_CHECK_NOT_NULL` guard, and add `FilterNode` unwrapping for `IndexJoinNode`. - `PlanConverterTest.cpp`: Add `indexSource` test covering `IndexSourceNode` to `TableScanNode` conversion. ## Release Notes ``` == NO RELEASE NOTE == ``` Co-authored-by: Joe-Abraham <53977252+Joe-Abraham@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Add a virtual method
toVeloxTableHandleForIndexSourcetoPrestoToVeloxConnectorthat allows connectors to customize how anIndexSourceNodeis converted into a VeloxConnectorTableHandle. The default implementation delegates totoVeloxTableHandle, ignoring theIndexHandle. Connectors that support index lookup can override this to incorporate theIndexHandleinto the resulting table handle, enabling index-aware table scan creation.Without this extensibility point, the
IndexHandle(carrying index column names resolved by the coordinator) would be silently dropped during worker-side plan conversion, and the worker would have no way to know which columns are indexed.Also handles the case where
IndexJoinOptimizerinserts aFilterNodebetweenIndexJoinNodeandIndexSourceNodefor non-domain-expressible predicates. TheFilterNodeis unwrapped and its filter is merged into the join's remaining filter.Changes:
PrestoToVeloxConnector.h: AddtoVeloxTableHandleForIndexSource()virtual method with default delegation totoVeloxTableHandle().PrestoToVeloxQueryPlan.cpp: AddtoConnectorTableHandleForIndexSource()free function, updateIndexSourceNodeconversion to use it, addVELOX_CHECK_NOT_NULLguard, and addFilterNodeunwrapping forIndexJoinNode.PlanConverterTest.cpp: AddindexSourcetest coveringIndexSourceNodetoTableScanNodeconversion.Release Notes