hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject hive git commit: HIVE-17765 : expose Hive keywords (Sergey Shelukhin, reviewed by Thejas M Nair)
Date Wed, 25 Oct 2017 19:39:12 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-2 680963707 -> 7093e5313


HIVE-17765 : expose Hive keywords (Sergey Shelukhin, reviewed by Thejas M Nair)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/7093e531
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/7093e531
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/7093e531

Branch: refs/heads/branch-2
Commit: 7093e531384591c27a5d967d890472ae224a18f2
Parents: 6809637
Author: sergey <sershe@apache.org>
Authored: Wed Oct 25 12:24:52 2017 -0700
Committer: sergey <sershe@apache.org>
Committed: Wed Oct 25 12:30:42 2017 -0700

----------------------------------------------------------------------
 .../org/apache/hive/jdbc/TestJdbcDriver2.java   |  8 ++++
 .../apache/hive/jdbc/HiveDatabaseMetaData.java  |  8 ++--
 .../apache/hadoop/hive/ql/parse/ParseUtils.java | 37 ++++++++++++------
 service-rpc/if/TCLIService.thrift               |  1 +
 .../gen/thrift/gen-cpp/TCLIService_types.cpp    |  8 ++--
 .../src/gen/thrift/gen-cpp/TCLIService_types.h  |  3 +-
 .../hive/service/rpc/thrift/TGetInfoType.java   |  5 ++-
 service-rpc/src/gen/thrift/gen-php/Types.php    |  2 +
 .../src/gen/thrift/gen-py/TCLIService/ttypes.py |  3 ++
 .../gen/thrift/gen-rb/t_c_l_i_service_types.rb  |  5 ++-
 .../apache/hive/service/cli/GetInfoType.java    |  3 +-
 .../service/cli/session/HiveSessionImpl.java    | 40 +++++++++++++++++++-
 12 files changed, 99 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
