Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ public class ClpSplit
implements ConnectorSplit
{
private final String path;
private final SplitType type;
private final Optional<String> kqlQuery;

@JsonCreator
public ClpSplit(
@JsonProperty("path") String path,
@JsonProperty("type") SplitType type,
@JsonProperty("kqlQuery") Optional<String> kqlQuery)
{
this.path = requireNonNull(path, "Split path is null");
this.type = requireNonNull(type, "Split type is null");
this.kqlQuery = kqlQuery;
}

Expand All @@ -50,6 +53,12 @@ public String getPath()
return path;
}

@JsonProperty
public SplitType getType()
{
return type;
}

@JsonProperty
public Optional<String> getKqlQuery()
{
Expand All @@ -71,6 +80,12 @@ public List<HostAddress> getPreferredNodes(NodeProvider nodeProvider)
@Override
public Map<String, String> getInfo()
{
return ImmutableMap.of("path", path, "kqlQuery", kqlQuery.orElse("<null>"));
return ImmutableMap.of("path", path, "type", type.toString(), "kqlQuery", kqlQuery.orElse("<null>"));
}

public enum SplitType
{
ARCHIVE,
IR,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -81,7 +82,7 @@ public List<ClpSplit> 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()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,10 @@ ClpPrestoToVeloxConnector::toVeloxSplit(
VELOX_CHECK_NOT_NULL(
clpSplit, "Unexpected split type {}", connectorSplit->_type);
return std::make_unique<connector::clp::ClpConnectorSplit>(
catalogId, clpSplit->path, clpSplit->kqlQuery);
catalogId,
clpSplit->path,
static_cast<int>(clpSplit->type),
clpSplit->kqlQuery);
}

std::unique_ptr<velox::connector::ColumnHandle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, json> 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<SplitType>::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<SplitType, json>& ej_pair) -> bool {
return ej_pair.first == e;
});
j = ((it != std::end(SplitType_enum_table))
? it
: std::begin(SplitType_enum_table))
->second;
}
Comment thread
anlowee marked this conversation as resolved.
void from_json(const json& j, SplitType& e) {
static_assert(std::is_enum<SplitType>::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<SplitType, json>& ej_pair) -> bool {
return ej_pair.second == j;
});
e = ((it != std::end(SplitType_enum_table))
? it
: std::begin(SplitType_enum_table))
->first;
}
Comment thread
anlowee marked this conversation as resolved.
} // namespace facebook::presto::protocol::clp
namespace facebook::presto::protocol::clp {
ClpSplit::ClpSplit() noexcept {
_type = "clp";
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> kqlQuery = {};

ClpSplit() noexcept;
Expand Down
Loading