You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/23 14:44:11 UTC

[GitHub] [arrow-rs] xudong963 opened a new pull request, #3170: Add read parquet examples

xudong963 opened a new pull request, #3170:
URL: https://github.com/apache/arrow-rs/pull/3170

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   No
   
   # Rationale for this change
    
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   Let users know about parquet's read-related API quickly.
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   Add two example: async parquet read and sync parquet read
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   
   No
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3170: Add read parquet examples

Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #3170:
URL: https://github.com/apache/arrow-rs/pull/3170#discussion_r1031396435


##########
parquet/examples/async_read_parquet.rs:
##########
@@ -36,16 +36,19 @@ async fn main() -> Result<()> {
         .await
         .unwrap()
         .with_batch_size(8192);
-    let file_metadata = builder.metadata().file_metadata();
 
-    let mask = ProjectionMask::roots(file_metadata.schema_descr(), [1, 2]);
-    // Set projection mask to read only leaf columns 1 and 2.
-    builder = builder.with_projection(mask);
+    let file_metadata = builder.metadata().file_metadata().clone();
+    let mask = ProjectionMask::roots(file_metadata.schema_descr(), [0, 1, 2]);
+    // Set projection mask to read only root columns 1 and 2.
+    builder = builder.with_projection(mask.clone());

Review Comment:
   ```suggestion
       builder = builder.with_projection(mask);
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] xudong963 commented on a diff in pull request #3170: Add read parquet examples

Posted by GitBox <gi...@apache.org>.
xudong963 commented on code in PR #3170:
URL: https://github.com/apache/arrow-rs/pull/3170#discussion_r1031396521


##########
parquet/examples/async_read_parquet.rs:
##########
@@ -0,0 +1,63 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::util::pretty::print_batches;
+use futures::TryStreamExt;
+use parquet::arrow::arrow_reader::{ArrowPredicate, RowFilter};
+use parquet::arrow::{ParquetRecordBatchStreamBuilder, ProjectionMask};
+use parquet::errors::Result;
+use std::time::SystemTime;
+use tokio::fs::File;
+
+#[tokio::main(flavor = "current_thread")]
+async fn main() -> Result<()> {
+    // Create parquet file that will be read.
+    let testdata = arrow::util::test_util::parquet_test_data();
+    let path = format!("{}/alltypes_plain.parquet", testdata);
+    let file = File::open(path).await.unwrap();
+
+    // Create a async parquet reader builder with batch_size.
+    // batch_size is the number of rows to read up to buffer once from pages, defaults to 1024
+    let mut builder = ParquetRecordBatchStreamBuilder::new(file)
+        .await
+        .unwrap()
+        .with_batch_size(8192);
+    let file_metadata = builder.metadata().file_metadata();
+
+    let mask = ProjectionMask::roots(file_metadata.schema_descr(), [1, 2]);
+    // Set projection mask to read only leaf columns 1 and 2.
+    builder = builder.with_projection(mask);
+
+    // Highlight: set `RowFilter`, it'll push down filter predicates to skip IO and decode.
+    // For more specific usage: please refer to https://github.com/apache/arrow-datafusion/blob/master/datafusion/core/src/physical_plan/file_format/parquet/row_filter.rs.
+    let predicates: Vec<Box<dyn ArrowPredicate>> = Vec::new();

Review Comment:
   Ok (failure to be lazy 🤣 )



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold merged pull request #3170: Add read parquet examples

Posted by GitBox <gi...@apache.org>.
tustvold merged PR #3170:
URL: https://github.com/apache/arrow-rs/pull/3170


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] xudong963 commented on a diff in pull request #3170: Add read parquet examples

Posted by GitBox <gi...@apache.org>.
xudong963 commented on code in PR #3170:
URL: https://github.com/apache/arrow-rs/pull/3170#discussion_r1030572609


##########
arrow/Cargo.toml:
##########
@@ -53,6 +53,7 @@ arrow-ipc = { version = "27.0.0", path = "../arrow-ipc", optional = true }
 arrow-json = { version = "27.0.0", path = "../arrow-json", optional = true }
 arrow-schema = { version = "27.0.0", path = "../arrow-schema" }
 arrow-select = { version = "27.0.0", path = "../arrow-select" }
+parquet = { version = "27.0.0", path = "../parquet", features = ["arrow", "async"]}

Review Comment:
   Make sense



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3170: Add read parquet examples

Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #3170:
URL: https://github.com/apache/arrow-rs/pull/3170#discussion_r1031215932


##########
parquet/examples/async_read_parquet.rs:
##########
@@ -0,0 +1,63 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::util::pretty::print_batches;
+use futures::TryStreamExt;
+use parquet::arrow::arrow_reader::{ArrowPredicate, RowFilter};
+use parquet::arrow::{ParquetRecordBatchStreamBuilder, ProjectionMask};
+use parquet::errors::Result;
+use std::time::SystemTime;
+use tokio::fs::File;
+
+#[tokio::main(flavor = "current_thread")]
+async fn main() -> Result<()> {
+    // Create parquet file that will be read.
+    let testdata = arrow::util::test_util::parquet_test_data();
+    let path = format!("{}/alltypes_plain.parquet", testdata);
+    let file = File::open(path).await.unwrap();
+
+    // Create a async parquet reader builder with batch_size.
+    // batch_size is the number of rows to read up to buffer once from pages, defaults to 1024
+    let mut builder = ParquetRecordBatchStreamBuilder::new(file)
+        .await
+        .unwrap()
+        .with_batch_size(8192);
+    let file_metadata = builder.metadata().file_metadata();
+
+    let mask = ProjectionMask::roots(file_metadata.schema_descr(), [1, 2]);
+    // Set projection mask to read only leaf columns 1 and 2.
+    builder = builder.with_projection(mask);
+
+    // Highlight: set `RowFilter`, it'll push down filter predicates to skip IO and decode.
+    // For more specific usage: please refer to https://github.com/apache/arrow-datafusion/blob/master/datafusion/core/src/physical_plan/file_format/parquet/row_filter.rs.
+    let predicates: Vec<Box<dyn ArrowPredicate>> = Vec::new();

Review Comment:
   It might be nice to actually specify a predicate here, e.g. using https://docs.rs/parquet/latest/parquet/arrow/arrow_reader/struct.ArrowPredicateFn.html



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3170: Add read parquet examples

Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #3170:
URL: https://github.com/apache/arrow-rs/pull/3170#discussion_r1030534652


##########
arrow/Cargo.toml:
##########
@@ -53,6 +53,7 @@ arrow-ipc = { version = "27.0.0", path = "../arrow-ipc", optional = true }
 arrow-json = { version = "27.0.0", path = "../arrow-json", optional = true }
 arrow-schema = { version = "27.0.0", path = "../arrow-schema" }
 arrow-select = { version = "27.0.0", path = "../arrow-select" }
+parquet = { version = "27.0.0", path = "../parquet", features = ["arrow", "async"]}

Review Comment:
   This results in a circular dependency, could we move these examples to the parquet crate?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] ursabot commented on pull request #3170: Add read parquet examples

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #3170:
URL: https://github.com/apache/arrow-rs/pull/3170#issuecomment-1326336399

   Benchmark runs are scheduled for baseline = 5640a5b0c7d456a68c7c0cc562425ccf5494ecec and contender = 4b9e3fee2878401b141c17a7ac3767cc3fa6c06f. 4b9e3fee2878401b141c17a7ac3767cc3fa6c06f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/a04cc1d9c4774379b85ef42fc65c61cb...eab08c8408f04cc8b0b5b4acbf669f2e/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/db99187969824622b8b16e0eefcf5ed6...01f3235713f644f995dfe716d3971228/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/ac19151b2f5b48bcb68526ae582dc105...586c2d4f179744c9af185c1a97e0a89a/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/33ff54d1762343e080854dd54b2dd832...fc40d47ff308459cb07a35139dfb8b3b/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org