This is an automated email from the ASF dual-hosted git repository.

maplefu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new b32f71a157 GH-39363: [C++] Use Cast() instead of CastTo() for Parquet  
(#39364)
b32f71a157 is described below

commit b32f71a157eb90a7eb107c540b9cadd343e5e388
Author: Hyunseok Seo <[email protected]>
AuthorDate: Tue Dec 26 15:25:51 2023 +0900

    GH-39363: [C++] Use Cast() instead of CastTo() for Parquet  (#39364)
    
    
    
    ### Rationale for this change
    
    Remove legacy code
    
    ### What changes are included in this PR?
    
    Replace the legacy scalar CastTo implementation for Parquet.
    
    ### Are these changes tested?
    
    Yes. It is passed by existing all test cases for Parquet.
    
    ### Are there any user-facing changes?
    
    Maybe, Yes.
    
    There is a dependency on the Parquet schema that the user handles. There 
may be a problem if the user has to deal with a type for which Casting is not 
implemented. However, in this case, it should be treated as a new issue with an 
implementation that improves the `Cast` compute kernel.
    
    * Closes: #39363
    
    Authored-by: Hyunseok Seo <[email protected]>
    Signed-off-by: mwish <[email protected]>
---
 cpp/src/arrow/dataset/file_parquet.cc | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/cpp/src/arrow/dataset/file_parquet.cc 
b/cpp/src/arrow/dataset/file_parquet.cc
index 3afe4ec85c..1c2fd2dea6 100644
--- a/cpp/src/arrow/dataset/file_parquet.cc
+++ b/cpp/src/arrow/dataset/file_parquet.cc
@@ -24,6 +24,7 @@
 #include <utility>
 #include <vector>
 
+#include "arrow/compute/cast.h"
 #include "arrow/compute/exec.h"
 #include "arrow/dataset/dataset_internal.h"
 #include "arrow/dataset/parquet_encryption_config.h"
@@ -58,6 +59,8 @@ using parquet::arrow::SchemaField;
 using parquet::arrow::SchemaManifest;
 using parquet::arrow::StatisticsAsScalars;
 
+using compute::Cast;
+
 namespace {
 
 parquet::ReaderProperties MakeReaderProperties(
@@ -370,12 +373,12 @@ std::optional<compute::Expression> 
ParquetFileFragment::EvaluateStatisticsAsExpr
     return std::nullopt;
   }
 
-  auto maybe_min = min->CastTo(field.type());
-  auto maybe_max = max->CastTo(field.type());
+  auto maybe_min = Cast(min, field.type());
+  auto maybe_max = Cast(max, field.type());
 
   if (maybe_min.ok() && maybe_max.ok()) {
-    min = maybe_min.MoveValueUnsafe();
-    max = maybe_max.MoveValueUnsafe();
+    min = maybe_min.MoveValueUnsafe().scalar();
+    max = maybe_max.MoveValueUnsafe().scalar();
 
     if (min->Equals(*max)) {
       auto single_value = compute::equal(field_expr, 
compute::literal(std::move(min)));

Reply via email to