Skip to content

Commit

Permalink
reference to the default UInt8Chunked instead of the owned value.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasMAhern committed Jun 19, 2024
1 parent b4ce022 commit 89464c4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions polars_hash/src/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,30 +180,30 @@ fn ghash_encode(inputs: &[Series]) -> PolarsResult<Series> {
DataType::Int32 => inputs[1].cast(&DataType::Int64)?,
DataType::Int16 => inputs[1].cast(&DataType::Int64)?,
DataType::Int8 => inputs[1].cast(&DataType::Int64)?,
_ => polars_bail!(InvalidOperation:"Length input needs to be integer"),
_ => polars_bail!(InvalidOperation: "Length input needs to be integer"),
};
let len = len.i64()?;

let base = match inputs.get(2) {
Some(base_series) => match base_series.dtype() {
DataType::UInt8 => base_series.u8()?,
_ => polars_bail!(InvalidOperation:"Base input needs to be uint8"),
_ => polars_bail!(InvalidOperation: "Base input needs to be uint8"),
},
None => UInt8Chunked::full("base", 16, ca.len()), // Default to base 16 if not provided
None => &UInt8Chunked::full("base", 16, ca.len()), // Borrow the default base 16 chunked array
};

let lat = ca.field_by_name("latitude")?;
let long = ca.field_by_name("longitude")?;
let lat = match lat.dtype() {
DataType::Float32 => lat.cast(&DataType::Float64)?,
DataType::Float64 => lat,
_ => polars_bail!(InvalidOperation:"Latitude input needs to be float"),
_ => polars_bail!(InvalidOperation: "Latitude input needs to be float"),
};

let long = match long.dtype() {
DataType::Float32 => long.cast(&DataType::Float64)?,
DataType::Float64 => long,
_ => polars_bail!(InvalidOperation:"Longitude input needs to be float"),
_ => polars_bail!(InvalidOperation: "Longitude input needs to be float"),
};

let ca_lat = lat.f64()?;
Expand All @@ -229,6 +229,7 @@ fn ghash_encode(inputs: &[Series]) -> PolarsResult<Series> {




#[polars_expr(output_type=String)]
fn h3_encode(inputs: &[Series]) -> PolarsResult<Series> {
let ca = inputs[0].struct_()?;
Expand Down

0 comments on commit 89464c4

Please sign in to comment.