Skip to content
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

select get(parse_json(a, 'aa')) from json_test panic #4776

Closed
BohuTANG opened this issue Apr 9, 2022 · 3 comments · Fixed by #4888
Closed

select get(parse_json(a, 'aa')) from json_test panic #4776

BohuTANG opened this issue Apr 9, 2022 · 3 comments · Fixed by #4888
Assignees
Labels
A-query Area: databend query C-bug Category: something isn't working

Comments

@BohuTANG
Copy link
Member

BohuTANG commented Apr 9, 2022

Summary

Table:

 CREATE TABLE `json_test` (
  `a` Variant,
);

insert into json_test values('{"aa":1,"aA":2,"Aa":3}');

query:

select get(parse_json(a, 'aa')) from json_test;

server log:

^[[2m2022-04-09T11:32:34.421393Z^[[0m ^[[31mERROR^[[0m ^[[2mcommon_tracing::panic_hook^[[0m^[[2m:^[[0m panicked at 'index out of bounds: the len is 1 but the index is 1', common/functions/src/scalars/semi_structureds/get.rs:64:25 ^[[3mbacktrace^[[0m^[[2m=^[[0m   0: common_tracing::panic_hook::set_panic_hook::{{closure}}
             at /home/ubuntu/bohu/github/databend/common/tracing/src/panic_hook.rs:25:25
   1: std::panicking::rust_panic_with_hook
             at /rustc/76d770ac21d9521db6a92a48c7b3d5b2cc535941/library/std/src/panicking.rs:702:17
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/76d770ac21d9521db6a92a48c7b3d5b2cc535941/library/std/src/panicking.rs:588:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/76d770ac21d9521db6a92a48c7b3d5b2cc535941/library/std/src/sys_common/backtrace.rs:138:18
   4: rust_begin_unwind
             at /rustc/76d770ac21d9521db6a92a48c7b3d5b2cc535941/library/std/src/panicking.rs:584:5
   5: core::panicking::panic_fmt
             at /rustc/76d770ac21d9521db6a92a48c7b3d5b2cc535941/library/core/src/panicking.rs:143:14
   6: core::panicking::panic_bounds_check
             at /rustc/76d770ac21d9521db6a92a48c7b3d5b2cc535941/library/core/src/panicking.rs:84:5
   7: <common_functions::scalars::semi_structureds::get::GetFunctionImpl<_,_> as common_functions::scalars::function::Function>::return_type
             at /home/ubuntu/bohu/github/databend/common/functions/src/scalars/semi_structureds/get.rs:64:25
   8: <common_functions::scalars::function_adapter::FunctionAdapter as common_functions::scalars::function::Function>::return_type
             at /home/ubuntu/bohu/github/databend/common/functions/src/scalars/function_adapter.rs:109:23
   9: common_planners::plan_expression_common::ExpressionDataTypeVisitor::visit_function
             at /home/ubuntu/bohu/github/databend/common/planners/src/plan_expression_common.rs:414:27
  10: <common_planners::plan_expression_common::ExpressionDataTypeVisitor as common_planners::plan_expression_visitor::ExpressionVisitor>::post_visit
  11: common_planners::plan_expression_visitor::ExpressionVisitor::visit
             at /home/ubuntu/bohu/github/databend/common/planners/src/plan_expression_visitor.rs:41:28
      common_planners::plan_expression::Expression::to_data_type
             at /home/ubuntu/bohu/github/databend/common/planners/src/plan_expression.rs:290:9
  12: common_planners::plan_expression::Expression::to_data_field
             at /home/ubuntu/bohu/github/databend/common/planners/src/plan_expression.rs:224:9
  13: databend_query::sql::statements::statement_select::DfQueryStatement::dry_run_exprs

@BohuTANG BohuTANG added C-bug Category: something isn't working A-query Area: databend query labels Apr 9, 2022
@b41sh
Copy link
Member

b41sh commented Apr 9, 2022

The syntax of the tested SQL is incorrect, panic is caused by the wrong number of parameters.
The correct SQL should be

mysql> select get(parse_json(a), 'aa') from json_test;
+--------------------------+
| get(parse_json(a), 'aa') |
+--------------------------+
| 1                        |
+--------------------------+
1 row in set (0.03 sec)

@BohuTANG
Copy link
Member Author

BohuTANG commented Apr 9, 2022

Ok, it should return error instead of panic.

@b41sh
Copy link
Member

b41sh commented Apr 9, 2022

Ok, it should return error instead of panic.

Ok, I will fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query Area: databend query C-bug Category: something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants