diff --git a/cpp/src/parquet/thrift_internal.h b/cpp/src/parquet/thrift_internal.h index 888f286f17648..cd424914f1110 100644 --- a/cpp/src/parquet/thrift_internal.h +++ b/cpp/src/parquet/thrift_internal.h @@ -257,7 +257,7 @@ static inline EncodedGeoStatistics FromThrift( } static inline format::EdgeInterpolationAlgorithm::type ToThrift( - LogicalType::EdgeInterpolationAlgorithm::algorithm algorithm) { + LogicalType::EdgeInterpolationAlgorithm algorithm) { switch (algorithm) { case LogicalType::EdgeInterpolationAlgorithm::SPHERICAL: return format::EdgeInterpolationAlgorithm::SPHERICAL; @@ -270,11 +270,12 @@ static inline format::EdgeInterpolationAlgorithm::type ToThrift( case LogicalType::EdgeInterpolationAlgorithm::KARNEY: return format::EdgeInterpolationAlgorithm::KARNEY; default: - throw ParquetException("Unknown value for geometry algorithm: ", algorithm); + throw ParquetException("Unknown value for geometry algorithm: ", + static_cast(algorithm)); } } -static inline LogicalType::EdgeInterpolationAlgorithm::algorithm FromThrift( +static inline LogicalType::EdgeInterpolationAlgorithm FromThrift( const format::EdgeInterpolationAlgorithm::type algorithm) { switch (algorithm) { case format::EdgeInterpolationAlgorithm::SPHERICAL: @@ -288,7 +289,8 @@ static inline LogicalType::EdgeInterpolationAlgorithm::algorithm FromThrift( case format::EdgeInterpolationAlgorithm::KARNEY: return LogicalType::EdgeInterpolationAlgorithm::KARNEY; default: - throw ParquetException("Unknown value for geometry algorithm: ", algorithm); + throw ParquetException("Unknown value for geometry algorithm: ", + static_cast(algorithm)); } } diff --git a/cpp/src/parquet/types.cc b/cpp/src/parquet/types.cc index 1ace995a964bf..ee583185502f6 100644 --- a/cpp/src/parquet/types.cc +++ b/cpp/src/parquet/types.cc @@ -493,7 +493,7 @@ std::shared_ptr LogicalType::FromThrift( crs = type.GEOGRAPHY.crs; } - LogicalType::EdgeInterpolationAlgorithm::algorithm algorithm; + LogicalType::EdgeInterpolationAlgorithm algorithm; if (!type.GEOGRAPHY.__isset.algorithm) { algorithm = LogicalType::EdgeInterpolationAlgorithm::SPHERICAL; } else { @@ -563,7 +563,7 @@ std::shared_ptr LogicalType::Geometry(std::string crs) { } std::shared_ptr LogicalType::Geography( - std::string crs, LogicalType::EdgeInterpolationAlgorithm::algorithm algorithm) { + std::string crs, LogicalType::EdgeInterpolationAlgorithm algorithm) { return GeographyLogicalType::Make(std::move(crs), algorithm); } @@ -1723,7 +1723,7 @@ bool LogicalType::Impl::Geometry::Equals(const LogicalType& other) const { } const std::string& GeometryLogicalType::crs() const { - return (dynamic_cast(*impl_)).crs(); + return checked_cast(*impl_).crs(); } std::shared_ptr GeometryLogicalType::Make(std::string crs) { @@ -1743,9 +1743,7 @@ class LogicalType::Impl::Geography final : public LogicalType::Impl::Incompatibl bool Equals(const LogicalType& other) const override; const std::string& crs() const { return crs_; } - LogicalType::EdgeInterpolationAlgorithm::algorithm algorithm() const { - return algorithm_; - } + LogicalType::EdgeInterpolationAlgorithm algorithm() const { return algorithm_; } std::string_view algorithm_name() const { switch (algorithm_) { @@ -1765,14 +1763,14 @@ class LogicalType::Impl::Geography final : public LogicalType::Impl::Incompatibl } private: - Geography(std::string crs, LogicalType::EdgeInterpolationAlgorithm::algorithm algorithm) + Geography(std::string crs, LogicalType::EdgeInterpolationAlgorithm algorithm) : LogicalType::Impl(LogicalType::Type::GEOGRAPHY, SortOrder::UNKNOWN), LogicalType::Impl::SimpleApplicable(parquet::Type::BYTE_ARRAY), crs_(std::move(crs)), algorithm_(algorithm) {} std::string crs_; - LogicalType::EdgeInterpolationAlgorithm::algorithm algorithm_; + LogicalType::EdgeInterpolationAlgorithm algorithm_; }; std::string LogicalType::Impl::Geography::ToString() const { @@ -1832,8 +1830,7 @@ const std::string& GeographyLogicalType::crs() const { return (dynamic_cast(*impl_)).crs(); } -LogicalType::EdgeInterpolationAlgorithm::algorithm GeographyLogicalType::algorithm() - const { +LogicalType::EdgeInterpolationAlgorithm GeographyLogicalType::algorithm() const { return (dynamic_cast(*impl_)).algorithm(); } @@ -1842,7 +1839,7 @@ std::string_view GeographyLogicalType::algorithm_name() const { } std::shared_ptr GeographyLogicalType::Make( - std::string crs, LogicalType::EdgeInterpolationAlgorithm::algorithm algorithm) { + std::string crs, LogicalType::EdgeInterpolationAlgorithm algorithm) { auto* logical_type = new GeographyLogicalType(); logical_type->impl_.reset(new LogicalType::Impl::Geography(std::move(crs), algorithm)); return std::shared_ptr(logical_type); diff --git a/cpp/src/parquet/types.h b/cpp/src/parquet/types.h index fbb7666b5c82e..2d6c48ff25a4c 100644 --- a/cpp/src/parquet/types.h +++ b/cpp/src/parquet/types.h @@ -168,15 +168,13 @@ class PARQUET_EXPORT LogicalType { enum unit { UNKNOWN = 0, MILLIS = 1, MICROS, NANOS }; }; - struct EdgeInterpolationAlgorithm { - enum algorithm { - UNKNOWN = 0, - SPHERICAL = 1, - VINCENTY = 2, - THOMAS = 3, - ANDOYER = 4, - KARNEY = 5 - }; + enum class EdgeInterpolationAlgorithm { + UNKNOWN = 0, + SPHERICAL = 1, + VINCENTY = 2, + THOMAS = 3, + ANDOYER = 4, + KARNEY = 5 }; /// \brief If possible, return a logical type equivalent to the given legacy @@ -229,7 +227,7 @@ class PARQUET_EXPORT LogicalType { static std::shared_ptr Geometry(std::string crs = ""); static std::shared_ptr Geography( - std::string crs = "", LogicalType::EdgeInterpolationAlgorithm::algorithm algorithm = + std::string crs = "", LogicalType::EdgeInterpolationAlgorithm algorithm = EdgeInterpolationAlgorithm::SPHERICAL); /// \brief Create a placeholder for when no logical type is specified @@ -480,11 +478,11 @@ class PARQUET_EXPORT GeometryLogicalType : public LogicalType { class PARQUET_EXPORT GeographyLogicalType : public LogicalType { public: static std::shared_ptr Make( - std::string crs = "", LogicalType::EdgeInterpolationAlgorithm::algorithm algorithm = + std::string crs = "", LogicalType::EdgeInterpolationAlgorithm algorithm = EdgeInterpolationAlgorithm::SPHERICAL); const std::string& crs() const; - LogicalType::EdgeInterpolationAlgorithm::algorithm algorithm() const; + LogicalType::EdgeInterpolationAlgorithm algorithm() const; std::string_view algorithm_name() const; private: diff --git a/python/pyarrow/_parquet.pxd b/python/pyarrow/_parquet.pxd index 24332e9ba01e0..9a65e0df16527 100644 --- a/python/pyarrow/_parquet.pxd +++ b/python/pyarrow/_parquet.pxd @@ -78,7 +78,7 @@ cdef extern from "parquet/api/schema.h" namespace "parquet" nogil: ParquetTimeUnit_MICROS" parquet::LogicalType::TimeUnit::MICROS" ParquetTimeUnit_NANOS" parquet::LogicalType::TimeUnit::NANOS" - enum ParquetEdgeInterpolationAlgorithm" parquet::LogicalType::EdgeInterpolationAlgorithm::algorithm": + enum ParquetEdgeInterpolationAlgorithm" parquet::LogicalType::EdgeInterpolationAlgorithm": ParquetEdgeInterpolationAlgorithm_UNKNOWN" parquet::LogicalType::EdgeInterpolationAlgorithm::UNKNOWN" ParquetEdgeInterpolationAlgorithm_SPHERICAL" parquet::LogicalType::EdgeInterpolationAlgorithm::SPHERICAL" ParquetEdgeInterpolationAlgorithm_VINCENTY" parquet::LogicalType::EdgeInterpolationAlgorithm::VINCENTY"