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

kou 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 ae497bf11a GH-44802: [C++][CI] Migrate to `arrow::Result` based 
`parquet::arrow::OpenFile() API` in example tutorials (#44807)
ae497bf11a is described below

commit ae497bf11a4078f48b02f53b8dc843e3c0579d76
Author: Mohammad Linjawi <[email protected]>
AuthorDate: Fri Nov 22 04:15:34 2024 +0300

    GH-44802: [C++][CI] Migrate to `arrow::Result` based 
`parquet::arrow::OpenFile() API` in example tutorials (#44807)
    
    
    
    ### Rationale for this change
    This PR address this [issue](https://github.com/apache/arrow/issues/44802) 
and updates the `example-cpp-tutorial` in Crossbow to resolve build failures 
caused by deprecated APIs, as seen in [this CI 
job](https://github.com/ursacomputing/crossbow/actions/runs/11944262092/job/33294899404).
 The change migrates the examples to non-deprecated APIs to ensure 
compatibility with the latest Arrow C++ version.
    
    Updating these APIs is necessary to:
    
    Fix build failures and prevent future issues.
    Align with the current Arrow C++ API.
    
    ### What changes are included in this PR?
    
    This PR updates the example-cpp-tutorial to replace deprecated Arrow C++ 
APIs with the latest supported APIs, resolving build failures in the Crossbow 
night build.
    
    ### Are these changes tested?
    
    By running:
    ```
    $ cd arrow/cpp/examples/tutorial_examples
    $ docker compose run --rm tutorial
    ```
    
    output:
    ```==
    == Running example project
    ==
    
    Day:   [
        1,
        12,
        17,
        23,
        28
      ]
    Month:   [
        1,
        3,
        5,
        7,
        1
      ]
    Year:   [
        1990,
        2000,
        1995,
        2000,
        1995
      ]
    Day: int8
    Month: int8
    Year: int16
    ----
    Day:
      [
        [
          1,
          12,
          17,
          23,
          28
        ],
        [
          6,
          12,
          3,
          30,
          22
        ]
      ]
    Month:
      [
        [
          1,
          3,
          5,
          7,
          1
        ],
        [
          5,
          4,
          11,
          3,
          2
        ]
      ]
    Year:
      [
        [
          1990,
          2000,
          1995,
          2000,
          1995
        ],
        [
          1980,
          2001,
          1915,
          2020,
          1996
        ]
      ]
    Datum kind: Scalar(12891) content type: int64
    12891
    Datum kind: ChunkedArray([
      [
        75376,
        647,
        2287,
        5671,
        5092
      ]
    ]) content type: int32
    [
      [
        75376,
        647,
        2287,
        5671,
        5092
      ]
    ]
    Datum kind: Scalar(2) content type: int64
    2
    Found fragment: parquet_dataset/data1.parquet
    Partition expression: true
    Found fragment: parquet_dataset/data2.parquet
    Partition expression: true
    a: int64
    b: int64
    c: int64
    ----
    a:
      [
        [
          0,
          1,
          2,
          3,
          4
        ],
        [
          5,
          6,
          7,
          8,
          9
        ]
      ]
    b:
      [
        [
          9,
          8,
          7,
          6,
          5
        ],
        [
          4,
          3,
          2,
          1,
          0
        ]
      ]
    c:
      [
        [
          1,
          2,
          1,
          2,
          1
        ],
        [
          2,
          1,
          2,
          1,
          2
        ]
      ]
    
    ```
    
    ### Are there any user-facing changes?
    
    Yes, the tutorial has been updated to use non-deprecated APIs, which may 
affect the example code provided to users.
    
    * GitHub Issue: #44802
    
    Lead-authored-by: Mohammad Linjawi <[email protected]>
    Co-authored-by: Mohammad Linjawi <[email protected]>
    Co-authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/examples/tutorial_examples/file_access_example.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cpp/examples/tutorial_examples/file_access_example.cc 
b/cpp/examples/tutorial_examples/file_access_example.cc
index fdc312ff42..df57174b31 100644
--- a/cpp/examples/tutorial_examples/file_access_example.cc
+++ b/cpp/examples/tutorial_examples/file_access_example.cc
@@ -180,8 +180,8 @@ arrow::Status RunMain() {
   // (Doc section: Parquet OpenFile)
   // Note that Parquet's OpenFile() takes the reader by reference, rather than 
returning
   // a reader.
-  PARQUET_THROW_NOT_OK(
-      parquet::arrow::OpenFile(infile, arrow::default_memory_pool(), &reader));
+  PARQUET_ASSIGN_OR_THROW(reader,
+                          parquet::arrow::OpenFile(infile, 
arrow::default_memory_pool()));
   // (Doc section: Parquet OpenFile)
 
   // (Doc section: Parquet Read)

Reply via email to