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

liyang updated KYLIN-3047:
--------------------------
    Labels: scope  (was: )

> Wrong column type when sync hive table via beeline
> --------------------------------------------------
>
>                 Key: KYLIN-3047
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3047
>             Project: Kylin
>          Issue Type: Bug
>            Reporter: liyang
>              Labels: scope
>
> Thanks chenglong.fu <chenglong...@mljr.com> reporting this issue. Below 
> quotes from his email.
> The origin table looks like:
> {code}
> 75    is_scene        char(2) 客户是否在现场
> 76    reference_code  varchar(50)     推荐人代码
> 77    reference_jgcode        varchar(50)     推荐人机构代码
> 78    applicationagreementbarcode     varchar(50)     领用合约代码
> 79    remakes varchar(1000)   备注信息
> 80    data_idn        char(1) 数据标示C-渠道,D-直销
> 81    source_type     varchar(20)     源系统
> 82    lst_up_time     timestamp       上一次更新日期
> 83    data_date       date    数据日期 
> {code}
> After import, it becomes in Kylin:
> {code}
> 62    IS_CERT_ALL     char(256)       2       
> 63    IS_SCENE        char(256)       4       客户是否在现场 
> 64    REFERENCE_CODE  varchar(256)    33      推荐人代码 
> 65    REFERENCE_JGCODE        varchar(256)    16      推荐人机构代码 
> 66    APPLICATIONAGREEMENTBARCODE     varchar(256)    12504   领用合约代码 
> 67    REMAKES         varchar(256)    2       备注信息 
> 68    DATA_IDN        char(256)       2       数据标示C-渠道,D-直销 
> 69    SOURCE_TYPE     varchar(256)    2       源系统 
> 70    LST_UP_TIME     timestamp       1       上一次更新日期 
> 71    DATA_DATE       date    1       数据日期
> {code}
> Code analysis leads to {{org.apache.kylin.source.hive.BeelineHiveClient}}:
> {code}
> public HiveTableMeta getHiveTableMeta(String database, String tableName) 
> throws SQLException {
>     ResultSet columns = metaData.getColumns(null, database, tableName, null);
>     HiveTableMetaBuilder builder = new HiveTableMetaBuilder();
>     builder.setTableName(tableName);
>     List<HiveTableMeta.HiveTableColumnMeta> allColumns = Lists.newArrayList();
>     while (columns.next()) {
>         allColumns.add(new 
> HiveTableMeta.HiveTableColumnMeta(columns.getString(4), columns.getString(6), 
> columns.getString(12)));
>     }
>     builder.setAllColumns(allColumns);
>     DBUtils.closeQuietly(columns);
>     stmt.execute("use " + database);
>     ResultSet resultSet = stmt.executeQuery("describe formatted " + 
> tableName);
>     extractHiveTableMeta(resultSet, builder);
>     DBUtils.closeQuietly(resultSet);
>     return builder.createHiveTableMeta();
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to