你好,

是否能尝试一下用hive dialect建表呢?

On Mon, Jul 26, 2021 at 2:44 PM Asahi Lee <[email protected]> wrote:

> hi!
> 我使用flink 1.13.1版本,通过sql创建hive表,程序正常运行,表创建成功,但是没有列信息;我的程序如下:
> 我连接的是hive 2.3.6版本,使用flink-sql-connector-hive-2.3.6依赖包。
>
>
> package com.meritdata.cloud.flink.test;
>
>
> import org.apache.flink.table.api.EnvironmentSettings;
> import org.apache.flink.table.api.TableEnvironment;
>
>
> public class Test {
>
>
> &nbsp; &nbsp; public static void main(String[] args) {
>
>
> &nbsp; &nbsp; &nbsp; &nbsp; EnvironmentSettings bbSettings =
> EnvironmentSettings.newInstance().useBlinkPlanner().inBatchMode().build();
> &nbsp; &nbsp; &nbsp; &nbsp; TableEnvironment tableEnvironment =
> TableEnvironment.create(bbSettings);
>
>
> &nbsp; &nbsp; &nbsp; &nbsp; tableEnvironment.executeSql("create catalog
> myhive with (" +
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; " 'type' = 'hive',
> " +
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "
> 'default-database' = 'default', " +
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ")");
>
>
> &nbsp; &nbsp; &nbsp; &nbsp; tableEnvironment.executeSql("use catalog
> myhive");
> &nbsp; &nbsp; &nbsp; &nbsp; tableEnvironment.executeSql("create table if
> not exists q1 " +
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "( id string ) " +
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "with
> ('is_generic' = 'false')");
>
>
> &nbsp; &nbsp; &nbsp; &nbsp; /**
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* hive上表创建成功,没有列, 信息如下
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* desc formatted q1;
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* col_name&nbsp; &nbsp; &nbsp; &nbsp;
> &nbsp; &nbsp; &nbsp; data_type&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
> &nbsp;comment
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Table Parameters:
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* flink.is_generic&nbsp; &nbsp; false
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* flink.schema.0.data-type&nbsp;
> VARCHAR(2147483647)
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* flink.schema.0.name&nbsp; &nbsp;id
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* transient_lastDdTime 1627279802
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/
>
>
> &nbsp; &nbsp; }
>
>
>
>
> }



-- 
Best regards!
Rui Li

回复