This is an automated email from the ASF dual-hosted git repository.
eldenmoon pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 59d3326cb1d [fix](json-quote) fix json quote func for not find the
func (#42005)
59d3326cb1d is described below
commit 59d3326cb1da80f6b88c417985b4a180fd17e8c0
Author: amory <[email protected]>
AuthorDate: Thu Oct 17 20:54:08 2024 +0800
[fix](json-quote) fix json quote func for not find the func (#42005)
pick #39931
---
be/src/vec/functions/function_json.cpp | 10 +++++--
.../sql_functions/json_functions/json_table.out | 32 ++++++++++++++++++++++
.../sql_functions/json_functions/json_table.sql | 32 ++++++++++++++++++++++
3 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/functions/function_json.cpp
b/be/src/vec/functions/function_json.cpp
index 3dcc94691ef..50bb5339341 100644
--- a/be/src/vec/functions/function_json.cpp
+++ b/be/src/vec/functions/function_json.cpp
@@ -802,6 +802,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;
@@ -810,13 +816,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());
}
@@ -893,7 +899,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/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/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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]