You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
select sum(hd.paid_amount) from
(
SELECT 'fl',cast(a.hosted_ymd as date) as hosted_ymd,a.user_id,'boss1',a.paid_amount,m.user_id,m.create_date,m.pmcode,n.type_name,n.product_name,n.acctype_id,n.acctype_name,n.account_name,n.plan
FROM hive.bdc_dwd.dw_mk_copyright_order a
left join hive.bdc_dwd.dw_mk_chance b on (a.chance_id=b.chance_id and b.acct_day='03')
left join hive.bdc_dwd.dw_lg_stat_user m on (a.user_id =m.user_id and m.acct_day='03')
left join hive.bdc_dwd.dw_lg_pmcode n on (m.pmcode=n.id and n.acct_day='03')
where a.hosted_ymd between '2016-01-01' and '2017-06-30' and b.chance_type_group=3
and a.acct_day='03'
union
select 'fl',b.paid_date as hosted_ymd,b.user_id,'boss2',b.paid_amount,m.user_id,m.create_date,m.pmcode,n.type_name,n.product_name,n.acctype_id,n.acctype_name,n.account_name,n.plan
from hive.bdc_dwd.dw_fx_chance a
left join hive.bdc_dwd.dw_fx_chance_order b on (a.chance_id=b.chance_id and b.acct_day='03')
left join hive.bdc_dwd.dw_lg_stat_user m on (a.user_id =m.user_id and m.acct_day='03')
left join hive.bdc_dwd.dw_lg_pmcode n on (m.pmcode=n.id and n.acct_day='03')
where a.project_id=1 and b.paid_amount>0 and cast(b.paid_date as varchar(10))>='2016-01-01' and
cast(b.paid_date as varchar(10))<='2017-06-30' and b.state=1 and a.acct_day='03'
)hd
我有一个比较复杂一点的sql:
使用Druid Mysql语法解析后得到的结果不正确:
1、别名映射不对,在有union这种情况下,且union两边都有相同别名时,映射会出现覆盖和错乱

对于a和b两个别名,对于union来说在两个子句下面别名对应了不同的数据表。而aliasMap中只解析出了基中的一部分。
2、因上面别名映射错乱的原因,对于别名无法正确解析到字段上,可能导致字段与数据表的归属出现问题:

b.paid_date 实际上是 dw_fx_chance_order表(别名:b)的字段。 而解析引擎解析成另一张表的字段。猜想可能与别名重复和覆盖有关。
这也许是一个bug,温少可以看看。
The text was updated successfully, but these errors were encountered: