You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by "kandy.wang" <ka...@163.com> on 2020/09/23 09:34:19 UTC

flink sql grouping sets语义中NOT NULL不生效

sql如下:
select
           (case when act_name is not null then  act_name else 'default_value' end) as act_name,
           (case when fst_plat is not null then  fst_plat  else 'default_value' end) as fst_plat,
            sum(amount) as saleN
    from  hive.temp_dw.view_trad_order_goods_source_act_last_value
    group by  grouping sets((act_name),(act_name,fst_plat)


 而hive.temp_dw.view_trad_order_goods_source_act_last_value 是一个 view,view的结构如下:
Flink SQL> desc hive.temp_dw.view_trad_order_goods_source_act_last_value
 |-- act_name: STRING
 |-- fst_plat: STRING NOT NULL   
  ......
 其中fst_plat 数据类型为:STRING NOT NULL ,在grouping sets的(act_name)条件分支时,fst_plat不参与group,
 实际测下来发现 (case when fst_plat is not null then  fst_plat  else 'default_value' end) as fst_plat 输出的结果都没走到 else的default_value
 感觉 fst_plat is not null 不生效。 感觉是和fst_plat: STRING NOT NULL  这个条件有关系。有这个条件限制时,就破坏了NOT NULL的语义。