zoukankan      html  css  js  c++  java
  • 【翻译】Flink Table Api & SQL — Hive —— 在 scala shell 中使用 Hive 连接器

    本文翻译自官网:Use Hive connector in scala shell  https://ci.apache.org/projects/flink/flink-docs-release-1.9/dev/table/hive/scala_shell_hive.html

    Flink Table Api & SQL 翻译目录

     Flink Scala Shell 是尝试 flink 的便捷方法。 您也可以在 scala shell 中使用 hive,而不是在pom文件中指定 hive 依赖关系,打包程序并通过flink run命令提交。 为了在scala shell中使用 hive 连接器,您需要将以下hive 连接器依赖项放在flink dist的lib文件夹下。

    • flink-connector-hive_ {scala_version}-{flink.version} .jar
    • flink-hadoop-compatibility_ {scala_version}-{flink.version} .jar
    • flink-shaded-hadoop-2-uber- {hadoop.version}-{flink-shaded.version} .jar
    • hive-exec-2.x.jar(对于Hive 1.x,您需要复制hive-exec-1.x.jar,hive-metastore-1.x.jar,libfb303-0.9.2.jar和libthrift- 0.9.2.jar)

    然后,您可以在scala shell 中使用 hive 连接器,如下所示:

    Scala-Flink> import org.apache.flink.table.catalog.hive.HiveCatalog
    Scala-Flink> val hiveCatalog = new HiveCatalog("hive", "default", "<Replace it with HIVE_CONF_DIR>", "2.3.4");
    Scala-Flink> btenv.registerCatalog("hive", hiveCatalog)
    Scala-Flink> btenv.useCatalog("hive")
    Scala-Flink> btenv.listTables
    Scala-Flink> btenv.sqlQuery("<sql query>").toDataSet[Row].print()

    欢迎关注Flink菜鸟公众号,会不定期更新Flink(开发技术)相关的推文

     

  • 相关阅读:
    IntentService源码分析
    startService过程源码分析
    洛谷P3300 城市规划
    agc033
    洛谷P3306 随机数生成器
    洛谷P3299 保护出题人
    洛谷P3298 泉
    洛谷P3296 刺客信条
    树hash
    我们都爱膜您退火!
  • 原文地址:https://www.cnblogs.com/Springmoon-venn/p/11982327.html
Copyright © 2011-2022 走看看