Skip to content

Conversation

@liutang123
Copy link
Contributor

cherry-pick #40948

Like mysql, json_search returns the path which point to a json string witch match the pattern.
SELECT JSON_SEARCH('["A",[{"B":"1"}],{"C":"AB"},{"D":"BC"}]', 'one', 'A_') as res;

+----------+
| res      |
+----------+
| "$[2].C" |
+----------+

Proposed changes

Issue Number: close #xxx

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

Copy link
Contributor

@github-actions github-actions bot left a 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

bool seek(const char* string, size_t length);

void add_leg_to_leg_vector(std::unique_ptr<leg_info> leg) {
leg_vector.emplace_back(leg.release());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'leg_vector' [clang-diagnostic-error]

        leg_vector.emplace_back(leg.release());
        ^

leg_vector.emplace_back(leg.release());
}

void pop_leg_from_leg_vector() { leg_vector.pop_back(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'leg_vector' [clang-diagnostic-error]

    void pop_leg_from_leg_vector() { leg_vector.pop_back(); }
                                     ^


bool to_string(std::string* res) const {
res->push_back(SCOPE);
for (const auto& leg : leg_vector) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'leg_vector' [clang-diagnostic-error]

        for (const auto& leg : leg_vector) {
                               ^

return true;
}

size_t get_leg_vector_size() { return leg_vector.size(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'leg_vector' [clang-diagnostic-error]

    size_t get_leg_vector_size() { return leg_vector.size(); }
                                          ^


size_t get_leg_vector_size() { return leg_vector.size(); }

leg_info* get_leg_from_leg_vector(size_t i) { return leg_vector[i].get(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use of undeclared identifier 'leg_vector' [clang-diagnostic-error]

    leg_info* get_leg_from_leg_vector(size_t i) { return leg_vector[i].get(); }
                                                         ^

} else if (element.isArray()) {
const SimdJSONParser::Array& array = element.getArray();
bool find = false;
for (size_t i = 0; i < array.size(); ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use range-based for loop instead [modernize-loop-convert]

Suggested change
for (size_t i = 0; i < array.size(); ++i) {
for (auto child_element : array) {

be/src/vec/functions/function_jsonb.cpp:1676:

-                 const SimdJSONParser::Element& child_element = array[i];
-                 // construct an array cell path leg.
+                 // construct an array cell path leg.

return Status::OK();
}

Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'execute_impl' exceeds recommended size/complexity thresholds [readability-function-size]

    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
           ^
Additional context

be/src/vec/functions/function_jsonb.cpp:1827: 120 lines including whitespace and comments (threshold 80)

    Status execute_impl(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
           ^

}
}

Status FunctionLike::construct_like_const_state(FunctionContext* context, const StringRef& pattern,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'construct_like_const_state' exceeds recommended size/complexity thresholds [readability-function-size]

Status FunctionLike::construct_like_const_state(FunctionContext* context, const StringRef& pattern,
                     ^
Additional context

be/src/vec/functions/like.cpp:818: 96 lines including whitespace and comments (threshold 80)

Status FunctionLike::construct_like_const_state(FunctionContext* context, const StringRef& pattern,
                     ^

@liutang123
Copy link
Contributor Author

run buildall

@liutang123
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 36.06% (9339/25902)
Line Coverage: 27.61% (76674/277664)
Region Coverage: 26.41% (39364/149059)
Branch Coverage: 23.20% (20026/86336)
Coverage Report: http://coverage.selectdb-in.cc/coverage/d144000df1e805d7150c1f7c2dbc408768ac92f2_d144000df1e805d7150c1f7c2dbc408768ac92f2/report/index.html

liutang123 and others added 3 commits October 11, 2024 09:54
Like mysql, json_search returns the path which point to a json string
witch match the pattern.
`SELECT JSON_SEARCH('["A",[{"B":"1"}],{"C":"AB"},{"D":"BC"}]', 'one',
'A_') as res;`
```
+----------+
| res      |
+----------+
| "$[2].C" |
+----------+
```
@liutang123
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 36.04% (9339/25916)
Line Coverage: 27.62% (76729/277810)
Region Coverage: 26.42% (39410/149145)
Branch Coverage: 23.21% (20053/86384)
Coverage Report: http://coverage.selectdb-in.cc/coverage/36f9479532c1d93a23e24eba59ab52bf22fc8ca9_36f9479532c1d93a23e24eba59ab52bf22fc8ca9/report/index.html

@liutang123 liutang123 merged commit 4ac07fe into apache:branch-2.1 Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants