-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[func](jsonb)support json_depth function #24801
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
run buildall |
TeamCity be ut coverage result: |
(From new machine)TeamCity pipeline, clickbench performance test result: |
68a669c
to
5a9e071
Compare
5a9e071
to
52c5de5
Compare
run buildall |
|
||
* 空数组、空对象或标量的深度为 1。 | ||
* 仅包含深度为 1 的元素的非空数组的深度为2。 | ||
* 仅包含深度为 1 的成员值的非空对象的深度为2。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add explanation for depth > 2
@@ -1771,6 +1771,7 @@ | |||
[['json_contains'], 'BOOLEAN', ['JSONB', 'JSONB'], 'ALWAYS_NULLABLE'], | |||
[['json_contains'], 'BOOLEAN', ['JSONB', 'JSONB', 'VARCHAR'], 'ALWAYS_NULLABLE'], | |||
[['json_contains'], 'BOOLEAN', ['JSONB', 'JSONB', 'STRING'], 'ALWAYS_NULLABLE'], | |||
[['json_depth'], 'INT', ['JSONB'], 'ALWAYS_NULLABLE'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not depends on argument?
be/src/util/jsonb_document.h
Outdated
return 1; | ||
} | ||
case JsonbType::T_Object: { | ||
int depth = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest a better name base_depth
auto return_type = block.get_data_type(result); | ||
MutableColumnPtr res = return_type->create_column(); | ||
|
||
//if(jsonb_data_column->) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete unused code
continue; | ||
} | ||
auto depth = value->depth(); | ||
res->insert_data(const_cast<const char*>((char*)&depth), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's unsafe. Add a int32 to column is safe and efficient.
52c5de5
to
c3e83e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
String get_name() const override { return name; } | ||
static FunctionPtr create() { return std::make_shared<FunctionJsonbDepth>(); } | ||
|
||
DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'get_return_type_impl' can be made static [readability-convert-member-functions-to-static]
DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { | |
static DataTypePtr get_return_type_impl(const DataTypes& arguments) override { |
|
||
bool use_default_implementation_for_nulls() const override { return false; } | ||
|
||
Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'execute_impl' can be made static [readability-convert-member-functions-to-static]
Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, | |
static Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, | ||
size_t result, size_t input_rows_count) const override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'execute_impl' can be made static [readability-convert-member-functions-to-static]
Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, | |
size_t result, size_t input_rows_count) const override { | |
static Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments, | |
size_t result, size_t input_rows_count) override { |
run buildall |
1 similar comment
run buildall |
(From new machine)TeamCity pipeline, clickbench performance test result: |
TPC-H test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
|
run buildall |
TeamCity be ut coverage result: |
TPC-H test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
|
(From new machine)TeamCity pipeline, clickbench performance test result: |
run buildall |
1 similar comment
run buildall |
TeamCity be ut coverage result: |
TPC-H test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
|
(From new machine)TeamCity pipeline, clickbench performance test result: |
run buildall |
TeamCity be ut coverage result: |
TPC-H test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
|
722c271
to
401ccb1
Compare
run buildall |
TPC-H: Total hot run time: 38737 ms
|
TeamCity be ut coverage result: |
TPC-DS: Total hot run time: 186313 ms
|
ClickBench: Total hot run time: 30.33 s
|
run buildall |
TPC-H: Total hot run time: 38574 ms
|
TeamCity be ut coverage result: |
TPC-DS: Total hot run time: 185648 ms
|
ClickBench: Total hot run time: 29.97 s
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
* ScalarFunction 'json_depth'. This class is generated by GenerateFunction. | ||
*/ | ||
public class JsonDepth extends ScalarFunction | ||
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsonDepth should be UnaryExpression
Proposed changes
Issue Number: close #xxx
Further comments
If this is a relatively large or complex change, kick off the discussion at [email protected] by explaining why you chose the solution you did and what alternatives you considered, etc...