This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new f8e20ceca2 [Improvement](jsonb) add suport for JSONB type for arrow 
(#16869)
f8e20ceca2 is described below

commit f8e20ceca2360a0528eeb14d35aef2036c116a85
Author: Kang <[email protected]>
AuthorDate: Tue Feb 28 17:04:13 2023 +0800

    [Improvement](jsonb) add suport for JSONB type for arrow (#16869)
    
    add suport for JSONB type for arrow, which is used by doris spark/flink 
connector.
---
 be/src/util/arrow/block_convertor.cpp | 9 ++++++++-
 be/src/util/arrow/row_batch.cpp       | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/be/src/util/arrow/block_convertor.cpp 
b/be/src/util/arrow/block_convertor.cpp
index 31211f44a3..d4c4f2f6ba 100644
--- a/be/src/util/arrow/block_convertor.cpp
+++ b/be/src/util/arrow/block_convertor.cpp
@@ -38,6 +38,7 @@
 #include "gutil/strings/substitute.h"
 #include "runtime/descriptor_helper.h"
 #include "runtime/descriptors.h"
+#include "runtime/jsonb_value.h"
 #include "runtime/large_int_value.h"
 #include "util/arrow/utils.h"
 #include "util/types.h"
@@ -137,9 +138,15 @@ public:
                 ARROW_RETURN_NOT_OK(builder.Append(string_temp.data(), 
string_temp.size()));
                 break;
             }
+            case vectorized::TypeIndex::JSONB: {
+                std::string string_temp =
+                        JsonbToJson::jsonb_to_json_string(data_ref.data, 
data_ref.size);
+                ARROW_RETURN_NOT_OK(builder.Append(string_temp.data(), 
string_temp.size()));
+                break;
+            }
             default: {
                 LOG(WARNING) << "can't convert this type = " << 
vectorized::getTypeName(type_idx)
-                             << "to arrow type";
+                             << " to arrow type";
                 return arrow::Status::TypeError("unsupported column type");
             }
             }
diff --git a/be/src/util/arrow/row_batch.cpp b/be/src/util/arrow/row_batch.cpp
index dd93cb7b87..508a495c69 100644
--- a/be/src/util/arrow/row_batch.cpp
+++ b/be/src/util/arrow/row_batch.cpp
@@ -78,6 +78,7 @@ Status convert_to_arrow_type(const TypeDescriptor& type, 
std::shared_ptr<arrow::
     case TYPE_DATEV2:
     case TYPE_DATETIMEV2:
     case TYPE_STRING:
+    case TYPE_JSONB:
         *result = arrow::utf8();
         break;
     case TYPE_DECIMALV2:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to