You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ji...@apache.org on 2022/02/02 09:01:05 UTC

[arrow-rs] branch upgrade-clap updated: update one last tool

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

jiayuliu pushed a commit to branch upgrade-clap
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/upgrade-clap by this push:
     new 11688aa  update one last tool
11688aa is described below

commit 11688aae1af348e54047d7d56466400faa219dd3
Author: Jiayu Liu <ji...@hey.com>
AuthorDate: Wed Feb 2 17:00:46 2022 +0800

    update one last tool
---
 parquet/src/bin/parquet-rowcount.rs |  5 +++--
 parquet/src/bin/parquet-schema.rs   | 45 +++++++++++++------------------------
 rustfmt.toml                        |  1 -
 3 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/parquet/src/bin/parquet-rowcount.rs b/parquet/src/bin/parquet-rowcount.rs
index 3e8da3e..41ebf82 100644
--- a/parquet/src/bin/parquet-rowcount.rs
+++ b/parquet/src/bin/parquet-rowcount.rs
@@ -69,8 +69,9 @@ fn main() {
 
     for filename in args.file_paths {
         let path = Path::new(&filename);
-        let file = File::open(path).unwrap();
-        let parquet_reader = SerializedFileReader::new(file).unwrap();
+        let file = File::open(path).expect("Unable to open file");
+        let parquet_reader =
+            SerializedFileReader::new(file).expect("Unable to read file");
         let row_group_metadata = parquet_reader.metadata().row_groups();
         let mut total_num_rows = 0;
 
diff --git a/parquet/src/bin/parquet-schema.rs b/parquet/src/bin/parquet-schema.rs
index 1b80637..8090ef4 100644
--- a/parquet/src/bin/parquet-schema.rs
+++ b/parquet/src/bin/parquet-schema.rs
@@ -50,43 +50,28 @@
 //! when not provided or print full file metadata when provided.
 
 extern crate parquet;
-
-use std::{env, fs::File, path::Path};
-
-use clap::{crate_authors, crate_version, App, Arg};
-
+use clap::Parser;
 use parquet::{
     file::reader::{FileReader, SerializedFileReader},
     schema::printer::{print_file_metadata, print_parquet_metadata},
 };
+use std::{fs::File, path::Path};
 
-fn main() {
-    let matches = App::new("parquet-schema")
-        .version(crate_version!())
-        .author(crate_authors!())
-        .arg(
-            Arg::with_name("file_path")
-                .value_name("file-path")
-                .required(true)
-                .index(1)
-                .help("Path to a Parquet file"),
-        )
-        .arg(
-            Arg::with_name("verbose")
-                .short("v")
-                .long("verbose")
-                .takes_value(false)
-                .help("Enable printing full file metadata"),
-        )
-        .get_matches();
+#[derive(Debug, Parser)]
+#[clap( author, version, about, long_about = None)]
+struct Args {
+    #[clap(long, help("List of Parquet files to read from separated by space"))]
+    file_path: String,
+    #[clap(short, long, help("Enable printing full file metadata"))]
+    verbose: bool,
+}
 
-    let filename = matches.value_of("file_path").unwrap();
+fn main() {
+    let args = Args::parse();
+    let filename = args.file_path;
     let path = Path::new(&filename);
-    let file = match File::open(&path) {
-        Err(e) => panic!("Error when opening file {}: {}", path.display(), e),
-        Ok(f) => f,
-    };
-    let verbose = matches.is_present("verbose");
+    let file = File::open(&path).expect("Unable to open file");
+    let verbose = args.verbose;
 
     match SerializedFileReader::new(file) {
         Err(e) => panic!("Error when parsing Parquet file: {}", e),
diff --git a/rustfmt.toml b/rustfmt.toml
index 590e7cb..4522e52 100644
--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -16,7 +16,6 @@
 # under the License.
 
 edition = "2021"
-rust-version = "1.57"
 max_width = 90
 
 # ignore generated files