pitrou commented on code in PR #55599:
URL: https://github.com/apache/arrow/pull/55599#discussion_r4597083309


##########
cpp/src/parquet/geospatial/util_json_internal_test.cc:
##########
@@ -30,6 +31,124 @@
 
 namespace parquet {
 
+struct LogicalTypeToGeoArrowCase {
+  std::shared_ptr<const LogicalType> logical_type;
+  std::string expected_metadata;
+};
+
+class LogicalTypeToGeoArrowTest
+    : public ::testing::TestWithParam<LogicalTypeToGeoArrowCase> {};
+
+TEST_P(LogicalTypeToGeoArrowTest, ConvertsMetadata) {
+  ::arrow::ExtensionTypeGuard guard(test::geoarrow_wkb());
+  const auto& test_case = GetParam();
+  ARROW_SCOPED_TRACE("logical type = ", test_case.logical_type->ToString());
+
+  ASSERT_OK_AND_ASSIGN(
+      auto type,
+      GeoArrowTypeFromLogicalType(*test_case.logical_type, nullptr, 
::arrow::binary()));
+  auto extension = std::dynamic_pointer_cast<::arrow::ExtensionType>(type);
+  ASSERT_NE(extension, nullptr);
+  ASSERT_OK_AND_ASSIGN(auto actual,
+                       ::arrow::internal::MinifyJson(extension->Serialize()));
+  EXPECT_EQ(actual, test_case.expected_metadata);
+}
+
+INSTANTIATE_TEST_SUITE_P(
+    GeoArrowConversion, LogicalTypeToGeoArrowTest,
+    ::testing::Values(

Review Comment:
   Is there a documentation pointer that you can add so that the reader 
understands how to maintain these parameter lists?



##########
cpp/src/parquet/geospatial/util_json_internal_test.cc:
##########
@@ -30,6 +31,124 @@
 
 namespace parquet {
 
+struct LogicalTypeToGeoArrowCase {
+  std::shared_ptr<const LogicalType> logical_type;
+  std::string expected_metadata;
+};
+
+class LogicalTypeToGeoArrowTest
+    : public ::testing::TestWithParam<LogicalTypeToGeoArrowCase> {};
+
+TEST_P(LogicalTypeToGeoArrowTest, ConvertsMetadata) {
+  ::arrow::ExtensionTypeGuard guard(test::geoarrow_wkb());
+  const auto& test_case = GetParam();
+  ARROW_SCOPED_TRACE("logical type = ", test_case.logical_type->ToString());
+
+  ASSERT_OK_AND_ASSIGN(
+      auto type,
+      GeoArrowTypeFromLogicalType(*test_case.logical_type, nullptr, 
::arrow::binary()));
+  auto extension = std::dynamic_pointer_cast<::arrow::ExtensionType>(type);
+  ASSERT_NE(extension, nullptr);
+  ASSERT_OK_AND_ASSIGN(auto actual,
+                       ::arrow::internal::MinifyJson(extension->Serialize()));
+  EXPECT_EQ(actual, test_case.expected_metadata);
+}
+
+INSTANTIATE_TEST_SUITE_P(
+    GeoArrowConversion, LogicalTypeToGeoArrowTest,
+    ::testing::Values(
+        LogicalTypeToGeoArrowCase{LogicalType::Geometry(), 
R"({"crs":"OGC:CRS84"})"},
+        LogicalTypeToGeoArrowCase{LogicalType::Geometry("srid:0"), R"({})"},
+        LogicalTypeToGeoArrowCase{LogicalType::Geometry("EPSG:4267"),
+                                  R"({"crs":"EPSG:4267"})"},
+        LogicalTypeToGeoArrowCase{
+            
LogicalType::Geometry(R"({"id":{"authority":"EPSG","code":4326}})"),
+            R"({"crs":{"id":{"authority":"EPSG","code":4326}}})"},
+        LogicalTypeToGeoArrowCase{LogicalType::Geography(),
+                                  
R"({"crs":"OGC:CRS84","edges":"spherical"})"},
+        LogicalTypeToGeoArrowCase{
+            LogicalType::Geography("",
+                                   
LogicalType::EdgeInterpolationAlgorithm::SPHERICAL),
+            R"({"crs":"OGC:CRS84","edges":"spherical"})"},
+        LogicalTypeToGeoArrowCase{
+            LogicalType::Geography("", 
LogicalType::EdgeInterpolationAlgorithm::KARNEY),
+            R"({"crs":"OGC:CRS84","edges":"karney"})"},
+        LogicalTypeToGeoArrowCase{
+            LogicalType::Geography("", 
LogicalType::EdgeInterpolationAlgorithm::VINCENTY),
+            R"({"crs":"OGC:CRS84","edges":"vincenty"})"},
+        LogicalTypeToGeoArrowCase{
+            LogicalType::Geography("", 
LogicalType::EdgeInterpolationAlgorithm::ANDOYER),
+            R"({"crs":"OGC:CRS84","edges":"andoyer"})"},
+        LogicalTypeToGeoArrowCase{
+            LogicalType::Geography("", 
LogicalType::EdgeInterpolationAlgorithm::THOMAS),
+            R"({"crs":"OGC:CRS84","edges":"thomas"})"},
+        LogicalTypeToGeoArrowCase{LogicalType::Geography("srid:0"),
+                                  R"({"edges":"spherical"})"},
+        LogicalTypeToGeoArrowCase{LogicalType::Geography("EPSG:4267"),
+                                  
R"({"crs":"EPSG:4267","edges":"spherical"})"},
+        LogicalTypeToGeoArrowCase{
+            
LogicalType::Geography(R"({"id":{"authority":"EPSG","code":4326}})"),
+            
R"({"crs":{"id":{"authority":"EPSG","code":4326}},"edges":"spherical"})"}));
+
+struct GeoArrowToLogicalTypeCase {
+  std::string metadata;
+  std::shared_ptr<const LogicalType> expected_logical_type;
+};
+
+class GeoArrowToLogicalTypeTest
+    : public ::testing::TestWithParam<GeoArrowToLogicalTypeCase> {};
+
+TEST_P(GeoArrowToLogicalTypeTest, ConvertsMetadata) {
+  const auto& test_case = GetParam();
+  ARROW_SCOPED_TRACE("metadata = ", test_case.metadata);
+  ASSERT_OK_AND_ASSIGN(auto actual, 
LogicalTypeFromGeoArrowMetadata(test_case.metadata));
+  EXPECT_TRUE(actual->Equals(*test_case.expected_logical_type))
+      << "Actual: " << actual->ToString()
+      << ", expected: " << test_case.expected_logical_type->ToString();
+}
+
+INSTANTIATE_TEST_SUITE_P(
+    GeoArrowConversion, GeoArrowToLogicalTypeTest,
+    ::testing::Values(

Review Comment:
   Same Q here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to