Skip to content

Commit 220ed80

Browse files
committed
[native] Relevant changes of presto protocol for iceberg
1 parent 9e7c682 commit 220ed80

File tree

4 files changed

+203
-1
lines changed

4 files changed

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

743884
void to_json(json& j, const SortField& p) {
744885
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 & 1 deletion
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
@@ -72,4 +78,3 @@ JavaClasses:
7278
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/changelog/ChangelogOperation.java
7379
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/changelog/ChangelogSplitInfo.java
7480
- presto-iceberg/src/main/java/com/facebook/presto/iceberg/SortField.java
75-
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)