Skip to content

Commit 22911d9

Browse files
committed
fix test, remove err
1 parent 8acb466 commit 22911d9

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/rewrite.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use datafusion::common::tree_node::Transformed;
66
use datafusion::common::Column;
77
use datafusion::common::DFSchema;
88
use datafusion::common::Result;
9-
use datafusion::error::DataFusionError;
109
use datafusion::logical_expr::expr::{Alias, Cast, Expr, ScalarFunction};
1110
use datafusion::logical_expr::expr_rewriter::FunctionRewrite;
1211
use datafusion::logical_expr::planner::{ExprPlanner, PlannerResult, RawBinaryExpr};
@@ -107,17 +106,14 @@ enum JsonOperator {
107106
}
108107

109108
impl TryFrom<&BinaryOperator> for JsonOperator {
110-
type Error = DataFusionError;
109+
type Error = ();
111110

112-
fn try_from(op: &BinaryOperator) -> Result<Self> {
111+
fn try_from(op: &BinaryOperator) -> Result<Self, Self::Error> {
113112
match op {
114113
BinaryOperator::Arrow => Ok(JsonOperator::Arrow),
115114
BinaryOperator::LongArrow => Ok(JsonOperator::LongArrow),
116115
BinaryOperator::Question => Ok(JsonOperator::Question),
117-
_ => Err(DataFusionError::Internal(format!(
118-
"Unexpected operator {:?} in JSON function rewriter",
119-
op
120-
))),
116+
_ => Err(()),
121117
}
122118
}
123119
}

tests/main.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -819,21 +819,21 @@ async fn test_long_arrow_eq_str() {
819819
assert_batches_eq!(expected, &batches);
820820
}
821821

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

827828
let expected = [
828-
"+------------------------+",
829-
"| '{\"foo\": 42}' -> 'foo' |",
830-
"+------------------------+",
831-
"| {int=42} |",
832-
"+------------------------+",
829+
"+-------------------------+",
830+
"| '{\"foo\": 42}' ->> 'foo' |",
831+
"+-------------------------+",
832+
"| 42 |",
833+
"+-------------------------+",
833834
];
834-
assert_batches_eq!(expected, &batches);
835835

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

839839
#[tokio::test]

0 commit comments

Comments
 (0)