From f573a395da46c251479d0a06c3ea58f2dca3cfa1 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Fri, 28 Jun 2024 11:05:40 +0100 Subject: [PATCH] try to fix lexical precedence --- src/rewrite.rs | 4 ++++ tests/main.rs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/rewrite.rs b/src/rewrite.rs index 2c58fcf..91be30a 100644 --- a/src/rewrite.rs +++ b/src/rewrite.rs @@ -141,6 +141,10 @@ impl CustomOperator for JsonOperator { JsonOperator::LongArrow => "LongArrow", } } + + fn precedence(&self) -> u8 { + 255 + } } impl TryFrom<&str> for JsonOperator { diff --git a/tests/main.rs b/tests/main.rs index 27b5b0f..4dd0d17 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -856,3 +856,10 @@ async fn test_arrow_nested_double_columns() { let batches = run_query(sql).await.unwrap(); assert_batches_eq!(expected, &batches); } + +#[tokio::test] +async fn test_lexical_precedence_wrong() { + let sql = r#"select '{"a": "b"}'->>'a'='b' as v"#; + let err = run_query(sql).await.unwrap_err(); + assert_eq!(err.to_string(), "Error during planning: Unexpected argument type to 'LongArrow' at position 2, expected string or int, got Boolean.") +}