index 6e9223a..7223fcb 100644
--- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
+++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
@@ -1466,6 +1466,14 @@ public class TestJdbcDriver2 {
     DatabaseMetaData meta = con.getMetaData();
 
     assertEquals("Apache Hive", meta.getDatabaseProductName());
+    String[] keywords = meta.getSQLKeywords().toLowerCase().split(",");
+    // Check a random one. These can change w/Hive versions.
+    boolean found = false;
+    for (String keyword : keywords) {
+     found = "limit".equals(keyword);
+     if (found) break;
+    }
+    assertTrue(found);
     assertEquals(HiveVersionInfo.getVersion(), meta.getDatabaseProductVersion());
     assertEquals(System.getProperty("hive.version"), meta.getDatabaseProductVersion());
     assertTrue("verifying hive version pattern. got " + meta.getDatabaseProductVersion(),

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
----------------------------------------------------------------------
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java b/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
index e3bdb68..862c926 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
@@ -579,11 +579,13 @@ public class HiveDatabaseMetaData implements DatabaseMetaData {
   public RowIdLifetime getRowIdLifetime() throws SQLException {
     throw new SQLFeatureNotSupportedException("Method not supported");
   }
-
   public String getSQLKeywords() throws SQLException {
-    throw new SQLFeatureNotSupportedException("Method not supported");
+    // Note: the definitions of what ODBC and JDBC keywords exclude are different in different
+    //       places. For now, just return the ODBC version here; that excludes Hive keywords

+    //       that are also ODBC reserved keywords. We could also exclude SQL:2003.
+    TGetInfoResp resp = getServerInfo(GetInfoType.CLI_ODBC_KEYWORDS.toTGetInfoType());
+    return resp.getInfoValue().getStringValue();
   }
-
   public int getSQLStateType() throws SQLException {
     return DatabaseMetaData.sqlStateSQL99;
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java
index a15dd9b..8a743b5 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java
@@ -18,15 +18,9 @@
 
 package org.apache.hadoop.hive.ql.parse;
 
-import org.apache.hadoop.hive.ql.Context;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.antlr.runtime.tree.CommonTree;
-import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTBuilder;
-import org.apache.hadoop.hive.ql.parse.CalcitePlanner.ASTSearcher;
-
+import com.google.common.base.Preconditions;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -35,14 +29,17 @@ import java.util.List;
 import java.util.Queue;
 import java.util.Set;
 import java.util.Stack;
-
+import org.antlr.runtime.tree.CommonTree;
 import org.antlr.runtime.tree.Tree;
 import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.ql.Context;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.apache.hadoop.hive.ql.exec.PTFUtils;
 import org.apache.hadoop.hive.ql.exec.Utilities;
 import org.apache.hadoop.hive.ql.lib.Node;
+import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTBuilder;
+import org.apache.hadoop.hive.ql.parse.CalcitePlanner.ASTSearcher;
 import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
 import org.apache.hadoop.hive.serde2.typeinfo.CharTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo;
@@ -50,8 +47,8 @@ import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils;
 import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo;
-
-import com.google.common.base.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -523,4 +520,20 @@ public final class ParseUtils {
       newChildren.add(selExpr.node());
       return true;
     }
+
+    public static String getKeywords(Set<String> excludes) {
+      StringBuilder sb = new StringBuilder();
+      for (Field f : HiveLexer.class.getDeclaredFields()) {
+        if (!Modifier.isStatic(f.getModifiers())) continue;
+        String name = f.getName();
+        if (!name.startsWith("KW_")) continue;
+        name = name.substring(3);
+        if (excludes != null && excludes.contains(name)) continue;
+        if (sb.length() > 0) {
+          sb.append(",");
+        }
+        sb.append(name);
+      }
+      return sb.toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/service-rpc/if/TCLIService.thrift
----------------------------------------------------------------------
diff --git a/service-rpc/if/TCLIService.thrift b/service-rpc/if/TCLIService.thrift
index 824b049..19a49f6 100644
--- a/service-rpc/if/TCLIService.thrift
+++ b/service-rpc/if/TCLIService.thrift
@@ -655,6 +655,7 @@ enum TGetInfoType {
   CLI_CATALOG_NAME =                     10003,
   CLI_COLLATION_SEQ =                    10004,
   CLI_MAX_IDENTIFIER_LEN =               10005,
+  CLI_ODBC_KEYWORDS =                    10006
 }
 
 union TGetInfoValue {

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.cpp
----------------------------------------------------------------------
diff --git a/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.cpp b/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.cpp
index b6995c4..74e571c 100644
--- a/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.cpp
+++ b/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.cpp
@@ -200,7 +200,8 @@ int _kTGetInfoTypeValues[] = {
   TGetInfoType::CLI_DESCRIBE_PARAMETER,
   TGetInfoType::CLI_CATALOG_NAME,
   TGetInfoType::CLI_COLLATION_SEQ,
-  TGetInfoType::CLI_MAX_IDENTIFIER_LEN
+  TGetInfoType::CLI_MAX_IDENTIFIER_LEN,
+  TGetInfoType::CLI_ODBC_KEYWORDS
 };
 const char* _kTGetInfoTypeNames[] = {
   "CLI_MAX_DRIVER_CONNECTIONS",
@@ -249,9 +250,10 @@ const char* _kTGetInfoTypeNames[] = {
   "CLI_DESCRIBE_PARAMETER",
   "CLI_CATALOG_NAME",
   "CLI_COLLATION_SEQ",
-  "CLI_MAX_IDENTIFIER_LEN"
+  "CLI_MAX_IDENTIFIER_LEN",
+  "CLI_ODBC_KEYWORDS"
 };
-const std::map<int, const char*> _TGetInfoType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(47,
_kTGetInfoTypeValues, _kTGetInfoTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
+const std::map<int, const char*> _TGetInfoType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(48,
_kTGetInfoTypeValues, _kTGetInfoTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL));
 
 int _kTFetchOrientationValues[] = {
   TFetchOrientation::FETCH_NEXT,

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.h
----------------------------------------------------------------------
diff --git a/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.h b/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.h
index 8accf66..5b2518e 100644
--- a/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.h
+++ b/service-rpc/src/gen/thrift/gen-cpp/TCLIService_types.h
@@ -157,7 +157,8 @@ struct TGetInfoType {
     CLI_DESCRIBE_PARAMETER = 10002,
     CLI_CATALOG_NAME = 10003,
     CLI_COLLATION_SEQ = 10004,
-    CLI_MAX_IDENTIFIER_LEN = 10005
+    CLI_MAX_IDENTIFIER_LEN = 10005,
+    CLI_ODBC_KEYWORDS = 10006
   };
 };
 

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TGetInfoType.java
----------------------------------------------------------------------
diff --git a/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TGetInfoType.java
b/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TGetInfoType.java
index 5b219b6..b74ff7d 100644
--- a/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TGetInfoType.java
+++ b/service-rpc/src/gen/thrift/gen-javabean/org/apache/hive/service/rpc/thrift/TGetInfoType.java
@@ -58,7 +58,8 @@ public enum TGetInfoType implements org.apache.thrift.TEnum {
   CLI_DESCRIBE_PARAMETER(10002),
   CLI_CATALOG_NAME(10003),
   CLI_COLLATION_SEQ(10004),
-  CLI_MAX_IDENTIFIER_LEN(10005);
+  CLI_MAX_IDENTIFIER_LEN(10005),
+  CLI_ODBC_KEYWORDS(10006);
 
   private final int value;
 
@@ -173,6 +174,8 @@ public enum TGetInfoType implements org.apache.thrift.TEnum {
         return CLI_COLLATION_SEQ;
       case 10005:
         return CLI_MAX_IDENTIFIER_LEN;
+      case 10006:
+        return CLI_ODBC_KEYWORDS;
       default:
         return null;
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/service-rpc/src/gen/thrift/gen-php/Types.php
----------------------------------------------------------------------
diff --git a/service-rpc/src/gen/thrift/gen-php/Types.php b/service-rpc/src/gen/thrift/gen-php/Types.php
index ee5acd2..7e0f007 100644
--- a/service-rpc/src/gen/thrift/gen-php/Types.php
+++ b/service-rpc/src/gen/thrift/gen-php/Types.php
@@ -198,6 +198,7 @@ final class TGetInfoType {
   const CLI_CATALOG_NAME = 10003;
   const CLI_COLLATION_SEQ = 10004;
   const CLI_MAX_IDENTIFIER_LEN = 10005;
+  const CLI_ODBC_KEYWORDS = 10006;
   static public $__names = array(
     0 => 'CLI_MAX_DRIVER_CONNECTIONS',
     1 => 'CLI_MAX_CONCURRENT_ACTIVITIES',
@@ -246,6 +247,7 @@ final class TGetInfoType {
     10003 => 'CLI_CATALOG_NAME',
     10004 => 'CLI_COLLATION_SEQ',
     10005 => 'CLI_MAX_IDENTIFIER_LEN',
+    10006 => 'CLI_ODBC_KEYWORDS',
   );
 }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/service-rpc/src/gen/thrift/gen-py/TCLIService/ttypes.py
----------------------------------------------------------------------
diff --git a/service-rpc/src/gen/thrift/gen-py/TCLIService/ttypes.py b/service-rpc/src/gen/thrift/gen-py/TCLIService/ttypes.py
index e9faa2a..a69ab94 100644
--- a/service-rpc/src/gen/thrift/gen-py/TCLIService/ttypes.py
+++ b/service-rpc/src/gen/thrift/gen-py/TCLIService/ttypes.py
@@ -269,6 +269,7 @@ class TGetInfoType:
   CLI_CATALOG_NAME = 10003
   CLI_COLLATION_SEQ = 10004
   CLI_MAX_IDENTIFIER_LEN = 10005
+  CLI_ODBC_KEYWORDS = 10006
 
   _VALUES_TO_NAMES = {
     0: "CLI_MAX_DRIVER_CONNECTIONS",
@@ -318,6 +319,7 @@ class TGetInfoType:
     10003: "CLI_CATALOG_NAME",
     10004: "CLI_COLLATION_SEQ",
     10005: "CLI_MAX_IDENTIFIER_LEN",
+    10006: "CLI_ODBC_KEYWORDS",
   }
 
   _NAMES_TO_VALUES = {
@@ -368,6 +370,7 @@ class TGetInfoType:
     "CLI_CATALOG_NAME": 10003,
     "CLI_COLLATION_SEQ": 10004,
     "CLI_MAX_IDENTIFIER_LEN": 10005,
+    "CLI_ODBC_KEYWORDS": 10006,
   }
 
 class TFetchOrientation:

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb
----------------------------------------------------------------------
diff --git a/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb b/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb
index 714309c..eec27ee 100644
--- a/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb
+++ b/service-rpc/src/gen/thrift/gen-rb/t_c_l_i_service_types.rb
@@ -134,8 +134,9 @@ module TGetInfoType
   CLI_CATALOG_NAME = 10003
   CLI_COLLATION_SEQ = 10004
   CLI_MAX_IDENTIFIER_LEN = 10005
-  VALUE_MAP = {0 => "CLI_MAX_DRIVER_CONNECTIONS", 1 => "CLI_MAX_CONCURRENT_ACTIVITIES",
2 => "CLI_DATA_SOURCE_NAME", 8 => "CLI_FETCH_DIRECTION", 13 => "CLI_SERVER_NAME",
14 => "CLI_SEARCH_PATTERN_ESCAPE", 17 => "CLI_DBMS_NAME", 18 => "CLI_DBMS_VER", 19
=> "CLI_ACCESSIBLE_TABLES", 20 => "CLI_ACCESSIBLE_PROCEDURES", 23 => "CLI_CURSOR_COMMIT_BEHAVIOR",
25 => "CLI_DATA_SOURCE_READ_ONLY", 26 => "CLI_DEFAULT_TXN_ISOLATION", 28 => "CLI_IDENTIFIER_CASE",
29 => "CLI_IDENTIFIER_QUOTE_CHAR", 30 => "CLI_MAX_COLUMN_NAME_LEN", 31 => "CLI_MAX_CURSOR_NAME_LEN",
32 => "CLI_MAX_SCHEMA_NAME_LEN", 34 => "CLI_MAX_CATALOG_NAME_LEN", 35 => "CLI_MAX_TABLE_NAME_LEN",
43 => "CLI_SCROLL_CONCURRENCY", 46 => "CLI_TXN_CAPABLE", 47 => "CLI_USER_NAME", 72
=> "CLI_TXN_ISOLATION_OPTION", 73 => "CLI_INTEGRITY", 81 => "CLI_GETDATA_EXTENSIONS",
85 => "CLI_NULL_COLLATION", 86 => "CLI_ALTER_TABLE", 90 => "CLI_ORDER_BY_COLUMNS_IN_SELECT",
94 => "CLI_SPECIAL_CHARACTERS", 97 => "CLI_MAX_COLUMNS_IN_GROUP_BY", 98 => "CLI_MAX_
 COLUMNS_IN_INDEX", 99 => "CLI_MAX_COLUMNS_IN_ORDER_BY", 100 => "CLI_MAX_COLUMNS_IN_SELECT",
101 => "CLI_MAX_COLUMNS_IN_TABLE", 102 => "CLI_MAX_INDEX_SIZE", 104 => "CLI_MAX_ROW_SIZE",
105 => "CLI_MAX_STATEMENT_LEN", 106 => "CLI_MAX_TABLES_IN_SELECT", 107 => "CLI_MAX_USER_NAME_LEN",
115 => "CLI_OJ_CAPABILITIES", 10000 => "CLI_XOPEN_CLI_YEAR", 10001 => "CLI_CURSOR_SENSITIVITY",
10002 => "CLI_DESCRIBE_PARAMETER", 10003 => "CLI_CATALOG_NAME", 10004 => "CLI_COLLATION_SEQ",
10005 => "CLI_MAX_IDENTIFIER_LEN"}
-  VALID_VALUES = Set.new([CLI_MAX_DRIVER_CONNECTIONS, CLI_MAX_CONCURRENT_ACTIVITIES, CLI_DATA_SOURCE_NAME,
CLI_FETCH_DIRECTION, CLI_SERVER_NAME, CLI_SEARCH_PATTERN_ESCAPE, CLI_DBMS_NAME, CLI_DBMS_VER,
CLI_ACCESSIBLE_TABLES, CLI_ACCESSIBLE_PROCEDURES, CLI_CURSOR_COMMIT_BEHAVIOR, CLI_DATA_SOURCE_READ_ONLY,
CLI_DEFAULT_TXN_ISOLATION, CLI_IDENTIFIER_CASE, CLI_IDENTIFIER_QUOTE_CHAR, CLI_MAX_COLUMN_NAME_LEN,
CLI_MAX_CURSOR_NAME_LEN, CLI_MAX_SCHEMA_NAME_LEN, CLI_MAX_CATALOG_NAME_LEN, CLI_MAX_TABLE_NAME_LEN,
CLI_SCROLL_CONCURRENCY, CLI_TXN_CAPABLE, CLI_USER_NAME, CLI_TXN_ISOLATION_OPTION, CLI_INTEGRITY,
CLI_GETDATA_EXTENSIONS, CLI_NULL_COLLATION, CLI_ALTER_TABLE, CLI_ORDER_BY_COLUMNS_IN_SELECT,
CLI_SPECIAL_CHARACTERS, CLI_MAX_COLUMNS_IN_GROUP_BY, CLI_MAX_COLUMNS_IN_INDEX, CLI_MAX_COLUMNS_IN_ORDER_BY,
CLI_MAX_COLUMNS_IN_SELECT, CLI_MAX_COLUMNS_IN_TABLE, CLI_MAX_INDEX_SIZE, CLI_MAX_ROW_SIZE,
CLI_MAX_STATEMENT_LEN, CLI_MAX_TABLES_IN_SELECT, CLI_MAX_USER_NAME_LEN, CLI_OJ_CAPABILITIES,
CLI_XOPEN
 _CLI_YEAR, CLI_CURSOR_SENSITIVITY, CLI_DESCRIBE_PARAMETER, CLI_CATALOG_NAME, CLI_COLLATION_SEQ,
CLI_MAX_IDENTIFIER_LEN]).freeze
+  CLI_ODBC_KEYWORDS = 10006
+  VALUE_MAP = {0 => "CLI_MAX_DRIVER_CONNECTIONS", 1 => "CLI_MAX_CONCURRENT_ACTIVITIES",
2 => "CLI_DATA_SOURCE_NAME", 8 => "CLI_FETCH_DIRECTION", 13 => "CLI_SERVER_NAME",
14 => "CLI_SEARCH_PATTERN_ESCAPE", 17 => "CLI_DBMS_NAME", 18 => "CLI_DBMS_VER", 19
=> "CLI_ACCESSIBLE_TABLES", 20 => "CLI_ACCESSIBLE_PROCEDURES", 23 => "CLI_CURSOR_COMMIT_BEHAVIOR",
25 => "CLI_DATA_SOURCE_READ_ONLY", 26 => "CLI_DEFAULT_TXN_ISOLATION", 28 => "CLI_IDENTIFIER_CASE",
29 => "CLI_IDENTIFIER_QUOTE_CHAR", 30 => "CLI_MAX_COLUMN_NAME_LEN", 31 => "CLI_MAX_CURSOR_NAME_LEN",
32 => "CLI_MAX_SCHEMA_NAME_LEN", 34 => "CLI_MAX_CATALOG_NAME_LEN", 35 => "CLI_MAX_TABLE_NAME_LEN",
43 => "CLI_SCROLL_CONCURRENCY", 46 => "CLI_TXN_CAPABLE", 47 => "CLI_USER_NAME", 72
=> "CLI_TXN_ISOLATION_OPTION", 73 => "CLI_INTEGRITY", 81 => "CLI_GETDATA_EXTENSIONS",
85 => "CLI_NULL_COLLATION", 86 => "CLI_ALTER_TABLE", 90 => "CLI_ORDER_BY_COLUMNS_IN_SELECT",
94 => "CLI_SPECIAL_CHARACTERS", 97 => "CLI_MAX_COLUMNS_IN_GROUP_BY", 98 => "CLI_MAX_
 COLUMNS_IN_INDEX", 99 => "CLI_MAX_COLUMNS_IN_ORDER_BY", 100 => "CLI_MAX_COLUMNS_IN_SELECT",
101 => "CLI_MAX_COLUMNS_IN_TABLE", 102 => "CLI_MAX_INDEX_SIZE", 104 => "CLI_MAX_ROW_SIZE",
105 => "CLI_MAX_STATEMENT_LEN", 106 => "CLI_MAX_TABLES_IN_SELECT", 107 => "CLI_MAX_USER_NAME_LEN",
115 => "CLI_OJ_CAPABILITIES", 10000 => "CLI_XOPEN_CLI_YEAR", 10001 => "CLI_CURSOR_SENSITIVITY",
10002 => "CLI_DESCRIBE_PARAMETER", 10003 => "CLI_CATALOG_NAME", 10004 => "CLI_COLLATION_SEQ",
10005 => "CLI_MAX_IDENTIFIER_LEN", 10006 => "CLI_ODBC_KEYWORDS"}
+  VALID_VALUES = Set.new([CLI_MAX_DRIVER_CONNECTIONS, CLI_MAX_CONCURRENT_ACTIVITIES, CLI_DATA_SOURCE_NAME,
CLI_FETCH_DIRECTION, CLI_SERVER_NAME, CLI_SEARCH_PATTERN_ESCAPE, CLI_DBMS_NAME, CLI_DBMS_VER,
CLI_ACCESSIBLE_TABLES, CLI_ACCESSIBLE_PROCEDURES, CLI_CURSOR_COMMIT_BEHAVIOR, CLI_DATA_SOURCE_READ_ONLY,
CLI_DEFAULT_TXN_ISOLATION, CLI_IDENTIFIER_CASE, CLI_IDENTIFIER_QUOTE_CHAR, CLI_MAX_COLUMN_NAME_LEN,
CLI_MAX_CURSOR_NAME_LEN, CLI_MAX_SCHEMA_NAME_LEN, CLI_MAX_CATALOG_NAME_LEN, CLI_MAX_TABLE_NAME_LEN,
CLI_SCROLL_CONCURRENCY, CLI_TXN_CAPABLE, CLI_USER_NAME, CLI_TXN_ISOLATION_OPTION, CLI_INTEGRITY,
CLI_GETDATA_EXTENSIONS, CLI_NULL_COLLATION, CLI_ALTER_TABLE, CLI_ORDER_BY_COLUMNS_IN_SELECT,
CLI_SPECIAL_CHARACTERS, CLI_MAX_COLUMNS_IN_GROUP_BY, CLI_MAX_COLUMNS_IN_INDEX, CLI_MAX_COLUMNS_IN_ORDER_BY,
CLI_MAX_COLUMNS_IN_SELECT, CLI_MAX_COLUMNS_IN_TABLE, CLI_MAX_INDEX_SIZE, CLI_MAX_ROW_SIZE,
CLI_MAX_STATEMENT_LEN, CLI_MAX_TABLES_IN_SELECT, CLI_MAX_USER_NAME_LEN, CLI_OJ_CAPABILITIES,
CLI_XOPEN
 _CLI_YEAR, CLI_CURSOR_SENSITIVITY, CLI_DESCRIBE_PARAMETER, CLI_CATALOG_NAME, CLI_COLLATION_SEQ,
CLI_MAX_IDENTIFIER_LEN, CLI_ODBC_KEYWORDS]).freeze
 end
 
 module TFetchOrientation

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/service/src/java/org/apache/hive/service/cli/GetInfoType.java
----------------------------------------------------------------------
diff --git a/service/src/java/org/apache/hive/service/cli/GetInfoType.java b/service/src/java/org/apache/hive/service/cli/GetInfoType.java
index a64d262..575dff8 100644
--- a/service/src/java/org/apache/hive/service/cli/GetInfoType.java
+++ b/service/src/java/org/apache/hive/service/cli/GetInfoType.java
@@ -72,7 +72,8 @@ public enum GetInfoType {
   CLI_DESCRIBE_PARAMETER(TGetInfoType.CLI_DESCRIBE_PARAMETER),
   CLI_CATALOG_NAME(TGetInfoType.CLI_CATALOG_NAME),
   CLI_COLLATION_SEQ(TGetInfoType.CLI_COLLATION_SEQ),
-  CLI_MAX_IDENTIFIER_LEN(TGetInfoType.CLI_MAX_IDENTIFIER_LEN);
+  CLI_MAX_IDENTIFIER_LEN(TGetInfoType.CLI_MAX_IDENTIFIER_LEN),
+  CLI_ODBC_KEYWORDS(TGetInfoType.CLI_ODBC_KEYWORDS);
 
   private final TGetInfoType tInfoType;
 

http://git-wip-us.apache.org/repos/asf/hive/blob/7093e531/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
----------------------------------------------------------------------
diff --git a/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java b/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
index 418f453..470c4f1 100644
--- a/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
+++ b/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
@@ -18,6 +18,8 @@
 
 package org.apache.hive.service.cli.session;
 
+import java.util.Collections;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -31,7 +33,6 @@ import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.concurrent.FutureTask;
 import java.util.concurrent.Semaphore;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.hive.common.cli.HiveFileProcessor;
@@ -44,6 +45,7 @@ import org.apache.hadoop.hive.ql.exec.Utilities;
 import org.apache.hadoop.hive.ql.history.HiveHistory;
 import org.apache.hadoop.hive.ql.metadata.Hive;
 import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.parse.ParseUtils;
 import org.apache.hadoop.hive.ql.processors.SetProcessor;
 import org.apache.hadoop.hive.ql.session.SessionState;
 import org.apache.hadoop.hive.serde2.SerDeUtils;
@@ -77,6 +79,8 @@ import org.apache.hive.service.server.ThreadWithGarbageCleanup;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.Lists;
+
 /**
  * HiveSession
  *
@@ -481,6 +485,8 @@ public class HiveSessionImpl implements HiveSession {
         return new GetInfoValue(128);
       case CLI_MAX_TABLE_NAME_LEN:
         return new GetInfoValue(128);
+      case CLI_ODBC_KEYWORDS:
+        return new GetInfoValue(ParseUtils.getKeywords(ODBC_KEYWORDS));
       case CLI_TXN_CAPABLE:
       default:
         throw new HiveSQLException("Unrecognized GetInfoType value: " + getInfoType.toString());
@@ -974,4 +980,36 @@ public class HiveSessionImpl implements HiveSession {
       release(true, true);
     }
   }
+
+
+  // From https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql#odbc-reserved-keywords
+  private static final Set<String> ODBC_KEYWORDS = Collections.unmodifiableSet(new
HashSet<>(
+      Lists.newArrayList("ABSOLUTE", "ACTION", "ADA", "ADD", "ALL", "ALLOCATE", "ALTER",
"AND",
+      "ANY", "ARE", "AS", "ASC", "ASSERTION", "AT", "AUTHORIZATION", "AVG", "BEGIN", "BETWEEN",
+      "BIT_LENGTH", "BIT", "BOTH", "BY", "CASCADE", "CASCADED", "CASE", "CAST", "CATALOG",
+      "CHAR_LENGTH", "CHAR", "CHARACTER_LENGTH", "CHARACTER", "CHECK", "CLOSE", "COALESCE",
+      "COLLATE", "COLLATION", "COLUMN", "COMMIT", "CONNECT", "CONNECTION", "CONSTRAINT",
+      "CONSTRAINTS", "CONTINUE", "CONVERT", "CORRESPONDING", "COUNT", "CREATE", "CROSS",
+      "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURRENT", "CURSOR",
+      "DATE", "DAY", "DEALLOCATE", "DEC", "DECIMAL", "DECLARE", "DEFAULT", "DEFERRABLE",
+      "DEFERRED", "DELETE", "DESC", "DESCRIBE", "DESCRIPTOR", "DIAGNOSTICS", "DISCONNECT",
+      "DISTINCT", "DOMAIN", "DOUBLE", "DROP", "ELSE", "END", "ESCAPE", "EXCEPT", "EXCEPTION",
+      "EXEC", "EXECUTE", "EXISTS", "EXTERNAL", "EXTRACT", "FALSE", "FETCH", "FIRST", "FLOAT",
+      "FOR", "FOREIGN", "FORTRAN", "FOUND", "FROM", "FULL", "GET", "GLOBAL", "GO", "GOTO",
"GRANT",
+      "GROUP", "HAVING", "HOUR", "IDENTITY", "IMMEDIATE", "IN", "INCLUDE", "INDEX", "INDICATOR",
+      "INITIALLY", "INNER", "INPUT", "INSENSITIVE", "INSERT", "INT", "INTEGER", "INTERSECT",
+      "INTERVAL", "INTO", "IS", "ISOLATION", "JOIN", "KEY", "LANGUAGE", "LAST", "LEADING",
"LEFT",
+      "LEVEL", "LIKE", "LOCAL", "LOWER", "MATCH", "MAX", "MIN", "MINUTE", "MODULE", "MONTH",
+      "NAMES", "NATIONAL", "NATURAL", "NCHAR", "NEXT", "NO", "NONE", "NOT", "NULL", "NULLIF",
+      "NUMERIC", "OCTET_LENGTH", "OF", "ON", "ONLY", "OPEN", "OPTION", "OR", "ORDER", "OUTER",
+      "OUTPUT", "OVERLAPS", "PAD", "PARTIAL", "PASCAL", "POSITION", "PRECISION", "PREPARE",
+      "PRESERVE", "PRIMARY", "PRIOR", "PRIVILEGES", "PROCEDURE", "PUBLIC", "READ", "REAL",
+      "REFERENCES", "RELATIVE", "RESTRICT", "REVOKE", "RIGHT", "ROLLBACK", "ROWS", "SCHEMA",
+      "SCROLL", "SECOND", "SECTION", "SELECT", "SESSION_USER", "SESSION", "SET", "SIZE",
+      "SMALLINT", "SOME", "SPACE", "SQL", "SQLCA", "SQLCODE", "SQLERROR", "SQLSTATE", "SQLWARNING",
+      "SUBSTRING", "SUM", "SYSTEM_USER", "TABLE", "TEMPORARY", "THEN", "TIME", "TIMESTAMP",
+      "TIMEZONE_HOUR", "TIMEZONE_MINUTE", "TO", "TRAILING", "TRANSACTION", "TRANSLATE",
+      "TRANSLATION", "TRIM", "TRUE", "UNION", "UNIQUE", "UNKNOWN", "UPDATE", "UPPER", "USAGE",
+      "USER", "USING", "VALUE", "VALUES", "VARCHAR", "VARYING", "VIEW", "WHEN", "WHENEVER",
+      "WHERE", "WITH", "WORK", "WRITE", "YEAR", "ZONE")));
 }


Mime
View raw message