Skip to content

Commit b52d97c

Browse files
committed
PrestoToVelox
1 parent a86c9ca commit b52d97c

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

presto-native-execution/presto_cpp/main/tvf/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
12-
add_library(presto_tvf_core TableFunctionProcessorNode.cpp)
12+
add_library(presto_tvf_core OBJECT TableFunctionProcessorNode.cpp)
1313

1414
target_link_libraries(presto_tvf_core velox_core)

presto-native-execution/presto_cpp/main/types/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ add_library(presto_types PrestoToVeloxQueryPlan.cpp VeloxPlanValidator.cpp
2121
PrestoToVeloxSplit.cpp)
2222
target_link_libraries(
2323
presto_types
24+
$<TARGET_OBJECTS:presto_tvf_core>
2425
presto_velox_expr_conversion
2526
presto_connectors
2627
presto_operators

presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,37 @@ VeloxQueryPlanConverterBase::toVeloxQueryPlan(
17691769
toVeloxQueryPlan(node->source, tableWriteInfo, taskId));
17701770
}
17711771

1772+
std::shared_ptr<const tvf::TableFunctionProcessorNode>
1773+
VeloxQueryPlanConverterBase::toVeloxQueryPlan(
1774+
const std::shared_ptr<const protocol::TableFunctionProcessorNode>& node,
1775+
const std::shared_ptr<protocol::TableWriteInfo>& tableWriteInfo,
1776+
const protocol::TaskId& taskId) {
1777+
const auto outputType = toRowType(node->properOutputs, typeParser_);
1778+
1779+
std::vector<column_index_t> requiredColumns;
1780+
std::vector<core::PlanNodePtr> sources;
1781+
if (node->source) {
1782+
const auto sourceNode = toVeloxQueryPlan(*node->source, tableWriteInfo, taskId);
1783+
const auto inputType = sourceNode->outputType();
1784+
for (const auto& variables : node->requiredVariables) {
1785+
for (const auto& expr : toVeloxExprs(variables)) {
1786+
requiredColumns.push_back(exprToChannel(expr.get(), inputType));
1787+
}
1788+
}
1789+
}
1790+
1791+
// TODO: deserialize node->handle.functionHandle to construct the handle
1792+
const auto tableFunctionHandlePtr = nullptr;
1793+
1794+
return std::make_shared<tvf::TableFunctionProcessorNode>(
1795+
node->id,
1796+
node->name,
1797+
tableFunctionHandlePtr,
1798+
outputType,
1799+
requiredColumns,
1800+
sources);
1801+
}
1802+
17721803
core::PlanNodePtr VeloxQueryPlanConverterBase::toVeloxQueryPlan(
17731804
const std::shared_ptr<const protocol::PlanNode>& node,
17741805
const std::shared_ptr<protocol::TableWriteInfo>& tableWriteInfo,

presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <stdexcept>
1616
#include <vector>
1717
#include "presto_cpp/main/operators/ShuffleInterface.h"
18+
#include "presto_cpp/main/tvf/core/TableFunctionProcessorNode.h"
1819
#include "presto_cpp/presto_protocol/core/presto_protocol_core.h"
1920
#include "velox/core/Expressions.h"
2021
#include "velox/core/PlanFragment.h"
@@ -190,6 +191,11 @@ class VeloxQueryPlanConverterBase {
190191
const std::shared_ptr<protocol::TableWriteInfo>& tableWriteInfo,
191192
const protocol::TaskId& taskId);
192193

194+
std::shared_ptr<const tvf::TableFunctionProcessorNode> toVeloxQueryPlan(
195+
const std::shared_ptr<const protocol::TableFunctionProcessorNode>& node,
196+
const std::shared_ptr<protocol::TableWriteInfo>& tableWriteInfo,
197+
const protocol::TaskId& taskId);
198+
193199
std::vector<velox::core::FieldAccessTypedExprPtr> toVeloxExprs(
194200
const std::vector<protocol::VariableReferenceExpression>& variables);
195201

presto-native-execution/presto_cpp/main/types/tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ target_link_libraries(
5151
GTest::gtest_main
5252
presto_connectors
5353
$<TARGET_OBJECTS:presto_protocol>
54+
$<TARGET_OBJECTS:presto_tvf_core>
5455
$<TARGET_OBJECTS:presto_type_converter>
5556
$<TARGET_OBJECTS:presto_types>
5657
presto_operators

0 commit comments

Comments
 (0)