Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qsvdp: add polars support #1664

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ cargo install qsv --locked --bin qsv -F feature_capable,apply,polars
cargo install qsv --locked --bin qsvlite -F lite

# or to install qsvdp
cargo install qsv --locked --bin qsvdp -F datapusher_plus,luau
cargo install qsv --locked --bin qsvdp -F datapusher_plus,luau,polars
```

### Option 4: Compile from Source
Expand Down Expand Up @@ -201,7 +201,7 @@ cargo build --release --locked --bin qsv -F feature_capable,fetch,foreach
cargo build --release --locked --bin qsvlite -F lite

# for qsvdp
cargo build --release --locked --bin qsvdp -F datapusher_plus,luau
cargo build --release --locked --bin qsvdp -F datapusher_plus,luau,polars
```

NOTE: To build with Rust nightly, see [Nightly Release Builds](docs/PERFORMANCE.md#nightly-release-builds).
Expand Down Expand Up @@ -397,7 +397,7 @@ cargo test --features lite
cargo test stats --features lite

# to test qsvdp
cargo test --features datapusher_plus,luau
cargo test --features datapusher_plus,luau,polars

# to test a specific command
# here we test only stats and use the
Expand Down
7 changes: 7 additions & 0 deletions src/clitypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,10 @@ impl From<reqwest::Error> for CliError {
CliError::Network(err.to_string())
}
}

#[cfg(feature = "polars")]
impl From<polars::error::PolarsError> for CliError {
fn from(err: polars::error::PolarsError) -> CliError {
CliError::Other(format!("Polars error: {err:?}"))
}
}
8 changes: 1 addition & 7 deletions src/cmd/joinp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ use polars::{
use serde::Deserialize;
use tempfile::tempdir;

use crate::{cmd::sqlp::compress_output_if_needed, config::Delimiter, util, CliError, CliResult};
use crate::{cmd::sqlp::compress_output_if_needed, config::Delimiter, util, CliResult};

#[derive(Deserialize)]
struct Args {
Expand Down Expand Up @@ -225,12 +225,6 @@ struct Args {
flag_quiet: bool,
}

impl From<polars::error::PolarsError> for CliError {
fn from(err: polars::error::PolarsError) -> CliError {
CliError::Other(format!("Polars error: {err:?}"))
}
}

pub fn run(argv: &[&str]) -> CliResult<()> {
let mut args: Args = util::get_args(USAGE, argv)?;

Expand Down
4 changes: 2 additions & 2 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub mod index;
pub mod input;
#[cfg(any(feature = "feature_capable", feature = "lite"))]
pub mod join;
#[cfg(all(feature = "polars", feature = "feature_capable"))]
#[cfg(feature = "polars")]
pub mod joinp;
#[cfg(any(feature = "feature_capable", feature = "lite"))]
pub mod jsonl;
Expand Down Expand Up @@ -70,7 +70,7 @@ pub mod sort;
pub mod sortcheck;
#[cfg(any(feature = "feature_capable", feature = "lite"))]
pub mod split;
#[cfg(all(feature = "polars", feature = "feature_capable"))]
#[cfg(feature = "polars")]
pub mod sqlp;
pub mod stats;
#[cfg(any(feature = "feature_capable", feature = "lite"))]
Expand Down
10 changes: 10 additions & 0 deletions src/maindp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ macro_rules! command_list {
help Show this usage message
index Create CSV index for faster access
input Read CSVs w/ special quoting, skipping, trimming & transcoding rules
joinp Join CSV files using the Pola.rs engine
luau Execute Luau script on CSV data
pseudo Pseudonymise the values of a column
rename Rename the columns of CSV data efficiently
Expand All @@ -82,6 +83,7 @@ macro_rules! command_list {
sniff Quickly sniff CSV metadata
sort Sort CSV data in alphabetical, numerical, reverse or random order
sortcheck Check if a CSV is sorted
sqlp Run a SQL query against several CSVs using the Pola.rs engine
stats Infer data types and compute summary statistics
validate Validate CSV data for RFC4180-compliance or with JSON Schema

Expand Down Expand Up @@ -245,6 +247,8 @@ enum Command {
Help,
Index,
Input,
#[cfg(feature = "polars")]
JoinP,
#[cfg(feature = "luau")]
Luau,
Pseudo,
Expand All @@ -261,6 +265,8 @@ enum Command {
Sniff,
Sort,
SortCheck,
#[cfg(feature = "polars")]
SqlP,
Stats,
Validate,
}
Expand Down Expand Up @@ -298,6 +304,8 @@ impl Command {
},
Command::Index => cmd::index::run(argv),
Command::Input => cmd::input::run(argv),
#[cfg(feature = "polars")]
Command::JoinP => cmd::joinp::run(argv),
#[cfg(feature = "luau")]
Command::Luau => cmd::luau::run(argv),
Command::Pseudo => cmd::pseudo::run(argv),
Expand All @@ -314,6 +322,8 @@ impl Command {
Command::Sniff => cmd::sniff::run(argv),
Command::Sort => cmd::sort::run(argv),
Command::SortCheck => cmd::sortcheck::run(argv),
#[cfg(feature = "polars")]
Command::SqlP => cmd::sqlp::run(argv),
Command::Stats => cmd::stats::run(argv),
Command::Validate => cmd::validate::run(argv),
}
Expand Down
4 changes: 2 additions & 2 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ mod test_index;
mod test_input;
#[cfg(any(feature = "feature_capable", feature = "lite"))]
mod test_join;
#[cfg(all(feature = "feature_capable", feature = "polars"))]
#[cfg(feature = "polars")]
mod test_joinp;
#[cfg(any(feature = "feature_capable", feature = "lite"))]
mod test_jsonl;
Expand Down Expand Up @@ -102,7 +102,7 @@ mod test_sort;
mod test_sortcheck;
#[cfg(any(feature = "feature_capable", feature = "lite"))]
mod test_split;
#[cfg(all(feature = "feature_capable", feature = "polars"))]
#[cfg(feature = "polars")]
mod test_sqlp;
mod test_stats;
#[cfg(any(feature = "feature_capable", feature = "lite"))]
Expand Down