hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject [02/15] hive git commit: HIVE-14558: Add support for listing views similar to "show tables" (Naveen Gangam, reviewed by Aihua Xu)
Date Tue, 04 Oct 2016 18:46:43 GMT
http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
index de6adb5..691c3a8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
@@ -1313,7 +1313,7 @@ public class Hive {
    * @throws HiveException
    */
   public List<String> getAllTables() throws HiveException {
-    return getAllTables(SessionState.get().getCurrentDatabase());
+    return getTablesByType(SessionState.get().getCurrentDatabase(), null, null);
   }
 
   /**
@@ -1323,7 +1323,7 @@ public class Hive {
    * @throws HiveException
    */
   public List<String> getAllTables(String dbName) throws HiveException {
-    return getTablesByPattern(dbName, ".*");
+    return getTablesByType(dbName, ".*", null);
   }
 
   /**
@@ -1336,8 +1336,8 @@ public class Hive {
    * @throws HiveException
    */
   public List<String> getTablesByPattern(String tablePattern) throws HiveException
{
-    return getTablesByPattern(SessionState.get().getCurrentDatabase(),
-        tablePattern);
+    return getTablesByType(SessionState.get().getCurrentDatabase(),
+        tablePattern, null);
   }
 
   /**
@@ -1349,11 +1349,7 @@ public class Hive {
    * @throws HiveException
    */
   public List<String> getTablesByPattern(String dbName, String tablePattern) throws
HiveException {
-    try {
-      return getMSC().getTables(dbName, tablePattern);
-    } catch (Exception e) {
-      throw new HiveException(e);
-    }
+    return getTablesByType(dbName, tablePattern, null);
   }
 
   /**
@@ -1369,8 +1365,38 @@ public class Hive {
    */
   public List<String> getTablesForDb(String database, String tablePattern)
       throws HiveException {
+    return getTablesByType(database, tablePattern, null);
+  }
+
+  /**
+   * Returns all existing tables of a type (VIRTUAL_VIEW|EXTERNAL_TABLE|MANAGED_TABLE) from
the specified
+   * database which match the given pattern. The matching occurs as per Java regular expressions.
+   * @param dbName Database name to find the tables in. if null, uses the current database
in this session.
+   * @param pattern A pattern to match for the table names.If null, returns all names from
this DB.
+   * @param type The type of tables to return. VIRTUAL_VIEWS for views. If null, returns
all tables and views.
+   * @return list of table names that match the pattern.
+   * @throws HiveException
+   */
+  public List<String> getTablesByType(String dbName, String pattern, TableType type)
+      throws HiveException {
+    List<String> retList = new ArrayList<String>();
+    if (dbName == null)
+      dbName = SessionState.get().getCurrentDatabase();
+
     try {
-      return getMSC().getTables(database, tablePattern);
+      if (type != null) {
+        if (pattern != null) {
+          return getMSC().getTables(dbName, pattern, type);
+        } else {
+          return getMSC().getTables(dbName, ".*", type);
+        }
+      } else {
+        if (pattern != null) {
+          return getMSC().getTables(dbName, pattern);
+        } else {
+          return getMSC().getTables(dbName, ".*");
+        }
+      }
     } catch (Exception e) {
       throw new HiveException(e);
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
index 8b0db4a..a264c4d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java
@@ -394,6 +394,10 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer {
       ctx.setResFile(ctx.getLocalTmpPath());
       analyzeShowConf(ast);
       break;
+    case HiveParser.TOK_SHOWVIEWS:
+      ctx.setResFile(ctx.getLocalTmpPath());
+      analyzeShowViews(ast);
+      break;
     case HiveParser.TOK_DESCFUNCTION:
       ctx.setResFile(ctx.getLocalTmpPath());
       analyzeDescFunction(ast);
@@ -2402,6 +2406,45 @@ public class DDLSemanticAnalyzer extends BaseSemanticAnalyzer {
     setFetchTask(createFetchTask(showConfDesc.getSchema()));
   }
 
+  private void analyzeShowViews(ASTNode ast) throws SemanticException {
+    ShowTablesDesc showViewsDesc;
+    String dbName = SessionState.get().getCurrentDatabase();
+    String viewNames = null;
+
+    if (ast.getChildCount() > 3) {
+      throw new SemanticException(ErrorMsg.GENERIC_ERROR.getMsg());
+    }
+
+    switch (ast.getChildCount()) {
+    case 1: // Uses a pattern
+      viewNames = unescapeSQLString(ast.getChild(0).getText());
+      showViewsDesc = new ShowTablesDesc(ctx.getResFile(), dbName, viewNames, TableType.VIRTUAL_VIEW);
+      break;
+    case 2: // Specifies a DB
+      assert (ast.getChild(0).getType() == HiveParser.TOK_FROM);
+      dbName = unescapeIdentifier(ast.getChild(1).getText());
+      validateDatabase(dbName);
+      showViewsDesc = new ShowTablesDesc(ctx.getResFile(), dbName);
+      showViewsDesc.setType(TableType.VIRTUAL_VIEW);
+      break;
+    case 3: // Uses a pattern and specifies a DB
+      assert (ast.getChild(0).getType() == HiveParser.TOK_FROM);
+      dbName = unescapeIdentifier(ast.getChild(1).getText());
+      viewNames = unescapeSQLString(ast.getChild(2).getText());
+      validateDatabase(dbName);
+      showViewsDesc = new ShowTablesDesc(ctx.getResFile(), dbName, viewNames, TableType.VIRTUAL_VIEW);
+      break;
+    default: // No pattern or DB
+      showViewsDesc = new ShowTablesDesc(ctx.getResFile(), dbName);
+      showViewsDesc.setType(TableType.VIRTUAL_VIEW);
+      break;
+    }
+
+    rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(),
+        showViewsDesc), conf));
+    setFetchTask(createFetchTask(showViewsDesc.getSchema()));
+  }
+
   /**
    * Add the task according to the parsed command tree. This is used for the CLI
    * command "LOCK TABLE ..;".

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g
index b623187..58e76c8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveLexer.g
@@ -216,6 +216,7 @@ KW_MINUS: 'MINUS';
 KW_FETCH: 'FETCH';
 KW_INTERSECT: 'INTERSECT';
 KW_VIEW: 'VIEW';
+KW_VIEWS: 'VIEWS';
 KW_IN: 'IN';
 KW_DATABASE: 'DATABASE';
 KW_DATABASES: 'DATABASES';

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
index 62bbcc6..bf78545 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
@@ -368,6 +368,7 @@ TOK_ANONYMOUS;
 TOK_COL_NAME;
 TOK_URI_TYPE;
 TOK_SERVER_TYPE;
+TOK_SHOWVIEWS;
 TOK_START_TRANSACTION;
 TOK_ISOLATION_LEVEL;
 TOK_ISOLATION_SNAPSHOT;
@@ -1443,6 +1444,7 @@ showStatement
 @after { popMsg(state); }
     : KW_SHOW (KW_DATABASES|KW_SCHEMAS) (KW_LIKE showStmtIdentifier)? -> ^(TOK_SHOWDATABASES
showStmtIdentifier?)
     | KW_SHOW KW_TABLES ((KW_FROM|KW_IN) db_name=identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)?
 -> ^(TOK_SHOWTABLES (TOK_FROM $db_name)? showStmtIdentifier?)
+    | KW_SHOW KW_VIEWS ((KW_FROM|KW_IN) db_name=identifier)? (KW_LIKE showStmtIdentifier|showStmtIdentifier)?
 -> ^(TOK_SHOWVIEWS (TOK_FROM $db_name)? showStmtIdentifier?)
     | KW_SHOW KW_COLUMNS (KW_FROM|KW_IN) tableName ((KW_FROM|KW_IN) db_name=identifier)?
     -> ^(TOK_SHOWCOLUMNS tableName $db_name?)
     | KW_SHOW KW_FUNCTIONS (KW_LIKE showFunctionIdentifier|showFunctionIdentifier)?  ->
^(TOK_SHOWFUNCTIONS KW_LIKE? showFunctionIdentifier?)

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzerFactory.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzerFactory.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzerFactory.java
index 18439f9..4f0ead0 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzerFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzerFactory.java
@@ -78,6 +78,7 @@ public final class SemanticAnalyzerFactory {
     commandType.put(HiveParser.TOK_SHOWLOCKS, HiveOperation.SHOWLOCKS);
     commandType.put(HiveParser.TOK_SHOWDBLOCKS, HiveOperation.SHOWLOCKS);
     commandType.put(HiveParser.TOK_SHOWCONF, HiveOperation.SHOWCONF);
+    commandType.put(HiveParser.TOK_SHOWVIEWS, HiveOperation.SHOWVIEWS);
     commandType.put(HiveParser.TOK_CREATEFUNCTION, HiveOperation.CREATEFUNCTION);
     commandType.put(HiveParser.TOK_DROPFUNCTION, HiveOperation.DROPFUNCTION);
     commandType.put(HiveParser.TOK_RELOADFUNCTION, HiveOperation.RELOADFUNCTION);
@@ -256,6 +257,7 @@ public final class SemanticAnalyzerFactory {
       case HiveParser.TOK_SHOW_TRANSACTIONS:
       case HiveParser.TOK_ABORT_TRANSACTIONS:
       case HiveParser.TOK_SHOWCONF:
+      case HiveParser.TOK_SHOWVIEWS:
       case HiveParser.TOK_CREATEINDEX:
       case HiveParser.TOK_DROPINDEX:
       case HiveParser.TOK_ALTERTABLE_CLUSTER_SORT:

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/java/org/apache/hadoop/hive/ql/plan/DDLWork.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/DDLWork.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/DDLWork.java
index 8b54609..e069acd 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/DDLWork.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/DDLWork.java
@@ -524,7 +524,7 @@ public class DDLWork implements Serializable {
     this.cacheMetadataDesc = cacheMetadataDesc;
   }
 
-    /**
+  /**
    * @return Create Database descriptor
    */
   public CreateDatabaseDesc getCreateDatabaseDesc() {

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
index 6fd4df4..d333f91 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/HiveOperation.java
@@ -72,6 +72,7 @@ public enum HiveOperation {
   SHOWPARTITIONS("SHOWPARTITIONS", null, null),
   SHOWLOCKS("SHOWLOCKS", null, null),
   SHOWCONF("SHOWCONF", null, null),
+  SHOWVIEWS("SHOWVIEWS", null, null),
   CREATEFUNCTION("CREATEFUNCTION", null, null),
   DROPFUNCTION("DROPFUNCTION", null, null),
   RELOADFUNCTION("RELOADFUNCTION", null, null),

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/java/org/apache/hadoop/hive/ql/plan/ShowTablesDesc.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ShowTablesDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ShowTablesDesc.java
index 9e9d639..c9193b7 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ShowTablesDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ShowTablesDesc.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.ql.plan;
 import java.io.Serializable;
 
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hadoop.hive.ql.plan.Explain.Level;
 
 
@@ -34,6 +35,7 @@ public class ShowTablesDesc extends DDLDesc implements Serializable {
   String pattern;
   String dbName;
   String resFile;
+  TableType type;
   /**
    * table name for the result of show tables.
    */
@@ -82,6 +84,17 @@ public class ShowTablesDesc extends DDLDesc implements Serializable {
   }
 
   /**
+   * @param type
+   *          type of the tables to show
+   */
+  public ShowTablesDesc(Path resFile, String dbName, String pattern, TableType type) {
+    this.resFile = resFile.toString();
+    this.dbName = dbName;
+    this.pattern = pattern;
+    this.type    = type;
+  }
+
+  /**
    * @return the pattern
    */
   @Explain(displayName = "pattern")
@@ -98,6 +111,22 @@ public class ShowTablesDesc extends DDLDesc implements Serializable {
   }
 
   /**
+   * @return the table type to be fetched
+   */
+  @Explain(displayName = "type")
+  public TableType getType() {
+    return type;
+  }
+
+  /**
+   * @param type
+   *          the table type to set
+   */
+  public void setType(TableType type) {
+    this.type = type;
+  }
+
+  /**
    * @return the resFile
    */
   @Explain(displayName = "result file", explainLevels = { Level.EXTENDED })

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
index 2da4249..7da44e8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HiveOperationType.java
@@ -76,6 +76,7 @@ public enum HiveOperationType {
   SHOWPARTITIONS,
   SHOWLOCKS,
   SHOWCONF,
+  SHOWVIEWS,
   CREATEFUNCTION,
   DROPFUNCTION,
   RELOADFUNCTION,

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
index e5389bd..e7bbd54 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/Operation2Privilege.java
@@ -360,6 +360,8 @@ public class Operation2Privilege {
 (null, null));
     op2Priv.put(HiveOperationType.SHOWCONF, PrivRequirement.newIOPrivRequirement
 (null, null));
+    op2Priv.put(HiveOperationType.SHOWVIEWS, PrivRequirement.newIOPrivRequirement
+(null, null));
 
     op2Priv.put(HiveOperationType.LOCKTABLE, PrivRequirement.newIOPrivRequirement
 (null, null));

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/test/queries/clientpositive/show_views.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/show_views.q b/ql/src/test/queries/clientpositive/show_views.q
new file mode 100644
index 0000000..61aad43
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/show_views.q
@@ -0,0 +1,56 @@
+CREATE DATABASE test1;
+CREATE DATABASE test2;
+
+USE test1;
+CREATE TABLE shtb_test1(KEY INT, VALUE STRING) PARTITIONED BY(ds STRING) STORED AS TEXTFILE;
+CREATE VIEW shtb_test1_view1 AS SELECT * FROM shtb_test1 where KEY > 1000 and KEY <
2000;
+CREATE VIEW shtb_test1_view2 AS SELECT * FROM shtb_test1 where KEY > 100 and KEY <
200;
+CREATE VIEW shtb_full_view2 AS SELECT * FROM shtb_test1;
+USE test2;
+CREATE TABLE shtb_test1(KEY INT, VALUE STRING) PARTITIONED BY(ds STRING) STORED AS TEXTFILE;
+CREATE TABLE shtb_test2(KEY INT, VALUE STRING) PARTITIONED BY(ds STRING) STORED AS TEXTFILE;
+CREATE VIEW shtb_test1_view1 AS SELECT * FROM shtb_test1 where KEY > 1000 and KEY <
2000;
+CREATE VIEW shtb_test2_view2 AS SELECT * FROM shtb_test2 where KEY > 100 and KEY <
200;
+
+USE test1;
+SHOW VIEWS;
+SHOW VIEWS 'test_*';
+SHOW VIEWS '*view2';
+SHOW VIEWS LIKE 'test_view1|test_view2';
+
+USE test2;
+SHOW VIEWS 'shtb_*';
+
+-- SHOW VIEWS basic syntax tests
+USE default;
+SHOW VIEWS FROM test1;
+SHOW VIEWS FROM test2;
+SHOW VIEWS IN test1;
+SHOW VIEWS IN default;
+SHOW VIEWS IN test1 "shtb_test_*";
+SHOW VIEWS IN test2 LIKE "nomatch";
+
+-- SHOW VIEWS from a database with a name that requires escaping
+CREATE DATABASE `database`;
+USE `database`;
+CREATE TABLE foo(a INT);
+CREATE VIEW fooview AS SELECT * FROM foo;
+USE default;
+SHOW VIEWS FROM `database` LIKE "fooview";
+
+DROP VIEW fooview;
+DROP TABLE foo;
+
+USE test1;
+DROP VIEW shtb_test1_view1;
+DROP VIEW shtb_test1_view2;
+DROP VIEW shtb_full_view2;
+DROP TABLE shtb_test1;
+DROP DATABASE test1;
+
+USE test2;
+DROP VIEW shtb_test1_view1;
+DROP VIEW shtb_test2_view2;
+DROP TABLE shtb_test1;
+DROP TABLE shtb_test2;
+DROP DATABASE test2;

http://git-wip-us.apache.org/repos/asf/hive/blob/21a0142f/ql/src/test/results/clientpositive/show_views.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/show_views.q.out b/ql/src/test/results/clientpositive/show_views.q.out
new file mode 100644
index 0000000..61b5f1d
--- /dev/null
+++ b/ql/src/test/results/clientpositive/show_views.q.out
@@ -0,0 +1,320 @@
+PREHOOK: query: CREATE DATABASE test1
+PREHOOK: type: CREATEDATABASE
+PREHOOK: Output: database:test1
+POSTHOOK: query: CREATE DATABASE test1
+POSTHOOK: type: CREATEDATABASE
+POSTHOOK: Output: database:test1
+PREHOOK: query: CREATE DATABASE test2
+PREHOOK: type: CREATEDATABASE
+PREHOOK: Output: database:test2
+POSTHOOK: query: CREATE DATABASE test2
+POSTHOOK: type: CREATEDATABASE
+POSTHOOK: Output: database:test2
+PREHOOK: query: USE test1
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:test1
+POSTHOOK: query: USE test1
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:test1
+PREHOOK: query: CREATE TABLE shtb_test1(KEY INT, VALUE STRING) PARTITIONED BY(ds STRING)
STORED AS TEXTFILE
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:test1
+PREHOOK: Output: test1@shtb_test1
+POSTHOOK: query: CREATE TABLE shtb_test1(KEY INT, VALUE STRING) PARTITIONED BY(ds STRING)
STORED AS TEXTFILE
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:test1
+POSTHOOK: Output: test1@shtb_test1
+PREHOOK: query: CREATE VIEW shtb_test1_view1 AS SELECT * FROM shtb_test1 where KEY > 1000
and KEY < 2000
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: test1@shtb_test1
+PREHOOK: Output: database:test1
+PREHOOK: Output: test1@shtb_test1_view1
+POSTHOOK: query: CREATE VIEW shtb_test1_view1 AS SELECT * FROM shtb_test1 where KEY >
1000 and KEY < 2000
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: test1@shtb_test1
+POSTHOOK: Output: database:test1
+POSTHOOK: Output: test1@shtb_test1_view1
+PREHOOK: query: CREATE VIEW shtb_test1_view2 AS SELECT * FROM shtb_test1 where KEY > 100
and KEY < 200
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: test1@shtb_test1
+PREHOOK: Output: database:test1
+PREHOOK: Output: test1@shtb_test1_view2
+POSTHOOK: query: CREATE VIEW shtb_test1_view2 AS SELECT * FROM shtb_test1 where KEY >
100 and KEY < 200
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: test1@shtb_test1
+POSTHOOK: Output: database:test1
+POSTHOOK: Output: test1@shtb_test1_view2
+PREHOOK: query: CREATE VIEW shtb_full_view2 AS SELECT * FROM shtb_test1
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: test1@shtb_test1
+PREHOOK: Output: database:test1
+PREHOOK: Output: test1@shtb_full_view2
+POSTHOOK: query: CREATE VIEW shtb_full_view2 AS SELECT * FROM shtb_test1
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: test1@shtb_test1
+POSTHOOK: Output: database:test1
+POSTHOOK: Output: test1@shtb_full_view2
+PREHOOK: query: USE test2
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:test2
+POSTHOOK: query: USE test2
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:test2
+PREHOOK: query: CREATE TABLE shtb_test1(KEY INT, VALUE STRING) PARTITIONED BY(ds STRING)
STORED AS TEXTFILE
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:test2
+PREHOOK: Output: test2@shtb_test1
+POSTHOOK: query: CREATE TABLE shtb_test1(KEY INT, VALUE STRING) PARTITIONED BY(ds STRING)
STORED AS TEXTFILE
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:test2
+POSTHOOK: Output: test2@shtb_test1
+PREHOOK: query: CREATE TABLE shtb_test2(KEY INT, VALUE STRING) PARTITIONED BY(ds STRING)
STORED AS TEXTFILE
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:test2
+PREHOOK: Output: test2@shtb_test2
+POSTHOOK: query: CREATE TABLE shtb_test2(KEY INT, VALUE STRING) PARTITIONED BY(ds STRING)
STORED AS TEXTFILE
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:test2
+POSTHOOK: Output: test2@shtb_test2
+PREHOOK: query: CREATE VIEW shtb_test1_view1 AS SELECT * FROM shtb_test1 where KEY > 1000
and KEY < 2000
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: test2@shtb_test1
+PREHOOK: Output: database:test2
+PREHOOK: Output: test2@shtb_test1_view1
+POSTHOOK: query: CREATE VIEW shtb_test1_view1 AS SELECT * FROM shtb_test1 where KEY >
1000 and KEY < 2000
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: test2@shtb_test1
+POSTHOOK: Output: database:test2
+POSTHOOK: Output: test2@shtb_test1_view1
+PREHOOK: query: CREATE VIEW shtb_test2_view2 AS SELECT * FROM shtb_test2 where KEY > 100
and KEY < 200
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: test2@shtb_test2
+PREHOOK: Output: database:test2
+PREHOOK: Output: test2@shtb_test2_view2
+POSTHOOK: query: CREATE VIEW shtb_test2_view2 AS SELECT * FROM shtb_test2 where KEY >
100 and KEY < 200
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: test2@shtb_test2
+POSTHOOK: Output: database:test2
+POSTHOOK: Output: test2@shtb_test2_view2
+PREHOOK: query: USE test1
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:test1
+POSTHOOK: query: USE test1
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:test1
+PREHOOK: query: SHOW VIEWS
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS
+POSTHOOK: type: SHOWVIEWS
+shtb_full_view2
+shtb_test1_view1
+shtb_test1_view2
+PREHOOK: query: SHOW VIEWS 'test_*'
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS 'test_*'
+POSTHOOK: type: SHOWVIEWS
+PREHOOK: query: SHOW VIEWS '*view2'
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS '*view2'
+POSTHOOK: type: SHOWVIEWS
+shtb_full_view2
+shtb_test1_view2
+PREHOOK: query: SHOW VIEWS LIKE 'test_view1|test_view2'
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS LIKE 'test_view1|test_view2'
+POSTHOOK: type: SHOWVIEWS
+PREHOOK: query: USE test2
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:test2
+POSTHOOK: query: USE test2
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:test2
+PREHOOK: query: SHOW VIEWS 'shtb_*'
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS 'shtb_*'
+POSTHOOK: type: SHOWVIEWS
+shtb_test1_view1
+shtb_test2_view2
+PREHOOK: query: -- SHOW VIEWS basic syntax tests
+USE default
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:default
+POSTHOOK: query: -- SHOW VIEWS basic syntax tests
+USE default
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:default
+PREHOOK: query: SHOW VIEWS FROM test1
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS FROM test1
+POSTHOOK: type: SHOWVIEWS
+shtb_full_view2
+shtb_test1_view1
+shtb_test1_view2
+PREHOOK: query: SHOW VIEWS FROM test2
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS FROM test2
+POSTHOOK: type: SHOWVIEWS
+shtb_test1_view1
+shtb_test2_view2
+PREHOOK: query: SHOW VIEWS IN test1
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS IN test1
+POSTHOOK: type: SHOWVIEWS
+shtb_full_view2
+shtb_test1_view1
+shtb_test1_view2
+PREHOOK: query: SHOW VIEWS IN default
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS IN default
+POSTHOOK: type: SHOWVIEWS
+PREHOOK: query: SHOW VIEWS IN test1 "shtb_test_*"
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS IN test1 "shtb_test_*"
+POSTHOOK: type: SHOWVIEWS
+PREHOOK: query: SHOW VIEWS IN test2 LIKE "nomatch"
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS IN test2 LIKE "nomatch"
+POSTHOOK: type: SHOWVIEWS
+PREHOOK: query: -- SHOW VIEWS from a database with a name that requires escaping
+CREATE DATABASE `database`
+PREHOOK: type: CREATEDATABASE
+PREHOOK: Output: database:database
+POSTHOOK: query: -- SHOW VIEWS from a database with a name that requires escaping
+CREATE DATABASE `database`
+POSTHOOK: type: CREATEDATABASE
+POSTHOOK: Output: database:database
+PREHOOK: query: USE `database`
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:database
+POSTHOOK: query: USE `database`
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:database
+PREHOOK: query: CREATE TABLE foo(a INT)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:database
+PREHOOK: Output: database@foo
+POSTHOOK: query: CREATE TABLE foo(a INT)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:database
+POSTHOOK: Output: database@foo
+PREHOOK: query: CREATE VIEW fooview AS SELECT * FROM foo
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: database@foo
+PREHOOK: Output: database:database
+PREHOOK: Output: database@fooview
+POSTHOOK: query: CREATE VIEW fooview AS SELECT * FROM foo
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: database@foo
+POSTHOOK: Output: database:database
+POSTHOOK: Output: database@fooview
+PREHOOK: query: USE default
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:default
+POSTHOOK: query: USE default
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:default
+PREHOOK: query: SHOW VIEWS FROM `database` LIKE "fooview"
+PREHOOK: type: SHOWVIEWS
+POSTHOOK: query: SHOW VIEWS FROM `database` LIKE "fooview"
+POSTHOOK: type: SHOWVIEWS
+fooview
+PREHOOK: query: DROP VIEW fooview
+PREHOOK: type: DROPVIEW
+POSTHOOK: query: DROP VIEW fooview
+POSTHOOK: type: DROPVIEW
+PREHOOK: query: DROP TABLE foo
+PREHOOK: type: DROPTABLE
+POSTHOOK: query: DROP TABLE foo
+POSTHOOK: type: DROPTABLE
+PREHOOK: query: USE test1
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:test1
+POSTHOOK: query: USE test1
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:test1
+PREHOOK: query: DROP VIEW shtb_test1_view1
+PREHOOK: type: DROPVIEW
+PREHOOK: Input: test1@shtb_test1_view1
+PREHOOK: Output: test1@shtb_test1_view1
+POSTHOOK: query: DROP VIEW shtb_test1_view1
+POSTHOOK: type: DROPVIEW
+POSTHOOK: Input: test1@shtb_test1_view1
+POSTHOOK: Output: test1@shtb_test1_view1
+PREHOOK: query: DROP VIEW shtb_test1_view2
+PREHOOK: type: DROPVIEW
+PREHOOK: Input: test1@shtb_test1_view2
+PREHOOK: Output: test1@shtb_test1_view2
+POSTHOOK: query: DROP VIEW shtb_test1_view2
+POSTHOOK: type: DROPVIEW
+POSTHOOK: Input: test1@shtb_test1_view2
+POSTHOOK: Output: test1@shtb_test1_view2
+PREHOOK: query: DROP VIEW shtb_full_view2
+PREHOOK: type: DROPVIEW
+PREHOOK: Input: test1@shtb_full_view2
+PREHOOK: Output: test1@shtb_full_view2
+POSTHOOK: query: DROP VIEW shtb_full_view2
+POSTHOOK: type: DROPVIEW
+POSTHOOK: Input: test1@shtb_full_view2
+POSTHOOK: Output: test1@shtb_full_view2
+PREHOOK: query: DROP TABLE shtb_test1
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: test1@shtb_test1
+PREHOOK: Output: test1@shtb_test1
+POSTHOOK: query: DROP TABLE shtb_test1
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: test1@shtb_test1
+POSTHOOK: Output: test1@shtb_test1
+PREHOOK: query: DROP DATABASE test1
+PREHOOK: type: DROPDATABASE
+PREHOOK: Input: database:test1
+PREHOOK: Output: database:test1
+POSTHOOK: query: DROP DATABASE test1
+POSTHOOK: type: DROPDATABASE
+POSTHOOK: Input: database:test1
+POSTHOOK: Output: database:test1
+PREHOOK: query: USE test2
+PREHOOK: type: SWITCHDATABASE
+PREHOOK: Input: database:test2
+POSTHOOK: query: USE test2
+POSTHOOK: type: SWITCHDATABASE
+POSTHOOK: Input: database:test2
+PREHOOK: query: DROP VIEW shtb_test1_view1
+PREHOOK: type: DROPVIEW
+PREHOOK: Input: test2@shtb_test1_view1
+PREHOOK: Output: test2@shtb_test1_view1
+POSTHOOK: query: DROP VIEW shtb_test1_view1
+POSTHOOK: type: DROPVIEW
+POSTHOOK: Input: test2@shtb_test1_view1
+POSTHOOK: Output: test2@shtb_test1_view1
+PREHOOK: query: DROP VIEW shtb_test2_view2
+PREHOOK: type: DROPVIEW
+PREHOOK: Input: test2@shtb_test2_view2
+PREHOOK: Output: test2@shtb_test2_view2
+POSTHOOK: query: DROP VIEW shtb_test2_view2
+POSTHOOK: type: DROPVIEW
+POSTHOOK: Input: test2@shtb_test2_view2
+POSTHOOK: Output: test2@shtb_test2_view2
+PREHOOK: query: DROP TABLE shtb_test1
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: test2@shtb_test1
+PREHOOK: Output: test2@shtb_test1
+POSTHOOK: query: DROP TABLE shtb_test1
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: test2@shtb_test1
+POSTHOOK: Output: test2@shtb_test1
+PREHOOK: query: DROP TABLE shtb_test2
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: test2@shtb_test2
+PREHOOK: Output: test2@shtb_test2
+POSTHOOK: query: DROP TABLE shtb_test2
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: test2@shtb_test2
+POSTHOOK: Output: test2@shtb_test2
+PREHOOK: query: DROP DATABASE test2
+PREHOOK: type: DROPDATABASE
+PREHOOK: Input: database:test2
+PREHOOK: Output: database:test2
+POSTHOOK: query: DROP DATABASE test2
+POSTHOOK: type: DROPDATABASE
+POSTHOOK: Input: database:test2
+POSTHOOK: Output: database:test2


Mime
View raw message