You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/08/06 12:22:16 UTC

[GitHub] [flink] WeiZhong94 commented on a change in pull request #13077: [FLINK-18839][docs] Add documentation about how to use catalog in Python Table API

WeiZhong94 commented on a change in pull request #13077:
URL: https://github.com/apache/flink/pull/13077#discussion_r466370837



##########
File path: docs/dev/table/connectors/jdbc.md
##########
@@ -375,6 +375,38 @@ tableEnv.registerCatalog("mypg", catalog)
 tableEnv.useCatalog("mypg")
 {% endhighlight %}
 </div>
+<div data-lang="Python" markdown="1">
+{% highlight python %}
+from pyflink.table.catalog import Catalog
+
+class JdbcCatalog(Catalog):
+    """
+    A catalog implementation for Jdbc.
+    """
+    def __init__(self, catalog_name, default_database, username, pwd, base_url):
+        from pyflink.java_gateway import get_gateway
+        gateway = get_gateway()
+
+        j_jdbc_catalog = gateway.jvm.org.apache.flink.connector.jdbc.catalog.JdbcCatalog(
+            catalog_name, default_database, username, pwd, base_url)
+        super(JdbcCatalog, self).__init__(j_jdbc_catalog)
+
+environment_settings=EnvironmentSettings.new_instance().in_streaming_mode().use_blink_planner().build()

Review comment:
       add space before and after the '='?

##########
File path: docs/dev/table/hive/hive_dialect.zh.md
##########
@@ -80,6 +82,22 @@ tableEnv.getConfig().setSqlDialect(SqlDialect.HIVE);
 tableEnv.getConfig().setSqlDialect(SqlDialect.DEFAULT);
 
 {% endhighlight %}
+</div>
+<div data-lang="Python" markdown="1">
+{% highlight python %}
+from pyflink.table import *
+
+settings = EnvironmentSettings.new_instance().in_batch_mode().use_blink_planner().build()
+t_env = StreamTableEnvironment.create(environment_settings=settings)

Review comment:
       BatchTableEnvironment?

##########
File path: docs/dev/table/catalogs.md
##########
@@ -212,6 +233,59 @@ catalog.createTable(
     
 val tables = catalog.listTables("mydb") // tables should contain "mytable"
 {% endhighlight %}
+</div>
+<div data-lang="Python" markdown="1">
+{% highlight python %}
+from pyflink.table import *
+from pyflink.table.catalog import HiveCatalog, CatalogDatabase, ObjectPath, CatalogBaseTable
+from pyflink.table.descriptors import Kafka
+
+settings = EnvironmentSettings.new_instance().in_batch_mode().use_blink_planner().build()
+t_env = StreamTableEnvironment.create(environment_settings=settings)

Review comment:
       BatchTableEnvironment?

##########
File path: docs/dev/table/connectors/jdbc.zh.md
##########
@@ -375,6 +375,38 @@ tableEnv.registerCatalog("mypg", catalog)
 tableEnv.useCatalog("mypg")
 {% endhighlight %}
 </div>
+<div data-lang="Python" markdown="1">
+{% highlight python %}
+from pyflink.table.catalog import Catalog
+
+class JdbcCatalog(Catalog):
+    """
+    A catalog implementation for Jdbc.
+    """
+    def __init__(self, catalog_name, default_database, username, pwd, base_url):
+        from pyflink.java_gateway import get_gateway
+        gateway = get_gateway()
+
+        j_jdbc_catalog = gateway.jvm.org.apache.flink.connector.jdbc.catalog.JdbcCatalog(
+            catalog_name, default_database, username, pwd, base_url)
+        super(JdbcCatalog, self).__init__(j_jdbc_catalog)
+
+environment_settings=EnvironmentSettings.new_instance().in_streaming_mode().use_blink_planner().build()

Review comment:
       ditto

##########
File path: docs/dev/table/hive/index.md
##########
@@ -336,6 +338,25 @@ tableEnv.registerCatalog("myhive", hive)
 tableEnv.useCatalog("myhive")
 {% endhighlight %}
 </div>
+<div data-lang="Python" markdown="1">
+{% highlight python %}
+from pyflink.table import *
+from pyflink.table.catalog import HiveCatalog
+
+settings = EnvironmentSettings.new_instance().in_batch_mode().use_blink_planner().build()
+t_env = StreamTableEnvironment.create(environment_settings=settings)

Review comment:
       ditto

##########
File path: docs/dev/table/hive/index.zh.md
##########
@@ -331,6 +333,26 @@ tableEnv.registerCatalog("myhive", hive)
 tableEnv.useCatalog("myhive")
 {% endhighlight %}
 </div>
+</div>
+<div data-lang="Python" markdown="1">
+{% highlight python %}
+from pyflink.table import *
+from pyflink.table.catalog import HiveCatalog
+
+settings = EnvironmentSettings.new_instance().in_batch_mode().use_blink_planner().build()
+t_env = StreamTableEnvironment.create(environment_settings=settings)

Review comment:
       ditto




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org