diff --git a/presto-native-execution/CMakeLists.txt b/presto-native-execution/CMakeLists.txt index f6d6950c00983..f9b2da3f2c9cf 100644 --- a/presto-native-execution/CMakeLists.txt +++ b/presto-native-execution/CMakeLists.txt @@ -31,7 +31,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SCRIPT_CXX_FLAGS}") # Known warnings that are benign can be disabled. set(DISABLED_WARNINGS - "-Wno-nullability-completeness -Wno-deprecated-declarations") + "-Wno-nullability-completeness \ + -Wno-deprecated-declarations \ + -Wno-restrict") # Important warnings that must be explicitly enabled. set(ENABLE_WARNINGS "-Wreorder") diff --git a/presto-native-execution/presto_cpp/main/CMakeLists.txt b/presto-native-execution/presto_cpp/main/CMakeLists.txt index c1f42336991bd..0336238c331d2 100644 --- a/presto-native-execution/presto_cpp/main/CMakeLists.txt +++ b/presto-native-execution/presto_cpp/main/CMakeLists.txt @@ -55,6 +55,7 @@ target_link_libraries( velox_abfs velox_aggregates velox_caching + velox_clp_connector velox_common_base velox_core velox_dwio_common_exception diff --git a/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.cpp b/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.cpp index 52f33909d241e..beee96f467c6f 100644 --- a/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.cpp +++ b/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.cpp @@ -15,11 +15,15 @@ #include "presto_cpp/main/connectors/PrestoToVeloxConnector.h" #include "presto_cpp/main/types/PrestoToVeloxExpr.h" #include "presto_cpp/main/types/TypeParser.h" +#include "presto_cpp/presto_protocol/connector/clp/ClpConnectorProtocol.h" #include "presto_cpp/presto_protocol/connector/hive/HiveConnectorProtocol.h" #include "presto_cpp/presto_protocol/connector/iceberg/IcebergConnectorProtocol.h" #include "presto_cpp/presto_protocol/connector/tpch/TpchConnectorProtocol.h" #include +#include "velox/connectors/clp/ClpColumnHandle.h" +#include "velox/connectors/clp/ClpConnectorSplit.h" +#include "velox/connectors/clp/ClpTableHandle.h" #include "velox/connectors/hive/HiveConnector.h" #include "velox/connectors/hive/HiveConnectorSplit.h" #include "velox/connectors/hive/HiveDataSink.h" @@ -1412,9 +1416,11 @@ IcebergPrestoToVeloxConnector::toVeloxColumnHandle( // constructor similar to how Hive Connector is handling for bucketing velox::type::fbhive::HiveTypeParser hiveTypeParser; auto type = stringToType(icebergColumn->type, typeParser); - connector::hive::HiveColumnHandle::ColumnParseParameters columnParseParameters; + connector::hive::HiveColumnHandle::ColumnParseParameters + columnParseParameters; if (type->isDate()) { - columnParseParameters.partitionDateValueFormat = connector::hive::HiveColumnHandle::ColumnParseParameters::kDaysSinceEpoch; + columnParseParameters.partitionDateValueFormat = connector::hive:: + HiveColumnHandle::ColumnParseParameters::kDaysSinceEpoch; } return std::make_unique( icebergColumn->columnIdentity.name, @@ -1548,4 +1554,57 @@ std::unique_ptr TpchPrestoToVeloxConnector::createConnectorProtocol() const { return std::make_unique(); } + +std::unique_ptr +ClpPrestoToVeloxConnector::toVeloxSplit( + const protocol::ConnectorId& catalogId, + const protocol::ConnectorSplit* connectorSplit, + const protocol::SplitContext* splitContext) const { + auto clpSplit = dynamic_cast(connectorSplit); + VELOX_CHECK_NOT_NULL( + clpSplit, "Unexpected split type {}", connectorSplit->_type); + return std::make_unique( + catalogId, clpSplit->path); +} + +std::unique_ptr +ClpPrestoToVeloxConnector::toVeloxColumnHandle( + const protocol::ColumnHandle* column, + const TypeParser& typeParser) const { + auto clpColumn = dynamic_cast(column); + VELOX_CHECK_NOT_NULL( + clpColumn, "Unexpected column handle type {}", column->_type); + return std::make_unique( + clpColumn->columnName, + clpColumn->originalColumnName, + typeParser.parse(clpColumn->columnType), + clpColumn->nullable); +} + +std::unique_ptr +ClpPrestoToVeloxConnector::toVeloxTableHandle( + const protocol::TableHandle& tableHandle, + const VeloxExprConverter& exprConverter, + const TypeParser& typeParser, + std::unordered_map< + std::string, + std::shared_ptr>& assignments) const { + auto clpLayout = + std::dynamic_pointer_cast( + tableHandle.connectorTableLayout); + VELOX_CHECK_NOT_NULL( + clpLayout, + "Unexpected layout type {}", + tableHandle.connectorTableLayout->_type); + return std::make_unique( + tableHandle.connectorId, + clpLayout->table.schemaTableName.table, + clpLayout->kqlQuery); +} + +std::unique_ptr +ClpPrestoToVeloxConnector::createConnectorProtocol() const { + return std::make_unique(); +} + } // namespace facebook::presto diff --git a/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.h b/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.h index b9a763c5b8aa6..c20fa3fd3a73e 100644 --- a/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.h +++ b/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.h @@ -13,9 +13,9 @@ */ #pragma once +#include "presto_cpp/main/types/PrestoToVeloxExpr.h" #include "presto_cpp/presto_protocol/connector/hive/presto_protocol_hive.h" #include "presto_cpp/presto_protocol/core/ConnectorProtocol.h" -#include "presto_cpp/main/types/PrestoToVeloxExpr.h" #include "velox/connectors/Connector.h" #include "velox/connectors/hive/TableHandle.h" #include "velox/core/PlanNode.h" @@ -223,4 +223,31 @@ class TpchPrestoToVeloxConnector final : public PrestoToVeloxConnector { std::unique_ptr createConnectorProtocol() const final; }; + +class ClpPrestoToVeloxConnector final : public PrestoToVeloxConnector { + public: + explicit ClpPrestoToVeloxConnector(std::string connectorName) + : PrestoToVeloxConnector(std::move(connectorName)) {} + + std::unique_ptr toVeloxSplit( + const protocol::ConnectorId& catalogId, + const protocol::ConnectorSplit* connectorSplit, + const protocol::SplitContext* splitContext) const final; + + std::unique_ptr toVeloxColumnHandle( + const protocol::ColumnHandle* column, + const TypeParser& typeParser) const final; + + std::unique_ptr toVeloxTableHandle( + const protocol::TableHandle& tableHandle, + const VeloxExprConverter& exprConverter, + const TypeParser& typeParser, + std::unordered_map< + std::string, + std::shared_ptr>& assignments) + const final; + + std::unique_ptr createConnectorProtocol() + const final; +}; } // namespace facebook::presto diff --git a/presto-native-execution/presto_cpp/main/connectors/Registration.cpp b/presto-native-execution/presto_cpp/main/connectors/Registration.cpp index d6f6555fb8a22..2d26796cae72f 100644 --- a/presto-native-execution/presto_cpp/main/connectors/Registration.cpp +++ b/presto-native-execution/presto_cpp/main/connectors/Registration.cpp @@ -19,6 +19,7 @@ #include "presto_cpp/main/connectors/arrow_flight/ArrowPrestoToVeloxConnector.h" #endif +#include "velox/connectors/clp/ClpConnector.h" #include "velox/connectors/hive/HiveConnector.h" #include "velox/connectors/tpch/TpchConnector.h" @@ -45,6 +46,12 @@ void registerConnectorFactories() { std::make_shared()); } + if (!velox::connector::hasConnectorFactory( + velox::connector::clp::ClpConnectorFactory::kClpConnectorName)) { + velox::connector::registerConnectorFactory( + std::make_shared()); + } + // Register Velox connector factory for iceberg. // The iceberg catalog is handled by the hive connector factory. if (!velox::connector::hasConnectorFactory(kIcebergConnectorName)) { @@ -74,6 +81,8 @@ void registerConnectors() { std::make_unique(kIcebergConnectorName)); registerPrestoToVeloxConnector(std::make_unique( velox::connector::tpch::TpchConnectorFactory::kTpchConnectorName)); + registerPrestoToVeloxConnector(std::make_unique( + velox::connector::clp::ClpConnectorFactory::kClpConnectorName)); // Presto server uses system catalog or system schema in other catalogs // in different places in the code. All these resolve to the SystemConnector. diff --git a/presto-native-execution/presto_cpp/main/tests/CMakeLists.txt b/presto-native-execution/presto_cpp/main/tests/CMakeLists.txt index 74c2dc24b495f..8638ef42e0a35 100644 --- a/presto-native-execution/presto_cpp/main/tests/CMakeLists.txt +++ b/presto-native-execution/presto_cpp/main/tests/CMakeLists.txt @@ -47,6 +47,7 @@ target_link_libraries( $ velox_hive_connector velox_tpch_connector + velox_clp_connector velox_presto_serializer velox_functions_prestosql velox_aggregates diff --git a/presto-native-execution/presto_cpp/main/types/tests/CMakeLists.txt b/presto-native-execution/presto_cpp/main/types/tests/CMakeLists.txt index 9286f3296bb09..99741b42abff2 100644 --- a/presto-native-execution/presto_cpp/main/types/tests/CMakeLists.txt +++ b/presto-native-execution/presto_cpp/main/types/tests/CMakeLists.txt @@ -27,6 +27,7 @@ target_link_libraries( velox_dwio_orc_reader velox_hive_connector velox_tpch_connector + velox_clp_connector velox_exec velox_dwio_common_exception presto_type_converter @@ -64,6 +65,7 @@ target_link_libraries( velox_functions_lib velox_hive_connector velox_tpch_connector + velox_clp_connector velox_hive_partition_function velox_presto_serializer velox_serialization @@ -96,6 +98,7 @@ target_link_libraries( velox_dwio_common velox_hive_connector velox_tpch_connector + velox_clp_connector GTest::gtest GTest::gtest_main) diff --git a/presto-native-execution/presto_cpp/main/types/tests/PrestoToVeloxConnectorTest.cpp b/presto-native-execution/presto_cpp/main/types/tests/PrestoToVeloxConnectorTest.cpp index a88b235686498..9398e4b65d961 100644 --- a/presto-native-execution/presto_cpp/main/types/tests/PrestoToVeloxConnectorTest.cpp +++ b/presto-native-execution/presto_cpp/main/types/tests/PrestoToVeloxConnectorTest.cpp @@ -33,6 +33,8 @@ TEST_F(PrestoToVeloxConnectorTest, registerVariousConnectors) { "iceberg", std::make_unique("iceberg"))); connectorList.emplace_back( std::pair("tpch", std::make_unique("tpch"))); + connectorList.emplace_back( + std::pair("clp", std::make_unique("clp"))); for (auto& [connectorName, connector] : connectorList) { registerPrestoToVeloxConnector(std::move(connector)); diff --git a/presto-native-execution/presto_cpp/presto_protocol/Makefile b/presto-native-execution/presto_cpp/presto_protocol/Makefile index 09b43df28b4f5..f9a7a228ca717 100644 --- a/presto-native-execution/presto_cpp/presto_protocol/Makefile +++ b/presto-native-execution/presto_cpp/presto_protocol/Makefile @@ -52,12 +52,20 @@ presto_protocol-cpp: presto_protocol-json chevron -d connector/arrow_flight/presto_protocol_arrow_flight.json connector/arrow_flight/presto_protocol-json-hpp.mustache >> connector/arrow_flight/presto_protocol_arrow_flight.h clang-format -style=file -i connector/arrow_flight/presto_protocol_arrow_flight.h connector/arrow_flight/presto_protocol_arrow_flight.cpp -presto_protocol-json: + # build clp connector related structs + echo "// DO NOT EDIT : This file is generated by chevron" > connector/clp/presto_protocol_clp.cpp + chevron -d connector/clp/presto_protocol_clp.json connector/clp/presto_protocol-json-cpp.mustache >> connector/clp/presto_protocol_clp.cpp + echo "// DO NOT EDIT : This file is generated by chevron" > connector/clp/presto_protocol_clp.h + chevron -d connector/clp/presto_protocol_clp.json connector/clp/presto_protocol-json-hpp.mustache >> connector/clp/presto_protocol_clp.h + clang-format -style=file -i connector/clp/presto_protocol_clp.h connector/clp/presto_protocol_clp.cpp + +presto_protocol-json: ./java-to-struct-json.py --config core/presto_protocol_core.yml core/special/*.java core/special/*.inc -j | jq . > core/presto_protocol_core.json ./java-to-struct-json.py --config connector/hive/presto_protocol_hive.yml connector/hive/special/*.inc -j | jq . > connector/hive/presto_protocol_hive.json ./java-to-struct-json.py --config connector/iceberg/presto_protocol_iceberg.yml connector/iceberg/special/*.inc -j | jq . > connector/iceberg/presto_protocol_iceberg.json ./java-to-struct-json.py --config connector/tpch/presto_protocol_tpch.yml connector/tpch/special/*.inc -j | jq . > connector/tpch/presto_protocol_tpch.json ./java-to-struct-json.py --config connector/arrow_flight/presto_protocol_arrow_flight.yml connector/arrow_flight/special/*.inc -j | jq . > connector/arrow_flight/presto_protocol_arrow_flight.json + ./java-to-struct-json.py --config connector/clp/presto_protocol_clp.yml connector/clp/special/*.inc -j | jq . > connector/clp/presto_protocol_clp.json presto_protocol.proto: presto_protocol-json pystache presto_protocol-protobuf.mustache core/presto_protocol_core.json > core/presto_protocol_core.proto @@ -65,3 +73,4 @@ presto_protocol.proto: presto_protocol-json pystache presto_protocol-protobuf.mustache connector/iceberg/presto_protocol_iceberg.json > connector/iceberg/presto_protocol_iceberg.proto pystache presto_protocol-protobuf.mustache connector/tpch/presto_protocol_tpch.json > connector/tpch/presto_protocol_tpch.proto pystache presto_protocol-protobuf.mustache connector/arrow_flight/presto_protocol_arrow_flight.json > connector/arrow_flight/presto_protocol_arrow_flight.proto + pystache presto_protocol-protobuf.mustache connector/clp/presto_protocol_clp.json > connector/clp/presto_protocol_clp.proto diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/clp/ClpConnectorProtocol.h b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/ClpConnectorProtocol.h new file mode 100644 index 0000000000000..5b1e76b4606c4 --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/ClpConnectorProtocol.h @@ -0,0 +1,29 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once +#include "presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.h" +#include "presto_cpp/presto_protocol/core/ConnectorProtocol.h" + +namespace facebook::presto::protocol::clp { +using ClpConnectorProtocol = ConnectorProtocolTemplate< + ClpTableHandle, + ClpTableLayoutHandle, + ClpColumnHandle, + NotImplemented, + NotImplemented, + ClpSplit, + NotImplemented, + ClpTransactionHandle, + NotImplemented>; +} // namespace facebook::presto::protocol::clp diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol-json-cpp.mustache b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol-json-cpp.mustache new file mode 100644 index 0000000000000..f30beed5a875a --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol-json-cpp.mustache @@ -0,0 +1,146 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// presto_protocol.prolog.cpp +// + +{{#.}} +{{#comment}} +{{comment}} +{{/comment}} +{{/.}} + + +#include "presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.h" +using namespace std::string_literals; + +namespace facebook::presto::protocol::clp { + +void to_json(json& j, const ClpTransactionHandle& p) { + j = json::array(); + j.push_back(p._type); + j.push_back(p.instance); +} + +void from_json(const json& j, ClpTransactionHandle& p) { + j[0].get_to(p._type); + j[1].get_to(p.instance); +} +} // namespace facebook::presto::protocol +{{#.}} +{{#cinc}} +{{&cinc}} +{{/cinc}} +{{^cinc}} +{{#struct}} +namespace facebook::presto::protocol::clp { + {{#super_class}} + {{&class_name}}::{{&class_name}}() noexcept { + _type = "{{json_key}}"; + } + {{/super_class}} + + void to_json(json& j, const {{&class_name}}& p) { + j = json::object(); + {{#super_class}} + j["@type"] = "{{&json_key}}"; + {{/super_class}} + {{#fields}} + to_json_key(j, "{{&field_name}}", p.{{field_name}}, "{{&class_name}}", "{{&field_text}}", "{{&field_name}}"); + {{/fields}} + } + + void from_json(const json& j, {{&class_name}}& p) { + {{#super_class}} + p._type = j["@type"]; + {{/super_class}} + {{#fields}} + from_json_key(j, "{{&field_name}}", p.{{field_name}}, "{{&class_name}}", "{{&field_text}}", "{{&field_name}}"); + {{/fields}} + } +} +{{/struct}} +{{#enum}} +namespace facebook::presto::protocol::clp { + //Loosly copied this here from NLOHMANN_JSON_SERIALIZE_ENUM() + + // NOLINTNEXTLINE: cppcoreguidelines-avoid-c-arrays + static const std::pair<{{&class_name}}, json> + {{&class_name}}_enum_table[] = { // NOLINT: cert-err58-cpp + {{#elements}} + { {{&class_name}}::{{&element}}, "{{&element}}" }{{^_last}},{{/_last}} + {{/elements}} + }; + void to_json(json& j, const {{&class_name}}& e) + { + static_assert(std::is_enum<{{&class_name}}>::value, "{{&class_name}} must be an enum!"); + const auto* it = std::find_if(std::begin({{&class_name}}_enum_table), std::end({{&class_name}}_enum_table), + [e](const std::pair<{{&class_name}}, json>& ej_pair) -> bool + { + return ej_pair.first == e; + }); + j = ((it != std::end({{&class_name}}_enum_table)) ? it : std::begin({{&class_name}}_enum_table))->second; + } + void from_json(const json& j, {{&class_name}}& e) + { + static_assert(std::is_enum<{{&class_name}}>::value, "{{&class_name}} must be an enum!"); + const auto* it = std::find_if(std::begin({{&class_name}}_enum_table), std::end({{&class_name}}_enum_table), + [&j](const std::pair<{{&class_name}}, json>& ej_pair) -> bool + { + return ej_pair.second == j; + }); + e = ((it != std::end({{&class_name}}_enum_table)) ? it : std::begin({{&class_name}}_enum_table))->first; + } +} +{{/enum}} +{{#abstract}} +namespace facebook::presto::protocol::clp { + void to_json(json& j, const std::shared_ptr<{{&class_name}}>& p) { + if ( p == nullptr ) { + return; + } + String type = p->_type; + + {{#subclasses}} + if ( type == "{{&key}}" ) { + j = *std::static_pointer_cast<{{&type}}>(p); + return; + } + {{/subclasses}} + + throw TypeError(type + " no abstract type {{&class_name}} {{&key}}"); + } + + void from_json(const json& j, std::shared_ptr<{{&class_name}}>& p) { + String type; + try { + type = p->getSubclassKey(j); + } catch (json::parse_error &e) { + throw ParseError(std::string(e.what()) + " {{&class_name}} {{&key}} {{&class_name}}"); + } + + {{#subclasses}} + if ( type == "{{&key}}" ) { + std::shared_ptr<{{&type}}> k = std::make_shared<{{&type}}>(); + j.get_to(*k); + p = std::static_pointer_cast<{{&class_name}}>(k); + return; + } + {{/subclasses}} + + throw TypeError(type + " no abstract type {{&class_name}} {{&key}}"); + } +} +{{/abstract}} +{{/cinc}} +{{/.}} diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol-json-hpp.mustache b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol-json-hpp.mustache new file mode 100644 index 0000000000000..f903bd681a5c2 --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol-json-hpp.mustache @@ -0,0 +1,68 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +{{#.}} +{{#comment}} +{{comment}} +{{/comment}} +{{/.}} + +#include +#include + +#include "presto_cpp/external/json/nlohmann/json.hpp" +#include "presto_cpp/presto_protocol/core/presto_protocol_core.h" + +namespace facebook::presto::protocol::clp { +struct ClpTransactionHandle : public ConnectorTransactionHandle { + String instance = {}; + }; +void to_json(json& j, const ClpTransactionHandle& p); + +void from_json(const json& j, ClpTransactionHandle& p); +} //namespace facebook::presto::protocol +{{#.}} +{{#hinc}} +{{&hinc}} +{{/hinc}} +{{^hinc}} +{{#struct}} +namespace facebook::presto::protocol::clp { + struct {{class_name}} {{#super_class}}: public {{super_class}}{{/super_class}}{ + {{#fields}} + {{#field_local}}{{#optional}}std::shared_ptr<{{/optional}}{{&field_text}}{{#optional}}>{{/optional}} {{&field_name}} = {};{{/field_local}} + {{/fields}} + + {{#super_class}} + {{class_name}}() noexcept; + {{/super_class}} + }; + void to_json(json& j, const {{class_name}}& p); + void from_json(const json& j, {{class_name}}& p); +} +{{/struct}} +{{#enum}} +namespace facebook::presto::protocol::clp { + enum class {{class_name}} { + {{#elements}} + {{&element}}{{^_last}},{{/_last}} + {{/elements}} + }; + extern void to_json(json& j, const {{class_name}}& e); + extern void from_json(const json& j, {{class_name}}& e); +} +{{/enum}} +{{/hinc}} +{{/.}} diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.cpp b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.cpp new file mode 100644 index 0000000000000..aa47514132c2b --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.cpp @@ -0,0 +1,158 @@ +// DO NOT EDIT : This file is generated by chevron +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// presto_protocol.prolog.cpp +// + +// This file is generated DO NOT EDIT @generated + +#include "presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.h" +using namespace std::string_literals; + +namespace facebook::presto::protocol::clp { + +void to_json(json& j, const ClpTransactionHandle& p) { + j = json::array(); + j.push_back(p._type); + j.push_back(p.instance); +} + +void from_json(const json& j, ClpTransactionHandle& p) { + j[0].get_to(p._type); + j[1].get_to(p.instance); +} +} // namespace facebook::presto::protocol::clp +namespace facebook::presto::protocol::clp { +ClpColumnHandle::ClpColumnHandle() noexcept { + _type = "clp"; +} + +void to_json(json& j, const ClpColumnHandle& p) { + j = json::object(); + j["@type"] = "clp"; + to_json_key( + j, "columnName", p.columnName, "ClpColumnHandle", "String", "columnName"); + to_json_key( + j, + "originalColumnName", + p.originalColumnName, + "ClpColumnHandle", + "String", + "originalColumnName"); + to_json_key( + j, "columnType", p.columnType, "ClpColumnHandle", "Type", "columnType"); + to_json_key(j, "nullable", p.nullable, "ClpColumnHandle", "bool", "nullable"); +} + +void from_json(const json& j, ClpColumnHandle& p) { + p._type = j["@type"]; + from_json_key( + j, "columnName", p.columnName, "ClpColumnHandle", "String", "columnName"); + from_json_key( + j, + "originalColumnName", + p.originalColumnName, + "ClpColumnHandle", + "String", + "originalColumnName"); + from_json_key( + j, "columnType", p.columnType, "ClpColumnHandle", "Type", "columnType"); + from_json_key( + j, "nullable", p.nullable, "ClpColumnHandle", "bool", "nullable"); +} +} // namespace facebook::presto::protocol::clp +namespace facebook::presto::protocol::clp { +ClpSplit::ClpSplit() noexcept { + _type = "clp"; +} + +void to_json(json& j, const ClpSplit& p) { + j = json::object(); + j["@type"] = "clp"; + to_json_key(j, "path", p.path, "ClpSplit", "String", "path"); +} + +void from_json(const json& j, ClpSplit& p) { + p._type = j["@type"]; + from_json_key(j, "path", p.path, "ClpSplit", "String", "path"); +} +} // namespace facebook::presto::protocol::clp +namespace facebook::presto::protocol::clp { +ClpTableHandle::ClpTableHandle() noexcept { + _type = "clp"; +} + +void to_json(json& j, const ClpTableHandle& p) { + j = json::object(); + j["@type"] = "clp"; + to_json_key( + j, + "schemaTableName", + p.schemaTableName, + "ClpTableHandle", + "SchemaTableName", + "schemaTableName"); + to_json_key( + j, "tablePath", p.tablePath, "ClpTableHandle", "String", "tablePath"); +} + +void from_json(const json& j, ClpTableHandle& p) { + p._type = j["@type"]; + from_json_key( + j, + "schemaTableName", + p.schemaTableName, + "ClpTableHandle", + "SchemaTableName", + "schemaTableName"); + from_json_key( + j, "tablePath", p.tablePath, "ClpTableHandle", "String", "tablePath"); +} +} // namespace facebook::presto::protocol::clp +namespace facebook::presto::protocol::clp { +ClpTableLayoutHandle::ClpTableLayoutHandle() noexcept { + _type = "clp"; +} + +void to_json(json& j, const ClpTableLayoutHandle& p) { + j = json::object(); + j["@type"] = "clp"; + to_json_key( + j, "table", p.table, "ClpTableLayoutHandle", "ClpTableHandle", "table"); + to_json_key( + j, "kqlQuery", p.kqlQuery, "ClpTableLayoutHandle", "String", "kqlQuery"); + to_json_key( + j, + "metadataFilterQuery", + p.metadataFilterQuery, + "ClpTableLayoutHandle", + "String", + "metadataFilterQuery"); +} + +void from_json(const json& j, ClpTableLayoutHandle& p) { + p._type = j["@type"]; + from_json_key( + j, "table", p.table, "ClpTableLayoutHandle", "ClpTableHandle", "table"); + from_json_key( + j, "kqlQuery", p.kqlQuery, "ClpTableLayoutHandle", "String", "kqlQuery"); + from_json_key( + j, + "metadataFilterQuery", + p.metadataFilterQuery, + "ClpTableLayoutHandle", + "String", + "metadataFilterQuery"); +} +} // namespace facebook::presto::protocol::clp diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.h b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.h new file mode 100644 index 0000000000000..6fc9e3dd5ac2c --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.h @@ -0,0 +1,81 @@ +// DO NOT EDIT : This file is generated by chevron +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +// This file is generated DO NOT EDIT @generated + +#include +#include + +#include "presto_cpp/external/json/nlohmann/json.hpp" +#include "presto_cpp/presto_protocol/core/presto_protocol_core.h" + +namespace facebook::presto::protocol::clp { +struct ClpTransactionHandle : public ConnectorTransactionHandle { + String instance = {}; +}; +void to_json(json& j, const ClpTransactionHandle& p); + +void from_json(const json& j, ClpTransactionHandle& p); +} // namespace facebook::presto::protocol::clp +// ClpColumnHandle is special since it needs an implementation of +// operator<(). + +namespace facebook::presto::protocol::clp { +struct ClpColumnHandle : public ColumnHandle { + String columnName = {}; + String originalColumnName = {}; + Type columnType = {}; + boolean nullable = {}; + + ClpColumnHandle() noexcept; + + bool operator<(const ColumnHandle& o) const override { + return columnName < dynamic_cast(o).columnName; + } +}; +void to_json(json& j, const ClpColumnHandle& p); +void from_json(const json& j, ClpColumnHandle& p); +} // namespace facebook::presto::protocol::clp +namespace facebook::presto::protocol::clp { +struct ClpSplit : public ConnectorSplit { + String path = {}; + + ClpSplit() noexcept; +}; +void to_json(json& j, const ClpSplit& p); +void from_json(const json& j, ClpSplit& p); +} // namespace facebook::presto::protocol::clp +namespace facebook::presto::protocol::clp { +struct ClpTableHandle : public ConnectorTableHandle { + SchemaTableName schemaTableName = {}; + String tablePath = {}; + + ClpTableHandle() noexcept; +}; +void to_json(json& j, const ClpTableHandle& p); +void from_json(const json& j, ClpTableHandle& p); +} // namespace facebook::presto::protocol::clp +namespace facebook::presto::protocol::clp { +struct ClpTableLayoutHandle : public ConnectorTableLayoutHandle { + ClpTableHandle table = {}; + std::shared_ptr kqlQuery = {}; + std::shared_ptr metadataFilterQuery = {}; + + ClpTableLayoutHandle() noexcept; +}; +void to_json(json& j, const ClpTableLayoutHandle& p); +void from_json(const json& j, ClpTableLayoutHandle& p); +} // namespace facebook::presto::protocol::clp diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.json b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.json new file mode 100644 index 0000000000000..6d73bc0c22128 --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.json @@ -0,0 +1,114 @@ +[ + { + "comment": "// This file is generated DO NOT EDIT @generated" + }, + { + "class_name": "ClpColumnHandle", + "hinc": "// ClpColumnHandle is special since it needs an implementation of\n// operator<().\n\nnamespace facebook::presto::protocol::clp {\nstruct ClpColumnHandle : public ColumnHandle {\n String columnName = {};\n String originalColumnName = {};\n Type columnType = {};\n boolean nullable = {};\n\n ClpColumnHandle() noexcept;\n\n bool operator<(const ColumnHandle& o) const override {\n return columnName < dynamic_cast(o).columnName;\n }\n};\nvoid to_json(json& j, const ClpColumnHandle& p);\nvoid from_json(const json& j, ClpColumnHandle& p);\n} // namespace facebook::presto::protocol::clp", + "struct": true, + "fields": [ + { + "field_type": "String", + "field_name": "columnName", + "field_text": "String", + "_N": 1, + "field_local": true + }, + { + "field_type": "String", + "field_name": "originalColumnName", + "field_text": "String", + "_N": 2, + "field_local": true + }, + { + "field_type": "Type", + "field_name": "columnType", + "field_text": "Type", + "_N": 3, + "field_local": true + }, + { + "field_type": "boolean", + "field_name": "nullable", + "field_text": "bool", + "_N": 4, + "field_local": true + } + ], + "subclass": true, + "super_class": "ColumnHandle", + "json_key": "clp" + }, + { + "class_name": "ClpSplit", + "struct": true, + "fields": [ + { + "field_type": "String", + "field_name": "path", + "field_text": "String", + "_N": 1, + "field_local": true + } + ], + "subclass": true, + "super_class": "ConnectorSplit", + "json_key": "clp" + }, + { + "class_name": "ClpTableHandle", + "struct": true, + "fields": [ + { + "field_type": "SchemaTableName", + "field_name": "schemaTableName", + "field_text": "SchemaTableName", + "_N": 1, + "field_local": true + }, + { + "field_type": "String", + "field_name": "tablePath", + "field_text": "String", + "_N": 2, + "field_local": true + } + ], + "subclass": true, + "super_class": "ConnectorTableHandle", + "json_key": "clp" + }, + { + "class_name": "ClpTableLayoutHandle", + "struct": true, + "fields": [ + { + "field_type": "ClpTableHandle", + "field_name": "table", + "field_text": "ClpTableHandle", + "_N": 1, + "field_local": true + }, + { + "field_type": "Optional", + "field_name": "kqlQuery", + "field_text": "String", + "optional": true, + "_N": 2, + "field_local": true + }, + { + "field_type": "Optional", + "field_name": "metadataFilterQuery", + "field_text": "String", + "optional": true, + "_N": 3, + "field_local": true + } + ], + "subclass": true, + "super_class": "ConnectorTableLayoutHandle", + "json_key": "clp" + } +] diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.yml b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.yml new file mode 100644 index 0000000000000..18fb7467967ba --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.yml @@ -0,0 +1,39 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +AbstractClasses: + ColumnHandle: + super: JsonEncodedSubclass + comparable: true + subclasses: + - { name: ClpColumnHandle, key: clp } + + ConnectorTableHandle: + super: JsonEncodedSubclass + subclasses: + - { name: ClpTableHandle, key: clp } + + ConnectorTableLayoutHandle: + super: JsonEncodedSubclass + subclasses: + - { name: ClpTableLayoutHandle, key: clp } + + ConnectorSplit: + super: JsonEncodedSubclass + subclasses: + - { name: ClpSplit, key: clp } + +JavaClasses: + - presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpColumnHandle.java + - presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpTableHandle.java + - presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpTableLayoutHandle.java + - presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpSplit.java diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/clp/special/ClpColumnHandle.hpp.inc b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/special/ClpColumnHandle.hpp.inc new file mode 100644 index 0000000000000..bb076b8ff23db --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/special/ClpColumnHandle.hpp.inc @@ -0,0 +1,33 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ClpColumnHandle is special since it needs an implementation of +// operator<(). + +namespace facebook::presto::protocol::clp { +struct ClpColumnHandle : public ColumnHandle { + String columnName = {}; + String originalColumnName = {}; + Type columnType = {}; + boolean nullable = {}; + + ClpColumnHandle() noexcept; + + bool operator<(const ColumnHandle& o) const override { + return columnName < dynamic_cast(o).columnName; + } +}; +void to_json(json& j, const ClpColumnHandle& p); +void from_json(const json& j, ClpColumnHandle& p); +} // namespace facebook::presto::protocol::clp diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/clp/special/ClpTransactionHandle.cpp.inc b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/special/ClpTransactionHandle.cpp.inc new file mode 100644 index 0000000000000..a753f42ab61f1 --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/special/ClpTransactionHandle.cpp.inc @@ -0,0 +1,30 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ClpTransactionHandle is special since +// the corresponding class in Java is an enum. + +namespace facebook::presto::protocol::clp { + +void to_json(json& j, const ClpTransactionHandle& p) { + j = json::array(); + j.push_back(p._type); + j.push_back(p.instance); +} + +void from_json(const json& j, ClpTransactionHandle& p) { + j[0].get_to(p._type); + j[1].get_to(p.instance); +} +} // namespace facebook::presto::protocol::clp diff --git a/presto-native-execution/presto_cpp/presto_protocol/connector/clp/special/ClpTransactionHandle.hpp.inc b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/special/ClpTransactionHandle.hpp.inc new file mode 100644 index 0000000000000..fc873366389eb --- /dev/null +++ b/presto-native-execution/presto_cpp/presto_protocol/connector/clp/special/ClpTransactionHandle.hpp.inc @@ -0,0 +1,28 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// ClpTransactionHandle is special since +// the corresponding class in Java is an enum. + +namespace facebook::presto::protocol::clp { + +struct ClpTransactionHandle : public ConnectorTransactionHandle { + String instance = {}; +}; + +void to_json(json& j, const ClpTransactionHandle& p); + +void from_json(const json& j, ClpTransactionHandle& p); + +} // namespace facebook::presto::protocol::clp diff --git a/presto-native-execution/presto_cpp/presto_protocol/java-to-struct-json.py b/presto-native-execution/presto_cpp/presto_protocol/java-to-struct-json.py index 98888d194f7b2..0f39c41e1cf44 100755 --- a/presto-native-execution/presto_cpp/presto_protocol/java-to-struct-json.py +++ b/presto-native-execution/presto_cpp/presto_protocol/java-to-struct-json.py @@ -170,7 +170,7 @@ def member_name(name): def special(filepath, current_class, key, classes, depends): classes[current_class].class_name = current_class (status, stdout, stderr) = classes[current_class][key] = util.run( - "../../velox/scripts/license-header.py --header ../../license.header --remove " + "../../velox/scripts/checks/license-header.py --header ../../license.header --remove " + filepath ) classes[current_class][key] = stdout diff --git a/presto-native-execution/presto_cpp/presto_protocol/presto_protocol.cpp b/presto-native-execution/presto_cpp/presto_protocol/presto_protocol.cpp index 24f24f27f87a3..0c0362ac434eb 100644 --- a/presto-native-execution/presto_cpp/presto_protocol/presto_protocol.cpp +++ b/presto-native-execution/presto_cpp/presto_protocol/presto_protocol.cpp @@ -16,6 +16,7 @@ // DEPRECATED: This file is deprecated and will be removed in future versions. #include "presto_cpp/presto_protocol/connector/arrow_flight/presto_protocol_arrow_flight.cpp" +#include "presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.cpp" #include "presto_cpp/presto_protocol/connector/hive/presto_protocol_hive.cpp" #include "presto_cpp/presto_protocol/connector/iceberg/presto_protocol_iceberg.cpp" #include "presto_cpp/presto_protocol/connector/tpch/presto_protocol_tpch.cpp" diff --git a/presto-native-execution/presto_cpp/presto_protocol/presto_protocol.h b/presto-native-execution/presto_cpp/presto_protocol/presto_protocol.h index c43ec92629f44..ba3bf29d4648f 100644 --- a/presto-native-execution/presto_cpp/presto_protocol/presto_protocol.h +++ b/presto-native-execution/presto_cpp/presto_protocol/presto_protocol.h @@ -17,6 +17,7 @@ // DEPRECATED: This file is deprecated and will be removed in future versions. #include "presto_cpp/presto_protocol/connector/arrow_flight/presto_protocol_arrow_flight.h" +#include "presto_cpp/presto_protocol/connector/clp/presto_protocol_clp.h" #include "presto_cpp/presto_protocol/connector/hive/presto_protocol_hive.h" #include "presto_cpp/presto_protocol/connector/iceberg/presto_protocol_iceberg.h" #include "presto_cpp/presto_protocol/connector/tpch/presto_protocol_tpch.h" diff --git a/presto-native-execution/velox b/presto-native-execution/velox index 52f4e376b2b7b..749d28944723a 160000 --- a/presto-native-execution/velox +++ b/presto-native-execution/velox @@ -1 +1 @@ -Subproject commit 52f4e376b2b7baf61b22a857f719cbe856bd9c0e +Subproject commit 749d28944723ad746b60ca7073f42b3df9896ff4