Skip to content

Commit 7b97da0

Browse files
committed
[native] Relevant changes of presto protocol for iceberg
1 parent 6ec42ed commit 7b97da0

File tree

4 files changed

+203
-0
lines changed

4 files changed

+203
-0
lines changed

presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/presto_protocol_iceberg.cpp

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,147 @@ void from_json(const json& j, PrestoIcebergPartitionSpec& p) {
741741
}
742742
} // namespace facebook::presto::protocol::iceberg
743743
namespace facebook::presto::protocol::iceberg {
744+
IcebergDistributedProcedureHandle::
745+
IcebergDistributedProcedureHandle() noexcept {
746+
_type = "hive-iceberg";
747+
}
748+
749+
void to_json(json& j, const IcebergDistributedProcedureHandle& p) {
750+
j = json::object();
751+
j["@type"] = "hive-iceberg";
752+
to_json_key(
753+
j,
754+
"schemaName",
755+
p.schemaName,
756+
"IcebergDistributedProcedureHandle",
757+
"String",
758+
"schemaName");
759+
to_json_key(
760+
j,
761+
"tableName",
762+
p.tableName,
763+
"IcebergDistributedProcedureHandle",
764+
"IcebergTableName",
765+
"tableName");
766+
to_json_key(
767+
j,
768+
"schema",
769+
p.schema,
770+
"IcebergDistributedProcedureHandle",
771+
"PrestoIcebergSchema",
772+
"schema");
773+
to_json_key(
774+
j,
775+
"partitionSpec",
776+
p.partitionSpec,
777+
"IcebergDistributedProcedureHandle",
778+
"PrestoIcebergPartitionSpec",
779+
"partitionSpec");
780+
to_json_key(
781+
j,
782+
"inputColumns",
783+
p.inputColumns,
784+
"IcebergDistributedProcedureHandle",
785+
"List<IcebergColumnHandle>",
786+
"inputColumns");
787+
to_json_key(
788+
j,
789+
"outputPath",
790+
p.outputPath,
791+
"IcebergDistributedProcedureHandle",
792+
"String",
793+
"outputPath");
794+
to_json_key(
795+
j,
796+
"fileFormat",
797+
p.fileFormat,
798+
"IcebergDistributedProcedureHandle",
799+
"FileFormat",
800+
"fileFormat");
801+
to_json_key(
802+
j,
803+
"compressionCodec",
804+
p.compressionCodec,
805+
"IcebergDistributedProcedureHandle",
806+
"HiveCompressionCodec",
807+
"compressionCodec");
808+
to_json_key(
809+
j,
810+
"storageProperties",
811+
p.storageProperties,
812+
"IcebergDistributedProcedureHandle",
813+
"Map<String, String>",
814+
"storageProperties");
815+
}
816+
817+
void from_json(const json& j, IcebergDistributedProcedureHandle& p) {
818+
p._type = j["@type"];
819+
from_json_key(
820+
j,
821+
"schemaName",
822+
p.schemaName,
823+
"IcebergDistributedProcedureHandle",
824+
"String",
825+
"schemaName");
826+
from_json_key(
827+
j,
828+
"tableName",
829+
p.tableName,
830+
"IcebergDistributedProcedureHandle",
831+
"IcebergTableName",
832+
"tableName");
833+
from_json_key(
834+
j,
835+
"schema",
836+
p.schema,
837+
"IcebergDistributedProcedureHandle",
838+
"PrestoIcebergSchema",
839+
"schema");
840+
from_json_key(
841+
j,
842+
"partitionSpec",
843+
p.partitionSpec,
844+
"IcebergDistributedProcedureHandle",
845+
"PrestoIcebergPartitionSpec",
846+
"partitionSpec");
847+
from_json_key(
848+
j,
849+
"inputColumns",
850+
p.inputColumns,
851+
"IcebergDistributedProcedureHandle",
852+
"List<IcebergColumnHandle>",
853+
"inputColumns");
854+
from_json_key(
855+
j,
856+
"outputPath",
857+
p.outputPath,
858+
"IcebergDistributedProcedureHandle",
859+
"String",
860+
"outputPath");
861+
from_json_key(
862+
j,
863+
"fileFormat",
864+
p.fileFormat,
865+
"IcebergDistributedProcedureHandle",
866+
"FileFormat",
867+
"fileFormat");
868+
from_json_key(
869+
j,
870+
"compressionCodec",
871+
p.compressionCodec,
872+
"IcebergDistributedProcedureHandle",
873+
"HiveCompressionCodec",
874+
"compressionCodec");
875+
from_json_key(
876+
j,
877+
"storageProperties",
878+
p.storageProperties,
879+
"IcebergDistributedProcedureHandle",
880+
"Map<String, String>",
881+
"storageProperties");
882+
}
883+
} // namespace facebook::presto::protocol::iceberg
884+
namespace facebook::presto::protocol::iceberg {
744885

745886
void to_json(json& j, const SortField& p) {
746887
j = json::object();

presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/presto_protocol_iceberg.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,27 @@ struct PrestoIcebergPartitionSpec {
183183
void to_json(json& j, const PrestoIcebergPartitionSpec& p);
184184
void from_json(const json& j, PrestoIcebergPartitionSpec& p);
185185
} // namespace facebook::presto::protocol::iceberg
186+
// IcebergDistributedProcedureHandle is special since it needs an usage of
187+
// hive::.
188+
189+
namespace facebook::presto::protocol::iceberg {
190+
struct IcebergDistributedProcedureHandle
191+
: public ConnectorDistributedProcedureHandle {
192+
String schemaName = {};
193+
IcebergTableName tableName = {};
194+
PrestoIcebergSchema schema = {};
195+
PrestoIcebergPartitionSpec partitionSpec = {};
196+
List<IcebergColumnHandle> inputColumns = {};
197+
String outputPath = {};
198+
FileFormat fileFormat = {};
199+
hive::HiveCompressionCodec compressionCodec = {};
200+
Map<String, String> storageProperties = {};
201+
202+
IcebergDistributedProcedureHandle() noexcept;
203+
};
204+
void to_json(json& j, const IcebergDistributedProcedureHandle& p);
205+
void from_json(const json& j, IcebergDistributedProcedureHandle& p);
206+
} // namespace facebook::presto::protocol::iceberg
186207
namespace facebook::presto::protocol::iceberg {
187208
struct SortField {
188209
int sourceColumnId = {};

presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/presto_protocol_iceberg.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ AbstractClasses:
3737
subclasses:
3838
- { name: IcebergInsertTableHandle, key: hive-iceberg }
3939

40+
ConnectorDistributedProcedureHandle:
41+
super: JsonEncodedSubclass
42+
subclasses:
43+
- { name: IcebergDistributedProcedureHandle, key: hive-iceberg }
44+
4045
ConnectorTableLayoutHandle:
4146
super: JsonEncodedSubclass
4247
subclasses:
@@ -62,6 +67,7 @@ JavaClasses:
6267
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergTableLayoutHandle.java
6368
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergOutputTableHandle.java
6469
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergInsertTableHandle.java
70+
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergDistributedProcedureHandle.java
6571
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergColumnHandle.java
6672
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/ColumnIdentity.java
6773
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergPartitionField.java
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
// IcebergDistributedProcedureHandle is special since it needs an usage of
16+
// hive::.
17+
18+
namespace facebook::presto::protocol::iceberg {
19+
struct IcebergDistributedProcedureHandle
20+
: public ConnectorDistributedProcedureHandle {
21+
String schemaName = {};
22+
IcebergTableName tableName = {};
23+
PrestoIcebergSchema schema = {};
24+
PrestoIcebergPartitionSpec partitionSpec = {};
25+
List<IcebergColumnHandle> inputColumns = {};
26+
String outputPath = {};
27+
FileFormat fileFormat = {};
28+
hive::HiveCompressionCodec compressionCodec = {};
29+
Map<String, String> storageProperties = {};
30+
31+
IcebergDistributedProcedureHandle() noexcept;
32+
};
33+
void to_json(json& j, const IcebergDistributedProcedureHandle& p);
34+
void from_json(const json& j, IcebergDistributedProcedureHandle& p);
35+
} // namespace facebook::presto::protocol::iceberg

0 commit comments

Comments
 (0)