starocean999 opened a new issue, #18263:
URL: https://github.com/apache/doris/issues/18263

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Version
   
   master
   
   ### What's Wrong?
   
   be crash when sql maches a mv with agg functions
   
   ### What You Expected?
   
   mysql> select sum(age) from schema_change_dup_mv_regression_test;
   +------------+
   | sum(`age`) |
   +------------+
   |         40 |
   +------------+
   1 row in set (0.02 sec)
   
   ### How to Reproduce?
   
   CREATE TABLE IF NOT EXISTS schema_change_dup_mv_regression_test (
                       `user_id` LARGEINT NOT NULL COMMENT "用户id",
                       `date` DATE NOT NULL COMMENT "数据灌入日期时间",
                       `city` VARCHAR(20) COMMENT "用户所在城市",
                       `age` SMALLINT COMMENT "用户年龄",
                       `sex` TINYINT COMMENT "用户性别",
                       `last_visit_date` DATETIME DEFAULT "1970-01-01 00:00:00" 
COMMENT "用户最后一次访问时间",
                       `last_update_date` DATETIME DEFAULT "1970-01-01 
00:00:00" COMMENT "用户最后一次更新时间",
                       `last_visit_date_not_null` DATETIME NOT NULL DEFAULT 
"1970-01-01 00:00:00" COMMENT "用户最后一次访问时间",
                       `cost` BIGINT DEFAULT "0" COMMENT "用户总消费",
                       `max_dwell_time` INT DEFAULT "0" COMMENT "用户最大停留时间",
                       `min_dwell_time` INT DEFAULT "99999" COMMENT "用户最小停留时间")
                   DUPLICATE KEY(`user_id`, `date`, `city`, `age`, `sex`) 
DISTRIBUTED BY HASH(`user_id`)
                   BUCKETS 1
                   PROPERTIES ( "replication_num" = "1", "light_schema_change" 
= "true" );
   
   create materialized view mv1 as select date, user_id, city, sum(age) from 
schema_change_dup_mv_regression_test group by date, user_id, city;
   
   INSERT INTO schema_change_dup_mv_regression_test VALUES
                   (1, '2017-10-01', 'Beijing', 10, 1, '2020-01-01', 
'2020-01-01', '2020-01-01', 1, 30, 20);
               
   INSERT INTO schema_change_dup_mv_regression_test VALUES
                   (1, '2017-10-01', 'Beijing', 10, 1, '2020-01-02', 
'2020-01-02', '2020-01-02', 1, 31, 19);
               
   INSERT INTO schema_change_dup_mv_regression_test VALUES
                   (2, '2017-10-01', 'Beijing', 10, 1, '2020-01-02', 
'2020-01-02', '2020-01-02', 1, 31, 21);
               
   INSERT INTO schema_change_dup_mv_regression_test VALUES
                   (2, '2017-10-01', 'Beijing', 10, 1, '2020-01-03', 
'2020-01-03', '2020-01-03', 1, 32, 20);
                   
   **set enable_nereids_planner=true;
   select sum(age) from schema_change_dup_mv_regression_test;** 
   F0330 20:16:34.413689 945194 assert_cast.h:49] Bad cast from 
type:doris::vectorized::ColumnVector<long> to 
doris::vectorized::ColumnVector<short>
   *** Check failure stack trace: ***
       @     0x555573b6f87d  google::LogMessage::Fail()
       @     0x555573b71db9  google::LogMessage::SendToLog()
       @     0x555573b6f3e6  google::LogMessage::Flush()
       @     0x555573b72429  google::LogMessageFatal::~LogMessageFatal()
       @     0x55556a39f0b2  assert_cast<>()
       @     0x55556cff1944  
doris::vectorized::ColumnVector<>::insert_range_from()
       @     0x55556cfba4b3  
doris::vectorized::ColumnNullable::insert_range_from()
       @     0x55556a428a51  doris::ExecNode::do_projections()
       @     0x55556a428d64  doris::ExecNode::get_next_after_projects()
       @     0x55556d235f0c  doris::vectorized::AggregationNode::open()
       @     0x55556a415085  
doris::PlanFragmentExecutor::open_vectorized_internal()
       @     0x55556a414b9b  doris::PlanFragmentExecutor::open()
       @     0x55556a3ce6c4  doris::FragmentExecState::execute()
       @     0x55556a3d2253  doris::FragmentMgr::_exec_actual()
       @     0x55556a3d2fb9  
_ZZN5doris11FragmentMgr18exec_plan_fragmentERKNS_23TExecPlanFragmentParamsERKSt8functionIFvPNS_12RuntimeStateEPNS_6StatusEEEENKUlvE_clEv
       @     0x55556a3dbeee  
