Org.Apache.calcite.runtime.CalciteException: Faile

2019-07-17 04:06发布

问题:

select
t1.city_name
from
(
        select
        '全国' as city_name
        from
        stg.t_vip

        union all

        select
                cc.city_name
        from
                stg.t_city_config cc
        join
                stg.t_vip v
        on
                v.city_id = cc.city_id
) t1
full join
(
 select
 '全国' as city_name
   from
     stg.t_vip_trade
 ) t2
on
t1.city_name = t2.city_name;

select
t1.city_name
from
(
        select
        '全国' as city_name
        from
        stg.t_vip

        union all

        select
                cc.city_name
        from
                stg.t_city_config cc
) t1
full join
(
 select
 '全国' as city_name
   from
     stg.t_vip_trade
 ) t2
on
t1.city_name = t2.city_name;

Why the second SQL is OK while the first one post an error:

Failed to encode '全国' in character set 'ISO-8859-1'

回答1:

May add such code :

System.setProperty("saffron.default.charset",ConversionUtil.NATIVE_UTF16_CHARSET_NAME); System.setProperty("saffron.default.nationalcharset",ConversionUtil.NATIVE_UTF16_CHARSET_NAME); System.setProperty("saffron.default.collation.name",ConversionUtil.NATIVE_UTF16_CHARSET_NAME + "$en_US");



回答2:

Because 全国 are letters not included in ISO-8859-1. Make sure, you use UTF-8 or UTF-16 instead.



标签: sql hive encode