Skip to content

Commit

Permalink
fix merge conflict + cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed Apr 19, 2024
1 parent ef563eb commit 24e739b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
20 changes: 7 additions & 13 deletions core/src/execution/datafusion/expressions/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use arrow::{
use arrow_array::{Array, ArrayRef, BooleanArray, GenericStringArray, OffsetSizeTrait};
use arrow_schema::{DataType, Schema};
use datafusion::logical_expr::ColumnarValue;
use datafusion_common::{Result as DataFusionResult, ScalarValue};
git use datafusion_common::{internal_err, Result as DataFusionResult, ScalarValue};
use datafusion_physical_expr::PhysicalExpr;

use crate::execution::datafusion::expressions::utils::{
Expand Down Expand Up @@ -127,13 +127,11 @@ impl Cast {
Some(value) => match value.to_ascii_lowercase().trim() {
"t" | "true" | "y" | "yes" | "1" => Ok(Some(true)),
"f" | "false" | "n" | "no" | "0" => Ok(Some(false)),
_ if eval_mode == EvalMode::Ansi => {
Err(CometError::CastInvalidValue {
value: value.to_string(),
from_type: "STRING".to_string(),
to_type: "BOOLEAN".to_string(),
})
}
_ if eval_mode == EvalMode::Ansi => Err(CometError::CastInvalidValue {
value: value.to_string(),
from_type: "STRING".to_string(),
to_type: "BOOLEAN".to_string(),
}),
_ => Ok(None),
},
_ => Ok(None),
Expand Down Expand Up @@ -207,15 +205,11 @@ impl PhysicalExpr for Cast {
1 => Ok(Arc::new(Cast::new(
children[0].clone(),
self.data_type.clone(),
self.eval_mode,
self.timezone.clone(),
))),
_ => internal_err!("Cast should have exactly one child"),
}
children[0].clone(),
self.data_type.clone(),
self.eval_mode,
self.timezone.clone(),
)))
}

fn dyn_hash(&self, state: &mut dyn Hasher) {
Expand Down
20 changes: 9 additions & 11 deletions core/src/execution/datafusion/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use crate::{
avg_decimal::AvgDecimal,
bitwise_not::BitwiseNotExpr,
bloom_filter_might_contain::BloomFilterMightContain,
cast::Cast,
cast::{Cast, EvalMode},
checkoverflow::CheckOverflow,
if_expr::IfExpr,
scalar_funcs::create_comet_physical_fun,
Expand All @@ -89,7 +89,6 @@ use crate::{
spark_partitioning::{partitioning::PartitioningStruct, Partitioning as SparkPartitioning},
},
};
use crate::execution::datafusion::expressions::cast::EvalMode;

// For clippy error on type_complexity.
type ExecResult<T> = Result<T, ExecutionError>;
Expand Down Expand Up @@ -349,12 +348,7 @@ impl PhysicalPlanner {
"TRY" => EvalMode::Try,
_ => EvalMode::Legacy,
};
Ok(Arc::new(Cast::new(
child,
datatype,
eval_mode,
timezone,
)))
Ok(Arc::new(Cast::new(child, datatype, eval_mode, timezone)))
}
ExprStruct::Hour(expr) => {
let child = self.create_expr(expr.child.as_ref().unwrap(), input_schema)?;
Expand Down Expand Up @@ -649,15 +643,19 @@ impl PhysicalPlanner {
let left = Arc::new(Cast::new_without_timezone(
left,
DataType::Decimal256(p1, s1),
EvalMode::Legacy
EvalMode::Legacy,
));
let right = Arc::new(Cast::new_without_timezone(
right,
DataType::Decimal256(p2, s2),
EvalMode::Legacy
EvalMode::Legacy,
));
let child = Arc::new(BinaryExpr::new(left, op, right));
Ok(Arc::new(Cast::new_without_timezone(child, data_type, EvalMode::Legacy)))
Ok(Arc::new(Cast::new_without_timezone(
child,
data_type,
EvalMode::Legacy,
)))
}
(
DataFusionOperator::Divide,
Expand Down

0 comments on commit 24e739b

Please sign in to comment.