zenoyang opened a new issue, #12273: URL: https://github.com/apache/doris/issues/12273
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/incubator-doris/issues?q=is%3Aissue) and found no similar issues. ### Version chunk ### What's Wrong? Users use grouping sets unreasonably and get wrong results. If a column appears in both the `select list` and `aggregate function`, an error will be returned: ``` ERROR 1105 (HY000): errCode = 2, detailMessage = column: `LO_REVENUE` cannot both in select list and aggregate functions when using GROUPING SETS/CUBE/ROLLUP, please use union instead. ``` However, if there are two expressions in the select, the error will not be recognized, and the wrong result will be obtained (vectorization is not turned on), or BE Core (vectorization is turned on) ### What You Expected? Report an error directly instead of returning an incorrect result, or cause BE Core. ### How to Reproduce? SSB flat table: lineorder_flat ``` SELECT count(P_CATEGORY), (LO_ORDERDATE DIV 10000) AS year, P_BRAND FROM lineorder_flat WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' and (LO_ORDERDATE DIV 10000) = 1996 GROUP BY grouping sets ((year),(P_BRAND),(P_CATEGORY)) ``` The above error will return: `column: `LO_REVENUE` cannot both in select list and aggregate functions when using GROUPING SETS/CUBE/ROLLUP, please use union instead.`, which is expected. ```sql SELECT count(P_CATEGORY) / count(P_CATEGORY), (LO_ORDERDATE DIV 10000) AS year, P_BRAND FROM lineorder_flat WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' and (LO_ORDERDATE DIV 10000) = 1996 GROUP BY grouping sets ((year),(P_BRAND),(P_CATEGORY)) ``` The above sql, if vectorization is not enabled, returns an error result: ```sql +-------------------------------------------+------+-----------+ | count(`P_CATEGORY`) / count(`P_CATEGORY`) | year | P_BRAND | +-------------------------------------------+------+-----------+ | NULL | NULL | MFGR#125 | | NULL | NULL | MFGR#1239 | | NULL | NULL | MFGR#1224 | | NULL | NULL | MFGR#1215 | | NULL | NULL | MFGR#126 | | NULL | NULL | MFGR#1227 | | NULL | NULL | MFGR#1216 | | 1 | NULL | NULL | | NULL | NULL | MFGR#1232 | | NULL | 1996 | NULL | | NULL | NULL | MFGR#1231 | | NULL | NULL | MFGR#1233 | | NULL | NULL | MFGR#1230 | | NULL | NULL | MFGR#1225 | | NULL | NULL | MFGR#1238 | | NULL | NULL | MFGR#124 | | NULL | NULL | MFGR#1214 | | NULL | NULL | MFGR#1226 | | NULL | NULL | MFGR#127 | | NULL | NULL | MFGR#1217 | | NULL | NULL | MFGR#1237 | | NULL | NULL | MFGR#1218 | | NULL | NULL | MFGR#1229 | | NULL | NULL | MFGR#1234 | | NULL | NULL | MFGR#128 | | NULL | NULL | MFGR#1240 | | NULL | NULL | MFGR#1221 | | NULL | NULL | MFGR#1210 | | NULL | NULL | MFGR#1222 | | NULL | NULL | MFGR#123 | | NULL | NULL | MFGR#1213 | | NULL | NULL | MFGR#121 | | NULL | NULL | MFGR#1220 | | NULL | NULL | MFGR#1211 | | NULL | NULL | MFGR#122 | | NULL | NULL | MFGR#1223 | | NULL | NULL | MFGR#1212 | | NULL | NULL | MFGR#1236 | | NULL | NULL | MFGR#1219 | | NULL | NULL | MFGR#129 | | NULL | NULL | MFGR#1235 | | NULL | NULL | MFGR#1228 | +-------------------------------------------+------+-----------+ 42 rows in set (2 min 43.05 sec) ``` If vectorization is turned on, it results in BE Core: ``` *** Current BE git commitID: 0c5b4ec *** *** SIGABRT unkown detail explain (@0x2d290) received by PID 184976 (TID 0x7fe984d78700) from PID 184976; stack trace: *** 0# doris::signal::(anonymous namespace)::FailureSignalHandler(int, siginfo_t*, void*) at /root/yangzheng13/workspace/incubator-doris/be/src/common/signal_handler.h:420 1# 0x00007FE9C9CAD400 in /lib64/libc.so.6 2# gsignal in /lib64/libc.so.6 3# abort in /lib64/libc.so.6 4# __gnu_cxx::__verbose_terminate_handler() [clone .cold] in /root/yangzheng13/workspace/incubator-doris/output/be-release/lib/doris_be 5# __cxxabiv1::__terminate(void (*)()) in /root/yangzheng13/workspace/incubator-doris/output/be-release/lib/doris_be 6# 0x00007FE9D4020391 in /root/yangzheng13/workspace/incubator-doris/output/be-release/lib/doris_be 7# 0x00007FE9D40204E5 in /root/yangzheng13/workspace/incubator-doris/output/be-release/lib/doris_be 8# doris::vectorized::throwFromErrno(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int) at /root/yangzheng13/workspace/incubator-doris/be/src/vec/common/exception.cpp:115 9# Allocator<false, false>::alloc(unsigned long, unsigned long) [clone .isra.0] at /root/yangzheng13/workspace/incubator-doris/be/src/vec/common/allocator.h:170 10# void doris::vectorized::PODArrayBase<1ul, 4096ul, Allocator<false, false>, 15ul, 16ul>::realloc<>(unsigned long) at /root/yangzheng13/workspace/incubator-doris/be/src/vec/common/pod_array.h:153 11# doris::vectorized::ColumnString::insert_range_from(doris::vectorized::IColumn const&, unsigned long, unsigned long) [clone .part.0] at /root/yangzheng13/workspace/incubator-doris/be/src/vec/columns/column_string.cpp:79 12# doris::vectorized::VRepeatNode::get_repeated_block(doris::vectorized::Block*, int, doris::vectorized::Block*) at /root/yangzheng13/workspace/incubator-doris/be/src/vec/exec/vrepeat_node.cpp:114 13# doris::vectorized::VRepeatNode::get_next(doris::RuntimeState*, doris::vectorized::Block*, bool*) at /root/yangzheng13/workspace/incubator-doris/be/src/vec/exec/vrepeat_node.cpp:193 14# doris::vectorized::AggregationNode::get_next(doris::RuntimeState*, doris::vectorized::Block*, bool*) at /root/yangzheng13/workspace/incubator-doris/be/src/vec/exec/vaggregation_node.cpp:464 15# doris::PlanFragmentExecutor::get_vectorized_internal(doris::vectorized::Block**) at /root/yangzheng13/workspace/incubator-doris/be/src/runtime/plan_fragment_executor.cpp:336 16# doris::PlanFragmentExecutor::open_vectorized_internal() at /root/yangzheng13/workspace/incubator-doris/be/src/runtime/plan_fragment_executor.cpp:284 17# doris::PlanFragmentExecutor::open() at /root/yangzheng13/workspace/incubator-doris/be/src/runtime/plan_fragment_executor.cpp:239 18# doris::FragmentExecState::execute() at /root/yangzheng13/workspace/incubator-doris/be/src/runtime/fragment_mgr.cpp:246 19# doris::FragmentMgr::_exec_actual(std::shared_ptr<doris::FragmentExecState>, std::function<void (doris::PlanFragmentExecutor*)>) at /root/yangzheng13/workspace/incubator-doris/be/src/runtime/fragment_mgr.cpp:499 20# std::_Function_handler<void (), doris::FragmentMgr::exec_plan_fragment(doris::TExecPlanFragmentParams const&, std::function<void (doris::PlanFragmentExecutor*)>)::{lambda()#1}>::_M_invoke(std::_Any_data const&) at /var/local/ldb-toolchain/include/c++/11/bits/std_function.h:291 21# doris::ThreadPool::dispatch_thread() at /root/yangzheng13/workspace/incubator-doris/be/src/util/threadpool.cpp:548 22# doris::Thread::supervise_thread(void*) at /root/yangzheng13/workspace/incubator-doris/be/src/util/thread.cpp:426 23# start_thread in /lib64/libpthread.so.0 24# clone in /lib64/libc.so.6 ``` ### Anything Else? none ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org