MCPcopy Create free account
hub / github.com/bytedance/bolt / partitionNameToPredicate

Method partitionNameToPredicate

bolt/exec/tests/TableWriteTest.cpp:743–765  ·  view source on GitHub ↗

Parameter partitionName is string formatted in the Hive style key1=value1/key2=value2/... Parameter partitionTypes are types of partition keys in the same order as in partitionName.The return value is a SQL predicate with values single quoted for string and date and not quoted for other supported types, ex., key1='value1' AND key2=value2 AND ...

Source from the content-addressed store, hash-verified

741 // predicate with values single quoted for string and date and not quoted for
742 // other supported types, ex., key1='value1' AND key2=value2 AND ...
743 std::string partitionNameToPredicate(
744 const std::string& partitionName,
745 const std::vector<TypePtr>& partitionTypes) {
746 std::vector<std::string> conjuncts;
747
748 std::vector<std::string> partitionKeyValues;
749 folly::split('/', partitionName, partitionKeyValues);
750 BOLT_CHECK_EQ(partitionKeyValues.size(), partitionTypes.size());
751
752 for (auto i = 0; i < partitionKeyValues.size(); ++i) {
753 if (partitionTypes[i]->isVarchar() || partitionTypes[i]->isVarbinary() ||
754 partitionTypes[i]->isDate()) {
755 conjuncts.push_back(
756 partitionKeyValues[i]
757 .replace(partitionKeyValues[i].find("="), 1, "='")
758 .append("'"));
759 } else {
760 conjuncts.push_back(partitionKeyValues[i]);
761 }
762 }
763
764 return folly::join(" AND ", conjuncts);
765 }
766
767 std::string partitionNameToPredicate(
768 const std::vector<std::string>& partitionDirNames) {

Callers

nothing calls this directly

Calls 6

isDateMethod · 0.80
replaceMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
appendMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected