21 namespace foreign_storage {
23 size_t column_index) {
24 std::optional<SQLTypes> tentative_geo_type{};
25 for (
const auto& row : sample_rows) {
26 static std::regex geo_regex{
27 "\\s*(POINT|MULTIPOINT|LINESTRING|MULTILINESTRING|POLYGON|MULTIPOLYGON)\\s*\\(.+"
31 if (std::regex_match(row[column_index], match, geo_regex)) {
32 CHECK_EQ(match.size(),
static_cast<size_t>(2));
34 const auto& geo_type_str = match[1];
35 if (geo_type_str ==
"POINT") {
37 }
else if (geo_type_str ==
"MULTIPOINT") {
39 }
else if (geo_type_str ==
"LINESTRING") {
41 }
else if (geo_type_str ==
"MULTILINESTRING") {
43 }
else if (geo_type_str ==
"POLYGON") {
45 }
else if (geo_type_str ==
"MULTIPOLYGON") {
48 UNREACHABLE() <<
"Unexpected geo type match: " << geo_type_str;
50 if (tentative_geo_type.has_value()) {
51 if (tentative_geo_type.value() != geo_type) {
55 tentative_geo_type = geo_type;
59 return tentative_geo_type;
std::optional< SQLTypes > detect_geo_type(const SampleRows &sample_rows, size_t column_index)
std::vector< std::vector< std::string >> SampleRows