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|LINESTRING|POLYGON|MULTIPOLYGON)\\s*\\(.+\\)\\s*"};
30 if (std::regex_match(row[column_index], match, geo_regex)) {
31 CHECK_EQ(match.size(),
static_cast<size_t>(2));
33 const auto& geo_type_str = match[1];
34 if (geo_type_str ==
"POINT") {
36 }
else if (geo_type_str ==
"LINESTRING") {
38 }
else if (geo_type_str ==
"POLYGON") {
40 }
else if (geo_type_str ==
"MULTIPOLYGON") {
43 UNREACHABLE() <<
"Unexpected geo type match: " << geo_type_str;
45 if (tentative_geo_type.has_value()) {
46 if (tentative_geo_type.value() != geo_type) {
50 tentative_geo_type = geo_type;
54 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