how to set table.sql-dialect in flink1.11 StreamTableEnvironment

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to set table.sql-dialect in flink1.11 StreamTableEnvironment

Zhou Zach
hi all,


我像下面那种方式尝试,报错了


streamTableEnv.executeSql(
"""
    |
    |
    |SET table.sql-dialect=hive;
    |CREATE TABLE hive_table (
    |  user_id STRING,
    |  age INT
    |) PARTITIONED BY (dt STRING, hr STRING) STORED AS parquet TBLPROPERTIES (
    |  'partition.time-extractor.timestamp-pattern'='$dt $hr:00:00',
    |  'sink.partition-commit.trigger'='partition-time',
    |  'sink.partition-commit.delay'='1 h',
    |  'sink.partition-commit.policy.kind'='metastore,success-file'
    |)
    |
    |""".stripMargin)


错误栈:
Exception in thread "main" org.apache.flink.table.api.SqlParserException: SQL parse failed. Encountered "table" at line 4, column 5.
Was expecting one of:
    <BRACKET_QUOTED_IDENTIFIER> ...
    <QUOTED_IDENTIFIER> ...
    <BACK_QUOTED_IDENTIFIER> ...
    <IDENTIFIER> ...
    <UNICODE_QUOTED_IDENTIFIER> ...
   
        at org.apache.flink.table.planner.calcite.CalciteParser.parse(CalciteParser.java:56)
        at org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:76)
        at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeSql(TableEnvironmentImpl.java:678)

Reply | Threaded
Open this post in threaded view
|

Re:how to set table.sql-dialect in flink1.11 StreamTableEnvironment

Zhou Zach
找到了:
tableEnv.getConfig().setSqlDialect(SqlDialect.HIVE);

















在 2020-07-13 14:01:45,"Zhou Zach" <[hidden email]> 写道:

>hi all,
>
>
>我像下面那种方式尝试,报错了
>
>
>streamTableEnv.executeSql(
>"""
>    |
>    |
>    |SET table.sql-dialect=hive;
>    |CREATE TABLE hive_table (
>    |  user_id STRING,
>    |  age INT
>    |) PARTITIONED BY (dt STRING, hr STRING) STORED AS parquet TBLPROPERTIES (
>    |  'partition.time-extractor.timestamp-pattern'='$dt $hr:00:00',
>    |  'sink.partition-commit.trigger'='partition-time',
>    |  'sink.partition-commit.delay'='1 h',
>    |  'sink.partition-commit.policy.kind'='metastore,success-file'
>    |)
>    |
>    |""".stripMargin)
>
>
>错误栈:
>Exception in thread "main" org.apache.flink.table.api.SqlParserException: SQL parse failed. Encountered "table" at line 4, column 5.
>Was expecting one of:
>    <BRACKET_QUOTED_IDENTIFIER> ...
>    <QUOTED_IDENTIFIER> ...
>    <BACK_QUOTED_IDENTIFIER> ...
>    <IDENTIFIER> ...
>    <UNICODE_QUOTED_IDENTIFIER> ...
>    
> at org.apache.flink.table.planner.calcite.CalciteParser.parse(CalciteParser.java:56)
> at org.apache.flink.table.planner.delegation.ParserImpl.parse(ParserImpl.java:76)
> at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeSql(TableEnvironmentImpl.java:678)
>