[ 
https://issues.apache.org/jira/browse/FLINK-23761?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

zhengjiewen updated FLINK-23761:
--------------------------------
    Component/s: Table SQL / API

> FlinkSQL1.12 BatchMode Group By with INT type can not produce the correct 
> result
> --------------------------------------------------------------------------------
>
>                 Key: FLINK-23761
>                 URL: https://issues.apache.org/jira/browse/FLINK-23761
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / API, Table SQL / Planner
>    Affects Versions: 1.12.2
>            Reporter: zhengjiewen
>            Priority: Major
>         Attachments: image-2021-08-13-16-08-31-970.png, 
> image-2021-08-13-16-09-19-951.png
>
>
> When Run a Flink Sql which have Group By oprator, and filed type is INT 
> type,the result is incorrect.
> I try to CAST the field to BIGINT type OR STRING type, the result is correct.
> the SQL is folllow: 【receipt_year ,receipt_month {color:#172b4d}is INT 
> type{color} 】
> {code:java}
>  "     SELECT " +
>                 "        ware_id, " +
>                 "        supplier_id," +
>                 "        supplier_name," +
>                 "        receipt_year as years, " +
>                 "        receipt_month  as months, " +
>                 "        SUM(COALESCE(receipt_count,0) * COALESCE(price,0.0)) 
> / SUM(COALESCE(receipt_count,0)) as supply_avg_price" +
>                 "     FROM " +
>                 "        
> `kudu`.`default_database`.`impala::cube_kudu.dwd_storage_purchase_receipt` " +
>                 "     WHERE " +
>                 "        receipt_date BETWEEN TO_TIMESTAMP('"+ beginTime +"') 
> AND TO_TIMESTAMP('"+ endTime +"') " +
>                 "     GROUP BY " +
>                 "        ware_id, supplier_id, supplier_name, receipt_year , 
> receipt_month "
> {code}
> {color:#172b4d}Here is the execution plan:{color}
> {color:#172b4d}!image-2021-08-13-16-08-31-970.png!{color}
>  
> {color:#172b4d}When I CAST to another type like BIGINT, the plan is 
> this:{color}
> {color:#172b4d}!image-2021-08-13-16-09-19-951.png!{color}
>  
> DDL:
> {code:java}
> CREATE TABLE cube_kudu.dwd_storage_purchase_receipt (
>          receipt_date TIMESTAMP comment '采购入库日期(审核时间)',
>           ware_id STRING COMMENT '商品ID',
>           supplier_id STRING COMMENT '供应商ID',
>           supplier_name STRING COMMENT '供应商名称',
>         receipt_year INT COMMENT '入库年份',    
>          receipt_month INT COMMENT '入库月份',
>           receipt_count DECIMAL(18, 4) COMMENT '入库数量',
>          price DECIMAL(18,4) COMMENT '采购商品单价',
>     PRIMARY key (receipt_date, ware_id)  
>   }
> PARTITION BY HASH(receipt_date) PARTITIONS 8
> STORED AS KUDU;
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to