Skip to content

Commit

Permalink
fix test, remove err
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb committed Feb 6, 2025
1 parent 8acb466 commit 22911d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
10 changes: 3 additions & 7 deletions src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use datafusion::common::tree_node::Transformed;
use datafusion::common::Column;
use datafusion::common::DFSchema;
use datafusion::common::Result;
use datafusion::error::DataFusionError;
use datafusion::logical_expr::expr::{Alias, Cast, Expr, ScalarFunction};
use datafusion::logical_expr::expr_rewriter::FunctionRewrite;
use datafusion::logical_expr::planner::{ExprPlanner, PlannerResult, RawBinaryExpr};
Expand Down Expand Up @@ -107,17 +106,14 @@ enum JsonOperator {
}

impl TryFrom<&BinaryOperator> for JsonOperator {
type Error = DataFusionError;
type Error = ();

fn try_from(op: &BinaryOperator) -> Result<Self> {
fn try_from(op: &BinaryOperator) -> Result<Self, Self::Error> {
match op {
BinaryOperator::Arrow => Ok(JsonOperator::Arrow),
BinaryOperator::LongArrow => Ok(JsonOperator::LongArrow),
BinaryOperator::Question => Ok(JsonOperator::Question),
_ => Err(DataFusionError::Internal(format!(
"Unexpected operator {:?} in JSON function rewriter",
op
))),
_ => Err(()),
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,21 +819,21 @@ async fn test_long_arrow_eq_str() {
assert_batches_eq!(expected, &batches);
}

/// Test column name / alias creation with a cast in the needle / key
#[tokio::test]
async fn test_arrow_cast_key_text() {
let sql = r#"select ('{"foo": 42}'->('foo'::text))"#;
let sql = r#"select ('{"foo": 42}'->>('foo'::text))"#;
let batches = run_query(sql).await.unwrap();

let expected = [
"+------------------------+",
"| '{\"foo\": 42}' -> 'foo' |",
"+------------------------+",
"| {int=42} |",
"+------------------------+",
"+-------------------------+",
"| '{\"foo\": 42}' ->> 'foo' |",
"+-------------------------+",
"| 42 |",
"+-------------------------+",
];
assert_batches_eq!(expected, &batches);

assert_eq!(display_val(batches).await, (DataType::Int64, "42".to_string()));
assert_batches_eq!(expected, &batches);
}

#[tokio::test]
Expand Down

0 comments on commit 22911d9

Please sign in to comment.