Skip to content

Commit 2a2de61

Browse files
Joe-Abrahamlga-zurich
authored andcommitted
[native] Add RestFunctionHandle to presto_protocol serialization
1 parent 48c4dac commit 2a2de61

File tree

3 files changed

+142
-33
lines changed

3 files changed

+142
-33
lines changed

presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.cpp

Lines changed: 127 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ namespace facebook::presto::protocol {
3636

3737
// NOLINTNEXTLINE: cppcoreguidelines-avoid-c-arrays
3838
static const std::pair<NodeSelectionStrategy, json>
39-
NodeSelectionStrategy_enum_table[] = { // NOLINT: cert-err58-cpp
40-
{NodeSelectionStrategy::HARD_AFFINITY, "HARD_AFFINITY"},
41-
{NodeSelectionStrategy::SOFT_AFFINITY, "SOFT_AFFINITY"},
42-
{NodeSelectionStrategy::NO_PREFERENCE, "NO_PREFERENCE"}};
39+
NodeSelectionStrategy_enum_table[] =
40+
{ // NOLINT: cert-err58-cpp
41+
{NodeSelectionStrategy::HARD_AFFINITY, "HARD_AFFINITY"},
42+
{NodeSelectionStrategy::SOFT_AFFINITY, "SOFT_AFFINITY"},
43+
{NodeSelectionStrategy::NO_PREFERENCE, "NO_PREFERENCE"}};
4344
void to_json(json& j, const NodeSelectionStrategy& e) {
4445
static_assert(
4546
std::is_enum<NodeSelectionStrategy>::value,
@@ -122,6 +123,10 @@ void to_json(json& j, const std::shared_ptr<FunctionHandle>& p) {
122123
j = *std::static_pointer_cast<SqlFunctionHandle>(p);
123124
return;
124125
}
126+
if (type == "rest") {
127+
j = *std::static_pointer_cast<RestFunctionHandle>(p);
128+
return;
129+
}
125130

126131
throw TypeError(type + " no abstract type FunctionHandle ");
127132
}
@@ -162,6 +167,13 @@ void from_json(const json& j, std::shared_ptr<FunctionHandle>& p) {
162167
p = std::static_pointer_cast<FunctionHandle>(k);
163168
return;
164169
}
170+
if (type == "rest") {
171+
std::shared_ptr<RestFunctionHandle> k =
172+
std::make_shared<RestFunctionHandle>();
173+
j.get_to(*k);
174+
p = std::static_pointer_cast<FunctionHandle>(k);
175+
return;
176+
}
165177

166178
throw TypeError(type + " no abstract type FunctionHandle ");
167179
}
@@ -547,11 +559,12 @@ namespace facebook::presto::protocol {
547559

548560
// NOLINTNEXTLINE: cppcoreguidelines-avoid-c-arrays
549561
static const std::pair<AggregationNodeStep, json>
550-
AggregationNodeStep_enum_table[] = { // NOLINT: cert-err58-cpp
551-
{AggregationNodeStep::PARTIAL, "PARTIAL"},
552-
{AggregationNodeStep::FINAL, "FINAL"},
553-
{AggregationNodeStep::INTERMEDIATE, "INTERMEDIATE"},
554-
{AggregationNodeStep::SINGLE, "SINGLE"}};
562+
AggregationNodeStep_enum_table[] =
563+
{ // NOLINT: cert-err58-cpp
564+
{AggregationNodeStep::PARTIAL, "PARTIAL"},
565+
{AggregationNodeStep::FINAL, "FINAL"},
566+
{AggregationNodeStep::INTERMEDIATE, "INTERMEDIATE"},
567+
{AggregationNodeStep::SINGLE, "SINGLE"}};
555568
void to_json(json& j, const AggregationNodeStep& e) {
556569
static_assert(
557570
std::is_enum<AggregationNodeStep>::value,
@@ -5681,6 +5694,13 @@ void to_json(json& j, const IndexJoinNode& p) {
56815694
"IndexJoinNode",
56825695
"VariableReferenceExpression",
56835696
"indexHashVariable");
5697+
to_json_key(
5698+
j,
5699+
"lookupVariables",
5700+
p.lookupVariables,
5701+
"IndexJoinNode",
5702+
"List<VariableReferenceExpression>",
5703+
"lookupVariables");
56845704
}
56855705

56865706
void from_json(const json& j, IndexJoinNode& p) {
@@ -5729,6 +5749,13 @@ void from_json(const json& j, IndexJoinNode& p) {
57295749
"IndexJoinNode",
57305750
"VariableReferenceExpression",
57315751
"indexHashVariable");
5752+
from_json_key(
5753+
j,
5754+
"lookupVariables",
5755+
p.lookupVariables,
5756+
"IndexJoinNode",
5757+
"List<VariableReferenceExpression>",
5758+
"lookupVariables");
57325759
}
57335760
} // namespace facebook::presto::protocol
57345761
namespace facebook::presto::protocol {
@@ -6045,9 +6072,10 @@ namespace facebook::presto::protocol {
60456072

60466073
// NOLINTNEXTLINE: cppcoreguidelines-avoid-c-arrays
60476074
static const std::pair<JoinDistributionType, json>
6048-
JoinDistributionType_enum_table[] = { // NOLINT: cert-err58-cpp
6049-
{JoinDistributionType::PARTITIONED, "PARTITIONED"},
6050-
{JoinDistributionType::REPLICATED, "REPLICATED"}};
6075+
JoinDistributionType_enum_table[] =
6076+
{ // NOLINT: cert-err58-cpp
6077+
{JoinDistributionType::PARTITIONED, "PARTITIONED"},
6078+
{JoinDistributionType::REPLICATED, "REPLICATED"}};
60516079
void to_json(json& j, const JoinDistributionType& e) {
60526080
static_assert(
60536081
std::is_enum<JoinDistributionType>::value,
@@ -6945,6 +6973,7 @@ void from_json(const json& j, MergeJoinNode& p) {
69456973
}
69466974
} // namespace facebook::presto::protocol
69476975
namespace facebook::presto::protocol {
6976+
69486977
void to_json(json& j, const NodeVersion& p) {
69496978
j = json::object();
69506979
to_json_key(j, "version", p.version, "NodeVersion", "String", "version");
@@ -7969,14 +7998,17 @@ namespace facebook::presto::protocol {
79697998

79707999
// NOLINTNEXTLINE: cppcoreguidelines-avoid-c-arrays
79718000
static const std::pair<StageExecutionStrategy, json>
7972-
StageExecutionStrategy_enum_table[] = { // NOLINT: cert-err58-cpp
7973-
{StageExecutionStrategy::UNGROUPED_EXECUTION, "UNGROUPED_EXECUTION"},
7974-
{StageExecutionStrategy::FIXED_LIFESPAN_SCHEDULE_GROUPED_EXECUTION,
7975-
"FIXED_LIFESPAN_SCHEDULE_GROUPED_EXECUTION"},
7976-
{StageExecutionStrategy::DYNAMIC_LIFESPAN_SCHEDULE_GROUPED_EXECUTION,
7977-
"DYNAMIC_LIFESPAN_SCHEDULE_GROUPED_EXECUTION"},
7978-
{StageExecutionStrategy::RECOVERABLE_GROUPED_EXECUTION,
7979-
"RECOVERABLE_GROUPED_EXECUTION"}};
8001+
StageExecutionStrategy_enum_table[] =
8002+
{ // NOLINT: cert-err58-cpp
8003+
{StageExecutionStrategy::UNGROUPED_EXECUTION,
8004+
"UNGROUPED_EXECUTION"},
8005+
{StageExecutionStrategy::FIXED_LIFESPAN_SCHEDULE_GROUPED_EXECUTION,
8006+
"FIXED_LIFESPAN_SCHEDULE_GROUPED_EXECUTION"},
8007+
{StageExecutionStrategy::
8008+
DYNAMIC_LIFESPAN_SCHEDULE_GROUPED_EXECUTION,
8009+
"DYNAMIC_LIFESPAN_SCHEDULE_GROUPED_EXECUTION"},
8010+
{StageExecutionStrategy::RECOVERABLE_GROUPED_EXECUTION,
8011+
"RECOVERABLE_GROUPED_EXECUTION"}};
79808012
void to_json(json& j, const StageExecutionStrategy& e) {
79818013
static_assert(
79828014
std::is_enum<StageExecutionStrategy>::value,
@@ -8713,6 +8745,66 @@ void from_json(const json& j, RemoteTransactionHandle& p) {
87138745
}
87148746
} // namespace facebook::presto::protocol
87158747
namespace facebook::presto::protocol {
8748+
RestFunctionHandle::RestFunctionHandle() noexcept {
8749+
_type = "rest";
8750+
}
8751+
8752+
void to_json(json& j, const RestFunctionHandle& p) {
8753+
j = json::object();
8754+
j["@type"] = "rest";
8755+
to_json_key(
8756+
j,
8757+
"functionId",
8758+
p.functionId,
8759+
"RestFunctionHandle",
8760+
"SqlFunctionId",
8761+
"functionId");
8762+
to_json_key(
8763+
j, "version", p.version, "RestFunctionHandle", "String", "version");
8764+
to_json_key(
8765+
j,
8766+
"signature",
8767+
p.signature,
8768+
"RestFunctionHandle",
8769+
"Signature",
8770+
"signature");
8771+
to_json_key(
8772+
j,
8773+
"executionEndpoint",
8774+
p.executionEndpoint,
8775+
"RestFunctionHandle",
8776+
"URI",
8777+
"executionEndpoint");
8778+
}
8779+
8780+
void from_json(const json& j, RestFunctionHandle& p) {
8781+
p._type = j["@type"];
8782+
from_json_key(
8783+
j,
8784+
"functionId",
8785+
p.functionId,
8786+
"RestFunctionHandle",
8787+
"SqlFunctionId",
8788+
"functionId");
8789+
from_json_key(
8790+
j, "version", p.version, "RestFunctionHandle", "String", "version");
8791+
from_json_key(
8792+
j,
8793+
"signature",
8794+
p.signature,
8795+
"RestFunctionHandle",
8796+
"Signature",
8797+
"signature");
8798+
from_json_key(
8799+
j,
8800+
"executionEndpoint",
8801+
p.executionEndpoint,
8802+
"RestFunctionHandle",
8803+
"URI",
8804+
"executionEndpoint");
8805+
}
8806+
} // namespace facebook::presto::protocol
8807+
namespace facebook::presto::protocol {
87168808
RowNumberNode::RowNumberNode() noexcept {
87178809
_type = "com.facebook.presto.sql.planner.plan.RowNumberNode";
87188810
}
@@ -9420,12 +9512,13 @@ namespace facebook::presto::protocol {
94209512

94219513
// NOLINTNEXTLINE: cppcoreguidelines-avoid-c-arrays
94229514
static const std::pair<SystemPartitionFunction, json>
9423-
SystemPartitionFunction_enum_table[] = { // NOLINT: cert-err58-cpp
9424-
{SystemPartitionFunction::SINGLE, "SINGLE"},
9425-
{SystemPartitionFunction::HASH, "HASH"},
9426-
{SystemPartitionFunction::ROUND_ROBIN, "ROUND_ROBIN"},
9427-
{SystemPartitionFunction::BROADCAST, "BROADCAST"},
9428-
{SystemPartitionFunction::UNKNOWN, "UNKNOWN"}};
9515+
SystemPartitionFunction_enum_table[] =
9516+
{ // NOLINT: cert-err58-cpp
9517+
{SystemPartitionFunction::SINGLE, "SINGLE"},
9518+
{SystemPartitionFunction::HASH, "HASH"},
9519+
{SystemPartitionFunction::ROUND_ROBIN, "ROUND_ROBIN"},
9520+
{SystemPartitionFunction::BROADCAST, "BROADCAST"},
9521+
{SystemPartitionFunction::UNKNOWN, "UNKNOWN"}};
94299522
void to_json(json& j, const SystemPartitionFunction& e) {
94309523
static_assert(
94319524
std::is_enum<SystemPartitionFunction>::value,
@@ -9462,13 +9555,14 @@ namespace facebook::presto::protocol {
94629555

94639556
// NOLINTNEXTLINE: cppcoreguidelines-avoid-c-arrays
94649557
static const std::pair<SystemPartitioning, json>
9465-
SystemPartitioning_enum_table[] = { // NOLINT: cert-err58-cpp
9466-
{SystemPartitioning::SINGLE, "SINGLE"},
9467-
{SystemPartitioning::FIXED, "FIXED"},
9468-
{SystemPartitioning::SOURCE, "SOURCE"},
9469-
{SystemPartitioning::SCALED, "SCALED"},
9470-
{SystemPartitioning::COORDINATOR_ONLY, "COORDINATOR_ONLY"},
9471-
{SystemPartitioning::ARBITRARY, "ARBITRARY"}};
9558+
SystemPartitioning_enum_table[] =
9559+
{ // NOLINT: cert-err58-cpp
9560+
{SystemPartitioning::SINGLE, "SINGLE"},
9561+
{SystemPartitioning::FIXED, "FIXED"},
9562+
{SystemPartitioning::SOURCE, "SOURCE"},
9563+
{SystemPartitioning::SCALED, "SCALED"},
9564+
{SystemPartitioning::COORDINATOR_ONLY, "COORDINATOR_ONLY"},
9565+
{SystemPartitioning::ARBITRARY, "ARBITRARY"}};
94729566
void to_json(json& j, const SystemPartitioning& e) {
94739567
static_assert(
94749568
std::is_enum<SystemPartitioning>::value,

presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,7 @@ struct IndexJoinNode : public PlanNode {
13661366
std::shared_ptr<std::shared_ptr<RowExpression>> filter = {};
13671367
std::shared_ptr<VariableReferenceExpression> probeHashVariable = {};
13681368
std::shared_ptr<VariableReferenceExpression> indexHashVariable = {};
1369+
List<VariableReferenceExpression> lookupVariables = {};
13691370

13701371
IndexJoinNode() noexcept;
13711372
};
@@ -1998,6 +1999,18 @@ void to_json(json& j, const RemoteTransactionHandle& p);
19981999
void from_json(const json& j, RemoteTransactionHandle& p);
19992000
} // namespace facebook::presto::protocol
20002001
namespace facebook::presto::protocol {
2002+
struct RestFunctionHandle : public FunctionHandle {
2003+
SqlFunctionId functionId = {};
2004+
String version = {};
2005+
Signature signature = {};
2006+
std::shared_ptr<URI> executionEndpoint = {};
2007+
2008+
RestFunctionHandle() noexcept;
2009+
};
2010+
void to_json(json& j, const RestFunctionHandle& p);
2011+
void from_json(const json& j, RestFunctionHandle& p);
2012+
} // namespace facebook::presto::protocol
2013+
namespace facebook::presto::protocol {
20012014
struct RowNumberNode : public PlanNode {
20022015
std::shared_ptr<PlanNode> source = {};
20032016
List<VariableReferenceExpression> partitionBy = {};

presto-native-execution/presto_cpp/presto_protocol/core/presto_protocol_core.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ AbstractClasses:
194194
- { name: SqlFunctionHandle, key: native }
195195
- { name: SqlFunctionHandle, key: json_file }
196196
- { name: SqlFunctionHandle, key: sql_function_handle }
197+
- { name: RestFunctionHandle, key: rest }
197198

198199

199200
JavaClasses:
@@ -211,6 +212,7 @@ JavaClasses:
211212
- presto-main-base/src/main/java/com/facebook/presto/execution/buffer/BufferState.java
212213
- presto-main-base/src/main/java/com/facebook/presto/metadata/BuiltInFunctionHandle.java
213214
- presto-spi/src/main/java/com/facebook/presto/spi/function/SqlFunctionHandle.java
215+
- presto-spi/src/main/java/com/facebook/presto/spi/function/RestFunctionHandle.java
214216
- presto-hdfs-core/src/main/java/com/facebook/presto/hive/CacheQuotaRequirement.java
215217
- presto-hdfs-core/src/main/java/com/facebook/presto/hive/CacheQuotaScope.java
216218
- presto-spi/src/main/java/com/facebook/presto/spi/relation/CallExpression.java

0 commit comments

Comments
 (0)