_ZSt13__invoke_implIvRZN5doris11FragmentMgr18exec_plan_fragmentERKNS0_23TExecPlanFragmentParamsERKSt8functionIFvPNS0_12RuntimeStateEPNS0_6StatusEEEEUlvE_JEET_St14__invoke_otherOT0_DpOT1_
       @     0x55556a3dbb2e  
_ZSt10__invoke_rIvRZN5doris11FragmentMgr18exec_plan_fragmentERKNS0_23TExecPlanFragmentParamsERKSt8functionIFvPNS0_12RuntimeStateEPNS0_6StatusEEEEUlvE_JEENSt9enable_ifIX16is_invocable_r_vIT_T0_DpT1_EESH_E4typeEOSI_DpOSJ_
       @     0x55556a3db574  
_ZNSt17_Function_handlerIFvvEZN5doris11FragmentMgr18exec_plan_fragmentERKNS1_23TExecPlanFragmentParamsERKSt8functionIFvPNS1_12RuntimeStateEPNS1_6StatusEEEEUlvE_E9_M_invokeERKSt9_Any_data
       @     0x555569339a7c  std::function<>::operator()()
       @     0x55556a7e0e66  doris::FunctionRunnable::run()
       @     0x55556a7dec12  doris::ThreadPool::dispatch_thread()
       @     0x55556a7ed348  std::__invoke_impl<>()
       @     0x55556a7ecdb7  std::__invoke<>()
       @     0x55556a7ec5eb  
_ZNSt5_BindIFMN5doris10ThreadPoolEFvvEPS1_EE6__callIvJEJLm0EEEET_OSt5tupleIJDpT0_EESt12_Index_tupleIJXspT1_EEE
       @     0x55556a7ebaaf  std::_Bind<>::operator()<>()
       @     0x55556a7ea87e  std::__invoke_impl<>()
       @     0x55556a7e92a4  
_ZSt10__invoke_rIvRSt5_BindIFMN5doris10ThreadPoolEFvvEPS2_EEJEENSt9enable_ifIX16is_invocable_r_vIT_T0_DpT1_EESA_E4typeEOSB_DpOSC_
       @     0x55556a7e7407  std::_Function_handler<>::_M_invoke()
       @     0x555569339a7c  std::function<>::operator()()
       @     0x55556a7ccff1  doris::Thread::supervise_thread()
       @     0x7ffff779d17a  start_thread
       @     0x7ffff714adf3  __GI___clone
   
   mysql> explain verbose select sum(age) from 
schema_change_dup_mv_regression_test;
   
+--------------------------------------------------------------------------------------------------+
   | Explain String                                                             
                      |
   
+--------------------------------------------------------------------------------------------------+
   | PLAN FRAGMENT 0                                                            
                      |
   |   OUTPUT EXPRS:                                                            
                      |
   |     sum(age)[#16]                                                          
                      |
   |   PARTITION: HASH_PARTITIONED: user_id[#0]                                 
                      |
   |                                                                            
                      |
   |   VRESULT SINK                                                             
                      |
   |                                                                            
                      |
   |   1:VAGGREGATE (update finalize)                                           
                      |
   |   |  output: sum(age[#15])[#16]                                            
                      |
   |   |  group by:                                                             
                      |
   |   |  cardinality=1                                                         
                      |
   |   |  tuple ids: 2                                                          
                      |
   |   |                                                                        
                      |
   |   0:VOlapScanNode                                                          
                      |
   |      TABLE: 
default_cluster:bugfix.schema_change_dup_mv_regression_test(**mv1**), 
PREAGGREGATION: ON |
   |      partitions=1/1, tablets=1/1, tabletList=2136448                       
                      |
   |      cardinality=1, avgRowSize=0.0, numNodes=1                             
                      |
   |      projections: age[#3]                                                  
                      |
   |      project output tuple id: 1                                            
                      |
   |      tuple ids: 0                                                          
                      |
   |                                                                            
                      |
   | Tuples:                                                                    
                      |
   | TupleDescriptor{id=0, tbl=schema_change_dup_mv_regression_test, 
byteSize=4}                      |
   |   SlotDescriptor{id=3, col=age, colUniqueId=3, **type=SMALLINT,** 
nullable=true}                     |
   |                                                                            
                      |
   | TupleDescriptor{id=1, tbl=null, byteSize=4}                                
                      |
   |   SlotDescriptor{id=15, col=age, colUniqueId=3, **type=SMALLINT**, 
nullable=true}                    |
   |                                                                            
                      |
   | TupleDescriptor{id=2, tbl=null, byteSize=16}                               
                      |
   |   SlotDescriptor{id=16, col=null, colUniqueId=null, type=BIGINT, 
nullable=true}                  |
   
+--------------------------------------------------------------------------------------------------+
   30 rows in set (5.00 sec)
   
   when mv1 is selected, the "age" column's type should be bigint in mv1 not 
small int as in base index
   
   ### Anything Else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] 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

Reply via email to