Skip to content

Commit

Permalink
refactor: joinp - --ignore-leading-zeros has its own `--ignore-ca…
Browse files Browse the repository at this point in the history
…se` handling
  • Loading branch information
jqnatividad committed Jan 7, 2025
1 parent 390b588 commit c511271
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/cmd/joinp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,22 +506,23 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}

struct JoinStruct {
left_lf: LazyFrame,
left_sel: String,
right_lf: LazyFrame,
right_sel: String,
output: Option<String>,
delim: u8,
coalesce: bool,
streaming: bool,
no_optimizations: bool,
sql_filter: Option<String>,
datetime_format: Option<String>,
date_format: Option<String>,
time_format: Option<String>,
float_precision: Option<usize>,
null_value: String,
ignore_case: bool,
left_lf: LazyFrame,
left_sel: String,
right_lf: LazyFrame,
right_sel: String,
output: Option<String>,
delim: u8,
coalesce: bool,
streaming: bool,
no_optimizations: bool,
sql_filter: Option<String>,
datetime_format: Option<String>,
date_format: Option<String>,
time_format: Option<String>,
float_precision: Option<usize>,
null_value: String,
ignore_case: bool,
ignore_leading_zeros: bool,
}

impl JoinStruct {
Expand All @@ -544,7 +545,9 @@ impl JoinStruct {
.collect();

// If ignore_case is enabled, create lowercase versions of the join columns
if self.ignore_case {
// but only if ignore_leading_zeros is not enabled
// because leading zeros handling does its own lowercase conversion
if self.ignore_case && !self.ignore_leading_zeros {
// Create temporary lowercase versions of join columns in left dataframe
for col in &left_selcols {
self.left_lf = self
Expand Down Expand Up @@ -711,7 +714,7 @@ impl JoinStruct {
};

// if self.ignore_case, remove the temporary lowercase columns from the dataframe
if self.ignore_case {
if self.ignore_case && !self.ignore_leading_zeros {
// Get all column names
let cols = results_df.get_column_names();
// Filter out the lowercase columns (those with "_qsv-*-lower" pattern)
Expand Down Expand Up @@ -1170,6 +1173,7 @@ impl Args {
self.flag_null_value.clone()
},
ignore_case: self.flag_ignore_case,
ignore_leading_zeros: self.flag_ignore_leading_zeros,
})
}
}
Expand Down

0 comments on commit c511271

Please sign in to comment.