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

eldenmoon 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 69b34896ee5 [fix](json-quote) fix  json quote func for not find the 
func (#39931)
69b34896ee5 is described below

commit 69b34896ee575e590661bcfb92f88fb962bae541
Author: amory <wangqian...@selectdb.com>
AuthorDate: Wed Aug 28 09:42:36 2024 +0800

    [fix](json-quote) fix  json quote func for not find the func (#39931)
    
    1.  fix function not found
    before this pr:
    ```
    drop table if exists t003;
    create table t003 (a bigint, b json not null) properties 
("replication_num"="1");
    insert into t003 values (1, '{"a":1,"b":2}');
    select a, map_agg("k1", json_quote(b)) from t003 group by a;
    
    [17:47]>  select a, map_agg("k1", json_quote(b)) from t003 group by a;
    (1105, 'errCode = 2, detailMessage = 
(172.20.48.119)[INTERNAL_ERROR]Function json_quote get failed, expr is 
VectorizedFnCall[json_quote](arguments=(CAST b(JSONB) TO 
String),return=Nullable(String)) and return type is Nullable(String).')
    ```
    after pr , we can carry on it
    2. fix a core if we use json_quote with table column
    ```
    [WARNING!] /sys/kernel/mm/transparent_hugepage/enabled: [always] madvise 
never, Doris not recommend turning on THP, which may cause the BE process to 
use more memory and cannot be freed in time. Turn off THP: `echo madvise | sudo 
tee /sys/kernel/mm/transparent_hugepage/enabled`
    start BE in local mode
    doris_be: 
/mnt/disk1/wangqiannan/amory/doris/thirdparty/installed/include/rapidjson/writer.h:488:void
 
rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<>>>::Prefix(Type)
 [OutputStream = rapidjson::GenericStringBuffer<rapidjson::UTF8<>>, 
SourceEncoding = rapidjson::UTF8<>, TargetEncoding = rapidjson::UTF8<>, 
StackAllocator = rapidjson::CrtAllocator, writeFlags = 0]: 假设 ‘!hasRoot_’ 失败。
    *** Query id: b7b94dead55e4090-8c8e94f65ec9efd3 ***
    *** is nereids: 1 ***
    *** tablet id: 0 ***
    *** Aborted at 1724744881 (unix time) try "date -d @1724744881" if you are 
using GNU date ***
    *** Current BE git commitID: bd5844ea0d ***
    *** SIGABRT unknown detail explain (@0x461003611e1) received by PID 3543521 
(TID 3548858 OR 0x7f8a53c1a700) from PID 3543521; stack trace: ***
    doris_be: 
/mnt/disk1/wangqiannan/amory/doris/thirdparty/installed/include/rapidjson/writer.h:488:void
 
rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<>>>::Prefix(Type)
 [OutputStream = rapidjson::GenericStringBuffer<rapidjson::UTF8<>>, 
SourceEncoding = rapidjson::UTF8<>, TargetEncoding = rapidjson::UTF8<>, 
StackAllocator = rapidjson::CrtAllocator, writeFlags = 0]: 假设 ‘!hasRoot_’ 失败。
    doris_be: 
/mnt/disk1/wangqiannan/amory/doris/thirdparty/installed/include/rapidjson/writer.h:488:void
 
rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<>>>::Prefix(Type)
 [OutputStream = rapidjson::GenericStringBuffer<rapidjson::UTF8<>>, 
SourceEncoding = rapidjson::UTF8<>, TargetEncoding = rapidjson::UTF8<>, 
StackAllocator = rapidjson::CrtAllocator, writeFlags = 0]: 假设 ‘!hasRoot_’ 失败。
    doris_be: 
/mnt/disk1/wangqiannan/amory/doris/thirdparty/installed/include/rapidjson/writer.h:488:void
 
rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<>>>::Prefix(Type)
 [OutputStream = rapidjson::GenericStringBuffer<rapidjson::UTF8<>>, 
SourceEncoding = rapidjson::UTF8<>, TargetEncoding = rapidjson::UTF8<>, 
StackAllocator = rapidjson::CrtAllocator, writeFlags = 0]: 假设 ‘!hasRoot_’ 失败。
    doris_be: 
/mnt/disk1/wangqiannan/amory/doris/thirdparty/installed/include/rapidjson/writer.h:488:void
 
rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<>>>::Prefix(Type)
 [OutputStream = rapidjson::GenericStringBuffer<rapidjson::UTF8<>>, 
SourceEncoding = rapidjson::UTF8<>, TargetEncoding = rapidjson::UTF8<>, 
StackAllocator = rapidjson::CrtAllocator, writeFlags = 0]: 假设 ‘!hasRoot_’ 失败。
    doris_be: 
/mnt/disk1/wangqiannan/amory/doris/thirdparty/installed/include/rapidjson/writer.h:488:void
 
rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<>>>::Prefix(Type)
 [OutputStream = rapidjson::GenericStringBuffer<rapidjson::UTF8<>>, 
SourceEncoding = rapidjson::UTF8<>, TargetEncoding = rapidjson::UTF8<>, 
StackAllocator = rapidjson::CrtAllocator, writeFlags = 0]: 假设 ‘!hasRoot_’ 失败。
    doris_be: 
/mnt/disk1/wangqiannan/amory/doris/thirdparty/installed/include/rapidjson/writer.h:488:void
 
rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<>>>::Prefix(Type)
 [OutputStream = rapidjson::GenericStringBuffer<rapidjson::UTF8<>>, 
SourceEncoding = rapidjson::UTF8<>, TargetEncoding = rapidjson::UTF8<>, 
StackAllocator = rapidjson::CrtAllocator, writeFlags = 0]: 假设 ‘!hasRoot_’ 失败。
     0# doris::signal::(anonymous namespace)::FailureSignalHandler(int, 
siginfo_t*, void*) at 
/mnt/disk1/wangqiannan/amory/doris/be/src/common/signal_handler.h:421
     1# 0x00007F9429595B50 in /lib64/libc.so.6
     2# gsignal in /lib64/libc.so.6
     3# __GI_abort in /lib64/libc.so.6
     4# _nl_load_domain.cold.0 in /lib64/libc.so.6
     5# 0x00007F942958E426 in /lib64/libc.so.6
     6# rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<char>, 
rapidjson::CrtAllocator>, rapidjson::UTF8<char>, rapidjson::UTF8<char>, 
rapidjson::CrtAllocator, 0u>::Prefix(rapidjson::Type) at 
/mnt/disk1/wangqiannan/amory/doris/thirdparty/installed/include/rapidjson/writer.h:488
     7# rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<char>, 
rapidjson::CrtAllocator>, rapidjson::UTF8<char>, rapidjson::UTF8<char>, 
rapidjson::CrtAllocator, 0u>::String(char const*, unsigned int, bool) at 
/mnt/disk1/wangqiannan/amory/doris/thirdparty/installed/include/rapidjson/writer.h:206
     8# bool rapidjson::GenericValue<rapidjson::UTF8<char>, 
rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> 
>::Accept<rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<char>,
 rapidjson::CrtAllocator>, rapidjson::UTF8<char>, rapidjson::UTF8<char>, 
rapidjson::CrtAllocator, 0u> 
>(rapidjson::Writer<rapidjson::GenericStringBuffer<rapidjson::UTF8<char>, 
rapidjson::CrtAllocator>, rapidjson::UTF8<char>, rapidjson::UTF8<char>, 
rapidjson::CrtAllocator, 0u>&) const at /mnt/dis [...]
     9# 
doris::vectorized::FunctionJsonQuoteImpl::execute(std::vector<doris::vectorized::ColumnStr<unsigned
 int> const*, std::allocator<doris::vectorized::ColumnStr<unsigned int> const*> 
> const&, doris::vectorized::ColumnStr<unsigned int>&, unsigned long) at 
/mnt/disk1/wangqiannan/amory/doris/be/src/vec/functions/function_json.cpp:826
    10# 
doris::vectorized::FunctionJson<doris::vectorized::FunctionJsonQuoteImpl>::execute_impl(doris::FunctionContext*,
 doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned 
long> > const&, unsigned long, unsigned long) const at 
/mnt/disk1/wangqiannan/amory/doris/be/src/vec/functions/function_json.cpp:985
    11# 
doris::vectorized::DefaultExecutable::execute_impl(doris::FunctionContext*, 
doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned 
long> > const&, unsigned long, unsigned long) const at 
/mnt/disk1/wangqiannan/amory/doris/be/src/vec/functions/function.h:463
    12# 
doris::vectorized::PreparedFunctionImpl::_execute_skipped_constant_deal(doris::FunctionContext*,
 doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned 
long> > const&, unsigned long, unsigned long, bool) const at 
/mnt/disk1/wangqiannan/amory/doris/be/src/vec/functions/function.cpp:120
    13# 
doris::vectorized::PreparedFunctionImpl::execute_without_low_cardinality_columns(doris::FunctionContext*,
 doris::vectorized::Block&, std::vector<unsigned long, std::allocator<unsigned 
long> > const&, unsigned long, unsigned long, bool) const at 
/mnt/disk1/wangqiannan/amory/doris/be/src/vec/functions/function.cpp:245
    ```
---
 be/src/vec/functions/function_json.cpp             | 10 +++++--
 .../java/org/apache/doris/analysis/CastExpr.java   |  1 +
 .../sql_functions/json_functions/json_table.out    | 32 ++++++++++++++++++++++
 .../json_functions/test_mapagg_with_jsonfuncs.out  |  7 +++++
 .../sql_functions/json_functions/json_table.sql    | 32 ++++++++++++++++++++++
 .../test_mapagg_with_jsonfuncs.groovy              | 28 +++++++++++++++++++
 6 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/functions/function_json.cpp 
b/be/src/vec/functions/function_json.cpp
index cb667d2dc76..d6a704613b4 100644
--- a/be/src/vec/functions/function_json.cpp
+++ b/be/src/vec/functions/function_json.cpp
@@ -801,6 +801,12 @@ public:
 struct FunctionJsonQuoteImpl {
     static constexpr auto name = "json_quote";
 
+    static DataTypePtr get_return_type_impl(const DataTypes& arguments) {
+        if (!arguments.empty() && arguments[0] && arguments[0]->is_nullable()) 
{
+            return make_nullable(std::make_shared<DataTypeString>());
+        }
+        return std::make_shared<DataTypeString>();
+    }
     static void execute(const std::vector<const ColumnString*>& data_columns,
                         ColumnString& result_column, size_t input_rows_count) {
         rapidjson::Document document;
@@ -809,13 +815,13 @@ struct FunctionJsonQuoteImpl {
         rapidjson::Value value;
 
         rapidjson::StringBuffer buf;
-        rapidjson::Writer<rapidjson::StringBuffer> writer(buf);
 
         for (int i = 0; i < input_rows_count; i++) {
             StringRef data = data_columns[0]->get_data_at(i);
             value.SetString(data.data, data.size, allocator);
 
             buf.Clear();
+            rapidjson::Writer<rapidjson::StringBuffer> writer(buf);
             value.Accept(writer);
             result_column.insert_data(buf.GetString(), buf.GetSize());
         }
@@ -960,7 +966,7 @@ public:
     bool is_variadic() const override { return true; }
 
     DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
-        return std::make_shared<DataTypeString>();
+        return Impl::get_return_type_impl(arguments);
     }
 
     Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
index d11cdc147a8..de257991ca6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
@@ -185,6 +185,7 @@ public class CastExpr extends Expr {
         targetTypeDef = other.targetTypeDef;
         isImplicit = other.isImplicit;
         noOp = other.noOp;
+        nullableFromNereids = other.nullableFromNereids;
     }
 
     private static String getFnName(Type targetType) {
diff --git 
a/regression-test/data/query_p0/sql_functions/json_functions/json_table.out 
b/regression-test/data/query_p0/sql_functions/json_functions/json_table.out
new file mode 100644
index 00000000000..acff465adad
--- /dev/null
+++ b/regression-test/data/query_p0/sql_functions/json_functions/json_table.out
@@ -0,0 +1,32 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !json_table --
+0
+
+-- !json_table_2 --
+0
+
+-- !json_table_3 --
+20
+
+-- !json_table_4 --
+"{\\"movie\\":{\\"name\\":\\"3 
Idiots\\",\\"genre\\":\\"Comedy\\"},\\"pronounpossessive\\":\\"ours\\",\\"minecraftmobpassive\\":\\"chicken\\",\\"productcategory\\":\\"pet
 
food\\",\\"emoji\\":\\"👿\\",\\"httpmethod\\":\\"HEAD\\",\\"weekday\\":\\"Thursday\\",\\"breakfast\\":\\"Broiled
 cinnamon 
toast\\",\\"nanosecond\\":808913887,\\"uint8\\":35,\\"creditcardexp\\":\\"11/25\\",\\"question\\":\\"Forage
 skateboard gastropub carry migas banjo lomo gluten-free austin 
venmo?\\",\\"beeryeast\\":\\" [...]
+"{\\"movie\\":{\\"name\\":\\"The Lion 
King\\",\\"genre\\":\\"Fantasy\\"},\\"pronounpossessive\\":\\"hers\\",\\"minecraftmobpassive\\":\\"wandering
 trader\\",\\"productcategory\\":\\"art 
supplies\\",\\"emoji\\":\\"🚈\\",\\"httpmethod\\":\\"PUT\\",\\"weekday\\":\\"Wednesday\\",\\"breakfast\\":\\"Moms
 cheat 
doughnuts\\",\\"nanosecond\\":967819589,\\"uint8\\":164,\\"creditcardexp\\":\\"08/28\\",\\"question\\":\\"Intelligentsia
 fashion axe goth keytar Yuccie pork belly flannel?\\",\\"beeryeast [...]
+"{\\"movie\\":{\\"name\\":\\"Once Upon a Time in 
America\\",\\"genre\\":\\"Drama\\"},\\"pronounpossessive\\":\\"hers\\",\\"minecraftmobpassive\\":\\"mooshroom\\",\\"productcategory\\":\\"sneakers
 and athletic 
shoes\\",\\"emoji\\":\\"🚴‍♂️\\",\\"httpmethod\\":\\"GET\\",\\"weekday\\":\\"Friday\\",\\"breakfast\\":\\"Awesome
 orange chocolate 
muffins\\",\\"nanosecond\\":12285057,\\"uint8\\":85,\\"creditcardexp\\":\\"01/32\\",\\"question\\":\\"Swag
 truffaut XOXO vice meh shabby chic?\\",\\"beer [...]
+"{\\"movie\\":{\\"name\\":\\"1917\\",\\"genre\\":\\"Crime\\"},\\"pronounpossessive\\":\\"theirs\\",\\"minecraftmobpassive\\":\\"strider\\",\\"productcategory\\":\\"mobile
 
phones\\",\\"emoji\\":\\"7️⃣\\",\\"httpmethod\\":\\"PATCH\\",\\"weekday\\":\\"Wednesday\\",\\"breakfast\\":\\"Whole
 grain pancake 
mix\\",\\"nanosecond\\":363621291,\\"uint8\\":237,\\"creditcardexp\\":\\"06/28\\",\\"question\\":\\"Truffaut
 gastropub tofu goth etsy scenester actually?\\",\\"beeryeast\\":\\"1450 - 
Dennys F [...]
+"{\\"movie\\":{\\"name\\":\\"Forrest 
Gump\\",\\"genre\\":\\"Biography\\"},\\"pronounpossessive\\":\\"theirs\\",\\"minecraftmobpassive\\":\\"turtle\\",\\"productcategory\\":\\"jewelry\\",\\"emoji\\":\\"🦩\\",\\"httpmethod\\":\\"DELETE\\",\\"weekday\\":\\"Tuesday\\",\\"breakfast\\":\\"Ham
 omelet 
deluxe\\",\\"nanosecond\\":78989938,\\"uint8\\":179,\\"creditcardexp\\":\\"05/33\\",\\"question\\":\\"Small
 batch hoodie craft beer austin kitsch?\\",\\"beeryeast\\":\\"3724 - Belgian 
Saison\\",\\"l [...]
+"{\\"movie\\":{\\"name\\":\\"Django 
Unchained\\",\\"genre\\":\\"Thriller\\"},\\"pronounpossessive\\":\\"yours\\",\\"minecraftmobpassive\\":\\"parrot\\",\\"productcategory\\":\\"stationery\\",\\"emoji\\":\\"🈶\\",\\"httpmethod\\":\\"PATCH\\",\\"weekday\\":\\"Thursday\\",\\"breakfast\\":\\"Caramel
 pull 
aparts\\",\\"nanosecond\\":861965659,\\"uint8\\":119,\\"creditcardexp\\":\\"06/33\\",\\"question\\":\\"Flexitarian
 freegan fashion axe?\\",\\"beeryeast\\":\\"2112 - California Lager\\",\\"lat 
[...]
+"{\\"movie\\":{\\"name\\":\\"The Shawshank 
Redemption\\",\\"genre\\":\\"Comedy\\"},\\"pronounpossessive\\":\\"hers\\",\\"minecraftmobpassive\\":\\"fox\\",\\"productcategory\\":\\"camping
 
gear\\",\\"emoji\\":\\"🇼🇫\\",\\"httpmethod\\":\\"GET\\",\\"weekday\\":\\"Monday\\",\\"breakfast\\":\\"Sleepy
 twisted sisters g n g breakfast 
ramekin\\",\\"nanosecond\\":459668660,\\"uint8\\":147,\\"creditcardexp\\":\\"04/30\\",\\"question\\":\\"Mlkshk
 five dollar toast sartorial gastropub gentrify kogi?\ [...]
+"{\\"movie\\":{\\"name\\":\\"Gladiator\\",\\"genre\\":\\"Family\\"},\\"pronounpossessive\\":\\"ours\\",\\"minecraftmobpassive\\":\\"horse\\",\\"productcategory\\":\\"pet
 
supplies\\",\\"emoji\\":\\"🇨🇼\\",\\"httpmethod\\":\\"PATCH\\",\\"weekday\\":\\"Friday\\",\\"breakfast\\":\\"Lizs
 morning glory 
muffins\\",\\"nanosecond\\":844220857,\\"uint8\\":122,\\"creditcardexp\\":\\"10/29\\",\\"question\\":\\"Try-hard
 flannel chartreuse try-hard kitsch?\\",\\"beeryeast\\":\\"5112 - Brettanomyces 
bru [...]
+"{\\"movie\\":{\\"name\\":\\"The Dark 
Knight\\",\\"genre\\":\\"Music\\"},\\"pronounpossessive\\":\\"his\\",\\"minecraftmobpassive\\":\\"chicken\\",\\"productcategory\\":\\"sneakers
 and athletic 
shoes\\",\\"emoji\\":\\"🕶️\\",\\"httpmethod\\":\\"PATCH\\",\\"weekday\\":\\"Monday\\",\\"breakfast\\":\\"Best
 buttermilk 
pancakes\\",\\"nanosecond\\":242118310,\\"uint8\\":192,\\"creditcardexp\\":\\"10/27\\",\\"question\\":\\"Taxidermy
 artisan kale chips pork belly sustainable normcore listicle?\\ [...]
+"{\\"movie\\":{\\"name\\":\\"The 
Matrix\\",\\"genre\\":\\"Fantasy\\"},\\"pronounpossessive\\":\\"yours\\",\\"minecraftmobpassive\\":\\"parrot\\",\\"productcategory\\":\\"watches\\",\\"emoji\\":\\"🙍\\",\\"httpmethod\\":\\"GET\\",\\"weekday\\":\\"Friday\\",\\"breakfast\\":\\"Banana
 blueberry oatmeal 
bread\\",\\"nanosecond\\":622515805,\\"uint8\\":218,\\"creditcardexp\\":\\"09/27\\",\\"question\\":\\"Irony
 kitsch occupy loko hashtag viral kombucha?\\",\\"beeryeast\\":\\"3056 - 
Bavarian Whea [...]
+"{\\"movie\\":{\\"name\\":\\"The Dark 
Knight\\",\\"genre\\":\\"War\\"},\\"pronounpossessive\\":\\"mine\\",\\"minecraftmobpassive\\":\\"mule\\",\\"productcategory\\":\\"mobile
 
phones\\",\\"emoji\\":\\"🧸\\",\\"httpmethod\\":\\"PATCH\\",\\"weekday\\":\\"Friday\\",\\"breakfast\\":\\"Sausage
 gravy for biscuits and 
gravy\\",\\"nanosecond\\":564033239,\\"uint8\\":160,\\"creditcardexp\\":\\"04/34\\",\\"question\\":\\"Selfies
 stumptown mustache lomo?\\",\\"beeryeast\\":\\"1318 - London Ale III\\" [...]
+"{\\"movie\\":{\\"name\\":\\"Django 
Unchained\\",\\"genre\\":\\"Adventure\\"},\\"pronounpossessive\\":\\"ours\\",\\"minecraftmobpassive\\":\\"strider\\",\\"productcategory\\":\\"food
 and 
groceries\\",\\"emoji\\":\\"✡️\\",\\"httpmethod\\":\\"PATCH\\",\\"weekday\\":\\"Friday\\",\\"breakfast\\":\\"Mexi
 eggs in a 
hole\\",\\"nanosecond\\":697142901,\\"uint8\\":198,\\"creditcardexp\\":\\"08/32\\",\\"question\\":\\"Banjo
 blue bottle taxidermy jean shorts wayfarers photo booth pickled Yuccie kom 
[...]
+"{\\"movie\\":{\\"name\\":\\"The 
Departed\\",\\"genre\\":\\"Horror\\"},\\"pronounpossessive\\":\\"yours\\",\\"minecraftmobpassive\\":\\"parrot\\",\\"productcategory\\":\\"mobile
 
phones\\",\\"emoji\\":\\"🌬️\\",\\"httpmethod\\":\\"POST\\",\\"weekday\\":\\"Thursday\\",\\"breakfast\\":\\"Asparagus
 omelette 
wraps\\",\\"nanosecond\\":39034078,\\"uint8\\":71,\\"creditcardexp\\":\\"04/29\\",\\"question\\":\\"VHS
 chartreuse typewriter meditation messenger bag 
cray?\\",\\"beeryeast\\":\\"1450 - De [...]
+"{\\"movie\\":{\\"name\\":\\"Into the 
Wild\\",\\"genre\\":\\"Horror\\"},\\"pronounpossessive\\":\\"hers\\",\\"minecraftmobpassive\\":\\"salmon\\",\\"productcategory\\":\\"fitness
 
equipment\\",\\"emoji\\":\\"🇪🇦\\",\\"httpmethod\\":\\"GET\\",\\"weekday\\":\\"Friday\\",\\"breakfast\\":\\"Ham
 omelet 
deluxe\\",\\"nanosecond\\":535766185,\\"uint8\\":145,\\"creditcardexp\\":\\"03/27\\",\\"question\\":\\"Knausgaard
 leggings mustache butcher artisan leggings tote bag health five dollar 
toast?\\", [...]
+"{\\"movie\\":{\\"name\\":\\"Gone with the 
Wind\\",\\"genre\\":\\"War\\"},\\"pronounpossessive\\":\\"ours\\",\\"minecraftmobpassive\\":\\"parrot\\",\\"productcategory\\":\\"sports
 
equipment\\",\\"emoji\\":\\"🙇‍♀️\\",\\"httpmethod\\":\\"HEAD\\",\\"weekday\\":\\"Friday\\",\\"breakfast\\":\\"Cardamom
 sour cream 
waffles\\",\\"nanosecond\\":189367732,\\"uint8\\":34,\\"creditcardexp\\":\\"05/34\\",\\"question\\":\\"Asymmetrical
 meh brunch beard?\\",\\"beeryeast\\":\\"1318 - London Ale III\\",\ [...]
+"{\\"movie\\":{\\"name\\":\\"Once Upon a Time in 
America\\",\\"genre\\":\\"Crime\\"},\\"pronounpossessive\\":\\"hers\\",\\"minecraftmobpassive\\":\\"mule\\",\\"productcategory\\":\\"bicycles
 and 
accessories\\",\\"emoji\\":\\"🔐\\",\\"httpmethod\\":\\"DELETE\\",\\"weekday\\":\\"Wednesday\\",\\"breakfast\\":\\"Israeli
 breakfast 
salad\\",\\"nanosecond\\":567750662,\\"uint8\\":211,\\"creditcardexp\\":\\"03/27\\",\\"question\\":\\"Fanny
 pack mustache scenester cleanse?\\",\\"beeryeast\\":\\"14 [...]
+"{\\"movie\\":{\\"name\\":\\"1917\\",\\"genre\\":\\"Film-Noir\\"},\\"pronounpossessive\\":\\"his\\",\\"minecraftmobpassive\\":\\"mule\\",\\"productcategory\\":\\"stationery\\",\\"emoji\\":\\"▫️\\",\\"httpmethod\\":\\"PUT\\",\\"weekday\\":\\"Saturday\\",\\"breakfast\\":\\"Baked
 
pears\\",\\"nanosecond\\":886075936,\\"uint8\\":210,\\"creditcardexp\\":\\"07/25\\",\\"question\\":\\"Ramps
 lumbersexual try-hard chicharrones franzen humblebrag green juice waistcoat 
park salvia?\\",\\"beeryeast\\ [...]
+"{\\"movie\\":{\\"name\\":\\"3 
Idiots\\",\\"genre\\":\\"Animation\\"},\\"pronounpossessive\\":\\"ours\\",\\"minecraftmobpassive\\":\\"cat\\",\\"productcategory\\":\\"bedding
 and 
linens\\",\\"emoji\\":\\"🚣\\",\\"httpmethod\\":\\"GET\\",\\"weekday\\":\\"Sunday\\",\\"breakfast\\":\\"Tomato
 and mushroom 
omelette\\",\\"nanosecond\\":607188757,\\"uint8\\":171,\\"creditcardexp\\":\\"08/29\\",\\"question\\":\\"Pop-up
 hashtag gastropub poutine pork belly humblebrag?\\",\\"beeryeast\\":\\"3942 - 
B [...]
+"{\\"movie\\":{\\"name\\":\\"A Clockwork 
Orange\\",\\"genre\\":\\"Crime\\"},\\"pronounpossessive\\":\\"ours\\",\\"minecraftmobpassive\\":\\"squid\\",\\"productcategory\\":\\"educational
 
toys\\",\\"emoji\\":\\"🥍\\",\\"httpmethod\\":\\"HEAD\\",\\"weekday\\":\\"Wednesday\\",\\"breakfast\\":\\"Danish
 
bubble\\",\\"nanosecond\\":679343363,\\"uint8\\":26,\\"creditcardexp\\":\\"03/31\\",\\"question\\":\\"Hashtag
 fixie direct trade hella?\\",\\"beeryeast\\":\\"5526 - Brettanomyces 
lambicus\\",\\" [...]
+"{\\"movie\\":{\\"name\\":\\"The Green 
Mile\\",\\"genre\\":\\"Crime\\"},\\"pronounpossessive\\":\\"theirs\\",\\"minecraftmobpassive\\":\\"cat\\",\\"productcategory\\":\\"jewelry\\",\\"emoji\\":\\"♓\\",\\"httpmethod\\":\\"POST\\",\\"weekday\\":\\"Tuesday\\",\\"breakfast\\":\\"English
 muffins with bacon 
butter\\",\\"nanosecond\\":30069308,\\"uint8\\":111,\\"creditcardexp\\":\\"07/27\\",\\"question\\":\\"Pickled
 whatever hashtag sriracha raw denim cray?\\",\\"beeryeast\\":\\"2206 - 
Bavarian [...]
+
diff --git 
a/regression-test/data/query_p0/sql_functions/json_functions/test_mapagg_with_jsonfuncs.out
 
b/regression-test/data/query_p0/sql_functions/json_functions/test_mapagg_with_jsonfuncs.out
new file mode 100644
index 00000000000..c79ebb2031e
--- /dev/null
+++ 
b/regression-test/data/query_p0/sql_functions/json_functions/test_mapagg_with_jsonfuncs.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1      {"k1":""{\\"a\\":1,\\"b\\":2}""}
+
+-- !sql --
+1      {"k1":""{\\"a\\":1,\\"b\\":2}""}
+
diff --git 
a/regression-test/suites/query_p0/sql_functions/json_functions/json_table.sql 
b/regression-test/suites/query_p0/sql_functions/json_functions/json_table.sql
new file mode 100644
index 00000000000..82da3fb2be5
--- /dev/null
+++ 
b/regression-test/suites/query_p0/sql_functions/json_functions/json_table.sql
@@ -0,0 +1,32 @@
+drop table if exists 
table_20_undef_partitions2_keys3_properties4_distributed_by5;
+
+create table if not exists 
table_20_undef_partitions2_keys3_properties4_distributed_by5 (
+pk int,
+col_json_undef_signed json  null  ,
+col_json_undef_signed_not_null json  not null  ,
+col_json_undef_signed2 json  null  ,
+col_json_undef_signed_not_null2 json  not null  ,
+col_json_undef_signed3 json  null  ,
+col_json_undef_signed_not_null3 json  not null  ,
+col_json_undef_signed4 json  null  ,
+col_json_undef_signed_not_null4 json  not null  ,
+col_json_undef_signed5 json  null  ,
+col_json_undef_signed_not_null5 json  not null  ,
+col_json_undef_signed6 json  null  ,
+col_json_undef_signed_not_null6 json  not null  ,
+col_json_undef_signed7 json  null  ,
+col_json_undef_signed_not_null7 json  not null  ,
+col_json_undef_signed8 json  null  ,
+col_json_undef_signed_not_null8 json  not null  ,
+col_json_undef_signed9 json  null  ,
+col_json_undef_signed_not_null9 json  not null  ,
+col_json_undef_signed10 json  null  ,
+col_json_undef_signed_not_null10 json  not null  
+) engine=olap
+DUPLICATE KEY(pk)
+distributed by hash(pk) buckets 10
+properties("replication_num" = "1");
+
+insert into 
table_20_undef_partitions2_keys3_properties4_distributed_by5(pk,col_json_undef_signed,col_json_undef_signed_not_null,col_json_undef_signed2,col_json_undef_signed_not_null2,col_json_undef_signed3,col_json_undef_signed_not_null3,col_json_undef_signed4,col_json_undef_signed_not_null4,col_json_undef_signed5,col_json_undef_signed_not_null5,col_json_undef_signed6,col_json_undef_signed_not_null6,col_json_undef_signed7,col_json_undef_signed_not_null7,col_json_undef_signed8,col_json_u
 [...]
+
+select json_quote(col_json_undef_signed3) from 
table_20_undef_partitions2_keys3_properties4_distributed_by5 order by pk;
\ No newline at end of file
diff --git 
a/regression-test/suites/query_p0/sql_functions/json_functions/test_mapagg_with_jsonfuncs.groovy
 
b/regression-test/suites/query_p0/sql_functions/json_functions/test_mapagg_with_jsonfuncs.groovy
new file mode 100644
index 00000000000..24bfdcc413a
--- /dev/null
+++ 
b/regression-test/suites/query_p0/sql_functions/json_functions/test_mapagg_with_jsonfuncs.groovy
@@ -0,0 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_mapagg_with_jsonfuncs") {
+   sql "set enable_nereids_planner = true"
+   sql "set enable_fallback_to_original_planner = false"
+   sql """ drop table if exists t003;"""
+   sql """ create table t003 (a bigint, b json not null) properties 
("replication_num"="1"); """
+   sql """ insert into t003 values (1, '{"a":1,"b":2}'); """
+   qt_sql """ select a, map_agg("k1", json_quote(b)) from t003 group by a; """
+
+   sql "set enable_nereids_planner = false"
+   qt_sql """ select a, map_agg("k1", json_quote(b)) from t003 group by a; """
+}


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

Reply via email to