You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2019/03/05 15:53:13 UTC

[hive] 01/02: HIVE-21383: JDBC storage handler: Use catalog and schema to retrieve tables if specified (Jesus Camacho Rodriguez, reviewed by Daniel Dai)

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

jcamacho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 911e1eb4b09bb369dc1962396bdd92617cd2e63c
Author: Jesus Camacho Rodriguez <jc...@apache.org>
AuthorDate: Mon Mar 4 14:41:54 2019 -0800

    HIVE-21383: JDBC storage handler: Use catalog and schema to retrieve tables if specified (Jesus Camacho Rodriguez, reviewed by Daniel Dai)
---
 common/src/java/org/apache/hadoop/hive/conf/Constants.java      | 2 ++
 ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/common/src/java/org/apache/hadoop/hive/conf/Constants.java b/common/src/java/org/apache/hadoop/hive/conf/Constants.java
index ee954d9..a2e6f49 100644
--- a/common/src/java/org/apache/hadoop/hive/conf/Constants.java
+++ b/common/src/java/org/apache/hadoop/hive/conf/Constants.java
@@ -45,6 +45,8 @@ public class Constants {
   public static final String JDBC_HIVE_STORAGE_HANDLER_ID =
       "org.apache.hive.storage.jdbc.JdbcStorageHandler";
   public static final String JDBC_CONFIG_PREFIX = "hive.sql";
+  public static final String JDBC_CATALOG = JDBC_CONFIG_PREFIX + ".catalog";
+  public static final String JDBC_SCHEMA = JDBC_CONFIG_PREFIX + ".schema";
   public static final String JDBC_TABLE = JDBC_CONFIG_PREFIX + ".table";
   public static final String JDBC_DATABASE_TYPE = JDBC_CONFIG_PREFIX + ".database.type";
   public static final String JDBC_URL = JDBC_CONFIG_PREFIX + ".jdbc.url";
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
index de88783..a7b9e62 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java
@@ -2945,12 +2945,14 @@ public class CalcitePlanner extends SemanticAnalyzer {
               String key = tabMetaData.getProperty(Constants.JDBC_KEY);
               pswd = Utilities.getPasswdFromKeystore(keystore, key);
             }
+            final String catalogName = tabMetaData.getProperty(Constants.JDBC_CATALOG);
+            final String schemaName = tabMetaData.getProperty(Constants.JDBC_SCHEMA);
             final String tableName = tabMetaData.getProperty(Constants.JDBC_TABLE);
 
             DataSource ds = JdbcSchema.dataSource(url, driver, user, pswd);
             SqlDialect jdbcDialect = JdbcSchema.createDialect(SqlDialectFactoryImpl.INSTANCE, ds);
             JdbcConvention jc = JdbcConvention.of(jdbcDialect, null, dataBaseType);
-            JdbcSchema schema = new JdbcSchema(ds, jc.dialect, jc, null/*catalog */, null/*schema */);
+            JdbcSchema schema = new JdbcSchema(ds, jc.dialect, jc, catalogName, schemaName);
             JdbcTable jt = (JdbcTable) schema.getTable(tableName);
             if (jt == null) {
               throw new SemanticException("Table " + tableName + " was not found in the database");