yiguolei commented on code in PR #24554:
URL: https://github.com/apache/doris/pull/24554#discussion_r1378896530


##########
be/src/vec/common/schema_util.cpp:
##########
@@ -129,164 +139,254 @@ bool is_conversion_required_between_integers(FieldType 
lhs, FieldType rhs) {
     return true;
 }
 
-Status cast_column(const ColumnWithTypeAndName& arg, const DataTypePtr& type, 
ColumnPtr* result,
-                   RuntimeState* state) {
-    ColumnsWithTypeAndName arguments;
-    if (WhichDataType(type->get_type_id()).is_string()) {
-        // Special handle ColumnString, since the original cast logic use 
ColumnString's first item
-        // as the name of the dest type
-        arguments = {arg, {type->create_column_const(1, type->get_name()), 
type, ""}};
-    } else {
-        arguments = {arg, {type->create_column_const_with_default_value(1), 
type, ""}};
-    }
+Status cast_column(const ColumnWithTypeAndName& arg, const DataTypePtr& type, 
ColumnPtr* result) {
+    ColumnsWithTypeAndName arguments {
+            arg, {type->create_column_const_with_default_value(1), type, 
type->get_name()}};
     auto function = SimpleFunctionFactory::instance().get_function("CAST", 
arguments, type);
+    if (!function) {
+        return Status::InternalError("Not found cast function {} to {}", 
arg.type->get_name(),
+                                     type->get_name());
+    }
     Block tmp_block {arguments};
-    // the 0 position is input argument, the 1 position is to type argument, 
the 2 position is result argument
     vectorized::ColumnNumbers argnum;
     argnum.emplace_back(0);
     argnum.emplace_back(1);
     size_t result_column = tmp_block.columns();
+    auto ctx = FunctionContext::create_context(nullptr, {}, {});
+    // We convert column string to jsonb type just add a string jsonb field to 
dst column instead of parse
+    // each line in original string column.
+    ctx->set_string_as_jsonb_string(true);

Review Comment:
   我感觉你这个参数不适合放到function context 中, 他更加是一个函数参数,应该放到arg column 中



##########
be/src/vec/common/schema_util.cpp:
##########
@@ -129,164 +139,254 @@ bool is_conversion_required_between_integers(FieldType 
lhs, FieldType rhs) {
     return true;
 }
 
-Status cast_column(const ColumnWithTypeAndName& arg, const DataTypePtr& type, 
ColumnPtr* result,
-                   RuntimeState* state) {
-    ColumnsWithTypeAndName arguments;
-    if (WhichDataType(type->get_type_id()).is_string()) {
-        // Special handle ColumnString, since the original cast logic use 
ColumnString's first item
-        // as the name of the dest type
-        arguments = {arg, {type->create_column_const(1, type->get_name()), 
type, ""}};
-    } else {
-        arguments = {arg, {type->create_column_const_with_default_value(1), 
type, ""}};
-    }
+Status cast_column(const ColumnWithTypeAndName& arg, const DataTypePtr& type, 
ColumnPtr* result) {
+    ColumnsWithTypeAndName arguments {
+            arg, {type->create_column_const_with_default_value(1), type, 
type->get_name()}};
     auto function = SimpleFunctionFactory::instance().get_function("CAST", 
arguments, type);
+    if (!function) {
+        return Status::InternalError("Not found cast function {} to {}", 
arg.type->get_name(),
+                                     type->get_name());
+    }
     Block tmp_block {arguments};
-    // the 0 position is input argument, the 1 position is to type argument, 
the 2 position is result argument
     vectorized::ColumnNumbers argnum;
     argnum.emplace_back(0);
     argnum.emplace_back(1);
     size_t result_column = tmp_block.columns();
+    auto ctx = FunctionContext::create_context(nullptr, {}, {});
+    // We convert column string to jsonb type just add a string jsonb field to 
dst column instead of parse
+    // each line in original string column.
+    ctx->set_string_as_jsonb_string(true);

Review Comment:
   我感觉你这个参数不适合放到function context 中, 他更加是一个函数参数,应该放到arg column 中



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to