From 90c1405113fde5f3816fc0dc0fbc633da28c30f8 Mon Sep 17 00:00:00 2001 From: taytzehao Date: Mon, 25 Sep 2023 23:07:03 +0800 Subject: [PATCH] slt update --- proto/expr.proto | 2 +- src/common/src/types/jsonb.rs | 1 - src/expr/src/vector_op/jsonb_concat.rs | 23 ++++++++++------------- src/frontend/src/binder/expr/binary_op.rs | 6 +++--- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/proto/expr.proto b/proto/expr.proto index 68be574349408..3569a9635f694 100644 --- a/proto/expr.proto +++ b/proto/expr.proto @@ -206,7 +206,7 @@ message ExprNode { HEX_TO_INT256 = 560; // Jsonb functions - + // jsonb -> int, jsonb -> text, jsonb #> text[] that returns jsonb JSONB_ACCESS_INNER = 600; diff --git a/src/common/src/types/jsonb.rs b/src/common/src/types/jsonb.rs index 77eb757144081..7f4c002037060 100644 --- a/src/common/src/types/jsonb.rs +++ b/src/common/src/types/jsonb.rs @@ -210,7 +210,6 @@ impl From for JsonbVal { } } - impl<'a> JsonbRef<'a> { pub fn memcmp_serialize( &self, diff --git a/src/expr/src/vector_op/jsonb_concat.rs b/src/expr/src/vector_op/jsonb_concat.rs index f702b347749a5..1d910aa2b28a0 100644 --- a/src/expr/src/vector_op/jsonb_concat.rs +++ b/src/expr/src/vector_op/jsonb_concat.rs @@ -41,21 +41,21 @@ use serde_json::{json, Value}; /// SELECT '1'::jsonb || '2'::jsonb; /// ---- /// [1, 2] -/// +/// /// query T /// SELECT '[1,2]'::jsonb || NULL::jsonb; /// ---- -/// NULL -/// +/// null +/// /// query T /// SELECT NULL::jsonb || '[1,2]'::jsonb; /// ---- -/// NULL +/// null /// ``` #[function("jsonb_cat(jsonb, jsonb) -> jsonb")] pub fn jsonb_cat(left: Option>, right: Option>) -> JsonbVal { - let left_val = left.map_or(Value::Null,|v| v.value().clone()); - let right_val = right.map_or(Value::Null,|v| v.value().clone()); + let left_val = left.map_or(Value::Null, |v| v.value().clone()); + let right_val = right.map_or(Value::Null, |v| v.value().clone()); match (left_val, right_val) { // left and right are object based. // This would have left:{'a':1}, right:{'b':2} -> {'a':1,'b':2} @@ -75,9 +75,9 @@ pub fn jsonb_cat(left: Option>, right: Option>) -> Jso // One operand is an array, and the other is a single element. // This would insert the non-array value as another element into the array // Eg left:[1,2] right: {'a':1} -> [1,2,{'a':1}] - (Value::Array(mut left_arr), single_val) - | (single_val, Value::Array(mut left_arr)) - if single_val != Value::Null => { + (Value::Array(mut left_arr), single_val) | (single_val, Value::Array(mut left_arr)) + if single_val != Value::Null => + { left_arr.push(single_val); JsonbVal::from(Value::Array(left_arr)) } @@ -85,10 +85,7 @@ pub fn jsonb_cat(left: Option>, right: Option>) -> Jso // Either left/right is None // This return a None value // This would have left:[1,2], right:None -> None - (Value::Null, _) - | (_, Value::Null) => { - JsonbVal::from(Value::Null) - } + (Value::Null, _) | (_, Value::Null) => JsonbVal::from(Value::Null), // Both are non-array inputs. // Both elements would be placed together in an array diff --git a/src/frontend/src/binder/expr/binary_op.rs b/src/frontend/src/binder/expr/binary_op.rs index 404cb6dbae5b9..f7c8a86144fc9 100644 --- a/src/frontend/src/binder/expr/binary_op.rs +++ b/src/frontend/src/binder/expr/binary_op.rs @@ -108,9 +108,9 @@ impl Binder { ExprType::ConcatOp } - (Some(DataType::Jsonb), Some(DataType::Jsonb)) - | (Some(DataType::Jsonb), None) - | (None, Some(DataType::Jsonb))=> ExprType::JsonbCat, + (Some(DataType::Jsonb), Some(DataType::Jsonb)) + | (Some(DataType::Jsonb), None) + | (None, Some(DataType::Jsonb)) => ExprType::JsonbCat, // bytea (and varbit, tsvector, tsquery) (Some(t @ DataType::Bytea), Some(DataType::Bytea))