You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by bl...@apache.org on 2019/08/15 17:59:52 UTC

[flink] branch release-1.9 updated: [FLINK-13415][docs] Document how to use hive connector in scala shell

This is an automated email from the ASF dual-hosted git repository.

bli pushed a commit to branch release-1.9
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.9 by this push:
     new 9e846ac  [FLINK-13415][docs] Document how to use hive connector in scala shell
9e846ac is described below

commit 9e846acc3e60edad77b0f4c8efe75bfaf1b60e4e
Author: Jeff Zhang <zj...@apache.org>
AuthorDate: Thu Jul 25 15:48:27 2019 +0800

    [FLINK-13415][docs] Document how to use hive connector in scala shell
    
    The purpose of this PR is to add docs about how to use hive connector in scala shell via table api.
    
    This closes #9233.
---
 docs/dev/table/hive/scala_shell_hive.md    | 43 ++++++++++++++++++++++++++++++
 docs/dev/table/hive/scala_shell_hive.zh.md | 43 ++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)

diff --git a/docs/dev/table/hive/scala_shell_hive.md b/docs/dev/table/hive/scala_shell_hive.md
new file mode 100644
index 0000000..b9e9155
--- /dev/null
+++ b/docs/dev/table/hive/scala_shell_hive.md
@@ -0,0 +1,43 @@
+---
+title: "Use Hive connector in scala shell"
+nav-parent_id: hive_tableapi
+nav-pos: 3
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+[Flink Scala Shell]({{ site.baseurl }}/ops/scala_shell.html) is a convenient quick way to try flink. 
+You can use hive in scala shell as well instead of specifying hive dependencies in pom file, packaging your program and submitting it via flink run command.
+In order to use hive connector in scala shell, you need to put the following [hive connector dependencies]({{ site.baseurl }}/dev/table/hive/#depedencies) under lib folder of flink dist .
+
+* 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 (for Hive 1.x, you need to copy hive-exec-1.x.jar, hive-metastore-1.x.jar, libfb303-0.9.2.jar and libthrift-0.9.2.jar)
+
+Then you can use hive connector in scala shell like following:
+
+{% highlight scala %}
+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()
+{% endhighlight %}
diff --git a/docs/dev/table/hive/scala_shell_hive.zh.md b/docs/dev/table/hive/scala_shell_hive.zh.md
new file mode 100644
index 0000000..b9e9155
--- /dev/null
+++ b/docs/dev/table/hive/scala_shell_hive.zh.md
@@ -0,0 +1,43 @@
+---
+title: "Use Hive connector in scala shell"
+nav-parent_id: hive_tableapi
+nav-pos: 3
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+[Flink Scala Shell]({{ site.baseurl }}/ops/scala_shell.html) is a convenient quick way to try flink. 
+You can use hive in scala shell as well instead of specifying hive dependencies in pom file, packaging your program and submitting it via flink run command.
+In order to use hive connector in scala shell, you need to put the following [hive connector dependencies]({{ site.baseurl }}/dev/table/hive/#depedencies) under lib folder of flink dist .
+
+* 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 (for Hive 1.x, you need to copy hive-exec-1.x.jar, hive-metastore-1.x.jar, libfb303-0.9.2.jar and libthrift-0.9.2.jar)
+
+Then you can use hive connector in scala shell like following:
+
+{% highlight scala %}
+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()
+{% endhighlight %}