diff --git a/presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpSplit.java b/presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpSplit.java index 48865c4138104..2e35840971c11 100644 --- a/presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpSplit.java +++ b/presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpSplit.java @@ -33,14 +33,17 @@ public class ClpSplit implements ConnectorSplit { private final String path; + private final SplitType type; private final Optional kqlQuery; @JsonCreator public ClpSplit( @JsonProperty("path") String path, + @JsonProperty("type") SplitType type, @JsonProperty("kqlQuery") Optional kqlQuery) { this.path = requireNonNull(path, "Split path is null"); + this.type = requireNonNull(type, "Split type is null"); this.kqlQuery = kqlQuery; } @@ -50,6 +53,12 @@ public String getPath() return path; } + @JsonProperty + public SplitType getType() + { + return type; + } + @JsonProperty public Optional getKqlQuery() { @@ -71,6 +80,12 @@ public List getPreferredNodes(NodeProvider nodeProvider) @Override public Map getInfo() { - return ImmutableMap.of("path", path, "kqlQuery", kqlQuery.orElse("")); + return ImmutableMap.of("path", path, "type", type.toString(), "kqlQuery", kqlQuery.orElse("")); + } + + public enum SplitType + { + ARCHIVE, + IR, } } diff --git a/presto-clp/src/main/java/com/facebook/presto/plugin/clp/split/ClpMySqlSplitProvider.java b/presto-clp/src/main/java/com/facebook/presto/plugin/clp/split/ClpMySqlSplitProvider.java index f8c7644c23b54..6b54218509c7f 100644 --- a/presto-clp/src/main/java/com/facebook/presto/plugin/clp/split/ClpMySqlSplitProvider.java +++ b/presto-clp/src/main/java/com/facebook/presto/plugin/clp/split/ClpMySqlSplitProvider.java @@ -29,6 +29,7 @@ import java.sql.SQLException; import java.util.List; +import static com.facebook.presto.plugin.clp.ClpSplit.SplitType.ARCHIVE; import static java.lang.String.format; public class ClpMySqlSplitProvider @@ -81,7 +82,7 @@ public List listSplits(ClpTableLayoutHandle clpTableLayoutHandle) while (resultSet.next()) { final String archiveId = resultSet.getString(ARCHIVES_TABLE_COLUMN_ID); final String archivePath = tablePath + "/" + archiveId; - splits.add(new ClpSplit(archivePath, clpTableLayoutHandle.getKqlQuery())); + splits.add(new ClpSplit(archivePath, ARCHIVE, clpTableLayoutHandle.getKqlQuery())); } } } diff --git a/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.cpp b/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.cpp index dda9e593c45f1..0784ad5ab1528 100644 --- a/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.cpp +++ b/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.cpp @@ -1564,7 +1564,10 @@ ClpPrestoToVeloxConnector::toVeloxSplit( VELOX_CHECK_NOT_NULL( clpSplit, "Unexpected split type {}", connectorSplit->_type); return std::make_unique( - catalogId, clpSplit->path, clpSplit->kqlQuery); + catalogId, + clpSplit->path, + static_cast(clpSplit->type), + clpSplit->kqlQuery); } std::unique_ptr 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 index f30beed5a875a..9158b9aa4f77d 100644 --- 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 @@ -72,7 +72,7 @@ namespace facebook::presto::protocol::clp { {{/struct}} {{#enum}} namespace facebook::presto::protocol::clp { - //Loosly copied this here from NLOHMANN_JSON_SERIALIZE_ENUM() + //Loosely copied this here from NLOHMANN_JSON_SERIALIZE_ENUM() // NOLINTNEXTLINE: cppcoreguidelines-avoid-c-arrays static const std::pair<{{&class_name}}, json> 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 index 555554d0b1de6..89ad3afe0a62d 100644 --- 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 @@ -70,6 +70,41 @@ void from_json(const json& j, ClpColumnHandle& p) { } } // namespace facebook::presto::protocol::clp namespace facebook::presto::protocol::clp { +// Loosely copied this here from NLOHMANN_JSON_SERIALIZE_ENUM() + +// NOLINTNEXTLINE: cppcoreguidelines-avoid-c-arrays +static const std::pair SplitType_enum_table[] = + { // NOLINT: cert-err58-cpp + {SplitType::ARCHIVE, "ARCHIVE"}, + {SplitType::IR, "IR"}}; +void to_json(json& j, const SplitType& e) { + static_assert(std::is_enum::value, "SplitType must be an enum!"); + const auto* it = std::find_if( + std::begin(SplitType_enum_table), + std::end(SplitType_enum_table), + [e](const std::pair& ej_pair) -> bool { + return ej_pair.first == e; + }); + j = ((it != std::end(SplitType_enum_table)) + ? it + : std::begin(SplitType_enum_table)) + ->second; +} +void from_json(const json& j, SplitType& e) { + static_assert(std::is_enum::value, "SplitType must be an enum!"); + const auto* it = std::find_if( + std::begin(SplitType_enum_table), + std::end(SplitType_enum_table), + [&j](const std::pair& ej_pair) -> bool { + return ej_pair.second == j; + }); + e = ((it != std::end(SplitType_enum_table)) + ? it + : std::begin(SplitType_enum_table)) + ->first; +} +} // namespace facebook::presto::protocol::clp +namespace facebook::presto::protocol::clp { ClpSplit::ClpSplit() noexcept { _type = "clp"; } @@ -78,12 +113,14 @@ void to_json(json& j, const ClpSplit& p) { j = json::object(); j["@type"] = "clp"; to_json_key(j, "path", p.path, "ClpSplit", "String", "path"); + to_json_key(j, "type", p.type, "ClpSplit", "SplitType", "type"); to_json_key(j, "kqlQuery", p.kqlQuery, "ClpSplit", "String", "kqlQuery"); } void from_json(const json& j, ClpSplit& p) { p._type = j["@type"]; from_json_key(j, "path", p.path, "ClpSplit", "String", "path"); + from_json_key(j, "type", p.type, "ClpSplit", "SplitType", "type"); from_json_key(j, "kqlQuery", p.kqlQuery, "ClpSplit", "String", "kqlQuery"); } } // 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 index 46b134642df27..59a3677c11608 100644 --- 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 @@ -49,8 +49,14 @@ 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 { +enum class SplitType { ARCHIVE, IR }; +extern void to_json(json& j, const SplitType& e); +extern void from_json(const json& j, SplitType& e); +} // namespace facebook::presto::protocol::clp +namespace facebook::presto::protocol::clp { struct ClpSplit : public ConnectorSplit { String path = {}; + SplitType type = {}; std::shared_ptr kqlQuery = {}; ClpSplit() noexcept; diff --git a/presto-native-execution/velox b/presto-native-execution/velox index 1f509a8114763..28be93b4d05bf 160000 --- a/presto-native-execution/velox +++ b/presto-native-execution/velox @@ -1 +1 @@ -Subproject commit 1f509a81147637d6d554eddc0ec2f34eed6e5a23 +Subproject commit 28be93b4d05bf6d9faa5058227dd4f8d4688b96d