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

   ### 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
   
   doris 2.0.3
   
   ### What's Wrong?
   
   exec sql
   ```sql
   select
        count(*) total_records
   from
        (with purchase_tmp as (
        select
                t1.seq_no ,
                t1.superior_com_name ,
                t3.bill_id  
        from
                dwt.dwt_purchase_order_detail_wt t1
        inner join app.app_bill_main_status_v t3 on
                t1.order_id = t3.biz_id
                and t3.bill_type = 25
                and t3.bill_status in (20, 40, 45, 50, 60)
     )
        select
                t1.superior_com_name as "companyName" ,
                concat('[', nvl(t2.bill_info, ''), ']') as "billDetail" ,
                round(t2.tot_amt, 2) as "billAmt" 
        from
                purchase_tmp t1
        left join (
        select
                t1.bill_main_id,
                GROUP_CONCAT( JSON_OBJECT( 'costName', t1.cost_name /** 费用类型 
*/, 'supplier', t1.biz_item_extend_name /** 供应商 */, 'payType', t2.std_code_desc 
/** 支付方式 */, 'amount', t1.cost_amt_rmb /** 费用金额 */, 'bearer', 
t1.undertake_method /** 费用承担方 */, 'remark', t1.remark_1 ) ) as bill_info,
                sum(nvl(cost_amt_rmb, 0)) as tot_amt 
        from
                (
                select
                        t1.bill_id as bill_main_id ,
                        t3.cost_name ,
                        t3.biz_item_extend_name ,
                        t3.payment_type ,
                        t3.cost_amt_rmb ,
                        t3.remark_1 ,
                        '我方承担(对方填写)' as undertake_method
                from
                        purchase_tmp t1
                inner join dwt.dwt_sales_order_wt t2 on
                        t1.seq_no = t2.seq_no
                inner join dwt.dwt_bill_cost_wt t3 on
                        t2.bill_main_id = t3.bill_main_id
                        and t3.deleted = 99
                        and t3.bill_item_type = 20
                        and t3.undertake_method = 20
        union all
                select
                        t2.bill_main_id ,
                        t2.cost_name ,
                        t2.biz_item_extend_name ,
                        t2.payment_type ,
                        t2.cost_amt_rmb ,
                        t2.remark_1 ,
                        '我方承担' as undertake_method
                from
                        purchase_tmp t1
                inner join dwt.dwt_bill_cost_wt t2 on
                        t1.bill_id = t2.bill_main_id
                        and t2.deleted = 99
                        and t2.bill_item_type = 20 ) t1
        left join dim.dim_code_std_type t2 on
                t1.payment_type = t2.std_code
                and t2.from_schema_name = 'dwt'
                and t2.from_table_name = 'dwt_bill_cost_wt'
                and t2.from_column_name = 'payment_type'
        group by
                t1.bill_main_id ) t2 on
                t1.bill_id = t2.bill_main_id
     ) total_records_tmp_table
   ```
   
   error: couldn't resolve slot descriptor 445
   ```text
   SQL 错误 [1105] [HY000]: errCode = 2, detailMessage = 
(192.168.10.250)[INTERNAL_ERROR]couldn't resolve slot descriptor 445, desc: 
tuples:
   Tuple(id=84 slots=[Slot(id=812 type=BIGINT col=-1, colname=bill_main_id, 
nullable=1), Slot(id=813 type=VARCHAR col=-1, colname=, nullable=1), 
Slot(id=814 type=DECIMAL128(38, 4) col=-1, colname=, nullable=1)] 
has_varlen_slots=1)
   Tuple(id=83 slots=[Slot(id=810 type=BIGINT col=-1, colname=order_id, 
nullable=1), Slot(id=811 type=BIGINT col=-1, colname=bill_main_id, nullable=1)] 
has_varlen_slots=0)
   Tuple(id=82 slots=[Slot(id=804 type=VARCHAR col=-1, colname=std_code, 
nullable=1), Slot(id=805 type=VARCHAR col=-1, colname=from_schema_name, 
nullable=1), Slot(id=806 type=VARCHAR col=-1, colname=from_table_name, 
nullable=1), Slot(id=807 type=VARCHAR col=-1, colname=from_column_name, 
nullable=1), Slot(id=808 type=VARCHAR col=-1, colname=std_code_desc, 
nullable=1), Slot(id=809 type=TINYINT col=-1, colname=__DORIS_DELETE_SIGN__, 
nullable=1)] has_varlen_slots=1)
   ..................
   ```
   
   But when I replaced `union all` with `union` ,  the query is ok
   And in doris-1.2.4 the query is ok
   
   
   ### What You Expected?
   
   Can be executed
   
   ### How to Reproduce?
   
   _No response_
   
   ### 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