You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by an...@apache.org on 2017/05/15 19:35:00 UTC

[1/5] incubator-trafodion git commit: TRAFODION-2610 Register native HBase tables in traf MD plus couple more

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 1767649c4 -> 113c4de55


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/seabase/EXPECTED031
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED031 b/core/sql/regress/seabase/EXPECTED031
index 4d0ba65..b132c19 100644
--- a/core/sql/regress/seabase/EXPECTED031
+++ b/core/sql/regress/seabase/EXPECTED031
@@ -446,7 +446,7 @@ Z            Z            (EXPR)  (EXPR)
 >>invoke t031t10;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T10
--- Definition current  Wed Apr 19 23:24:34 2017
+-- Definition current  Wed May  3 15:06:43 2017
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -648,7 +648,7 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Wed Apr 19 23:25:42 2017
+-- Definition current  Wed May  3 15:07:47 2017
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -679,7 +679,7 @@ A            B
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Wed Apr 19 23:25:51 2017
+-- Definition current  Wed May  3 15:07:53 2017
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -730,7 +730,7 @@ A            B                     C
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Wed Apr 19 23:26:03 2017
+-- Definition current  Wed May  3 15:07:58 2017
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -759,7 +759,7 @@ A            B                     C
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Wed Apr 19 23:26:15 2017
+-- Definition current  Wed May  3 15:08:09 2017
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -784,7 +784,7 @@ A            B                     C
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Wed Apr 19 23:26:24 2017
+-- Definition current  Wed May  3 15:08:13 2017
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -804,7 +804,7 @@ A            B                     C
 >>invoke t031t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1
--- Definition current  Wed Apr 19 23:26:29 2017
+-- Definition current  Wed May  3 15:08:16 2017
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -819,7 +819,7 @@ A            B                     C
 >>invoke t031v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T031V1
--- Definition current  Wed Apr 19 23:26:33 2017
+-- Definition current  Wed May  3 15:08:19 2017
 
   (
     A                                INT DEFAULT NULL
@@ -842,7 +842,7 @@ A            B                     C
 >>invoke t031v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T031V1
--- Definition current  Wed Apr 19 23:26:42 2017
+-- Definition current  Wed May  3 15:08:23 2017
 
   (
     A                                INT DEFAULT NULL
@@ -860,7 +860,7 @@ A            B                     C
 >>invoke t031v1;
 
 -- Definition of Trafodion view TRAFODION.SCH.T031V1
--- Definition current  Wed Apr 19 23:26:52 2017
+-- Definition current  Wed May  3 15:08:31 2017
 
   (
     A                                INT DEFAULT NULL
@@ -947,7 +947,7 @@ CREATE INDEX T031T1I1 ON TRAFODION.SCH.T031T1
 >>invoke table(index_table t031t1i1);
 
 -- Definition of Trafodion table TRAFODION.SCH.T031T1I1
--- Definition current  Wed Apr 19 23:27:18 2017
+-- Definition current  Wed May  3 15:08:49 2017
 
   (
     "A@"                             INT NO DEFAULT
@@ -1090,6 +1090,7 @@ CREATE TABLE T031HIVET1
 ;
 
 REGISTER /*INTERNAL*/ HIVE TABLE HIVE.HIVE.T031HIVET1;
+/* ObjectUID = 4568467281340475481 */
 
 /* Trafodion DDL */
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/seabase/FILTER022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/FILTER022 b/core/sql/regress/seabase/FILTER022
new file mode 100755
index 0000000..b9c9844
--- /dev/null
+++ b/core/sql/regress/seabase/FILTER022
@@ -0,0 +1,39 @@
+#! /bin/sh
+# @@@ START COPYRIGHT @@@
+#
+# 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.
+#
+# @@@ END COPYRIGHT @@@
+
+# Like the pattern-masking of QACOMP, here we filter out such stuff as
+# timestamps and generated identifiers.  Called by the runregr script
+# before doing diff.
+
+fil=$1
+if [ "$fil" = "" ]; then
+  echo "Usage: $0 filename"
+  exit 1
+fi
+
+# filters for showstats output
+#Table ID: 56910649950845593
+#2071939932      8           8           8 SYSKEY
+sed " 
+s/\/\* ObjectUID = *[0-9]*/ObjectUID = <UID removed>/g
+s:^[ ]\{0,9\}[0-9]\{1,10\}:0000000000:
+" $fil

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/seabase/TEST022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST022 b/core/sql/regress/seabase/TEST022
index e8e9d13..b7a1915 100644
--- a/core/sql/regress/seabase/TEST022
+++ b/core/sql/regress/seabase/TEST022
@@ -208,9 +208,19 @@ invoke t022hbm1;
 invoke t022hbm1;
 create table t022hbm1 (a int);
 invoke t022hbm1;
+
+-- join between traf and hbase table with the same name.
+prepare s from select * from t022hbm1, hbase."_MAP_".t022hbm1;
+explain options 'f' s;
+
 drop table t022hbm1;
 invoke t022hbm1;
 
+-- should return error 4056
+prepare s from select * from t022hbm1, hbase."_MAP_".t022hbm1;
+
+prepare s from select * from t022hbm1 x, hbase."_MAP_".t022hbm1 y;
+
 prepare s from select * from t022hbm1;
 execute s;
 select * from t022hbm1 where a = 'a1';
@@ -358,6 +368,47 @@ insert into hbase."_ROW_".t022hbm2 values ('a11',
            column_create(('cf1:A', '10'), ('cf2:B', '20')));
 invoke t022hbm2;
 select * from t022hbm2;
+cleanup hbase table t022hbm2;
+
+-- registration of external hbase tables
+drop external table if exists t022hbm2;
+drop hbase table t022hbm2;
+create hbase table t022hbm2 (column family 'cf1', column family 'cf2');
+create external table t022hbm2 ("cf1".A int, "cf2".B int, 
+                           "cf1".Z varchar(4) not null primary key) 
+     map to hbase table t022hbm2;
+
+insert into hbase."_ROW_".t022hbm2 values ('a11', 
+           column_create(('cf1:A', '10'), ('cf2:B', '20')));
+invoke t022hbm2;
+select * from t022hbm2;
+
+showddl hbase."_CELL_".t022hbm2;
+get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+register hbase table t022hbm2;
+get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+showddl hbase."_CELL_".t022hbm2;
+showddl hbase."_ROW_".t022hbm2;
+unregister hbase table t022hbm2;
+get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+showddl hbase."_CELL_".t022hbm2;
+
+showstats for table hbase."_CELL_".t022hbm2 on every column;
+update statistics for table hbase."_CELL_".t022hbm2 on every column;
+showstats for table hbase."_CELL_".t022hbm2 on every column;
+get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+showddl hbase."_CELL_".t022hbm2;
+
+showstats for table hbase."_ROW_".t022hbm2 on every column;
+update statistics for table hbase."_CELL_".t022hbm2 on every column;
+showstats for table hbase."_CELL_".t022hbm2 on every column;
+get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+showddl hbase."_CELL_".t022hbm2;
+
+showstats for table hbase."_MAP_".t022hbm2 on every column;
+update statistics for table hbase."_MAP_".t022hbm2 on every column;
+showstats for table hbase."_MAP_".t022hbm2 on every column;
+showddl hbase."_MAP_".t022hbm2;
 
 -- error cases
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/seabase/TEST030
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST030 b/core/sql/regress/seabase/TEST030
index f65648b..16d5593 100644
--- a/core/sql/regress/seabase/TEST030
+++ b/core/sql/regress/seabase/TEST030
@@ -25,7 +25,7 @@
 log LOG030 clear;
 
 select to_date('2016-03-01', 'YYYY-MM-DD') from (values(1)) x(a);
-select to_date('03/01/2016', 'MM/DD/YYYY') from (values(1)) x(a);
+select to_date('03/01/2016', 'mm/dd/yyyy') from (values(1)) x(a);
 select to_date('01.03.2016', 'DD.MM.YYYY') from (values(1)) x(a);
 select to_date('2016-03', 'YYYY-MM') from (values(1)) x(a);
 select to_date('2016/03/01', 'YYYY/MM/DD') from (values(1)) x(a);
@@ -33,7 +33,7 @@ select to_date('20160301', 'YYYYMMDD') from (values(1)) x(a);
 select to_date('16/03/01', 'YY/MM/DD') from (values(1)) x(a);
 select to_date('03/01/16', 'MM/DD/YY') from (values(1)) x(a);
 select to_date('03-01-2016', 'MM-DD-YYYY') from (values(1)) x(a);
-select to_date('201603', 'YYYYMM') from (values(1)) x(a);
+select to_date('201603', 'YYYYmm') from (values(1)) x(a);
 select to_date('01-03-2016', 'DD-MM-YYYY') from (values(1)) x(a);
 select to_date('01-MAR-2016', 'DD-MON-YYYY') from (values(1)) x(a);
 select to_date('01MAR2016', 'DDMONYYYY') from (values(1)) x(a);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index 98e8f64..5aa5ced 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -2282,6 +2282,8 @@ short CmpDescribeHiveTable (
       // if this hive view is registered in traf metadata, show that.
       if (naTable->isRegistered())
         {
+          Int64 objectUID = (Int64)naTable->objectUid().get_value();
+
           outputShortLine(space, " ");
 
           sprintf(buf,  "REGISTER%sHIVE VIEW %s;",
@@ -2289,6 +2291,9 @@ short CmpDescribeHiveTable (
                   naTable->getTableName().getQualifiedNameAsString().data());
           NAString bufnas(buf);
           outputLongLine(space, bufnas, 0);
+
+          str_sprintf(buf, "/* ObjectUID = %Ld */", objectUID);
+          outputShortLine(space, buf);
         }
 
       outbuflen = space.getAllocatedSpaceSize();
@@ -2384,6 +2389,8 @@ short CmpDescribeHiveTable (
   if ((type == 2) &&
       (naTable->isRegistered()))
     {
+      Int64 objectUID = (Int64)naTable->objectUid().get_value();
+
       outputShortLine(space, " ");
 
       sprintf(buf,  "REGISTER%sHIVE %s %s;",
@@ -2393,6 +2400,9 @@ short CmpDescribeHiveTable (
 
       NAString bufnas(buf);
       outputLongLine(space, bufnas, 0);
+
+      str_sprintf(buf, "/* ObjectUID = %Ld */", objectUID);
+      outputShortLine(space, buf);
     }
 
   // if this hive table has an associated external table, show ddl
@@ -2894,6 +2904,8 @@ short CmpDescribeSeabaseTable (
   NABoolean isExternalTable = naTable->isExternalTable();
   NABoolean isImplicitExternalTable = naTable->isImplicitExternalTable();
   NABoolean isHbaseMapTable = naTable->isHbaseMapTable();
+  NABoolean isHbaseCellOrRowTable = 
+    (naTable->isHbaseCellTable() || naTable->isHbaseRowTable());
 
   NABoolean isExternalHbaseTable = FALSE;
   NABoolean isExternalHiveTable = FALSE;
@@ -3061,6 +3073,9 @@ short CmpDescribeSeabaseTable (
     }
   else if (type == 2)
     {
+      if (isHbaseCellOrRowTable)
+        outputShortLine(*space, "/*");
+
       NAString tabType;
       if (isVolatile)
         tabType = " VOLATILE ";
@@ -3411,6 +3426,9 @@ short CmpDescribeSeabaseTable (
 
       if (NOT noTrailingSemi)
         outputShortLine(*space, ";");
+
+      if (isHbaseCellOrRowTable)
+        outputShortLine(*space, "*/");
     }
 
   // showddl internal sequences created for identity cols
@@ -3685,13 +3703,46 @@ short CmpDescribeSeabaseTable (
         } // showddl
     }
 
+  Int64 objectUID = (Int64)naTable->objectUid().get_value();
+  if ((type == 2) &&
+      (naTable->isHbaseCellTable() || naTable->isHbaseRowTable()) &&
+      (NOT isView))
+    {
+      outputShortLine(*space, " ");
+
+      outputShortLine(*space,"/* HBase DDL */");
+      sprintf(buf,  "CREATE HBASE TABLE %s ( COLUMN FAMILY '%s') ",
+              naTable->getTableName().getObjectName().data(),
+              "#1");
+      outputShortLine(*space, buf);
+      
+      // if this hbase table is registered in traf metadata, show that.
+      if (naTable->isRegistered())
+        {
+          outputShortLine(*space, " ");
+          
+          sprintf(buf,  "REGISTER%sHBASE %s %s;",
+                  (naTable->isInternalRegistered() ? " /*INTERNAL*/ " : " "),
+                  "TABLE",
+                  naTable->getTableName().getObjectName().data());
+          
+          NAString bufnas(buf);
+          outputLongLine(*space, bufnas, 0);
+
+          str_sprintf(buf, "/* ObjectUID = %Ld */", objectUID);
+          outputShortLine(*space, buf);
+        }
+    }
+
   // If SHOWDDL and authorization is enabled, display GRANTS
   if (type == 2)
   {
-    if (CmpCommon::context()->isAuthorizationEnabled() && displayPrivilegeGrants)
+    //objectUID = (int64_t)naTable->objectUid().get_value();
+    if ((CmpCommon::context()->isAuthorizationEnabled()) && 
+        displayPrivilegeGrants &&
+        (objectUID > 0))
     {
       // now get the grant stmts
-      int64_t objectUID = (int64_t)naTable->objectUid().get_value();
       std::string privMDLoc(ActiveSchemaDB()->getDefaults().getValue(SEABASE_CATALOG));
       privMDLoc += std::string(".\"") + 
                    std::string(SEABASE_PRIVMGR_SCHEMA) + 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/sqlcomp/CmpSeabaseDDL.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDL.h b/core/sql/sqlcomp/CmpSeabaseDDL.h
index f45f72d..3cd1e4e 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDL.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDL.h
@@ -82,7 +82,7 @@ class StmtDDLDropSequence;
 class StmtDDLDropSchema;
 class StmtDDLAlterSchema;
 
-class StmtDDLRegOrUnregHive;
+class StmtDDLRegOrUnregObject;
 
 // Classes for user management
 class StmtDDLRegisterUser;
@@ -1294,7 +1294,7 @@ protected:
   short createLibmgrProcs(ExeCliInterface * cliInterface);
   short grantLibmgrPrivs(ExeCliInterface *cliInterface);
 
-  short registerHiveTable
+  short registerNativeTable
   (
        const NAString &catalogNamePart,
        const NAString &schemaNamePart,
@@ -1306,7 +1306,7 @@ protected:
        NABoolean isInternal
    );
 
-  short unregisterHiveTable
+  short unregisterNativeTable
   (
        const NAString &catalogNamePart,
        const NAString &schemaNamePart,
@@ -1337,8 +1337,8 @@ protected:
        NABoolean cascade
    );
 
-  void regOrUnregHiveObjects (
-       StmtDDLRegOrUnregHive * regOrUnregHiveNode,
+  void regOrUnregNativeObject (
+       StmtDDLRegOrUnregObject * regOrUnregObject,
        NAString &currCatName, NAString &currSchName);
   
   short adjustHiveExternalSchemas(ExeCliInterface *cliInterface);
@@ -1353,15 +1353,15 @@ protected:
 			   NAString &currCatName, NAString &currSchName);
   
   void seabaseGrantRevoke(
-			  StmtDDLNode                  * stmtDDLNode,
+			  StmtDDLNode * stmtDDLNode,
 			  NABoolean isGrant,
 			  NAString &currCatName, NAString &currSchName,
-                          NABoolean useHBase = FALSE);
+                          NABoolean internalCall = FALSE);
+  
+  void hbaseGrantRevoke(StmtDDLNode * stmtDDLNode,
+                        NABoolean isGrant,
+                        NAString &currCatName, NAString &currSchName);
   
-  void seabaseGrantRevokeHBase(StmtDDLNode                  * stmtDDLNode,
-                               NABoolean isGrant,
-                               NAString &currCatName, NAString &currSchName);
-
   void dropSeabaseSchema(StmtDDLDropSchema * dropSchemaNode);
 
   void alterSeabaseSchema(StmtDDLAlterSchema * alterSchemaNode);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
index cd3ccb5..9788b25 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
@@ -1109,6 +1109,41 @@ void CmpSeabaseMDcleanup::cleanupHiveObject(const StmtDDLCleanupObjects * stmtCl
   return;
 }
 
+void CmpSeabaseMDcleanup::cleanupHBaseObject(const StmtDDLCleanupObjects * stmtCleanupNode,
+                                             ExeCliInterface *cliInterface)
+{
+
+  Lng32 cliRC = 0;
+  char query[1000];
+  NABoolean errorSeen = FALSE;
+
+  NAString objName(stmtCleanupNode->getTableNameAsQualifiedName()->getObjectName());
+
+  // drop external table
+  str_sprintf(query, "drop external table if exists %s;",
+              objName.data(),
+              stmtCleanupNode->getTableNameAsQualifiedName()->
+              getQualifiedNameAsString().data());
+  cliRC = cliInterface->executeImmediate(query);
+  if (cliRC < 0)
+    {
+      if (processCleanupErrors(NULL, errorSeen))
+        return;
+    }          
+  
+  // unregister registered table
+  str_sprintf(query, "unregister hbase table if exists %s cleanup;",
+              objName.data());
+  cliRC = cliInterface->executeImmediate(query);
+  if (cliRC < 0)
+    {
+      if (processCleanupErrors(NULL, errorSeen))
+        return;
+    }
+
+  return;
+}
+
 short CmpSeabaseMDcleanup::addReturnDetailsEntry(
                                                  ExeCliInterface * cliInterface,
                                                  Queue* &list, const char *value, 
@@ -2009,6 +2044,12 @@ void CmpSeabaseMDcleanup::cleanupObjects(StmtDDLCleanupObjects * stmtCleanupNode
       return cleanupHiveObject(stmtCleanupNode, &cliInterface);
     }
 
+  if (stmtCleanupNode &&
+      (stmtCleanupNode->getType() == StmtDDLCleanupObjects::HBASE_TABLE_))
+    {
+      return cleanupHBaseObject(stmtCleanupNode, &cliInterface);
+    }
+
   if (gatherDependentObjects(&cliInterface))
     {
       if (stopOnError_)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcleanup.h b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.h
index 4afe00e..29a3b3a 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcleanup.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.h
@@ -121,7 +121,10 @@ class CmpSeabaseMDcleanup : public CmpSeabaseDDL
 
   void cleanupHiveObject(const StmtDDLCleanupObjects * stmtCleanupNode,
                          ExeCliInterface *cliInterface);
-    
+
+  void cleanupHBaseObject(const StmtDDLCleanupObjects * stmtCleanupNode,
+                          ExeCliInterface *cliInterface);
+  
   void populateBlackBox(ExeCliInterface *cliInterface,
                         Queue *returnDetailsList,
                         Int32 &blackBoxLen,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index 9798c3e..fa61ab4 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -9353,12 +9353,12 @@ short CmpSeabaseDDL::executeSeabaseDDL(DDLExpr * ddlExpr, ExprNode * ddlNode,
           else
             unregisterSeabaseUser(registerUserParseNode);
         }
-      else if (ddlNode->getOperatorType() == DDL_REG_OR_UNREG_HIVE)
+      else if (ddlNode->getOperatorType() == DDL_REG_OR_UNREG_OBJECT)
         {
-         StmtDDLRegOrUnregHive *regOrUnregHiveParseNode =
-            ddlNode->castToStmtDDLNode()->castToStmtDDLRegOrUnregHive();
-         regOrUnregHiveObjects(
-              regOrUnregHiveParseNode, currCatName, currSchName);
+         StmtDDLRegOrUnregObject *regOrUnregObjectParseNode =
+            ddlNode->castToStmtDDLNode()->castToStmtDDLRegOrUnregObject();
+         regOrUnregNativeObject(
+              regOrUnregObjectParseNode, currCatName, currSchName);
         }
       else if (ddlNode->getOperatorType() == DDL_CREATE_ROLE)
         {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLmd.h b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
index da072a2..54ef42c 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLmd.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDLmd.h
@@ -270,9 +270,9 @@ enum SeabaseObjectsFlags {
   // (currently for: privilege info, ustat, views).
   SEABASE_OBJECT_IS_IMPLICIT_EXTERNAL  = 0x0000000000000010,
 
-  // set if this hive object was internally registered in traf metadata.
+  // set if this object was internally registered in traf metadata.
   // This can happen for upd stats, create views or grant privs.
-  MD_OBJECTS_HIVE_INTERNAL_REGISTER  = 0x0000000000000020
+  MD_OBJECTS_INTERNAL_REGISTER  = 0x0000000000000020
 
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 408df95..18bea7f 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -490,7 +490,7 @@ short CmpSeabaseDDL::createSeabaseTableExternal(
   }
 
   if (createTableNode->mapToHbaseTable())
-    return 0;
+      return 0;
 
   const NAString extTgtTableName = tgtTableName.getExternalName(TRUE);
 
@@ -554,6 +554,14 @@ short CmpSeabaseDDL::createSeabaseTableExternal(
   Int32 numCols = 0;
   ComTdbVirtTableColumnInfo * colInfoArray = NULL;
         
+  ElemDDLColDefArray &colArray = createTableNode->getColDefArray();
+  ElemDDLColRefArray &keyArray =
+    (createTableNode->getIsConstraintPKSpecified() ?
+     createTableNode->getPrimaryKeyColRefArray() :
+     (createTableNode->getStoreOption() == COM_KEY_COLUMN_LIST_STORE_OPTION ?
+      createTableNode->getKeyColumnArray() :
+      createTableNode->getPrimaryKeyColRefArray()));
+
   // Get a description of the source table
   BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
   NATable *naTable = bindWA.getNATable(cnSrc);
@@ -576,14 +584,6 @@ short CmpSeabaseDDL::createSeabaseTableExternal(
       return -1;
     }
 
-  ElemDDLColDefArray &colArray = createTableNode->getColDefArray();
-  ElemDDLColRefArray &keyArray =
-    (createTableNode->getIsConstraintPKSpecified() ?
-     createTableNode->getPrimaryKeyColRefArray() :
-     (createTableNode->getStoreOption() == COM_KEY_COLUMN_LIST_STORE_OPTION ?
-      createTableNode->getKeyColumnArray() :
-      createTableNode->getPrimaryKeyColRefArray()));
-
   // cqd HIVE_USE_EXT_TABLE_ATTRS:
   //  if OFF, col or key attrs cannot be specified during ext table creation.
   //  if ON,  col attrs could be specified.
@@ -1708,9 +1708,9 @@ short CmpSeabaseDDL::createSeabaseTable2(
   Lng32 cliRC = 0;
 
   ComObjectName tableName(createTableNode->getTableName());
+
   ComAnsiNamePart currCatAnsiName(currCatName);
   ComAnsiNamePart currSchAnsiName(currSchName);
-  tableName.applyDefaults(currCatAnsiName, currSchAnsiName);
 
   // external table to be mapped to an existing hbase table
   NABoolean hbaseMapFormat = FALSE;
@@ -1719,9 +1719,10 @@ short CmpSeabaseDDL::createSeabaseTable2(
   // See ComRowFormat in common/ComSmallDefs.h for details.
   NABoolean hbaseMappedDataFormatIsString = FALSE;
 
-  // Make some additional checks if creating an external table
+  // Make some additional checks if creating an external hive table
   ComObjectName *srcTableName = NULL;
-  if (createTableNode->isExternal())
+  if ((createTableNode->isExternal()) &&
+      (NOT createTableNode->mapToHbaseTable()))
     {
       // The schema name of the target table, if specified,  must match the 
       // schema name of the source table
@@ -1731,26 +1732,16 @@ short CmpSeabaseDDL::createSeabaseTable2(
       srcTableName = new(STMTHEAP) ComObjectName
           (createTableNode->getLikeSourceTableName(), COM_TABLE_NAME);
 
-      if (createTableNode->mapToHbaseTable())
-        {
-          if (CmpCommon::getDefault(TRAF_HBASE_MAPPED_TABLES) == DF_OFF)
-            {
-              *CmpCommon::diags() << DgSqlCode(-3242)
-                                  << DgString0("HBase mapped tables not supported.");
-
-              return -1;
-            }
-
-          ComAnsiNamePart cn(HBASE_SYSTEM_CATALOG);
-          ComAnsiNamePart sn("MAP");
-          srcTableName->applyDefaults(cn, sn);
+      srcTableName->applyDefaults(currCatAnsiName, currSchAnsiName);
 
-          hbaseMapFormat = TRUE;
-          hbaseMappedDataFormatIsString = 
-            createTableNode->isHbaseDataFormatString();
+      if (srcTableName->getCatalogNamePartAsAnsiString() == HBASE_SYSTEM_CATALOG)
+        {
+          *CmpCommon::diags()
+            << DgSqlCode(-3242)
+            << DgString0("Cannot create external table on a native HBase table without the MAP TO option.");
+          
+          return -1;
         }
-      else
-        srcTableName->applyDefaults(currCatAnsiName, currSchAnsiName);
 
       // Convert the native table name to its trafodion name
       NAString tabName = ComConvertNativeNameToTrafName 
@@ -1759,7 +1750,7 @@ short CmpSeabaseDDL::createSeabaseTable2(
          tableName.getObjectNamePartAsAnsiString());
                                
       ComObjectName adjustedName(tabName, COM_TABLE_NAME);
-      NAString type = adjustedName.isExternalHive() ? "HIVE" : "HBASE";
+      NAString type = "HIVE";
       tableName = adjustedName;
 
       // Verify that the name with prepending is not too long
@@ -1797,7 +1788,51 @@ short CmpSeabaseDDL::createSeabaseTable2(
             << DgString1((srcTableName->getObjectNamePart().getExternalName()));
           return -1;
         }
-    } // external table
+    } // external hive table
+
+  // Make some additional checks if creating an external hbase mapped table
+  if ((createTableNode->isExternal()) &&
+      (createTableNode->mapToHbaseTable()))
+    {
+      if (CmpCommon::getDefault(TRAF_HBASE_MAPPED_TABLES) == DF_OFF)
+        {
+          *CmpCommon::diags() << DgSqlCode(-3242)
+                              << DgString0("HBase mapped tables not supported.");
+          
+          return -1;
+        }
+      
+      srcTableName = new(STMTHEAP) ComObjectName
+          (createTableNode->getLikeSourceTableName(), COM_TABLE_NAME);
+
+      ComAnsiNamePart hbCat(HBASE_SYSTEM_CATALOG);
+      ComAnsiNamePart hbSch(HBASE_SYSTEM_SCHEMA);
+      srcTableName->applyDefaults(hbCat, hbSch);
+      
+      hbaseMapFormat = TRUE;
+      hbaseMappedDataFormatIsString = 
+        createTableNode->isHbaseDataFormatString();
+
+      ComAnsiNamePart trafCat(TRAFODION_SYSCAT_LIT);
+      ComAnsiNamePart trafSch(NAString(HBASE_EXT_MAP_SCHEMA), 
+                              ComAnsiNamePart::INTERNAL_FORMAT);
+
+      tableName.setCatalogNamePart(trafCat);
+      tableName.setSchemaNamePart(trafSch);
+
+      // For now the object name of the target table must match the
+      // object name of the source table
+      if (tableName.getObjectNamePart().getExternalName() !=
+          srcTableName->getObjectNamePart().getExternalName())
+        {
+          *CmpCommon::diags()
+            << DgSqlCode(-CAT_EXTERNAL_NAME_MISMATCH)
+            << DgString0 ("HBASE")
+            << DgTableName(tableName.getObjectNamePart().getExternalName())
+            << DgString1((srcTableName->getObjectNamePart().getExternalName()));
+          return -1;
+        }
+    } // external hbase mapped table
 
   const NAString catalogNamePart = tableName.getCatalogNamePartAsAnsiString();
   const NAString schemaNamePart = tableName.getSchemaNamePartAsAnsiString(TRUE);
@@ -1826,7 +1861,6 @@ short CmpSeabaseDDL::createSeabaseTable2(
       return -1;
     }
 
-
   retcode = existsInSeabaseMDTable(&cliInterface, 
                                    catalogNamePart, schemaNamePart, objectNamePart,
                                    COM_UNKNOWN_OBJECT, FALSE);
@@ -2935,7 +2969,7 @@ short CmpSeabaseDDL::createSeabaseTable2(
         ("hbase_serialization", hbVal, FALSE);
     }
   return -1;
-}
+} // createSeabaseTable2
 
 void CmpSeabaseDDL::createSeabaseTable(
                                        StmtDDLCreateTable * createTableNode,
@@ -9493,8 +9527,9 @@ void CmpSeabaseDDL::alterSeabaseTableDropConstraint(
 void CmpSeabaseDDL::seabaseGrantRevoke(
                                       StmtDDLNode * stmtDDLNode,
                                       NABoolean isGrant,
-                                      NAString &currCatName, NAString &currSchName,
-                                      NABoolean useHBase)
+                                      NAString &currCatName, 
+                                      NAString &currSchName,
+                                      NABoolean internalCall)
 {
   Lng32 retcode = 0;
 
@@ -9507,6 +9542,7 @@ void CmpSeabaseDDL::seabaseGrantRevoke(
   StmtDDLGrant * grantNode = NULL;
   StmtDDLRevoke * revokeNode = NULL;
   NAString tabName;
+  NAString origTabName;
   ComAnsiNameSpace nameSpace;  
 
   NAString grantedByName;
@@ -9515,6 +9551,7 @@ void CmpSeabaseDDL::seabaseGrantRevoke(
     {
       grantNode = stmtDDLNode->castToStmtDDLGrant();
       tabName = grantNode->getTableName();
+      origTabName = grantNode->getOrigObjectName();
       nameSpace = grantNode->getGrantNameAsQualifiedName().getObjectNameSpace();
       isGrantedBySpecified = grantNode->isByGrantorOptionSpecified();
       grantedByName = 
@@ -9524,38 +9561,24 @@ void CmpSeabaseDDL::seabaseGrantRevoke(
     {
       revokeNode = stmtDDLNode->castToStmtDDLRevoke();
       tabName = revokeNode->getTableName();
+      origTabName = revokeNode->getOrigObjectName();
       nameSpace = revokeNode->getRevokeNameAsQualifiedName().getObjectNameSpace();
       isGrantedBySpecified = revokeNode->isByGrantorOptionSpecified();
       grantedByName = 
        isGrantedBySpecified ? revokeNode->getByGrantor()->getAuthorizationIdentifier(): "";
     }
 
-  // If using HBase to perform authorization, call it now.
-  ComObjectName tableName(tabName, COM_TABLE_NAME);
-  if (useHBase || isHbase(tableName))
-  {
-    seabaseGrantRevokeHBase(stmtDDLNode, isGrant, currCatName, currSchName);
-    return;
-  }
-
-  ComAnsiNamePart currCatAnsiName(currCatName);
-  ComAnsiNamePart currSchAnsiName(currSchName);
-  tableName.applyDefaults(currCatAnsiName, currSchAnsiName);
-
-  const NAString catalogNamePart = tableName.getCatalogNamePartAsAnsiString();
-  const NAString schemaNamePart = tableName.getSchemaNamePartAsAnsiString(TRUE);
-  const NAString objectNamePart = tableName.getObjectNamePartAsAnsiString(TRUE);
-  const NAString extTableName = tableName.getExternalName(TRUE);
+  ComObjectName origTableName(origTabName, COM_TABLE_NAME);
 
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
   CmpCommon::context()->sqlSession()->getParentQid());
 
-
   BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  CorrName cn(tableName.getObjectNamePart().getInternalName(),
+
+  CorrName cn(origTableName.getObjectNamePart().getInternalName(),
               STMTHEAP,
-              tableName.getSchemaNamePart().getInternalName(),
-              tableName.getCatalogNamePart().getInternalName());
+              origTableName.getSchemaNamePart().getInternalName(),
+              origTableName.getCatalogNamePart().getInternalName());
               
   // set up common information for all grantees
   ComObjectType objectType = COM_BASE_TABLE_OBJECT;
@@ -9581,6 +9604,8 @@ void CmpSeabaseDDL::seabaseGrantRevoke(
   Int32 schemaOwnerID = 0;
   Int64 objectFlags =  0 ;
   NATable *naTable = NULL;
+
+  ComObjectName tableName(tabName, COM_TABLE_NAME);
   if (objectType == COM_BASE_TABLE_OBJECT)
     {
       naTable = bindWA.getNATable(cn);
@@ -9599,8 +9624,20 @@ void CmpSeabaseDDL::seabaseGrantRevoke(
       objectType = naTable->getObjectType();
       if (naTable->isView())
         objectType = COM_VIEW_OBJECT;
+
+      NAString tns = naTable->getTableName().getQualifiedNameAsAnsiString();
+      tableName = ComObjectName(tns);
     }
 
+  ComAnsiNamePart currCatAnsiName(currCatName);
+  ComAnsiNamePart currSchAnsiName(currSchName);
+  tableName.applyDefaults(currCatAnsiName, currSchAnsiName);
+
+  const NAString catalogNamePart = tableName.getCatalogNamePartAsAnsiString();
+  const NAString schemaNamePart = tableName.getSchemaNamePartAsAnsiString(TRUE);
+  const NAString objectNamePart = tableName.getObjectNamePartAsAnsiString(TRUE);
+  const NAString extTableName = tableName.getExternalName(TRUE);
+
   ElemDDLGranteeArray & pGranteeArray = 
     (isGrant ? grantNode->getGranteeArray() : revokeNode->getGranteeArray());
 
@@ -9629,9 +9666,11 @@ void CmpSeabaseDDL::seabaseGrantRevoke(
         return;
       }
 
-  // If column privs specified for non SELECT ops for Hive native tables, 
+  // If column privs specified for non SELECT ops for Hive/HBase native tables, 
   // return an error
-  if (cn.isHive() && (colPrivs.size() > 0))
+  if (naTable && 
+      (naTable->getTableName().isHive() || naTable->getTableName().isHbase()) &&
+      (colPrivs.size() > 0))
     {
       if (hasValue(colPrivs, INSERT_PRIV) ||
           hasValue(colPrivs, UPDATE_PRIV) ||
@@ -9732,6 +9771,52 @@ void CmpSeabaseDDL::seabaseGrantRevoke(
         objectType = COM_VIEW_OBJECT;
     }
 
+  // HBase tables must be registered in traf metadata
+  if (objectUID == 0 &&
+      naTable && 
+      ((naTable->isHbaseCellTable()) || (naTable->isHbaseRowTable())))
+    {
+      // For native hbase tables, grantor must be DB__ROOT or belong
+      // to one of the admin roles:  DB__ROOTROLE, DB__HIVEROLE
+      // In hive, you must be an admin, DB__ROOTROLE and DB__HIVEROLE
+      // is the equivalent of an admin.
+      if (!ComUser::isRootUserID() &&
+          !ComUser::currentUserHasRole(ROOT_ROLE_ID) &&
+          !ComUser::currentUserHasRole(HBASE_ROLE_ID)) 
+        {
+          *CmpCommon::diags() << DgSqlCode (-CAT_NOT_AUTHORIZED);
+          processReturn();
+          return;
+        }
+
+      // register this hive table in traf metadata
+      char query[(ComMAX_ANSI_IDENTIFIER_EXTERNAL_LEN*4) + 100];
+      snprintf(query, sizeof(query),
+               "register internal hbase table if not exists %s.\"%s\".\"%s\"",
+               catalogNamePart.data(),
+               schemaNamePart.data(),
+               objectNamePart.data());
+       Lng32 retcode = cliInterface.executeImmediate(query);
+      if (retcode < 0)
+        {
+          cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+          return;
+        }
+
+      // reload NATable to get registered objectUID
+      naTable = bindWA.getNATable(cn);
+      if (naTable == NULL)
+        {
+          SEABASEDDL_INTERNAL_ERROR("Bad NATable pointer in seabaseGrantRevoke");
+          return;
+        }
+
+      objectUID = (int64_t)naTable->objectUid().get_value();
+      objectOwnerID = (int32_t)naTable->getOwner();
+      schemaOwnerID = naTable->getSchemaOwner();
+      objectType = naTable->getObjectType();
+    }
+
   // for metadata tables, the objectUID is not initialized in the NATable
   // structure
   if (objectUID == 0)
@@ -9852,6 +9937,9 @@ void CmpSeabaseDDL::seabaseGrantRevoke(
   if (result == STATUS_ERROR)
     return;
 
+  if (isHbase(tableName))
+    hbaseGrantRevoke(stmtDDLNode, isGrant, currCatName, currSchName);
+
   // Adjust the stored descriptor
   char objectTypeLit[3] = {0};
   strncpy(objectTypeLit,PrivMgr::ObjectEnumToLit(objectType),2);
@@ -9862,10 +9950,10 @@ void CmpSeabaseDDL::seabaseGrantRevoke(
   return;
 }
 
-void CmpSeabaseDDL::seabaseGrantRevokeHBase(
-                                             StmtDDLNode * stmtDDLNode,
-                                             NABoolean isGrant,
-                                             NAString &currCatName, NAString &currSchName)
+void CmpSeabaseDDL::hbaseGrantRevoke(
+     StmtDDLNode * stmtDDLNode,
+     NABoolean isGrant,
+     NAString &currCatName, NAString &currSchName)
 {
   Lng32 cliRC = 0;
   Lng32 retcode = 0;
@@ -9903,7 +9991,7 @@ void CmpSeabaseDDL::seabaseGrantRevokeHBase(
     {
       *CmpCommon::diags() << DgSqlCode(-1118)
                           << DgTableName(extTableName);
-      //      deallocEHI(ehi); 
+
       processReturn();
       return;
     }
@@ -10138,7 +10226,7 @@ void CmpSeabaseDDL::dropNativeHbaseTable(
   
 }
 
-short CmpSeabaseDDL::registerHiveTable
+short CmpSeabaseDDL::registerNativeTable
 (
      const NAString &catalogNamePart,
      const NAString &schemaNamePart,
@@ -10156,7 +10244,7 @@ short CmpSeabaseDDL::registerHiveTable
 
   Int64 flags = 0;
   if (isRegister && isInternal)
-    flags = MD_OBJECTS_HIVE_INTERNAL_REGISTER;
+    flags = MD_OBJECTS_INTERNAL_REGISTER;
   
   Int64 objUID = -1;
   retcode =
@@ -10198,7 +10286,7 @@ short CmpSeabaseDDL::registerHiveTable
   return 0;
 }
 
-short CmpSeabaseDDL::unregisterHiveTable
+short CmpSeabaseDDL::unregisterNativeTable
 (
      const NAString &catalogNamePart,
      const NAString &schemaNamePart,
@@ -10284,7 +10372,7 @@ short CmpSeabaseDDL::registerHiveView
 
   Int64 flags = 0;
   if (isInternal)
-    flags = MD_OBJECTS_HIVE_INTERNAL_REGISTER;
+    flags = MD_OBJECTS_INTERNAL_REGISTER;
 
   ComObjectType objType = COM_VIEW_OBJECT;
 
@@ -10558,8 +10646,8 @@ short CmpSeabaseDDL::unregisterHiveViewUsage(StmtDDLCreateView * createViewParse
   return 0;
 } 
 
-void CmpSeabaseDDL::regOrUnregHiveObjects (
-     StmtDDLRegOrUnregHive * regOrUnregHiveNode,
+void CmpSeabaseDDL::regOrUnregNativeObject(
+     StmtDDLRegOrUnregObject * regOrUnregObject,
      NAString &currCatName, NAString &currSchName)
 {
   Lng32 retcode = 0;
@@ -10568,29 +10656,45 @@ void CmpSeabaseDDL::regOrUnregHiveObjects (
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
                                CmpCommon::context()->sqlSession()->getParentQid());
 
-  NAString catalogNamePart = regOrUnregHiveNode->getObjNameAsQualifiedName().
+  NAString catalogNamePart = regOrUnregObject->getObjNameAsQualifiedName().
     getCatalogName();
-  NAString schemaNamePart = regOrUnregHiveNode->getObjNameAsQualifiedName().
+  NAString schemaNamePart = regOrUnregObject->getObjNameAsQualifiedName().
     getSchemaName();
-  NAString objectNamePart = regOrUnregHiveNode->getObjNameAsQualifiedName().
+  NAString objectNamePart = regOrUnregObject->getObjNameAsQualifiedName().
     getObjectName();
   ComObjectName tableName;
   NAString tabName;
   NAString extTableName;
 
-  // make sure that underlying hive object exists
+  NABoolean isHive  = (catalogNamePart == HIVE_SYSTEM_CATALOG);
+  NABoolean isHBase = (catalogNamePart == HBASE_SYSTEM_CATALOG);
+
+  if (NOT (isHive || isHBase))
+    {
+      *CmpCommon::diags() << DgSqlCode(-3242) << 
+        DgString0("Register/Unregister statement must specify a hive or hbase object.");
+      
+      processReturn();
+      return;
+    }
+
+  // make sure that underlying hive/hbase object exists
   BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  CorrName cn(objectNamePart, STMTHEAP, schemaNamePart, catalogNamePart);
+  CorrName cn(objectNamePart, STMTHEAP, 
+              (isHBase? HBASE_CELL_SCHEMA : schemaNamePart),
+              catalogNamePart);
 
   NATable * naTable = bindWA.getNATable(cn);
   if (((naTable == NULL) || (bindWA.errStatus())) &&
-      ((regOrUnregHiveNode->isRegister()) || // register
-       (NOT regOrUnregHiveNode->cleanup()))) // unreg and not cleanup
+      ((regOrUnregObject->isRegister()) || // register
+       (NOT regOrUnregObject->cleanup()))) // unreg and not cleanup
     {
+      CmpCommon::diags()->clear();
+
       *CmpCommon::diags() << DgSqlCode(-3251)
-                          << (regOrUnregHiveNode->isRegister() ? DgString0("REGISTER") :
+                          << (regOrUnregObject->isRegister() ? DgString0("REGISTER") :
                               DgString0("UNREGISTER"))
-                          << DgString1(" ");
+                          << DgString1(NAString(" Reason: Specified object ") + objectNamePart + NAString(" does not exist."));
       
       processReturn();
       
@@ -10602,13 +10706,13 @@ void CmpSeabaseDDL::regOrUnregHiveObjects (
 
   if (naTable)
     {
-      if (regOrUnregHiveNode->isRegister() && 
+      if (regOrUnregObject->isRegister() && 
           (naTable->isRegistered())) // already registered
         {
-          if (NOT regOrUnregHiveNode->existsOption())
+          if (NOT regOrUnregObject->existsOption())
             {
               str_sprintf(errReason, " Reason: %s has already been registered.",
-                          regOrUnregHiveNode->getObjNameAsQualifiedName().
+                          regOrUnregObject->getObjNameAsQualifiedName().
                           getQualifiedNameAsString().data());
               *CmpCommon::diags() << DgSqlCode(-3251)
                                   << DgString0("REGISTER")
@@ -10619,13 +10723,13 @@ void CmpSeabaseDDL::regOrUnregHiveObjects (
           
           return;
         }
-      else if ((NOT regOrUnregHiveNode->isRegister()) && // unregister
+      else if ((NOT regOrUnregObject->isRegister()) && // unregister
                (NOT naTable->isRegistered())) // not registered
         {
-          if (NOT regOrUnregHiveNode->existsOption())
+          if (NOT regOrUnregObject->existsOption())
             {
               str_sprintf(errReason, " Reason: %s has not been registered.",
-                          regOrUnregHiveNode->getObjNameAsQualifiedName().
+                          regOrUnregObject->getObjNameAsQualifiedName().
                           getQualifiedNameAsString().data());
               *CmpCommon::diags() << DgSqlCode(-3251)
                                   << DgString0("UNREGISTER")
@@ -10638,25 +10742,26 @@ void CmpSeabaseDDL::regOrUnregHiveObjects (
         }
     }
 
-  // For native hive tables, grantor must be DB__ROOT or belong
-  // to one of the admin roles:  DB__ROOTROLE, DB__HIVEROLE
-  // In hive, you must be an admin, DB__ROOTROLE and DB__HIVEROLE
+  // For native hive/hbase tables, grantor must be DB__ROOT or belong
+  // to one of the admin roles:  DB__ROOTROLE, DB__HIVEROLE/DB__HBASEROLE.
+  // In hive/hbase, you must be an admin, DB__ROOTROLE,DB__HIVEROLE/HBASEROLE
   // is the equivalent of an admin.
   if (!ComUser::isRootUserID() &&
       !ComUser::currentUserHasRole(ROOT_ROLE_ID) &&
-      !ComUser::currentUserHasRole(HIVE_ROLE_ID)) 
+      ((isHive && !ComUser::currentUserHasRole(HIVE_ROLE_ID)) ||
+       (isHBase && !ComUser::currentUserHasRole(HBASE_ROLE_ID))))
     {
       *CmpCommon::diags() << DgSqlCode (-CAT_NOT_AUTHORIZED);
       processReturn();
       return;
     }
 
-  Int32 objOwnerId = HIVE_ROLE_ID;
-  Int32 schemaOwnerId = HIVE_ROLE_ID;
+  Int32 objOwnerId = (isHive ? HIVE_ROLE_ID : HBASE_ROLE_ID);
+  Int32 schemaOwnerId = (isHive ? HIVE_ROLE_ID : HBASE_ROLE_ID);
   Int64 objUID = -1;
   Int64 flags = 0;
-  if ((regOrUnregHiveNode->isRegister()) &&
-      (regOrUnregHiveNode->objType() == COM_SHARED_SCHEMA_OBJECT))
+  if ((regOrUnregObject->isRegister()) &&
+      (regOrUnregObject->objType() == COM_SHARED_SCHEMA_OBJECT))
     {
       retcode =
         updateSeabaseMDObjectsTable
@@ -10664,26 +10769,26 @@ void CmpSeabaseDDL::regOrUnregHiveObjects (
          catalogNamePart.data(),
          schemaNamePart.data(),
          "__SCHEMA__",
-         regOrUnregHiveNode->objType(),
+         regOrUnregObject->objType(),
          NULL,
          objOwnerId, schemaOwnerId,
          flags, objUID);
     }
-  else if (regOrUnregHiveNode->isRegister())
+  else if (regOrUnregObject->isRegister())
     {
-      if (((regOrUnregHiveNode->objType() == COM_BASE_TABLE_OBJECT) &&
-           (naTable->isView())) ||
-          ((regOrUnregHiveNode->objType() == COM_VIEW_OBJECT) &&
-           (! naTable->isView())))
+      if (((regOrUnregObject->objType() == COM_BASE_TABLE_OBJECT) &&
+           (naTable && naTable->isView())) ||
+          ((regOrUnregObject->objType() == COM_VIEW_OBJECT) &&
+           (naTable && (! naTable->isView()))))
         {
           // underlying object is a view but registered object type specified
           // in the register statement is a table, or
           // underlying object is a table but registered object type specified
           // in the register statement is a view
           str_sprintf(errReason, " Reason: Mismatch between specified(%s) and underlying(%s) type for %s.",
-                      (regOrUnregHiveNode->objType() == COM_BASE_TABLE_OBJECT ? "TABLE" : "VIEW"),
+                      (regOrUnregObject->objType() == COM_BASE_TABLE_OBJECT ? "TABLE" : "VIEW"),
                       (naTable->isView() ? "VIEW" : "TABLE"),
-                      regOrUnregHiveNode->getObjNameAsQualifiedName().
+                      regOrUnregObject->getObjNameAsQualifiedName().
                       getQualifiedNameAsString().data());
 
           *CmpCommon::diags() << DgSqlCode(-3251)
@@ -10695,14 +10800,34 @@ void CmpSeabaseDDL::regOrUnregHiveObjects (
           return;
         }
 
-      if (regOrUnregHiveNode->objType() == COM_BASE_TABLE_OBJECT)
+      if (regOrUnregObject->objType() == COM_BASE_TABLE_OBJECT)
         {
-          retcode = registerHiveTable(
-               catalogNamePart, schemaNamePart, objectNamePart,
-               objOwnerId, schemaOwnerId,
-               cliInterface, 
-               regOrUnregHiveNode->isRegister(), 
-               regOrUnregHiveNode->isInternal());
+          if (schemaNamePart == HBASE_SYSTEM_SCHEMA)
+            {
+              // register CELL and ROW formats of HBase table
+              retcode = registerNativeTable(
+                   catalogNamePart, HBASE_CELL_SCHEMA, objectNamePart,
+                   objOwnerId, schemaOwnerId,
+                   cliInterface, 
+                   regOrUnregObject->isRegister(), 
+                   regOrUnregObject->isInternal());
+
+              retcode = registerNativeTable(
+                   catalogNamePart, HBASE_ROW_SCHEMA, objectNamePart,
+                   objOwnerId, schemaOwnerId,
+                   cliInterface, 
+                   regOrUnregObject->isRegister(), 
+                   regOrUnregObject->isInternal());
+            }
+          else
+            {
+              retcode = registerNativeTable(
+                   catalogNamePart, schemaNamePart, objectNamePart,
+                   objOwnerId, schemaOwnerId,
+                   cliInterface, 
+                   regOrUnregObject->isRegister(), 
+                   regOrUnregObject->isInternal());
+            }
         }
       else // COM_VIEW_OBJECT
         {
@@ -10711,8 +10836,8 @@ void CmpSeabaseDDL::regOrUnregHiveObjects (
                objOwnerId, schemaOwnerId,
                naTable,
                cliInterface, 
-               regOrUnregHiveNode->isInternal(),
-               regOrUnregHiveNode->cascade());
+               regOrUnregObject->isInternal(),
+               regOrUnregObject->cascade());
         }
 
       if (retcode < 0)
@@ -10720,11 +10845,25 @@ void CmpSeabaseDDL::regOrUnregHiveObjects (
     }
   else // unregister
     {
-      if (regOrUnregHiveNode->objType() == COM_BASE_TABLE_OBJECT)
+      if (regOrUnregObject->objType() == COM_BASE_TABLE_OBJECT)
         {
-          retcode = unregisterHiveTable(
-               catalogNamePart, schemaNamePart, objectNamePart,
-               cliInterface);
+          if (schemaNamePart == HBASE_SYSTEM_SCHEMA)
+            {
+              // unregister CELL and ROW formats of HBase table
+              retcode = unregisterNativeTable(
+                   catalogNamePart, HBASE_CELL_SCHEMA, objectNamePart,
+                   cliInterface);
+
+              retcode = unregisterNativeTable(
+                   catalogNamePart, HBASE_ROW_SCHEMA, objectNamePart,
+                   cliInterface);
+            }
+          else
+            {
+              retcode = unregisterNativeTable(
+                   catalogNamePart, schemaNamePart, objectNamePart,
+                   cliInterface);
+            }
         }
       else // view
         {
@@ -10732,7 +10871,7 @@ void CmpSeabaseDDL::regOrUnregHiveObjects (
                catalogNamePart, schemaNamePart, objectNamePart,
                naTable,
                cliInterface,
-               regOrUnregHiveNode->cascade());
+               regOrUnregObject->cascade());
         }
     } // unregister
 
@@ -10741,9 +10880,21 @@ void CmpSeabaseDDL::regOrUnregHiveObjects (
 
   ActiveSchemaDB()->getNATableDB()->removeNATable
     (cn,
-     ComQiScope::REMOVE_FROM_ALL_USERS, regOrUnregHiveNode->objType(),
+     ComQiScope::REMOVE_FROM_ALL_USERS, regOrUnregObject->objType(),
      FALSE, FALSE);
   
+  if (isHBase)
+    {
+      CorrName cn(objectNamePart, STMTHEAP, 
+                  HBASE_ROW_SCHEMA,
+                  catalogNamePart);
+
+      ActiveSchemaDB()->getNATableDB()->removeNATable
+        (cn,
+         ComQiScope::REMOVE_FROM_ALL_USERS, regOrUnregObject->objType(),
+         FALSE, FALSE);
+    }
+  
   return;
 }
  

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
index bc210f5..e90596f 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
@@ -349,16 +349,23 @@ short CmpSeabaseDDL::updateViewUsage(StmtDDLCreateView * createViewParseNode,
 				.getQualifiedNameAsAnsiString(),
 				vtul[i].getAnsiNameSpace());
       
-      const NAString catalogNamePart = usedObjName.getCatalogNamePartAsAnsiString();
-      const NAString schemaNamePart = usedObjName.getSchemaNamePartAsAnsiString(TRUE);
+      NAString catalogNamePart = usedObjName.getCatalogNamePartAsAnsiString();
+      NAString schemaNamePart = usedObjName.getSchemaNamePartAsAnsiString(TRUE);
       const NAString objectNamePart = usedObjName.getObjectNamePartAsAnsiString(TRUE);
       const NAString extUsedObjName = usedObjName.getExternalName(TRUE);
 
+      if (usedObjName.isHBaseMappedExtFormat())
+        {
+          ComConvertHBaseMappedExtToInt(catalogNamePart, schemaNamePart,
+                                        catalogNamePart, schemaNamePart);
+        }
+
       char objType[10];
       Int64 usedObjUID = -1;      
-      if ((CmpCommon::getDefault(HIVE_VIEWS) == DF_ON) &&
-          (catalogNamePart == HIVE_SYSTEM_CATALOG))
-        {
+      if (((CmpCommon::getDefault(HIVE_VIEWS) == DF_ON) &&
+           (catalogNamePart == HIVE_SYSTEM_CATALOG)) ||
+          (catalogNamePart == HBASE_SYSTEM_CATALOG))
+       {
           CorrName cn(objectNamePart,STMTHEAP, schemaNamePart,catalogNamePart);
 
           BindWA bindWA(ActiveSchemaDB(),CmpCommon::context(),FALSE/*inDDL*/);
@@ -370,12 +377,13 @@ short CmpSeabaseDDL::updateViewUsage(StmtDDLCreateView * createViewParseNode,
               return -1; 
             }
 
-          if ((naTable->isHiveTable()) &&
-              (CmpCommon::getDefault(HIVE_NO_REGISTER_OBJECTS) == DF_OFF))
-
+          if (((naTable->isHiveTable()) &&
+               (CmpCommon::getDefault(HIVE_NO_REGISTER_OBJECTS) == DF_OFF)) ||
+              ((naTable->isHbaseCellTable()) || (naTable->isHbaseRowTable())))
             {
-              // register this hive object in traf metadata, if not already 
-              str_sprintf(query, "register internal hive %s if not exists %s.\"%s\".\"%s\" %s",
+              // register this object in traf metadata, if not already 
+              str_sprintf(query, "register internal %s %s if not exists %s.\"%s\".\"%s\" %s",
+                          (naTable->isHiveTable() ? "hive" : "hbase"),
                           (naTable->isView() ? "view" : "table"),
                           catalogNamePart.data(),
                           schemaNamePart.data(),
@@ -402,10 +410,9 @@ short CmpSeabaseDDL::updateViewUsage(StmtDDLCreateView * createViewParseNode,
                   SEABASEDDL_INTERNAL_ERROR("Bad NATable pointer in updateViewUsage");
                   return -1; 
                 }
-            } // isHiveTable
+            } // hive or hbase row/cell
 
-          if ((naTable->isHiveTable()) &&
-              (naTable->objectUid().get_value() > 0))
+          if (naTable->objectUid().get_value() > 0)
             {
               usedObjUID = naTable->objectUid().get_value();
               strcpy(objType, 
@@ -419,11 +426,12 @@ short CmpSeabaseDDL::updateViewUsage(StmtDDLCreateView * createViewParseNode,
                 appendErrorObjName(hiveObjsNoUsage, extUsedObjName);
               continue;
             }
-        } // hive table
+        } // hive or hbase table
 
       if (usedObjUID == -1)
         usedObjUID = getObjectUID(cliInterface,
-                                  catalogNamePart.data(), schemaNamePart.data(), 
+                                  catalogNamePart.data(), 
+                                  schemaNamePart.data(), 
                                   objectNamePart.data(),
                                   NULL,
                                   NULL,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/ustat/hs_la.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_la.cpp b/core/sql/ustat/hs_la.cpp
index c591641..0370f47 100644
--- a/core/sql/ustat/hs_la.cpp
+++ b/core/sql/ustat/hs_la.cpp
@@ -121,7 +121,6 @@ NABoolean HSSqTableDef::objExists(NABoolean createExternalTable)
 
 void HSTableDef::setNATable()
   {
-    //BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE, getIsNativeHbaseOrHive());
     BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE, 
                   HSGlobalsClass::isNativeCat(*catalog_));
 
@@ -1082,40 +1081,36 @@ NAString HSHbaseTableDef::getHistLoc(formatType format) const
 }
 
 static 
-Lng32 CreateExternalTable(const NAString& catName, const NAString& schName, const NAString& nativeTableName)
+Lng32 RegisterHiveTable(const NAString& catName, const NAString& schName, const NAString& nativeTableName)
 {
    HSLogMan *LM = HSLogMan::Instance();
    if (LM->LogNeeded())
       {
-        snprintf(LM->msg, sizeof(LM->msg), "Creating external table table for %s on demand.",
+        snprintf(LM->msg, sizeof(LM->msg), "Registering hive table %s on demand.",
                           nativeTableName.data());
         LM->Log(LM->msg);
       }
 
    // do not have to worry about the catalog and schema for the new external table 
    // here. These names will be determined by the processing logic. 
-   NAString ddl = "CREATE IMPLICIT EXTERNAL TABLE ";
-   ddl.append(nativeTableName);
-   ddl.append(" FOR ");
+   NAString ddl = "REGISTER INTERNAL HIVE TABLE IF NOT EXISTS ";
    ddl.append(catName);
    ddl.append(".");
    ddl.append(schName);
    ddl.append(".");
    ddl.append(nativeTableName);
-   ddl.append(" ATTRIBUTE NO AUDIT"); // The external table will not be audited because it 
-                                      // does not store any data.
 
    // set INTERNAL_QUERY_FROM_EXEUTIL bit in Sql_ParserFlags.
-   // This is needed to process 'implicit external' syntax
+   // This is needed to process 'register internal' syntax
    ULng32 flagToSet = INTERNAL_QUERY_FROM_EXEUTIL;
    PushAndSetSqlParserFlags savedParserFlags(flagToSet);
 
    Lng32 retcode = HSFuncExecDDL(ddl.data(), - UERR_INTERNAL_ERROR, NULL,
-                            "Create implicit external table", NULL);
+                            "register hive table", NULL);
 
    if (retcode < 0 && LM->LogNeeded())
       {
-        snprintf(LM->msg, sizeof(LM->msg), "Creation of the external table failed.");
+        snprintf(LM->msg, sizeof(LM->msg), "Registration of the hive table failed.");
         LM->Log(LM->msg);
       }
 
@@ -1123,19 +1118,20 @@ Lng32 CreateExternalTable(const NAString& catName, const NAString& schName, cons
 }
 
 static 
-Lng32 RegisterHiveTable(const NAString& catName, const NAString& schName, const NAString& nativeTableName)
+Lng32 RegisterHBaseTable(const NAString& catName, const NAString& schName, 
+                         const NAString& nativeTableName)
 {
    HSLogMan *LM = HSLogMan::Instance();
    if (LM->LogNeeded())
       {
-        snprintf(LM->msg, sizeof(LM->msg), "Registering hive table %s on demand.",
-                          nativeTableName.data());
+        snprintf(LM->msg, sizeof(LM->msg), "Registering hbase table %s on demand.",
+                 nativeTableName.data());
         LM->Log(LM->msg);
       }
 
    // do not have to worry about the catalog and schema for the new external table 
    // here. These names will be determined by the processing logic. 
-   NAString ddl = "REGISTER INTERNAL HIVE TABLE IF NOT EXISTS ";
+   NAString ddl = "REGISTER INTERNAL HBASE TABLE IF NOT EXISTS ";
    ddl.append(catName);
    ddl.append(".");
    ddl.append(schName);
@@ -1148,11 +1144,11 @@ Lng32 RegisterHiveTable(const NAString& catName, const NAString& schName, const
    PushAndSetSqlParserFlags savedParserFlags(flagToSet);
 
    Lng32 retcode = HSFuncExecDDL(ddl.data(), - UERR_INTERNAL_ERROR, NULL,
-                            "register hive table", NULL);
+                            "register hbase table", NULL);
 
    if (retcode < 0 && LM->LogNeeded())
       {
-        snprintf(LM->msg, sizeof(LM->msg), "Registration of the hive table failed.");
+        snprintf(LM->msg, sizeof(LM->msg), "Registration of the hbase table failed.");
         LM->Log(LM->msg);
       }
 
@@ -1172,11 +1168,12 @@ NABoolean HSTableDef::setObjectUID(NABoolean createExternalTable)
     NAString schName = getSchemaName(EXTERNAL_FORMAT);
     NAString objName = getObjectName(EXTERNAL_FORMAT);
     Lng32 retcode = 0;
+
     if (catName == HIVE_SYSTEM_CATALOG)
       retcode = RegisterHiveTable(catName, schName, objName);
     else
-      retcode = CreateExternalTable(catName, schName, objName);
-      
+      retcode = RegisterHBaseTable(catName, schName, objName);
+
     if (retcode != 0)
       return FALSE;
 
@@ -1184,8 +1181,7 @@ NABoolean HSTableDef::setObjectUID(NABoolean createExternalTable)
     if (!naTbl_)
       return FALSE;
 
-    CorrName corrName(getObjectName(), STMTHEAP, getSchemaName(), getCatName());
-
+    CorrName corrName(objName, STMTHEAP, schName, catName);
     if ( !naTbl_->fetchObjectUIDForNativeTable(corrName, naTbl_->isView()) )
       return FALSE;
 


[5/5] incubator-trafodion git commit: PR-1090 [TRAFODION-2610] Register native HBase tables in traf MD

Posted by an...@apache.org.
PR-1090 [TRAFODION-2610] Register native HBase tables in traf MD 


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/113c4de5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/113c4de5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/113c4de5

Branch: refs/heads/master
Commit: 113c4de556651068f9f0162029c1c1d5ec2f2ba3
Parents: 1767649 3298f0b
Author: Anoop Sharma <an...@esgyn.com>
Authored: Mon May 15 19:34:39 2017 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Mon May 15 19:34:39 2017 +0000

----------------------------------------------------------------------
 core/sql/bin/SqlciErrors.txt              |    2 +-
 core/sql/comexe/ComTdbExeUtil.h           |    1 +
 core/sql/common/ComMisc.cpp               |   42 +
 core/sql/common/ComMisc.h                 |   20 +
 core/sql/common/ComObjectName.h           |   18 +
 core/sql/common/ComSmallDefs.h            |    3 +
 core/sql/common/OperTypeEnum.h            |    2 +-
 core/sql/executor/ExExeUtilGet.cpp        |   34 +
 core/sql/exp/exp_datetime.h               |    6 +-
 core/sql/generator/GenExplain.cpp         |    5 +
 core/sql/generator/GenRelExeUtil.cpp      |   21 +-
 core/sql/generator/GenRelScan.cpp         |   17 +-
 core/sql/optimizer/BindRelExpr.cpp        |   35 +-
 core/sql/optimizer/NATable.cpp            |   24 +-
 core/sql/optimizer/ObjectNames.cpp        |    7 +-
 core/sql/optimizer/ObjectNames.h          |    6 +-
 core/sql/optimizer/RelExeUtil.cpp         |   13 +-
 core/sql/parser/BindStmtDDL.cpp           |   47 +-
 core/sql/parser/ElemDDLNode.cpp           |    4 +-
 core/sql/parser/ElemDDLNode.h             |    4 +-
 core/sql/parser/StmtDDLCleanupObjects.h   |    1 +
 core/sql/parser/StmtDDLGrant.h            |    9 +
 core/sql/parser/StmtDDLMisc.cpp           |    1 +
 core/sql/parser/StmtDDLNode.cpp           |    3 +-
 core/sql/parser/StmtDDLRegOrUnregHive.cpp |   46 +-
 core/sql/parser/StmtDDLRegOrUnregHive.h   |   53 +-
 core/sql/parser/StmtDDLRevoke.h           |    9 +
 core/sql/parser/sqlparser.y               |   57 +-
 core/sql/regress/hive/EXPECTED007         |   28 +-
 core/sql/regress/hive/EXPECTED009         |   85 +-
 core/sql/regress/hive/FILTER007           |    1 +
 core/sql/regress/hive/FILTER009           |    1 +
 core/sql/regress/hive/TEST007             |    2 +-
 core/sql/regress/hive/TEST009             |   20 +-
 core/sql/regress/seabase/EXPECTED022      | 1356 +++++++++++++++---------
 core/sql/regress/seabase/EXPECTED030      |    4 +-
 core/sql/regress/seabase/EXPECTED031      |   23 +-
 core/sql/regress/seabase/FILTER022        |   39 +
 core/sql/regress/seabase/TEST022          |   51 +
 core/sql/regress/seabase/TEST030          |    4 +-
 core/sql/sqlcomp/CmpDescribe.cpp          |   55 +-
 core/sql/sqlcomp/CmpSeabaseDDL.h          |   22 +-
 core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp |   41 +
 core/sql/sqlcomp/CmpSeabaseDDLcleanup.h   |    5 +-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp  |   10 +-
 core/sql/sqlcomp/CmpSeabaseDDLmd.h        |    4 +-
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp   |  381 +++++--
 core/sql/sqlcomp/CmpSeabaseDDLview.cpp    |   38 +-
 core/sql/ustat/hs_la.cpp                  |   38 +-
 49 files changed, 1790 insertions(+), 908 deletions(-)
----------------------------------------------------------------------



[4/5] incubator-trafodion git commit: expected files update

Posted by an...@apache.org.
expected files update


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/3298f0be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/3298f0be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/3298f0be

Branch: refs/heads/master
Commit: 3298f0befb7585391553a9eab4e2f3a5ea283a52
Parents: a44a909
Author: Anoop Sharma <an...@esgyn.com>
Authored: Mon May 15 15:34:37 2017 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Mon May 15 15:34:37 2017 +0000

----------------------------------------------------------------------
 core/sql/regress/seabase/EXPECTED022 | 13 +------------
 core/sql/regress/seabase/TEST022     |  2 +-
 2 files changed, 2 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3298f0be/core/sql/regress/seabase/EXPECTED022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED022 b/core/sql/regress/seabase/EXPECTED022
index fe7aab5..879a079 100644
--- a/core/sql/regress/seabase/EXPECTED022
+++ b/core/sql/regress/seabase/EXPECTED022
@@ -1337,18 +1337,7 @@ CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 
 --- SQL operation complete.
 >>
->>showstats for table hbase."_CELL_".t022hbm2 on every column;
-
-Histogram data for Table HBASE."_CELL_".T022HBM2
-Table ID: 0
-
-   Hist ID # Ints    Rowcount         UEC Colname(s)
-========== ====== =========== =========== ===========================
-
-No Histograms exist for the requested columns or groups
-
-
---- SQL operation complete.
+>>--showstats for table hbase."_CELL_".t022hbm2 on every column;
 >>update statistics for table hbase."_CELL_".t022hbm2 on every column;
 
 --- SQL operation complete.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3298f0be/core/sql/regress/seabase/TEST022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST022 b/core/sql/regress/seabase/TEST022
index ae40246..39da1c7 100644
--- a/core/sql/regress/seabase/TEST022
+++ b/core/sql/regress/seabase/TEST022
@@ -394,7 +394,7 @@ unregister hbase table t022hbm2;
 get hbase registered tables in catalog trafodion, match '%T022HBM2%';
 showddl hbase."_CELL_".t022hbm2;
 
-showstats for table hbase."_CELL_".t022hbm2 on every column;
+--showstats for table hbase."_CELL_".t022hbm2 on every column;
 update statistics for table hbase."_CELL_".t022hbm2 on every column;
 showstats for table hbase."_CELL_".t022hbm2 on every column;
 get hbase registered tables in catalog trafodion, match '%T022HBM2%';


[2/5] incubator-trafodion git commit: TRAFODION-2610 Register native HBase tables in traf MD plus couple more

Posted by an...@apache.org.
TRAFODION-2610 Register native HBase tables in traf MD plus couple more

-- support for registering hbase native cell/row format tables in traf MD
   Syntax:
       register [internal] hbase table [if not exists] <table-name>
       unregister [internal] hbase table [if exists] <table-name>

-- support to get info related to registered hbase tables
   Syntax: get hbase registered table in catalog trafodion

-- enhancements to HBase mapped tables and bug fixes

-- disabling of creation of external tables on native hbase
   tables unless they are mapped tables

-- support for case-insensitive format string in TO_DATE function
   (exp/exp_datetime.h)

-- regress/seabase/TEST022 enhanced with additional tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/6ffe0b5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/6ffe0b5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/6ffe0b5b

Branch: refs/heads/master
Commit: 6ffe0b5b6097ab503965f40734ba7f0275892f01
Parents: ef4a294
Author: Anoop Sharma <an...@esgyn.com>
Authored: Wed May 10 19:16:18 2017 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Wed May 10 19:16:18 2017 +0000

----------------------------------------------------------------------
 core/sql/bin/SqlciErrors.txt              |   2 +-
 core/sql/comexe/ComTdbExeUtil.h           |   1 +
 core/sql/common/ComMisc.cpp               |  42 +++
 core/sql/common/ComMisc.h                 |  20 ++
 core/sql/common/ComObjectName.h           |  18 ++
 core/sql/common/ComSmallDefs.h            |   3 +
 core/sql/common/OperTypeEnum.h            |   2 +-
 core/sql/executor/ExExeUtilGet.cpp        |  34 +++
 core/sql/exp/exp_datetime.h               |   6 +-
 core/sql/generator/GenExplain.cpp         |   5 +
 core/sql/generator/GenRelExeUtil.cpp      |  21 +-
 core/sql/generator/GenRelScan.cpp         |  17 +-
 core/sql/optimizer/BindRelExpr.cpp        |  35 ++-
 core/sql/optimizer/NATable.cpp            |  24 +-
 core/sql/optimizer/ObjectNames.cpp        |   7 +-
 core/sql/optimizer/ObjectNames.h          |   6 +-
 core/sql/optimizer/RelExeUtil.cpp         |  13 +-
 core/sql/parser/BindStmtDDL.cpp           |  47 ++-
 core/sql/parser/ElemDDLNode.cpp           |   4 +-
 core/sql/parser/ElemDDLNode.h             |   4 +-
 core/sql/parser/StmtDDLCleanupObjects.h   |   1 +
 core/sql/parser/StmtDDLGrant.h            |   9 +
 core/sql/parser/StmtDDLMisc.cpp           |   1 +
 core/sql/parser/StmtDDLNode.cpp           |   3 +-
 core/sql/parser/StmtDDLRegOrUnregHive.cpp |  46 +--
 core/sql/parser/StmtDDLRegOrUnregHive.h   |  53 ++--
 core/sql/parser/StmtDDLRevoke.h           |   9 +
 core/sql/parser/sqlparser.y               |  57 +++-
 core/sql/regress/hive/EXPECTED007         |  28 +-
 core/sql/regress/hive/EXPECTED009         |  85 +-----
 core/sql/regress/hive/FILTER007           |   1 +
 core/sql/regress/hive/FILTER009           |   1 +
 core/sql/regress/hive/TEST007             |   2 +-
 core/sql/regress/hive/TEST009             |  20 +-
 core/sql/regress/seabase/EXPECTED022      | 400 +++++++++++++++++++++++--
 core/sql/regress/seabase/EXPECTED030      |   4 +-
 core/sql/regress/seabase/EXPECTED031      |  23 +-
 core/sql/regress/seabase/FILTER022        |  39 +++
 core/sql/regress/seabase/TEST022          |  51 ++++
 core/sql/regress/seabase/TEST030          |   4 +-
 core/sql/sqlcomp/CmpDescribe.cpp          |  55 +++-
 core/sql/sqlcomp/CmpSeabaseDDL.h          |  22 +-
 core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp |  41 +++
 core/sql/sqlcomp/CmpSeabaseDDLcleanup.h   |   5 +-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp  |  10 +-
 core/sql/sqlcomp/CmpSeabaseDDLmd.h        |   4 +-
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp   | 381 ++++++++++++++++-------
 core/sql/sqlcomp/CmpSeabaseDDLview.cpp    |  38 ++-
 core/sql/ustat/hs_la.cpp                  |  38 ++-
 49 files changed, 1316 insertions(+), 426 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------
diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt
index 903d4af..4f2acda 100644
--- a/core/sql/bin/SqlciErrors.txt
+++ b/core/sql/bin/SqlciErrors.txt
@@ -25,7 +25,7 @@
 1023 ZZZZZ 99999 BEGINNER MINOR DBADMIN --- unused ---
 1024 ZZZZZ 99999 BEGINNER MINOR DBADMIN --- unused ---
 1025 ZZZZZ 99999 BEGINNER MINOR DBADMIN Request failed.  Dependent object $0~string0 exists.
-1026 ZZZZZ 99999 BEGINNER MINOR DBADMIN --- unused ---
+1026 ZZZZZ 99999 BEGINNER MINOR DBADMIN Specified object name $0~String0 is invalid for this command.
 1027 ZZZZZ 99999 BEGINNER MINOR DBADMIN The view $0~TableName was created before column privileges were supported. To grant column privileges, please recreate the view.
 1028 ZZZZZ 99999 BEGINNER MINOR DBADMIN The schema must be empty.  It contains at least one object $0~TableName.
 1029 ZZZZZ 99999 BEGINNER MINOR DBADMIN Object $0~TableName could not be created.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/comexe/ComTdbExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbExeUtil.h b/core/sql/comexe/ComTdbExeUtil.h
index 664736a..20c27c1 100644
--- a/core/sql/comexe/ComTdbExeUtil.h
+++ b/core/sql/comexe/ComTdbExeUtil.h
@@ -2483,6 +2483,7 @@ public:
     HIVE_REG_VIEWS_IN_CATALOG_,
     HIVE_REG_OBJECTS_IN_CATALOG_,
     HIVE_EXT_TABLES_IN_CATALOG_,
+    HBASE_REG_TABLES_IN_CATALOG_,
 
     TABLES_IN_SCHEMA_,
     INDEXES_IN_SCHEMA_,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/common/ComMisc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/ComMisc.cpp b/core/sql/common/ComMisc.cpp
index e04aa6c..b4a0cea 100644
--- a/core/sql/common/ComMisc.cpp
+++ b/core/sql/common/ComMisc.cpp
@@ -150,6 +150,48 @@ NABoolean ComIsHbaseMappedSchemaName (
   return (schName == HBASE_EXT_MAP_SCHEMA);
 }
 
+// external format of an HBase mapped table used by 
+// users: HBASE."_MAP_".<tablename>
+NABoolean ComIsHBaseMappedExtFormat(const NAString &catalogNamePart,
+                                    const NAString &schemaNamePart)
+{
+  if ((catalogNamePart == HBASE_SYSTEM_CATALOG) &&
+      (schemaNamePart == HBASE_MAP_SCHEMA))
+    return TRUE;
+
+  return FALSE;
+}
+
+// internal format of HBase mapped table as stored in traf
+// metadata: TRAFODION."_HB_MAP_".<tablename>
+NABoolean ComIsHBaseMappedIntFormat(const NAString &catalogNamePart,
+                                    const NAString &schemaNamePart)
+{
+  if ((catalogNamePart == TRAFODION_SYSCAT_LIT) &&
+      (schemaNamePart == HBASE_EXT_MAP_SCHEMA))
+    return TRUE;
+
+  return FALSE;
+}
+
+void ComConvertHBaseMappedIntToExt(const NAString &inCatName,
+                                   const NAString &inSchName,
+                                   NAString &outCatName, 
+                                   NAString &outSchName)
+{
+  outCatName = HBASE_SYSTEM_CATALOG;
+  outSchName = HBASE_MAP_SCHEMA;
+}
+
+void ComConvertHBaseMappedExtToInt(const NAString &inCatName,
+                                   const NAString &inSchName,
+                                   NAString &outCatName, 
+                                   NAString &outSchName)
+{
+  outCatName = TRAFODION_SYSCAT_LIT;
+  outSchName = HBASE_EXT_MAP_SCHEMA;
+}
+
 // ----------------------------------------------------------------------------
 // function: ComConvertNativeNameToTrafName
 //

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/common/ComMisc.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComMisc.h b/core/sql/common/ComMisc.h
index 450eb61..bbe418d 100644
--- a/core/sql/common/ComMisc.h
+++ b/core/sql/common/ComMisc.h
@@ -60,6 +60,26 @@ NABoolean ComIsTrafodionExternalSchemaName (
 
 NABoolean ComIsHbaseMappedSchemaName (const NAString &schName);
 
+// external format of an HBase mapped table used by 
+// users: HBASE."_MAP_".<tablename>
+NABoolean ComIsHBaseMappedExtFormat(const NAString &catName,
+                                    const NAString &schName);
+
+// internal format of HBase mapped table as stored in traf
+// metadata: TRAFODION."_HB_MAP_".<tablename>
+NABoolean ComIsHBaseMappedIntFormat(const NAString &catName,
+                                    const NAString &schName);
+
+void ComConvertHBaseMappedIntToExt(const NAString &inCatName,
+                                   const NAString &inSchName,
+                                   NAString &outCatName, 
+                                   NAString &outSchName);
+
+void ComConvertHBaseMappedExtToInt(const NAString &inCatName,
+                                   const NAString &inSchName,
+                                   NAString &outCatName, 
+                                   NAString &outSchName);
+
 NAString ComConvertNativeNameToTrafName ( 
                                          const NAString &catalogName,
                                          const NAString &schemaName,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/common/ComObjectName.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComObjectName.h b/core/sql/common/ComObjectName.h
index 1bbc09d..0b07a49 100644
--- a/core/sql/common/ComObjectName.h
+++ b/core/sql/common/ComObjectName.h
@@ -284,6 +284,12 @@ class ComObjectName : public NABasicObject
     inline NABoolean isExternalHive() const;  
     inline NABoolean isExternalHbase() const;
 
+    // external format of an HBase mapped table: HBASE."_MAP_".<tablename>
+    inline NABoolean isHBaseMappedExtFormat() const;
+
+    // internal format of HBase mapped table: TRAFODION."_HB_MAP_".<tablename>
+    inline NABoolean isHBaseMappedIntFormat() const;
+
   protected:
 
     // The following constructor is invoked by a constructor of class CatRoutineActionName
@@ -631,6 +637,18 @@ ComObjectName::isExternalHbase() const
   return FALSE;
 }
 
+NABoolean ComObjectName::isHBaseMappedExtFormat() const
+{
+  return ComIsHBaseMappedExtFormat(getCatalogNamePartAsAnsiString(), 
+                                   getSchemaNamePartAsAnsiString(TRUE));
+}
+
+NABoolean ComObjectName::isHBaseMappedIntFormat() const
+{
+  return ComIsHBaseMappedIntFormat(getCatalogNamePartAsAnsiString(), 
+                                   getSchemaNamePartAsAnsiString(TRUE));
+}
+
 void
 ComObjectName::setCatalogNamePart(const ComAnsiNamePart &catalogNamePart)
 {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index c3803e5..67a9af2 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -119,6 +119,9 @@ typedef NABoolean               ComBoolean;
 
 #define HBASE_SYSTEM_CATALOG          "HBASE"
 #define HBASE_SYSTEM_SCHEMA           "HBASE"
+#define HBASE_CELL_SCHEMA             "_CELL_"
+#define HBASE_ROW_SCHEMA              "_ROW_"
+#define HBASE_MAP_SCHEMA              "_MAP_"
 #define HBASE_HIST_NAME               "SB_HISTOGRAMS"
 #define HBASE_HISTINT_NAME            "SB_HISTOGRAM_INTERVALS"
 #define HBASE_PERS_SAMP_NAME          "SB_PERSISTENT_SAMPLES"

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/common/OperTypeEnum.h
----------------------------------------------------------------------
diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h
index 43e431c..a48f18e 100644
--- a/core/sql/common/OperTypeEnum.h
+++ b/core/sql/common/OperTypeEnum.h
@@ -957,7 +957,7 @@ enum OperatorTypeEnum {
                         DDL_REGISTER_COMPONENT,
                         DDL_UNREGISTER_CATALOG,
                         DDL_REGISTER_USER,
-                        DDL_REG_OR_UNREG_HIVE,
+                        DDL_REG_OR_UNREG_OBJECT,
                         DDL_REINITIALIZE_SQL,
                         DDL_REVOKE,
                         DDL_REVOKE_COMPONENT_PRIVILEGE,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/executor/ExExeUtilGet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilGet.cpp b/core/sql/executor/ExExeUtilGet.cpp
index d342f0a..389fc92 100644
--- a/core/sql/executor/ExExeUtilGet.cpp
+++ b/core/sql/executor/ExExeUtilGet.cpp
@@ -539,6 +539,22 @@ static const QueryString getHiveRegObjectsInCatalogQuery[] =
   {"; "                                                        }
 };
 
+static const QueryString getHBaseRegTablesInCatalogQuery[] =
+{
+  {" select '\"' || trim(O.s) || '\"' || '.' || trim(O.o) ||  "},
+  {" case when G.b is null then ' (inconsistent)' else '' end "},
+  {" from "                                                    },
+  {"  (select trim(schema_name), trim(object_name)            "},
+  {"   from %s.\"%s\".%s where catalog_name = 'HBASE'     "    },
+  {"      and object_type = 'BT') O(s, o) "                    },
+  {"  left join "                                              },
+  {"   (select trim(y) from "                                  },
+  {"    (get external hbase objects) x(y)) G(b)"               },
+  {"   on O.o = G.b  "                                         },
+  {" group by 1 order by 1 "                                   },
+  {"; "                                                        }
+};
+
 static const QueryString getHiveExtTablesInCatalogQuery[] =
 {
   {" select trim(O.a) ||  "                                    },
@@ -925,6 +941,13 @@ short ExExeUtilGetMetadataInfoTcb::displayHeading()
       }
     break;
 
+    case ComTdbExeUtilGetMetadataInfo::HBASE_REG_TABLES_IN_CATALOG_:
+      {
+	str_sprintf(headingBuf_, "HBase Registered Tables in Catalog %s",
+		    getMItdb().getCat());
+      }
+    break;
+
     case ComTdbExeUtilGetMetadataInfo::HIVE_REG_VIEWS_IN_CATALOG_:
       {
 	str_sprintf(headingBuf_, "Hive Registered Views in Catalog %s",
@@ -1821,6 +1844,17 @@ short ExExeUtilGetMetadataInfoTcb::work()
 		  param_[6] = hiveSysCat;
 		}
 	      break;
+
+	      case ComTdbExeUtilGetMetadataInfo::HBASE_REG_TABLES_IN_CATALOG_:
+		{
+		  qs = getHBaseRegTablesInCatalogQuery;
+		  sizeOfqs = sizeof(getHBaseRegTablesInCatalogQuery);
+
+		  param_[0] = cat;
+		  param_[1] = sch;
+		  param_[2] = tab;
+		}
+	      break;
 	      
 	      case ComTdbExeUtilGetMetadataInfo::HIVE_EXT_TABLES_IN_CATALOG_:
 		{

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/exp/exp_datetime.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_datetime.h b/core/sql/exp/exp_datetime.h
index fb15dec..57da0f2 100644
--- a/core/sql/exp/exp_datetime.h
+++ b/core/sql/exp/exp_datetime.h
@@ -340,7 +340,7 @@ static
   {
     for (Lng32 i = DATETIME_FORMAT_MIN; i <= DATETIME_FORMAT_MAX; i++)
       {
-        if (strcmp(formatStr, datetimeFormat[i].str) == 0)
+        if (stricmp(formatStr, datetimeFormat[i].str) == 0)
           {
             if (datetimeFormat[i].format != i)
               return -1;
@@ -351,7 +351,7 @@ static
 
     for (Lng32 i = DATETIME_FORMAT_MIN_NUM; i <= DATETIME_FORMAT_MAX_NUM; i++)
       {
-        if (strcmp(formatStr, datetimeFormat[i].str) == 0)
+        if (stricmp(formatStr, datetimeFormat[i].str) == 0)
           {
             if (datetimeFormat[i].format != i)
               return -1;
@@ -362,7 +362,7 @@ static
 
     for (Lng32 i = DATETIME_FORMAT_MIN_UNRESOLVED; i <= DATETIME_FORMAT_MAX_UNRESOLVED; i++)
       {
-        if (strcmp(formatStr, datetimeFormat[i].str) == 0)
+        if (stricmp(formatStr, datetimeFormat[i].str) == 0)
           {
             if (datetimeFormat[i].format != i)
               return -1;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/generator/GenExplain.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenExplain.cpp b/core/sql/generator/GenExplain.cpp
index 8b6729e..ee622af 100644
--- a/core/sql/generator/GenExplain.cpp
+++ b/core/sql/generator/GenExplain.cpp
@@ -2344,6 +2344,11 @@ ExplainTuple *ExeUtilHbaseCoProcAggr::addSpecificExplainInfo(
     description += "OFF " ;
   }
 
+  NAString aggr("aggr on table ");
+  aggr += NAString(((ComTdbHbaseCoProcAggr *)tdb)->getTableName());
+  description += "coproc_type: ";
+  description += aggr;
+
   explainTuple->setDescription(description);
 
   return explainTuple;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/generator/GenRelExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelExeUtil.cpp b/core/sql/generator/GenRelExeUtil.cpp
index 6e76c0e..71788e3 100644
--- a/core/sql/generator/GenRelExeUtil.cpp
+++ b/core/sql/generator/GenRelExeUtil.cpp
@@ -1645,6 +1645,7 @@ short ExeUtilGetMetadataInfo::codeGen(Generator * generator)
     {  "USER",   "HIVE_REG_VIEWS", "IN", "CATALOG",  1,      1,        0,      0,    ComTdbExeUtilGetMetadataInfo::HIVE_REG_VIEWS_IN_CATALOG_ },
     {  "USER",   "HIVE_REG_OBJECTS", "IN", "CATALOG",  1,      1,        0,      0,  ComTdbExeUtilGetMetadataInfo::HIVE_REG_OBJECTS_IN_CATALOG_ },
     {  "USER",   "HIVE_EXT_TABLES","IN", "CATALOG",  1,      1,        0,      0,    ComTdbExeUtilGetMetadataInfo::HIVE_EXT_TABLES_IN_CATALOG_ },
+    {  "USER",   "HBASE_REG_TABLES","IN", "CATALOG",  1,      1,        0,      0,    ComTdbExeUtilGetMetadataInfo::HBASE_REG_TABLES_IN_CATALOG_ },
 
     {  "USER",   "TABLES",    "IN",    "SCHEMA",   1,      2,        0,      0,      ComTdbExeUtilGetMetadataInfo::TABLES_IN_SCHEMA_ },
     {  "SYSTEM", "TABLES",    "IN",    "SCHEMA",   1,      2,        0,      0,      ComTdbExeUtilGetMetadataInfo::TABLES_IN_SCHEMA_ },
@@ -5160,10 +5161,21 @@ short ExeUtilHbaseCoProcAggr::codeGen(Generator * generator)
   // primary access.
   char * tablename = NULL;
 
-  tablename = 
-      space->AllocateAndCopyToAlignedSpace(
-					   GenGetQualifiedName(getTableName()), 0);
-  
+  TableDesc *tableDesc = getUtilTableDesc();
+  if (tableDesc->getNATable()->isHbaseMapTable())
+    {
+      tablename =
+        space->AllocateAndCopyToAlignedSpace(
+             GenGetQualifiedName(getTableName().getQualifiedNameObj()
+                                 .getObjectName()), 0);
+    }
+  else
+    {
+      tablename = 
+        space->AllocateAndCopyToAlignedSpace(
+             GenGetQualifiedName(getTableName()), 0);
+    }
+
   NAString serverNAS = ActiveSchemaDB()->getDefaults().getValue(HBASE_SERVER);
   NAString zkPortNAS = ActiveSchemaDB()->getDefaults().getValue(HBASE_ZOOKEEPER_PORT);
   char * server = space->allocateAlignedSpace(serverNAS.length() + 1);
@@ -5171,7 +5183,6 @@ short ExeUtilHbaseCoProcAggr::codeGen(Generator * generator)
   char * zkPort = space->allocateAlignedSpace(zkPortNAS.length() + 1);
   strcpy(zkPort, zkPortNAS.data());
 
-  TableDesc *tableDesc = getUtilTableDesc();
   ComTdbHbaseAccess::HbasePerfAttributes * hbpa =
     new(space) ComTdbHbaseAccess::HbasePerfAttributes();
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/generator/GenRelScan.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelScan.cpp b/core/sql/generator/GenRelScan.cpp
index dbb5891..e5a8788 100644
--- a/core/sql/generator/GenRelScan.cpp
+++ b/core/sql/generator/GenRelScan.cpp
@@ -3389,10 +3389,19 @@ short HbaseAccessCoProcAggr::codeGen(Generator * generator)
   // primary access.
   char * tablename = NULL;
 
-  tablename = 
-      space->AllocateAndCopyToAlignedSpace(
-					   GenGetQualifiedName(getTableName()), 0);
-  
+  if (getTableDesc()->getNATable()->isHbaseMapTable())
+    {
+      tablename =
+        space->AllocateAndCopyToAlignedSpace(
+             GenGetQualifiedName(getTableName().getQualifiedNameObj().getObjectName()), 0);
+    }
+  else
+    {
+      tablename = 
+        space->AllocateAndCopyToAlignedSpace(
+             GenGetQualifiedName(getTableName()), 0);
+    }
+
   NAString serverNAS = ActiveSchemaDB()->getDefaults().getValue(HBASE_SERVER);
   NAString zkPortNAS = ActiveSchemaDB()->getDefaults().getValue(HBASE_ZOOKEEPER_PORT);
   char * server = space->allocateAlignedSpace(serverNAS.length() + 1);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp
index 4efe407..203be58 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -1534,6 +1534,15 @@ NATable *BindWA::getNATable(CorrName& corrName,
         }
       }
 
+      // if specified name is an HBASE name, see if a mapped table exists
+      if ((corrName.getQualifiedNameObj().getCatalogName() == HBASE_SYSTEM_CATALOG) &&
+          ((corrName.getQualifiedNameObj().getSchemaName() == HBASE_MAP_SCHEMA) ||
+           (corrName.getQualifiedNameObj().getSchemaName() == HBASE_SYSTEM_SCHEMA)))
+        {
+          corrName.getQualifiedNameObj().setCatalogName(TRAFODION_SYSCAT_LIT);
+          corrName.getQualifiedNameObj().setSchemaName(HBASE_EXT_MAP_SCHEMA);
+        }
+      
       //get NATable (from cache or from metadata)
       table = bindWA->getSchemaDB()->getNATableDB()->
                                      get(corrName, bindWA, inTableDescStruct);
@@ -1594,9 +1603,23 @@ NATable *BindWA::getNATable(CorrName& corrName,
       // move to here, after public schema try because BindUtil_CollectTableUsageInfo
       // saves table info for mv definition, etc.
       // Conditionally (usually) do stuff for Catalog Manager (static func above).
+
       if (catmanCollectTableUsages)
         if (corrName.getSpecialType() != ExtendedQualName::TRIGTEMP_TABLE)
-          BindUtil_CollectTableUsageInfo(bindWA, corrName); 
+          {
+            if ((bindWA->inViewDefinition()) &&
+                (corrName.isHbaseMap()))
+              {
+                // this is an internal hbase mapped name.
+                // Use the original name to store in view definition.
+                CorrName origName(corrName);
+                origName.getQualifiedNameObj().setCatalogName(HBASE_SYSTEM_CATALOG);
+                origName.getQualifiedNameObj().setSchemaName(HBASE_MAP_SCHEMA);
+                BindUtil_CollectTableUsageInfo(bindWA, origName); 
+              }
+            else
+              BindUtil_CollectTableUsageInfo(bindWA, corrName); 
+          }
 
       if (!table)
         {
@@ -5343,13 +5366,15 @@ RelExpr *RelRoot::bindNode(BindWA *bindWA)
                   (selList[0]->getOperatorType() == ITM_COUNT) &&
 		  (selList[0]->origOpType() == ITM_COUNT_STAR__ORIGINALLY))
                 {
-		  NATable *naTable = bindWA->getNATable(scan->getTableName());
+                  CorrName cn(scan->getTableName());
+                  NATable *naTable = bindWA->getNATable(cn);
 		  if (bindWA->errStatus()) 
 		    return this;
 
 		  if (((naTable->getObjectType() == COM_BASE_TABLE_OBJECT) ||
 		       (naTable->getObjectType() == COM_INDEX_OBJECT)) &&
-		      ((naTable->isSeabaseTable()) ||
+		      (((naTable->isSeabaseTable()) &&
+                        (NOT naTable->isHbaseMapTable())) ||
                        ((naTable->isHiveTable()) &&
                         (NOT naTable->isView()) &&
                         (naTable->getClusteringIndex()) &&
@@ -5374,12 +5399,12 @@ RelExpr *RelRoot::bindNode(BindWA *bindWA)
                       if (naTable->isSeabaseTable())
                         eue = 
                           new(CmpCommon::statementHeap())
-                          ExeUtilHbaseCoProcAggr(scan->getTableName(),
+                          ExeUtilHbaseCoProcAggr(cn,
                                                  aggrSet);
                       else
                         eue = 
                           new(CmpCommon::statementHeap())
-                          ExeUtilOrcFastAggr(scan->getTableName(),
+                          ExeUtilOrcFastAggr(cn,
                                              aggrSet);
 		      
 		      eue->bindNode(bindWA);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index 2e62c09..0a4dd6f 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -4818,15 +4818,16 @@ NABoolean NATable::fetchObjectUIDForNativeTable(const CorrName& corrName,
    Int64 extCreateTime = -1;
    Int64 regObjectUID = -1;
    Int64 extObjectUID = -1;
-   if (corrName.isHive())
+   if ((corrName.isHive()) || (corrName.isHbase()))
      {
        // first get uid for the registered table/view.
        Int64 objectFlags = 0;
+
        regObjectUID = lookupObjectUidByName(corrName.getQualifiedNameObj(),
                                             (isView ? COM_VIEW_OBJECT :
                                              COM_BASE_TABLE_OBJECT), FALSE,
-                                            &objectFlags,
-                                            &regCreateTime);
+                                             &objectFlags,
+                                             &regCreateTime);
        
        if (NOT isView)
          {
@@ -4864,7 +4865,7 @@ NABoolean NATable::fetchObjectUIDForNativeTable(const CorrName& corrName,
          {
            setIsRegistered(TRUE);
            
-           if (CmpSeabaseDDL::isMDflagsSet(objectFlags, MD_OBJECTS_HIVE_INTERNAL_REGISTER))
+           if (CmpSeabaseDDL::isMDflagsSet(objectFlags, MD_OBJECTS_INTERNAL_REGISTER))
              setIsInternalRegistered(TRUE);
          }
 
@@ -5791,18 +5792,6 @@ NATable::NATable(BindWA *bindWA,
 
   insertMode_ = 
     COM_MULTISET_TABLE_INSERT_MODE; // allow dup, to check
-  //ComInsertMode::COM_MULTISET_TABLE_INSERT_MODE; // allow dup, to check
-
-  //
-  // Add timestamp information.
-  //
-
-  // To get from Hive
-  /*
-    createTime_ = longArrayToInt64(table_desc->tableDesc()->createtime);
-    redefTime_  = longArrayToInt64(table_desc->tableDesc()->redeftime);
-    cacheTime_  = longArrayToInt64(table_desc->tableDesc()->cachetime);
-  */
 
   // NATable has a schemaUID column, probably should propogate it.
   // for now, set to 0.
@@ -8375,6 +8364,9 @@ NATable * NATableDB::get(CorrName& corrName, BindWA * bindWA,
         {
           table->setIsHbaseMapTable(TRUE);
           table->setIsExternalTable(TRUE);
+
+          //          if (! table->fetchObjectUIDForNativeTable(corrName, FALSE))
+          //            return NULL;
         }
     }
     else if (isHiveTable(corrName) &&

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/optimizer/ObjectNames.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ObjectNames.cpp b/core/sql/optimizer/ObjectNames.cpp
index b50d795..bff93d4 100644
--- a/core/sql/optimizer/ObjectNames.cpp
+++ b/core/sql/optimizer/ObjectNames.cpp
@@ -678,7 +678,7 @@ NABoolean QualifiedName::isHbaseMappedName() const
 
 NABoolean QualifiedName::isHbaseCell() const
 {
-  if (isHbase() && (getSchemaName() == "_CELL_"))
+  if (isHbase() && (getSchemaName() == HBASE_CELL_SCHEMA))
     return TRUE;
   else
     return FALSE;
@@ -686,7 +686,7 @@ NABoolean QualifiedName::isHbaseCell() const
 
 NABoolean QualifiedName::isHbaseRow() const
 {
-  if (isHbase() && (getSchemaName() == "_ROW_"))
+  if (isHbase() && (getSchemaName() == HBASE_ROW_SCHEMA))
     return TRUE;
   else
     return FALSE;
@@ -695,7 +695,8 @@ NABoolean QualifiedName::isHbaseRow() const
 NABoolean QualifiedName::isHbaseCellOrRow() const
 {
   if (isHbase() && 
-      ((getSchemaName() == "_CELL_") || (getSchemaName() == "_ROW_")))
+      ((getSchemaName() == HBASE_CELL_SCHEMA) || 
+       (getSchemaName() == HBASE_ROW_SCHEMA)))
     return TRUE;
   else
     return FALSE;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/optimizer/ObjectNames.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ObjectNames.h b/core/sql/optimizer/ObjectNames.h
index 0bac50c..dadffe5 100644
--- a/core/sql/optimizer/ObjectNames.h
+++ b/core/sql/optimizer/ObjectNames.h
@@ -285,9 +285,9 @@ public:
   NABoolean fullyExpanded() const	{ return catalogName_ != (const char *)""; }
 
   Int32 numberExpanded() const {
-    if(catalogName_) return 3;
-    if(schemaName_) return 2;
-    if(objectName_) return 1;
+    if(NOT catalogName_.isNull()) return 3;
+    if(NOT schemaName_.isNull()) return 2;
+    if(NOT objectName_.isNull()) return 1;
     return 0;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/optimizer/RelExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExeUtil.cpp b/core/sql/optimizer/RelExeUtil.cpp
index 8cc7ab5..b59c58c 100644
--- a/core/sql/optimizer/RelExeUtil.cpp
+++ b/core/sql/optimizer/RelExeUtil.cpp
@@ -4499,12 +4499,12 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
       returnStatus_ = 
         getExprNode()->castToStmtDDLNode()->castToStmtDDLCleanupObjects()->getStatus();
     }
-    else if (getExprNode()->castToStmtDDLNode()->castToStmtDDLRegOrUnregHive())
+    else if (getExprNode()->castToStmtDDLNode()->castToStmtDDLRegOrUnregObject())
     {
       isRegister = TRUE;
 
       qualObjName_ = getExprNode()->castToStmtDDLNode()->
-        castToStmtDDLRegOrUnregHive()->getObjNameAsQualifiedName();
+        castToStmtDDLRegOrUnregObject()->getObjNameAsQualifiedName();
     }
 
     if (isCleanup_)
@@ -4548,15 +4548,6 @@ RelExpr * DDLExpr::bindNode(BindWA *bindWA)
 
         if (isRegister)
           {
-            if (NOT qualObjName_.isHive())
-              {
-                *CmpCommon::diags() << DgSqlCode(-3242) << 
-                  DgString0("Register/Unregister statement must specify a hive object.");
-                
-                bindWA->setErrStatus();
-                return NULL;
-              }
-
             isHbase_ = TRUE;
           }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/BindStmtDDL.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/BindStmtDDL.cpp b/core/sql/parser/BindStmtDDL.cpp
index 9680bd6..76afbb9 100644
--- a/core/sql/parser/BindStmtDDL.cpp
+++ b/core/sql/parser/BindStmtDDL.cpp
@@ -2459,7 +2459,7 @@ StmtDDLRegisterUser::bindNode(BindWA * pBindWA)
 }
 
 // -----------------------------------------------------------------------
-// bindNode() for class StmtDDLRegOrUnregHive
+// bindNode() for class StmtDDLRegOrUnregObject
 // -----------------------------------------------------------------------
 //
 ////
@@ -2467,16 +2467,57 @@ StmtDDLRegisterUser::bindNode(BindWA * pBindWA)
 // binding within the Register hive tree.
 //
 ExprNode *
-StmtDDLRegOrUnregHive::bindNode(BindWA * pBindWA)
+StmtDDLRegOrUnregObject::bindNode(BindWA * pBindWA)
 {
   ComASSERT(pBindWA);
 
+  if (storageType_ == HBASE)
+    {
+      if (origObjName_.numberExpanded() == 1)
+        {
+          objQualName_ = QualifiedName(origObjName_.getObjectName(),
+                                       NAString(HBASE_SYSTEM_SCHEMA),
+                                       NAString(HBASE_SYSTEM_CATALOG));
+        }
+      
+     if (origObjName_.numberExpanded() == 2)
+        {
+          *CmpCommon::diags() << DgSqlCode(-1026)
+                              << DgString0(origObjName_.getQualifiedNameAsString());
+          pBindWA->setErrStatus();
+          return NULL;
+        }
+ 
+     if ((origObjName_.numberExpanded() == 3) &&
+         ((origObjName_.getCatalogName() != HBASE_SYSTEM_CATALOG) ||
+          (NOT ((origObjName_.getSchemaName() == HBASE_CELL_SCHEMA) ||
+                (origObjName_.getSchemaName() == HBASE_ROW_SCHEMA) ||
+                (origObjName_.getSchemaName() == HBASE_MAP_SCHEMA)))))
+        {
+          *CmpCommon::diags() << DgSqlCode(-1026)
+                              << DgString0(origObjName_.getQualifiedNameAsString());
+          pBindWA->setErrStatus();
+          return NULL;
+        }
+    }
+  
   if (applyDefaultsAndValidateObject(pBindWA, &objQualName_))
     {
       pBindWA->setErrStatus();
       return this;
     }
-
+  
+  if (((storageType_ == HIVE) &&
+       (objQualName_.getCatalogName() != HIVE_SYSTEM_CATALOG)) ||
+      ((storageType_ == HBASE) &&
+       (objQualName_.getCatalogName() != HBASE_SYSTEM_CATALOG)))
+    {
+      *CmpCommon::diags() << DgSqlCode(-1026)
+                          << DgString0(origObjName_.getQualifiedNameAsString());
+      pBindWA->setErrStatus();
+      return NULL;
+    }
+      
   markAsBound();
   return this;
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/ElemDDLNode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.cpp b/core/sql/parser/ElemDDLNode.cpp
index 9d7bd9a..39b9486 100644
--- a/core/sql/parser/ElemDDLNode.cpp
+++ b/core/sql/parser/ElemDDLNode.cpp
@@ -1821,8 +1821,8 @@ ElemDDLNode::castToStmtDDLRegisterUser()
   return NULL;
 }
 
-StmtDDLRegOrUnregHive *
-ElemDDLNode::castToStmtDDLRegOrUnregHive()
+StmtDDLRegOrUnregObject *
+ElemDDLNode::castToStmtDDLRegOrUnregObject()
 {
   return NULL;
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/ElemDDLNode.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.h b/core/sql/parser/ElemDDLNode.h
index c9ef18b..e3dabe2 100644
--- a/core/sql/parser/ElemDDLNode.h
+++ b/core/sql/parser/ElemDDLNode.h
@@ -345,7 +345,7 @@ class StmtDDLCreateExceptionTable;
 class StmtDDLDropExceptionTable;
 class StmtDDLRegisterComponent;
 class StmtDDLRegisterUser;
-class StmtDDLRegOrUnregHive;
+class StmtDDLRegOrUnregObject;
 class StmtDDLCreateRole;
 class StmtDDLRoleGrant;
 class StmtDDLCleanupObjects;
@@ -684,7 +684,7 @@ public:
   virtual StmtDDLDropExceptionTable     * castToStmtDDLDropExceptionTable();
   virtual StmtDDLRegisterComponent      * castToStmtDDLRegisterComponent();
   virtual StmtDDLRegisterUser           * castToStmtDDLRegisterUser();
-  virtual StmtDDLRegOrUnregHive         * castToStmtDDLRegOrUnregHive();
+  virtual StmtDDLRegOrUnregObject       * castToStmtDDLRegOrUnregObject();
   virtual StmtDDLCreateRole             * castToStmtDDLCreateRole();
   virtual StmtDDLRoleGrant              * castToStmtDDLRoleGrant();
   virtual StmtDDLCleanupObjects         * castToStmtDDLCleanupObjects();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/StmtDDLCleanupObjects.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCleanupObjects.h b/core/sql/parser/StmtDDLCleanupObjects.h
index d8b15f5..33820e9 100644
--- a/core/sql/parser/StmtDDLCleanupObjects.h
+++ b/core/sql/parser/StmtDDLCleanupObjects.h
@@ -70,6 +70,7 @@ public:
     SCHEMA_SHARED_,
     HIVE_TABLE_,
     HIVE_VIEW_,
+    HBASE_TABLE_,
     UNKNOWN_,
     OBSOLETE_
   };

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/StmtDDLGrant.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLGrant.h b/core/sql/parser/StmtDDLGrant.h
index eb322fe..7500f32 100644
--- a/core/sql/parser/StmtDDLGrant.h
+++ b/core/sql/parser/StmtDDLGrant.h
@@ -91,6 +91,14 @@ public:
         // at least one element.
 
   inline NAString getObjectName() const;
+  inline NAString getOrigObjectName() const
+  {return origObjectName_;}
+
+  void setObjectQualName(QualifiedName qn)
+  {
+    objectQualName_ = qn;
+    objectName_ = qn.getQualifiedNameAsAnsiString();
+  }
 
   inline const QualifiedName * getActionNameAsQualifiedName() const;
 
@@ -149,6 +157,7 @@ public:
 
 private:
 
+  NAString origObjectName_;
   NAString objectName_;
   QualifiedName objectQualName_;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/StmtDDLMisc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLMisc.cpp b/core/sql/parser/StmtDDLMisc.cpp
index 211ca00..af2c9d4 100644
--- a/core/sql/parser/StmtDDLMisc.cpp
+++ b/core/sql/parser/StmtDDLMisc.cpp
@@ -99,6 +99,7 @@ StmtDDLCleanupObjects::bindNode(BindWA * pBindWA)
       (type_ == SCHEMA_SHARED_) ||
       (type_ == HIVE_TABLE_) ||
       (type_ == HIVE_VIEW_) ||
+      (type_ == HBASE_TABLE_) ||
       (type_ == UNKNOWN_))
     {
       ComObjectName tableName(param1_);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/StmtDDLNode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLNode.cpp b/core/sql/parser/StmtDDLNode.cpp
index e61beef..1946735 100644
--- a/core/sql/parser/StmtDDLNode.cpp
+++ b/core/sql/parser/StmtDDLNode.cpp
@@ -183,6 +183,7 @@ StmtDDLGrant::StmtDDLGrant(ElemDDLNode * pPrivileges,
   setChild(INDEX_GRANTEE_LIST, pGranteeList);
   setChild(INDEX_WITH_GRANT_OPTION, pWithGrantOption);
   setChild(INDEX_BY_GRANTOR_OPTION, pByGrantorOption);
+  origObjectName_ = objectQualName_.getQualifiedNameAsAnsiString();
   objectName_ = objectQualName_.getQualifiedNameAsAnsiString();
   //
   // inserts pointers to parse nodes representing privilege
@@ -1067,7 +1068,7 @@ StmtDDLRevoke::StmtDDLRevoke(NABoolean isGrantOptionFor,
   //
   // Fully expand the name. 
   //
-  
+  origObjectName_ = objectQualName_.getQualifiedNameAsAnsiString();  
   objectName_ = objectQualName_.getQualifiedNameAsAnsiString();
  
   //

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/StmtDDLRegOrUnregHive.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLRegOrUnregHive.cpp b/core/sql/parser/StmtDDLRegOrUnregHive.cpp
index ba133b0..1a49e94 100644
--- a/core/sql/parser/StmtDDLRegOrUnregHive.cpp
+++ b/core/sql/parser/StmtDDLRegOrUnregHive.cpp
@@ -21,7 +21,7 @@
 // @@@ END COPYRIGHT @@@
  ****************************************************************************
  *
- * File:         StmtDDLRegOrUnregHive.cpp
+ * File:         StmtDDLRegOrUnregObject.cpp
  * Description:  Methods for classes representing DDL (Un)Register Hive Objs
  *
  * Language:     C++
@@ -48,45 +48,47 @@
 
 
 // -----------------------------------------------------------------------
-// methods for class StmtDDLRegOrUnregHive
+// methods for class StmtDDLRegOrUnregObject
 // -----------------------------------------------------------------------
 
 //
 // constructor
 //
 // constructor used for REGISTER/UNREGISTER HIVE objects
-StmtDDLRegOrUnregHive::StmtDDLRegOrUnregHive(const QualifiedName & origObjName,
-                                             const NABoolean isRegister,
-                                             const ComObjectType objType,
-                                             const NABoolean existsOption,
-                                             const NABoolean isInternal,
-                                             const NABoolean cascade,
-                                             const NABoolean cleanup,
-                                             CollHeap * heap)
-  : StmtDDLNode(DDL_REG_OR_UNREG_HIVE),
-    origObjName_(origObjName, PARSERHEAP()),
-    objQualName_(origObjName, PARSERHEAP()),
-    isRegister_(isRegister),
-    objType_(objType),
-    existsOption_(existsOption),
-    isInternal_(isInternal),
-    cascade_(cascade),
-    cleanup_(cleanup)
+StmtDDLRegOrUnregObject::StmtDDLRegOrUnregObject(const QualifiedName & origObjName,
+                                                 const StorageType storageType,
+                                                 const NABoolean isRegister,
+                                                 const ComObjectType objType,
+                                                 const NABoolean existsOption,
+                                                 const NABoolean isInternal,
+                                                 const NABoolean cascade,
+                                                 const NABoolean cleanup,
+                                                 CollHeap * heap)
+     : StmtDDLNode(DDL_REG_OR_UNREG_OBJECT),
+       origObjName_(origObjName, PARSERHEAP()),
+       objQualName_(origObjName, PARSERHEAP()),
+       storageType_(storageType),
+       isRegister_(isRegister),
+       objType_(objType),
+       existsOption_(existsOption),
+       isInternal_(isInternal),
+       cascade_(cascade),
+       cleanup_(cleanup)
 {
 }
 
 //
 // virtual destructor
 //
-StmtDDLRegOrUnregHive::~StmtDDLRegOrUnregHive()
+StmtDDLRegOrUnregObject::~StmtDDLRegOrUnregObject()
 {
 }
 
 //
 // cast
 //
-StmtDDLRegOrUnregHive *
-StmtDDLRegOrUnregHive::castToStmtDDLRegOrUnregHive()
+StmtDDLRegOrUnregObject *
+StmtDDLRegOrUnregObject::castToStmtDDLRegOrUnregObject()
 {
   return this;
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/StmtDDLRegOrUnregHive.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLRegOrUnregHive.h b/core/sql/parser/StmtDDLRegOrUnregHive.h
index 0e244ec..a32f249 100644
--- a/core/sql/parser/StmtDDLRegOrUnregHive.h
+++ b/core/sql/parser/StmtDDLRegOrUnregHive.h
@@ -1,5 +1,5 @@
-#ifndef STMTDDLREGORUNREGHIVE_H
-#define STMTDDLREGORUNREGHIVE_H
+#ifndef STMTDDLREGORUNREGOBJECT_H
+#define STMTDDLREGORUNREGOBJECT_H
 //******************************************************************************
 // @@@ START COPYRIGHT @@@
 //
@@ -25,9 +25,9 @@
 /* -*-C++-*-
  *****************************************************************************
  *
- * File:         StmtDDLRegOrUnregHive.h
+ * File:         StmtDDLRegOrUnregObject.h
  * Description:  class for parse nodes representing register and unregister
- *               of hive objects in traf metadata.
+ *               of hive/hbase objects in traf metadata.
  *
  * Created:      
  * Language:     C++
@@ -44,7 +44,7 @@
 // -----------------------------------------------------------------------
 // contents of this file
 // -----------------------------------------------------------------------
-class StmtDDLRegOrUnregHive;
+class StmtDDLRegOrUnregObject;
 
 // -----------------------------------------------------------------------
 // forward references
@@ -52,28 +52,36 @@ class StmtDDLRegOrUnregHive;
 // None
 
 // -----------------------------------------------------------------------
-// Register and unregister hive statements
+// Register and unregister hive or hbase statements
 // -----------------------------------------------------------------------
-class StmtDDLRegOrUnregHive : public StmtDDLNode
+class StmtDDLRegOrUnregObject : public StmtDDLNode
 {
 public:
+  enum StorageType
+    {
+      HIVE  = 0,
+      HBASE = 1
+    };
 
   // constructors
-  // register hive
-  StmtDDLRegOrUnregHive(const QualifiedName & origObjName,
-                        const NABoolean isRegister, // true, register. false, unregister
-                        const ComObjectType objType,
-                        const NABoolean existsOption,
-                        const NABoolean isInternal,
-                        const NABoolean cascade,
-                        const NABoolean cleanup,
-                        CollHeap * heap);
-
+  // register hive or hbase
+  StmtDDLRegOrUnregObject(const QualifiedName & origObjName,
+                          const StorageType storageType,
+                          
+                          // true, register. false, unregister
+                          const NABoolean isRegister, 
+                          const ComObjectType objType,
+                          const NABoolean existsOption,
+                          const NABoolean isInternal,
+                          const NABoolean cascade,
+                          const NABoolean cleanup,
+                          CollHeap * heap);
+  
   // virtual destructor
-  virtual ~StmtDDLRegOrUnregHive();
+  virtual ~StmtDDLRegOrUnregObject();
 
   // cast
-  virtual StmtDDLRegOrUnregHive * castToStmtDDLRegOrUnregHive();
+  virtual StmtDDLRegOrUnregObject * castToStmtDDLRegOrUnregObject();
 
   // for binding
   ExprNode * bindNode(BindWA *bindWAPtr);
@@ -105,6 +113,9 @@ private:
   // private data members
   // ---------------------------------------------------------------------
 
+  // type of object to be registered (hive, hbase)
+  StorageType storageType_;
+
   // the tablename specified by user in the register/unregister stmt.
   // This name is not fully qualified during bind phase.
   QualifiedName origObjName_;
@@ -129,6 +140,6 @@ private:
 
   // set to true if cleanup option is specified with unregister
   NABoolean cleanup_;
-}; // class StmtDDLRegOrUnregHive
+}; // class StmtDDLRegOrUnregObject
 
-#endif // STMTDDLREGORUNREGHIVE_H
+#endif // STMTDDLREGORUNREGOBJECT_H

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/StmtDDLRevoke.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLRevoke.h b/core/sql/parser/StmtDDLRevoke.h
index 4369924..2e9d42e 100644
--- a/core/sql/parser/StmtDDLRevoke.h
+++ b/core/sql/parser/StmtDDLRevoke.h
@@ -96,6 +96,14 @@ public:
   inline       QualifiedName & getRevokeNameAsQualifiedName();   
   
   inline NAString getObjectName() const;
+  inline NAString getOrigObjectName() const
+  {return origObjectName_;}
+
+  void setObjectQualName(QualifiedName qn)
+  {
+    objectQualName_ = qn;
+    objectName_ = qn.getQualifiedNameAsAnsiString();
+  }
 
   inline const QualifiedName * getActionNameAsQualifiedName() const;
 
@@ -155,6 +163,7 @@ public:
 
 private:
 
+  NAString origObjectName_;
   NAString objectName_;
   QualifiedName objectQualName_;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 0ed6bc5..89a1738 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -2431,10 +2431,12 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %type <pStmtDDL>                register_component_statement
 %type <pStmtDDL>                register_user_statement
 %type <pStmtDDL>                register_hive_statement
+%type <pStmtDDL>                register_hbase_statement
 %type <boolean>                 optional_internal_clause
 %type <pStmtDDL>                unregister_component_statement
 %type <pStmtDDL>		unregister_user_statement
 %type <pStmtDDL>		unregister_hive_statement
+%type <pStmtDDL>		unregister_hbase_statement
 %type <pElemDDL>  		privileges
 %type <pElemDDL>  		privilege_action_list
 %type <pElemDDL>  		privilege_action
@@ -14468,6 +14470,12 @@ sql_schema_definition_statement :
               | unregister_hive_statement
                                 {
                                 }
+              | register_hbase_statement
+                                {
+                                }
+              | unregister_hbase_statement
+                                {
+                                }
 
 /* type pStmtDDL */
 sql_schema_manipulation_statement :
@@ -15850,6 +15858,8 @@ objects_identifier :
                   | TOK_HIVE TOK_REGISTERED TOK_VIEWS { $$ = new (PARSERHEAP()) NAString("HIVE_REG_VIEWS"); }
                   | TOK_HIVE TOK_REGISTERED TOK_OBJECTS { $$ = new (PARSERHEAP()) NAString("HIVE_REG_OBJECTS"); }
                   | TOK_HIVE TOK_EXTERNAL TOK_TABLES { $$ = new (PARSERHEAP()) NAString("HIVE_EXT_TABLES"); }
+                  | TOK_HBASE TOK_REGISTERED TOK_TABLES { $$ = new (PARSERHEAP()) NAString("HBASE_REG_TABLES"); }
+
 
 privileges_identifier :
                     TOK_PRIVILEGES { $$ = new (PARSERHEAP()) NAString("PRIVILEGES"); }
@@ -30214,6 +30224,8 @@ cleanup_objects_statement : TOK_CLEANUP cleanup_object_identifier ddl_qualified_
                    ot = StmtDDLCleanupObjects::HIVE_TABLE_;
                  else if (*$2 == "HIVE_VIEW")
                    ot = StmtDDLCleanupObjects::HIVE_VIEW_;
+                 else if (*$2 == "HBASE_TABLE")
+                   ot = StmtDDLCleanupObjects::HBASE_TABLE_;
                  else if (*$2 == "OBJECT")
                    ot = StmtDDLCleanupObjects::UNKNOWN_;
                  else
@@ -30334,6 +30346,7 @@ cleanup_object_identifier : object_identifier
                        | TOK_OBJECT { $$ = new (PARSERHEAP()) NAString("OBJECT");}
                        | TOK_HIVE TOK_TABLE { $$ = new (PARSERHEAP()) NAString("HIVE_TABLE");}
                        | TOK_HIVE TOK_VIEW { $$ = new (PARSERHEAP()) NAString("HIVE_VIEW");}
+                       | TOK_HBASE TOK_TABLE { $$ = new (PARSERHEAP()) NAString("HBASE_TABLE");}
 
 /* type boolean */
 optional_cleanup_return_details : empty
@@ -32948,8 +32961,9 @@ register_hive_statement : TOK_REGISTER optional_internal_clause TOK_HIVE object_
                               }
 
                             $$ = new (PARSERHEAP())
-                              StmtDDLRegOrUnregHive(
+                              StmtDDLRegOrUnregObject(
                                    *$6,
+                                   StmtDDLRegOrUnregObject::HIVE,
                                    TRUE, // register
                                    (*$4 == "TABLE" ? COM_BASE_TABLE_OBJECT
                                     : (*$4 == "VIEW" ? COM_VIEW_OBJECT
@@ -32982,8 +32996,9 @@ unregister_hive_statement : TOK_UNREGISTER optional_internal_clause TOK_HIVE obj
                                   }
                                 
                                 $$ = new (PARSERHEAP())
-                                  StmtDDLRegOrUnregHive(
+                                  StmtDDLRegOrUnregObject(
                                        *$6,
+                                       StmtDDLRegOrUnregObject::HIVE,
                                        FALSE, // unregister
                                        (*$4 == "TABLE" ? COM_BASE_TABLE_OBJECT
                                         : (*$4 == "VIEW" ? COM_VIEW_OBJECT
@@ -32996,6 +33011,44 @@ unregister_hive_statement : TOK_UNREGISTER optional_internal_clause TOK_HIVE obj
                                 delete $6;
                               }
 
+/* type pStmtDDL */
+// Syntax: register [internal] hbase table [if not exists] <table-name> 
+register_hbase_statement : TOK_REGISTER optional_internal_clause TOK_HBASE TOK_TABLE optional_if_not_exists_clause ddl_qualified_name
+                          {
+                            StmtDDLRegOrUnregObject *pNode = new (PARSERHEAP())
+                              StmtDDLRegOrUnregObject(
+                                   *$6,
+                                   StmtDDLRegOrUnregObject::HBASE,
+                                   TRUE, // register
+                                   COM_BASE_TABLE_OBJECT,
+                                   $5, // if not exists?
+                                   $2, // is internal registration?
+                                   FALSE,
+                                   FALSE,
+                                   PARSERHEAP());
+
+                            $$ = pNode;
+                            delete $6;
+                          }
+
+/* type pStmtDDL */
+// Syntax: unregister [internal] hbase table [if exists] <table-name>
+unregister_hbase_statement : TOK_UNREGISTER optional_internal_clause TOK_HBASE TOK_TABLE optional_if_exists_clause ddl_qualified_name optional_cleanup
+                              {
+                                $$ = new (PARSERHEAP())
+                                  StmtDDLRegOrUnregObject(
+                                       *$6,
+                                       StmtDDLRegOrUnregObject::HBASE,
+                                       FALSE, // unregister
+                                       COM_BASE_TABLE_OBJECT,
+                                       $5, // if exists?
+                                       $2, // is internal unregister?
+                                       FALSE,
+                                       $7, // is cleanup?
+                                       PARSERHEAP());
+                                delete $6;
+                              }
+
 /* type boolean */
 optional_internal_clause : empty
                   {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/hive/EXPECTED007
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED007 b/core/sql/regress/hive/EXPECTED007
index 81ad6c0..d8eab54 100644
--- a/core/sql/regress/hive/EXPECTED007
+++ b/core/sql/regress/hive/EXPECTED007
@@ -48,6 +48,7 @@ CREATE TABLE THIVE1
 ;
 
 REGISTER /*INTERNAL*/ HIVE TABLE HIVE.HIVE.THIVE1;
+/* ObjectUID = 7486236896221741445 */
 
 --- SQL operation complete.
 >>
@@ -79,7 +80,7 @@ REGISTER /*INTERNAL*/ HIVE TABLE HIVE.HIVE.THIVE1;
 >>invoke trafodion.sch007.vhivehbase;
 
 -- Definition of Trafodion view TRAFODION.SCH007.VHIVEHBASE
--- Definition current  Thu Apr  6 21:43:36 2017
+-- Definition current  Wed May  3 05:10:02 2017
 
   (
     AA                               INT DEFAULT NULL
@@ -257,6 +258,7 @@ CREATE TABLE THIVE2
 ;
 
 REGISTER /*INTERNAL*/ HIVE TABLE HIVE.HIVE.THIVE2;
+/* ObjectUID = 7486236896221741067 */
 
 --- SQL operation complete.
 >>showddl trafodion.sch007.vhive3;
@@ -353,9 +355,7 @@ A            B
 
 >>unregister hive table if exists hive.hive.thive1;
 
-*** ERROR[4263] Object HIVE.HIVE.THIVE1 has invalid state and cannot be accessed. It is registered in trafodion metadata but the correponding hive object does not exist. Use 'cleanup hive table/view' command to cleanup this object.
-
-*** ERROR[3251] UNREGISTER operation could not be completed.
+*** ERROR[3251] UNREGISTER operation could not be completed. Reason: Specified object THIVE1 does not exist.
 
 --- SQL operation failed with errors.
 >>select * from hive.hive.thive1;
@@ -411,7 +411,7 @@ A            B
 >>invoke hive.hivesch007.vhive1;
 
 -- Definition of native Hive view VHIVE1
--- Definition current  Thu Apr  6 21:45:25 2017
+-- Definition current  Wed May  3 05:11:22 2017
 
   (
     A                                INT
@@ -453,7 +453,7 @@ A
 >>invoke hive.hivesch007.vhive11;
 
 -- Definition of native Hive view VHIVE11
--- Definition current  Thu Apr  6 21:45:28 2017
+-- Definition current  Wed May  3 05:11:24 2017
 
   (
     A                                INT
@@ -669,6 +669,7 @@ CREATE VIEW vhive11 AS
   select vhive1.a from hivesch007.vhive1 where vhive1.a > 0 ;
 
 REGISTER HIVE VIEW HIVE.HIVESCH007.VHIVE11;
+/* ObjectUID = 7463718898080907566 */
 
 --- SQL operation complete.
 >>get tables in view hive.hivesch007.vhive11;
@@ -929,7 +930,7 @@ CREATE EXTERNAL TABLE THIVE9
 >>grant select on hive.hivesch007.thive9 to sql_user3;
 
 --- SQL operation complete.
->>get privileges for user sql_user3;
+>>get privileges for user sql_user3, match '%HIVESCH007%';
 
 Privileges for User SQL_USER3
 =============================
@@ -946,11 +947,11 @@ S------    HIVE.HIVESCH007.THIVE9
 >>showstats for table hive.hivesch007.thive9 on every column;
 
 Histogram data for Table HIVE.HIVESCH007.THIVE9
-Table ID: 1101817735408395584
+Table ID: 7463718898080914461
 
    Hist ID # Ints    Rowcount         UEC Colname(s)
 ========== ====== =========== =========== ===========================
- 808652373      6           6           6 A
+ 770517434      6           6           6 A
 
 
 --- SQL operation complete.
@@ -989,6 +990,7 @@ CREATE TABLE THIVE9
 ;
 
 REGISTER HIVE TABLE HIVE.HIVESCH007.THIVE9;
+/* ObjectUID = 7463718898080914461 */
 
 /* Trafodion DDL */
 
@@ -1000,11 +1002,11 @@ CREATE EXTERNAL TABLE THIVE9
 >>showstats for table hive.hivesch007.thive9 on every column;
 
 Histogram data for Table HIVE.HIVESCH007.THIVE9
-Table ID: 1101817735408395584
+Table ID: 7463718898080914461
 
    Hist ID # Ints    Rowcount         UEC Colname(s)
 ========== ====== =========== =========== ===========================
- 808652373      6           6           6 A
+ 770517434      6           6           6 A
 
 
 --- SQL operation complete.
@@ -1031,11 +1033,11 @@ CREATE EXTERNAL TABLE THIVE9
 >>showstats for table hive.hivesch007.thive9 on every column;
 
 Histogram data for Table HIVE.HIVESCH007.THIVE9
-Table ID: 1101817735408395584
+Table ID: 7463718898080914461
 
    Hist ID # Ints    Rowcount         UEC Colname(s)
 ========== ====== =========== =========== ===========================
- 808652373      6           6           6 A
+ 770517434      6           6           6 A
 
 
 --- SQL operation complete.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/hive/EXPECTED009
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED009 b/core/sql/regress/hive/EXPECTED009
index b56099f..6d97be0 100644
--- a/core/sql/regress/hive/EXPECTED009
+++ b/core/sql/regress/hive/EXPECTED009
@@ -396,73 +396,6 @@ A            B            C            D
 --- 10 row(s) selected.
 >>
 >>obey TEST009(test_hbase);
->>-- create external tables for precreated tables
->>create external table "baseball" for hbase."_ROW_"."baseball";
-
---- SQL operation complete.
->>create external table "baseball" for hbase."_CELL_"."baseball";
-
---- SQL operation complete.
->>
->>-- should create schemas called "_HB__ROW__" and "_HB__CELL__"
->>execute get_hb_schemas;
-
-SCHEMA_NAME
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-
-_HB__ROW__                                                                                                                                                                                                                                                      
-_HB__CELL__                                                                                                                                                                                                                                                     
-
---- 2 row(s) selected.
->>
->>-- Verify tables were created
->>invoke trafodion."_HB__ROW__"."baseball";
-
--- Definition of Trafodion external table TRAFODION."_HB__ROW__"."baseball"
--- Definition current  Mon May  1 18:17:41 2017
-
-  (
-    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
-      COLLATE DEFAULT DEFAULT NULL NOT NULL NOT DROPPABLE
-  , COLUMN_DETAILS                   VARCHAR(10000) CHARACTER SET ISO88591
-      COLLATE DEFAULT DEFAULT NULL NOT NULL NOT DROPPABLE
-  )
-
---- SQL operation complete.
->>invoke trafodion."_HB__CELL__"."baseball";
-
--- Definition of Trafodion external table TRAFODION."_HB__CELL__"."baseball"
--- Definition current  Mon May  1 18:17:42 2017
-
-  (
-    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
-      COLLATE DEFAULT DEFAULT NULL NOT NULL NOT DROPPABLE
-  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
-      COLLATE DEFAULT DEFAULT NULL NOT NULL NOT DROPPABLE
-  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
-      COLLATE DEFAULT DEFAULT NULL NOT NULL NOT DROPPABLE
-  , COL_TIMESTAMP                    LARGEINT DEFAULT NULL NOT NULL NOT
-      DROPPABLE
-  , COL_VALUE                        VARCHAR(1000) CHARACTER SET ISO88591
-      COLLATE DEFAULT DEFAULT NULL NOT NULL NOT DROPPABLE
-  )
-
---- SQL operation complete.
->>showddl trafodion."_HB__ROW__"."baseball";
-
-CREATE EXTERNAL TABLE baseball
-  FOR HBASE."_ROW_"."baseball"
-;
-
---- SQL operation complete.
->>showddl trafodion."_HB__CELL__"."baseball";
-
-CREATE EXTERNAL TABLE baseball
-  FOR HBASE."_CELL_"."baseball"
-;
-
---- SQL operation complete.
->>
 >>select count(*) from hbase."_ROW_"."baseball";
 
 (EXPR)              
@@ -491,20 +424,12 @@ ROW_ID      COLS
 
 --- 3 row(s) selected.
 >>
->>-- fails since accesses to the external name are prohibited
->>select * from trafodion."_HB__ROW__"."baseball";
-
-*** ERROR[4258] Trying to access external table TRAFODION."_HB__ROW__"."baseball" through its external name format. Please use the native table name.
-
-*** ERROR[8822] The statement was not prepared.
-
->>
->>drop external table trafodion."_HB__ROW__"."baseball";
+>>-- error. Cannot create a non-hbase-mapped table
+>>create external table "baseball" for hbase."_ROW_"."baseball";
 
---- SQL operation complete.
->>drop external table "baseball" for hbase."_CELL_"."baseball";
+*** ERROR[3242] This statement is not supported. Reason: Cannot create external table on a native HBase table without the MAP TO option.
 
---- SQL operation complete.
+--- SQL operation failed with errors.
 >>
 >>obey TEST009(test_ext);
 >>-- test external table attributes
@@ -980,6 +905,7 @@ CREATE TABLE DATE_DIM
 ;
 
 REGISTER /*INTERNAL*/ HIVE TABLE HIVE.HIVE.DATE_DIM;
+/* ObjectUID = 9189160505820275449 */
 
 /* Trafodion DDL */
 
@@ -1214,6 +1140,7 @@ CREATE TABLE DATE_DIM
 ;
 
 REGISTER /*INTERNAL*/ HIVE TABLE HIVE.HIVE.DATE_DIM;
+/* ObjectUID = 9189160505820275449 */
 
 /* Trafodion DDL */
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/hive/FILTER007
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/FILTER007 b/core/sql/regress/hive/FILTER007
index d15a796..4fe6448 100755
--- a/core/sql/regress/hive/FILTER007
+++ b/core/sql/regress/hive/FILTER007
@@ -35,6 +35,7 @@ fi
 #2071939932      8           8           8 SYSKEY
 sed " 
 s/Table ID: *[0-9]*/Table ID: <ID removed>/g
+s/\/\* ObjectUID = *[0-9]*/ObjectUID = <UID removed>/g
 s:^[ ]\{0,9\}[0-9]\{1,10\}:0000000000:
 " $fil
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/hive/FILTER009
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/FILTER009 b/core/sql/regress/hive/FILTER009
index 6c0e15a..3e46af6 100755
--- a/core/sql/regress/hive/FILTER009
+++ b/core/sql/regress/hive/FILTER009
@@ -46,4 +46,5 @@ s/num_cache_entries[ ]* .*/num_cache_entries... removed/g
 s/num_inner_tuples[ ]* .*/num_inner_tuples... removed/g
 s/REQUESTS_IN[ ]*[\.]* .*/REQUESTS_IN... removed/g
 s/ROWS\/REQUEST[ ]*[\.]* .*/ROWS\/REQUESTS... removed/g
+s/\/\* ObjectUID = *[0-9]*/ObjectUID = <UID removed>/g
 " $fil

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/hive/TEST007
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/TEST007 b/core/sql/regress/hive/TEST007
index 6fb32d7..3bac697 100644
--- a/core/sql/regress/hive/TEST007
+++ b/core/sql/regress/hive/TEST007
@@ -316,7 +316,7 @@ drop external table if exists thive9 for hive.hivesch007.thive9;
 create external table thive9 for hive.hivesch007.thive9;
 showddl thive9;
 grant select on hive.hivesch007.thive9 to sql_user3;
-get privileges for user sql_user3;
+get privileges for user sql_user3, match '%HIVESCH007%';
 insert into hive.hivesch007.thive9 values (1), (2), (3), (4), (5), (6);
 update statistics for table hive.hivesch007.thive9 on every column;
 showstats for table hive.hivesch007.thive9 on every column;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/hive/TEST009
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/TEST009 b/core/sql/regress/hive/TEST009
index f6c8a14..e9f1a22 100755
--- a/core/sql/regress/hive/TEST009
+++ b/core/sql/regress/hive/TEST009
@@ -196,29 +196,13 @@ select * from hive.sch_t009.t009t1;
 select * from hive.sch_t009.t009t2;
 
 ?section test_hbase
--- create external tables for precreated tables
-create external table "baseball" for hbase."_ROW_"."baseball";
-create external table "baseball" for hbase."_CELL_"."baseball";
-
--- should create schemas called "_HB__ROW__" and "_HB__CELL__"
-execute get_hb_schemas;
-
--- Verify tables were created
-invoke trafodion."_HB__ROW__"."baseball";
-invoke trafodion."_HB__CELL__"."baseball";
-showddl trafodion."_HB__ROW__"."baseball";
-showddl trafodion."_HB__CELL__"."baseball";
-
 select count(*) from hbase."_ROW_"."baseball";
 select count(*) from hbase."_CELL_"."baseball";
 
 select left(row_id, 10) as row_id, left(column_display(column_details, ('teams:team_number', 'games:visitor_team', 'games:game_time')), 100) as cols from hbase."_ROW_"."baseball";
 
--- fails since accesses to the external name are prohibited
-select * from trafodion."_HB__ROW__"."baseball";
-
-drop external table trafodion."_HB__ROW__"."baseball";
-drop external table "baseball" for hbase."_CELL_"."baseball";
+-- error. Cannot create a non-hbase-mapped table
+create external table "baseball" for hbase."_ROW_"."baseball";
 
 ?section test_ext
 -- test external table attributes

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/seabase/EXPECTED022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED022 b/core/sql/regress/seabase/EXPECTED022
index fa3a3af..1b43a94 100644
--- a/core/sql/regress/seabase/EXPECTED022
+++ b/core/sql/regress/seabase/EXPECTED022
@@ -426,7 +426,7 @@ ROW_ID      (EXPR)
 >>invoke hbase."_CELL_".t022hbt2;
 
 -- Definition of Trafodion table HBASE."_CELL_".T022HBT2
--- Definition current  Mon Dec 12 23:03:22 2016
+-- Definition current  Wed May 10 18:52:26 2017
 
   (
     ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
@@ -445,7 +445,7 @@ ROW_ID      (EXPR)
 >>invoke hbase."_ROW_".t022hbt2;
 
 -- Definition of Trafodion table HBASE."_ROW_".T022HBT2
--- Definition current  Mon Dec 12 23:03:23 2016
+-- Definition current  Wed May 10 18:52:27 2017
 
   (
     ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
@@ -465,7 +465,7 @@ ROW_ID      (EXPR)
 >>invoke hbase."_CELL_".t022hbt2;
 
 -- Definition of Trafodion table HBASE."_CELL_".T022HBT2
--- Definition current  Mon Dec 12 23:03:23 2016
+-- Definition current  Wed May 10 18:52:28 2017
 
   (
     ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
@@ -484,7 +484,7 @@ ROW_ID      (EXPR)
 >>invoke hbase."_ROW_".t022hbt2;
 
 -- Definition of Trafodion table HBASE."_ROW_".T022HBT2
--- Definition current  Mon Dec 12 23:03:24 2016
+-- Definition current  Wed May 10 18:52:28 2017
 
   (
     ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
@@ -603,7 +603,7 @@ ROW_ID      (EXPR)
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:03:37 2016
+-- Definition current  Wed May 10 18:52:37 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -619,7 +619,7 @@ ROW_ID      (EXPR)
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:03:38 2016
+-- Definition current  Wed May 10 18:52:38 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -636,7 +636,7 @@ ROW_ID      (EXPR)
 >>invoke t022hbm1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T022HBM1
--- Definition current  Mon Dec 12 23:03:40 2016
+-- Definition current  Wed May 10 18:52:40 2017
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -644,13 +644,30 @@ ROW_ID      (EXPR)
   )
 
 --- SQL operation complete.
+>>
+>>-- join between traf and hbase table with the same name.
+>>prepare s from select * from t022hbm1, hbase."_MAP_".t022hbm1;
+
+--- SQL command prepared.
+>>explain options 'f' s;
+
+LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
+---- ---- ---- --------------------  --------  --------------------  ---------
+
+3    .    4    root                                                  1.00E+004
+2    1    3    hybrid_hash_join                                      1.00E+004
+.    .    2    trafodion_scan                  T022HBM1              1.00E+002
+.    .    1    trafodion_scan                  T022HBM1              1.00E+002
+
+--- SQL operation complete.
+>>
 >>drop table t022hbm1;
 
 --- SQL operation complete.
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:03:49 2016
+-- Definition current  Wed May 10 18:52:47 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -662,6 +679,18 @@ ROW_ID      (EXPR)
 
 --- SQL operation complete.
 >>
+>>-- should return error 4056
+>>prepare s from select * from t022hbm1, hbase."_MAP_".t022hbm1;
+
+*** ERROR[4056] Exposed name TRAFODION."_HB_MAP_".T022HBM1 appears more than once.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>prepare s from select * from t022hbm1 x, hbase."_MAP_".t022hbm1 y;
+
+--- SQL command prepared.
+>>
 >>prepare s from select * from t022hbm1;
 
 --- SQL command prepared.
@@ -698,7 +727,7 @@ a2              ?
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:03:53 2016
+-- Definition current  Wed May 10 18:52:51 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -721,7 +750,7 @@ a2              ?
 >>invoke t022hbm1_like;
 
 -- Definition of Trafodion table TRAFODION.SCH.T022HBM1_LIKE
--- Definition current  Mon Dec 12 23:03:58 2016
+-- Definition current  Wed May 10 18:52:56 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -782,7 +811,7 @@ a2    ?               ?
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:04:14 2016
+-- Definition current  Wed May 10 18:53:16 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -799,7 +828,7 @@ a2    ?               ?
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:04:17 2016
+-- Definition current  Wed May 10 18:53:19 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -815,7 +844,7 @@ a2    ?               ?
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:04:20 2016
+-- Definition current  Wed May 10 18:53:22 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -941,7 +970,7 @@ b               ?
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:04:35 2016
+-- Definition current  Wed May 10 18:53:41 2017
 
   (
     "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -1001,7 +1030,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:04:41 2016
+-- Definition current  Wed May 10 18:53:47 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1024,7 +1053,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:04:49 2016
+-- Definition current  Wed May 10 18:53:52 2017
 
   (
     "cf".A                           CHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1046,7 +1075,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:04:54 2016
+-- Definition current  Wed May 10 18:54:00 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1068,7 +1097,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:04:58 2016
+-- Definition current  Wed May 10 18:54:05 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1091,7 +1120,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:05:03 2016
+-- Definition current  Wed May 10 18:54:10 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1115,7 +1144,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:05:07 2016
+-- Definition current  Wed May 10 18:54:15 2017
 
   (
     "cf".A                           CHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1138,7 +1167,7 @@ A            B            C
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:05:15 2016
+-- Definition current  Wed May 10 18:54:20 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
@@ -1190,7 +1219,7 @@ A            B            C
 >>invoke t022hbm2;
 
 -- Definition of Trafodion HBase mapped table T022HBM2
--- Definition current  Mon Dec 12 23:05:29 2016
+-- Definition current  Wed May 10 18:54:36 2017
 
   (
     "cf1".A                          INT DEFAULT NULL
@@ -1209,6 +1238,331 @@ A            B            Z
          10           20  a11 
 
 --- 1 row(s) selected.
+>>cleanup hbase table t022hbm2;
+
+--- SQL operation complete.
+>>
+>>-- registration of external hbase tables
+>>drop external table if exists t022hbm2;
+
+--- SQL operation complete.
+>>drop hbase table t022hbm2;
+
+--- SQL operation complete.
+>>create hbase table t022hbm2 (column family 'cf1', column family 'cf2');
+
+--- SQL operation complete.
+>>create external table t022hbm2 ("cf1".A int, "cf2".B int, 
++>                           "cf1".Z varchar(4) not null primary key) 
++>     map to hbase table t022hbm2;
+
+--- SQL operation complete.
+>>
+>>insert into hbase."_ROW_".t022hbm2 values ('a11', 
++>           column_create(('cf1:A', '10'), ('cf2:B', '20')));
+
+--- 1 row(s) inserted.
+>>invoke t022hbm2;
+
+-- Definition of Trafodion HBase mapped table T022HBM2
+-- Definition current  Wed May 10 18:54:54 2017
+
+  (
+    "cf1".A                          INT DEFAULT NULL
+  , "cf2".B                          INT DEFAULT NULL
+  , "cf1".Z                          VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  )
+  PRIMARY KEY NOT SERIALIZED (Z ASC)
+
+--- SQL operation complete.
+>>select * from t022hbm2;
+
+A            B            Z   
+-----------  -----------  ----
+
+         10           20  a11 
+
+--- 1 row(s) selected.
+>>
+>>showddl hbase."_CELL_".t022hbm2;
+
+/*
+CREATE TABLE HBASE."_CELL_".T022HBM2
+  (
+    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , PRIMARY KEY (ROW_ID ASC)
+  )
+;
+*/
+
+/* HBase DDL */
+CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
+
+--- SQL operation complete.
+>>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+
+--- SQL operation complete.
+>>register hbase table t022hbm2;
+
+--- SQL operation complete.
+>>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+
+HBase Registered Tables in Catalog TRAFODION
+============================================
+
+"_CELL_".T022HBM2
+"_ROW_".T022HBM2
+
+--- SQL operation complete.
+>>showddl hbase."_CELL_".t022hbm2;
+
+/*
+CREATE TABLE HBASE."_CELL_".T022HBM2
+  (
+    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , PRIMARY KEY (ROW_ID ASC)
+  )
+;
+*/
+
+/* HBase DDL */
+CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
+
+REGISTER HBASE TABLE T022HBM2;
+/* ObjectUID = 8119556248046151337 */
+
+--- SQL operation complete.
+>>showddl hbase."_ROW_".t022hbm2;
+
+/*
+CREATE TABLE HBASE."_ROW_".T022HBM2
+  (
+    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COLUMN_DETAILS                   VARCHAR(100000) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , PRIMARY KEY (ROW_ID ASC)
+  )
+;
+*/
+
+/* HBase DDL */
+CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
+
+REGISTER HBASE TABLE T022HBM2;
+/* ObjectUID = 8119556248046151348 */
+
+--- SQL operation complete.
+>>unregister hbase table t022hbm2;
+
+--- SQL operation complete.
+>>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+
+--- SQL operation complete.
+>>showddl hbase."_CELL_".t022hbm2;
+
+/*
+CREATE TABLE HBASE."_CELL_".T022HBM2
+  (
+    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , PRIMARY KEY (ROW_ID ASC)
+  )
+;
+*/
+
+/* HBase DDL */
+CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
+
+--- SQL operation complete.
+>>
+>>showstats for table hbase."_CELL_".t022hbm2 on every column;
+
+*** ERROR[9200] UPDATE STATISTICS for table HBASE._CELL_.T022HBM2 encountered an error (4082) from statement .
+
+*** ERROR[4082] Object TRAFODION."_HBASESTATS_".SB_HISTOGRAMS does not exist or is inaccessible.
+
+*** ERROR[8822] The statement was not prepared.
+
+--- SQL operation failed with errors.
+>>update statistics for table hbase."_CELL_".t022hbm2 on every column;
+
+--- SQL operation complete.
+>>showstats for table hbase."_CELL_".t022hbm2 on every column;
+
+Histogram data for Table HBASE."_CELL_".T022HBM2
+Table ID: 8224264939402516521
+
+   Hist ID # Ints    Rowcount         UEC Colname(s)
+========== ====== =========== =========== ===========================
+2014915224      1           2           1 ROW_ID
+2014915219      2           2           2 COL_FAMILY
+2014915214      2           2           2 COL_NAME
+2014915209      1           2           1 COL_TIMESTAMP
+2014915204      2           2           2 COL_VALUE
+
+
+--- SQL operation complete.
+>>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+
+HBase Registered Tables in Catalog TRAFODION
+============================================
+
+"_CELL_".T022HBM2
+
+--- SQL operation complete.
+>>showddl hbase."_CELL_".t022hbm2;
+
+/*
+CREATE TABLE HBASE."_CELL_".T022HBM2
+  (
+    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , PRIMARY KEY (ROW_ID ASC)
+  )
+;
+*/
+
+/* HBase DDL */
+CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
+
+--- SQL operation complete.
+>>
+>>showstats for table hbase."_ROW_".t022hbm2 on every column;
+
+Histogram data for Table HBASE."_ROW_".T022HBM2
+Table ID: 0
+
+   Hist ID # Ints    Rowcount         UEC Colname(s)
+========== ====== =========== =========== ===========================
+
+No Histograms exist for the requested columns or groups
+
+
+--- SQL operation complete.
+>>update statistics for table hbase."_CELL_".t022hbm2 on every column;
+
+--- SQL operation complete.
+>>showstats for table hbase."_CELL_".t022hbm2 on every column;
+
+Histogram data for Table HBASE."_CELL_".T022HBM2
+Table ID: 8224264939402516521
+
+   Hist ID # Ints    Rowcount         UEC Colname(s)
+========== ====== =========== =========== ===========================
+2014915225      1           2           1 ROW_ID
+2014915218      2           2           2 COL_FAMILY
+2014915215      2           2           2 COL_NAME
+2014915208      1           2           1 COL_TIMESTAMP
+2014915205      2           2           2 COL_VALUE
+
+
+--- SQL operation complete.
+>>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
+
+HBase Registered Tables in Catalog TRAFODION
+============================================
+
+"_CELL_".T022HBM2
+
+--- SQL operation complete.
+>>showddl hbase."_CELL_".t022hbm2;
+
+/*
+CREATE TABLE HBASE."_CELL_".T022HBM2
+  (
+    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
+      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , PRIMARY KEY (ROW_ID ASC)
+  )
+;
+*/
+
+/* HBase DDL */
+CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
+
+--- SQL operation complete.
+>>
+>>showstats for table hbase."_MAP_".t022hbm2 on every column;
+
+Histogram data for Table HBASE."_MAP_".T022HBM2
+Table ID: 8119556248046150805
+
+   Hist ID # Ints    Rowcount         UEC Colname(s)
+========== ====== =========== =========== ===========================
+
+No Histograms exist for the requested columns or groups
+
+
+--- SQL operation complete.
+>>update statistics for table hbase."_MAP_".t022hbm2 on every column;
+
+--- SQL operation complete.
+>>showstats for table hbase."_MAP_".t022hbm2 on every column;
+
+Histogram data for Table HBASE."_MAP_".T022HBM2
+Table ID: 8119556248046150805
+
+   Hist ID # Ints    Rowcount         UEC Colname(s)
+========== ====== =========== =========== ===========================
+2035453721      1           1           1 A
+2035453716      1           1           1 B
+2035453711      1           1           1 Z
+
+
+--- SQL operation complete.
+>>showddl hbase."_MAP_".t022hbm2;
+
+CREATE EXTERNAL TABLE T022HBM2
+  (
+    "cf1".A                          INT DEFAULT NULL
+  , "cf2".B                          INT DEFAULT NULL
+  , "cf1".Z                          VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  , PRIMARY KEY NOT SERIALIZED (Z ASC)
+  )
+  MAP TO HBASE TABLE T022HBM2 DATA FORMAT VARCHAR
+;
+
+--- SQL operation complete.
 >>
 >>-- error cases
 >>
@@ -1231,7 +1585,7 @@ a1             10
 >>invoke t022hbm1;
 
 -- Definition of Trafodion HBase mapped table T022HBM1
--- Definition current  Mon Dec 12 23:05:32 2016
+-- Definition current  Wed May 10 18:55:45 2017
 
   (
     "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ffe0b5b/core/sql/regress/seabase/EXPECTED030
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED030 b/core/sql/regress/seabase/EXPECTED030
index 4798386..9283713 100644
--- a/core/sql/regress/seabase/EXPECTED030
+++ b/core/sql/regress/seabase/EXPECTED030
@@ -7,7 +7,7 @@
 2016-03-01
 
 --- 1 row(s) selected.
->>select to_date('03/01/2016', 'MM/DD/YYYY') from (values(1)) x(a);
+>>select to_date('03/01/2016', 'mm/dd/yyyy') from (values(1)) x(a);
 
 (EXPR)    
 ----------
@@ -71,7 +71,7 @@
 2016-03-01
 
 --- 1 row(s) selected.
->>select to_date('201603', 'YYYYMM') from (values(1)) x(a);
+>>select to_date('201603', 'YYYYmm') from (values(1)) x(a);
 
 (EXPR)    
 ----------


[3/5] incubator-trafodion git commit: Merge remote branch 'origin/master' into ansharma_hbasereg_deliver_br

Posted by an...@apache.org.
Merge remote branch 'origin/master' into ansharma_hbasereg_deliver_br

Conflicts:
	core/sql/regress/seabase/EXPECTED022


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/a44a9093
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/a44a9093
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/a44a9093

Branch: refs/heads/master
Commit: a44a909358b181d4b0b7e1036590059f2d43ce86
Parents: 6ffe0b5 1767649
Author: Anoop Sharma <an...@esgyn.com>
Authored: Mon May 15 01:37:20 2017 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Mon May 15 01:37:20 2017 +0000

----------------------------------------------------------------------
 NOTICE                                          |    2 +-
 core/conn/jdbcT4/pom.xml                        |   93 +
 .../native/ResStatisticsStatement.cpp           |   72 +-
 .../jdbc_type2/native/ResStatisticsStatement.h  |    9 +
 .../odbc/nsksrvrcore/ResStatisticsStatement.cpp |   88 +-
 .../odbc/nsksrvrcore/ResStatisticsStatement.h   |    7 +
 .../odbc/odbcclient/unixcli/cli/sqltocconv.cpp  |    4 +
 core/sqf/build-scripts/build.branch             |    4 +-
 core/sqf/sqenvcom.sh                            |   32 +-
 core/sqf/src/seabed/src/ms.cpp                  |    2 +
 core/sqf/src/seatrans/.gitignore                |    1 +
 .../NonPendingTransactionException.java         |   47 +
 .../hbase/client/transactional/RMInterface.java |  296 +-
 .../hbase/client/transactional/TmDDL.java       |   28 +-
 .../hbase/client/transactional/TransState.java  |    6 +-
 .../transactional/TransactionManager.java       |  355 +-
 .../TransactionRegionLocation.java              |  137 +-
 .../client/transactional/TransactionState.java  |  157 +-
 .../TransactionalAggregationClient.java         |   83 +-
 .../TransactionalScanner.java.tmpl              |   30 +-
 .../transactional/TransactionalTable.java       |  162 +-
 .../transactional/SplitBalanceHelper.java       |    3 +-
 .../transactional/TrxRegionEndpoint.java.tmpl   | 3439 +++++----
 .../transactional/TrxRegionObserver.java.tmpl   |   34 +-
 .../generated/SsccRegionProtos.java             |   42 +-
 .../generated/TrxRegionProtos.java              | 6849 ++++++++++--------
 .../transactional/SsccTransactionState.java     |    4 +-
 .../transactional/TransactionState.java         |  108 +-
 .../TransactionalRegionScannerHolder.java       |   63 -
 .../TransactionalRegionScannerHolder.java.tmpl  |   79 +
 .../transactional/TrxTransactionState.java.tmpl |  337 +-
 .../hbase-trx/src/main/protobuf/TrxRegion.proto |  175 +-
 .../trafodion/dtm/HBaseAuditControlPoint.java   |  431 +-
 .../java/org/trafodion/dtm/HBaseTxClient.java   |  344 +-
 .../java/org/trafodion/dtm/TmAuditTlog.java     | 1712 +++--
 core/sql/cli/CliExtern.cpp                      |   23 +-
 core/sql/cli/sqlcli.h                           |    2 +
 core/sql/comexe/ComTdbHashGrby.h                |    2 +
 core/sql/executor/ExExeUtil.h                   |    8 +-
 core/sql/executor/ExExeUtilGetStats.cpp         |  444 +-
 core/sql/executor/ExStats.cpp                   |  311 +-
 core/sql/executor/ExStats.h                     |   30 +-
 core/sql/executor/ex_hash_grby.cpp              |   21 +-
 core/sql/executor/ex_hash_grby.h                |   11 +
 core/sql/executor/ex_hashj.cpp                  |   26 +-
 core/sql/executor/ex_hashj.h                    |   18 +-
 core/sql/executor/ex_sort.cpp                   |   17 +-
 core/sql/executor/ex_sort.h                     |   13 +-
 core/sql/parser/sqlparser.y                     |    2 +-
 core/sql/regress/core/EXPECTEDRTS               | 1903 ++---
 core/sql/regress/core/FILTERRTS                 |   18 +-
 core/sql/regress/hive/TEST003                   |   24 +-
 core/sql/regress/seabase/EXPECTED022            |  210 +-
 core/sql/regress/seabase/TEST022                |   43 +-
 core/sql/sort/Qsort.cpp                         |    9 +-
 core/sql/sort/Qsort.h                           |    3 +-
 core/sql/sort/SortAlgo.cpp                      |    3 +-
 core/sql/sort/SortAlgo.h                        |    3 +-
 core/sql/sort/SortTopN.cpp                      |    9 +-
 core/sql/sort/SortTopN.h                        |    3 +-
 core/sql/sort/SortUtil.cpp                      |    8 +-
 core/sql/sort/TourTree.cpp                      |    8 +-
 core/sql/sort/TourTree.h                        |    1 +
 .../java/org/trafodion/sql/HBaseClient.java     |    3 +-
 .../java/org/trafodion/sql/HTableClient.java    |   47 +-
 .../src/asciidoc/_chapters/ambari_install.adoc  |   51 +-
 docs/provisioning_guide/src/images/amb1.PNG     |  Bin 0 -> 46318 bytes
 docs/provisioning_guide/src/images/amb2.PNG     |  Bin 0 -> 12063 bytes
 docs/provisioning_guide/src/images/amb3.PNG     |  Bin 0 -> 13764 bytes
 docs/provisioning_guide/src/images/amb4.PNG     |  Bin 0 -> 44413 bytes
 docs/provisioning_guide/src/images/amb5.PNG     |  Bin 0 -> 10552 bytes
 .../src/asciidoc/_chapters/olap_functions.adoc  |    2 +-
 .../sql_functions_and_expressions.adoc          |    4 +-
 install/ambari-installer/Makefile               |   11 +-
 .../2.1/configuration/traf-cluster-env.xml      |    1 +
 .../2.1/configuration/trafodion-env.xml         |    4 +
 .../TRAFODION/2.1/package/scripts/params.py     |    2 +
 .../2.1/package/scripts/trafodionmaster.py      |    3 +-
 install/python-installer/db_install.py          |   11 +-
 install/python-installer/scripts/traf_check.py  |    5 +
 win-odbc64/odbcclient/drvr35/sqltocconv.cpp     |    6 +
 81 files changed, 10945 insertions(+), 7613 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a44a9093/core/sql/parser/sqlparser.y
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a44a9093/core/sql/regress/seabase/EXPECTED022
----------------------------------------------------------------------
diff --cc core/sql/regress/seabase/EXPECTED022
index 1b43a94,37e50e3..fe7aab5
--- a/core/sql/regress/seabase/EXPECTED022
+++ b/core/sql/regress/seabase/EXPECTED022
@@@ -425,35 -425,35 +425,35 @@@ ROW_ID      (EXPR
  >>-- tests with large rows
  >>invoke hbase."_CELL_".t022hbt2;
  
 --- Definition of table HBASE."_CELL_".T022HBT2
 --- Definition current
 +-- Definition of Trafodion table HBASE."_CELL_".T022HBT2
- -- Definition current  Wed May 10 18:52:26 2017
++-- Definition current  Mon May 15 01:28:23 2017
  
 - (
 - ROW_ID VARCHAR(100) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - , COL_FAMILY VARCHAR(100) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - , COL_NAME VARCHAR(100) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - , COL_TIMESTAMP LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 - , COL_VALUE VARCHAR(1000) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - )
 - PRIMARY KEY (ROW_ID ASC)
 +  (
 +    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_VALUE                        VARCHAR(1000) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  )
 +  PRIMARY KEY (ROW_ID ASC)
  
  --- SQL operation complete.
  >>invoke hbase."_ROW_".t022hbt2;
  
 --- Definition of table HBASE."_ROW_".T022HBT2
 --- Definition current
 +-- Definition of Trafodion table HBASE."_ROW_".T022HBT2
- -- Definition current  Wed May 10 18:52:27 2017
++-- Definition current  Mon May 15 01:28:24 2017
  
 - (
 - ROW_ID VARCHAR(100) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - , COLUMN_DETAILS VARCHAR(10000) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - )
 - PRIMARY KEY (ROW_ID ASC)
 +  (
 +    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COLUMN_DETAILS                   VARCHAR(10000) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  )
 +  PRIMARY KEY (ROW_ID ASC)
  
  --- SQL operation complete.
  >>cqd hbase_max_column_val_length '100000';
@@@ -464,35 -464,35 +464,35 @@@
  --- SQL operation complete.
  >>invoke hbase."_CELL_".t022hbt2;
  
 --- Definition of table HBASE."_CELL_".T022HBT2
 --- Definition current
 +-- Definition of Trafodion table HBASE."_CELL_".T022HBT2
- -- Definition current  Wed May 10 18:52:28 2017
++-- Definition current  Mon May 15 01:28:24 2017
  
 - (
 - ROW_ID VARCHAR(100) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - , COL_FAMILY VARCHAR(100) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - , COL_NAME VARCHAR(100) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - , COL_TIMESTAMP LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 - , COL_VALUE VARCHAR(100000) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - )
 - PRIMARY KEY (ROW_ID ASC)
 +  (
 +    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  )
 +  PRIMARY KEY (ROW_ID ASC)
  
  --- SQL operation complete.
  >>invoke hbase."_ROW_".t022hbt2;
  
 --- Definition of table HBASE."_ROW_".T022HBT2
 --- Definition current
 +-- Definition of Trafodion table HBASE."_ROW_".T022HBT2
- -- Definition current  Wed May 10 18:52:28 2017
++-- Definition current  Mon May 15 01:28:25 2017
  
 - (
 - ROW_ID VARCHAR(100) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - , COLUMN_DETAILS VARCHAR(100000) CHARACTER SET ISO88591
 - COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 - )
 - PRIMARY KEY (ROW_ID ASC)
 +  (
 +    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COLUMN_DETAILS                   VARCHAR(100000) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  )
 +  PRIMARY KEY (ROW_ID ASC)
  
  --- SQL operation complete.
  >>insert into hbase."_CELL_".t022hbt2 values ('1', 'cf', 'a', -1, repeat('a', 100000));
@@@ -506,65 -506,65 +506,65 @@@
  --- 1 row(s) inserted.
  >>select count(*) from hbase."_CELL_".t022hbt2;
  
 -(EXPR)
 -----------
 +(EXPR)              
 +--------------------
  
 - 3
 +                   3
  
  --- 1 row(s) selected.
- >>select char_length(col_value) from hbase."_CELL_".t022hbt2;
+ >>select char_length(col_value) from hbase."_CELL_".t022hbt2 order by 1;
  
 -(EXPR)
 +(EXPR)    
  ----------
  
-     100000
 - 40000
 - 40000
 - 100000
 +     40000
 +     40000
++    100000
  
  --- 3 row(s) selected.
  >>select count(*) from hbase."_CELL_".t022hbt2;
  
 -(EXPR)
 -----------
 +(EXPR)              
 +--------------------
  
 - 3
 +                   3
  
  --- 1 row(s) selected.
- >>select char_length(col_value) from hbase."_CELL_".t022hbt2;
+ >>select char_length(col_value) from hbase."_CELL_".t022hbt2 order by 1;
  
 -(EXPR)
 +(EXPR)    
  ----------
  
-     100000
 - 40000
 - 40000
 - 100000
 +     40000
 +     40000
++    100000
  
  --- 3 row(s) selected.
  >>select count(*) from hbase."_ROW_".t022hbt2;
  
 -(EXPR)
 -----------
 +(EXPR)              
 +--------------------
  
 - 2
 +                   2
  
  --- 1 row(s) selected.
- >>select char_length(column_details) from hbase."_ROW_".t022hbt2;
+ >>select char_length(column_details) from hbase."_ROW_".t022hbt2 order by 1;
  
 -(EXPR)
 +(EXPR)    
  ----------
  
-     100000
 - 80022
 - 100000
 +     80022
++    100000
  
  --- 2 row(s) selected.
 ->>select left(row_id, 10) row_id, left(column_display(column_details), 40)
 -+> from hbase."_ROW_".t022hbt2;
 +>>select left(row_id, 10) row_id, left(column_display(column_details), 40) 
 ++>           from hbase."_ROW_".t022hbt2;
  
 -ROW_ID (EXPR)
 -----------
 +ROW_ID      (EXPR)                                  
 +----------  ----------------------------------------
  
 -1 cf:a => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 -2 cf:1a => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +1           cf:a => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +2           cf:1a => aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  
  --- 2 row(s) selected.
  >>
@@@ -602,32 -602,32 +602,32 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:52:37 2017
++-- Definition current  Mon May 15 01:28:41 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B CHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           CHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
  >>-- if no schema is specified, table is looked in regular and then mapped schema
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:52:38 2017
++-- Definition current  Mon May 15 01:28:41 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B CHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           CHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>create table t022hbm1 (a int);
@@@ -635,47 -635,30 +635,47 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of table #CAT.#SCH.T022HBM1
 --- Definition current
 +-- Definition of Trafodion table TRAFODION.SCH.T022HBM1
- -- Definition current  Wed May 10 18:52:40 2017
++-- Definition current  Mon May 15 01:28:44 2017
 +
 +  (
 +    SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , A                                INT DEFAULT NULL
 +  )
 +
 +--- SQL operation complete.
 +>>
 +>>-- join between traf and hbase table with the same name.
 +>>prepare s from select * from t022hbm1, hbase."_MAP_".t022hbm1;
 +
 +--- SQL command prepared.
 +>>explain options 'f' s;
 +
 +LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 +---- ---- ---- --------------------  --------  --------------------  ---------
  
 - (
 - SYSKEY LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 - , A INT DEFAULT NULL
 - )
 +3    .    4    root                                                  1.00E+004
 +2    1    3    hybrid_hash_join                                      1.00E+004
 +.    .    2    trafodion_scan                  T022HBM1              1.00E+002
 +.    .    1    trafodion_scan                  T022HBM1              1.00E+002
  
  --- SQL operation complete.
 +>>
  >>drop table t022hbm1;
  
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:52:47 2017
++-- Definition current  Mon May 15 01:28:50 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B CHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           CHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -726,17 -697,17 +726,17 @@@ a2              
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:52:51 2017
++-- Definition current  Mon May 15 01:28:55 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B CHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT DEFAULT NULL
 - , "cf".C INT DEFAULT NULL /*added_col*/
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           CHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT DEFAULT NULL
 +  , "cf".C                           INT DEFAULT NULL /*added_col*/
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -749,17 -720,17 +749,17 @@@
  --- SQL operation complete.
  >>invoke t022hbm1_like;
  
 --- Definition of table #CAT.#SCH.T022HBM1_LIKE
 --- Definition current
 +-- Definition of Trafodion table TRAFODION.SCH.T022HBM1_LIKE
- -- Definition current  Wed May 10 18:52:56 2017
++-- Definition current  Mon May 15 01:29:01 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B CHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT DEFAULT NULL
 - , "cf".C INT DEFAULT NULL
 - )
 - PRIMARY KEY (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           CHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT DEFAULT NULL
 +  , "cf".C                           INT DEFAULT NULL
 +  )
 +  PRIMARY KEY (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -810,15 -781,15 +810,15 @@@ a2    ?               
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:53:16 2017
++-- Definition current  Mon May 15 01:29:22 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , B INT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , B                                INT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -827,14 -798,14 +827,14 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:53:19 2017
++-- Definition current  Mon May 15 01:29:25 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -843,15 -814,15 +843,15 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:53:22 2017
++-- Definition current  Mon May 15 01:29:28 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B INT DEFAULT NULL /*added_col*/
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           INT DEFAULT NULL /*added_col*/
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -869,93 -840,30 +869,30 @@@
  >>drop external table t022hbm1;
  
  --- SQL operation complete.
 ->>create external table t022hbm1 (a varchar(4) not null, b int)
 -+> primary key (a)
 -+> attribute default column family 'cf'
 -+> map to hbase table t022hbm1
 -+> data format native;
 +>>create external table t022hbm1 (a varchar(4) not null, b int) 
 ++>        primary key (a)
 ++>        attribute default column family 'cf'
 ++>        map to hbase table t022hbm1
 ++>        data format native;
  
  --- SQL operation complete.
- >>
- >>insert into t022hbm1 values ('a', 1);
- 
- --- 1 row(s) inserted.
- >>select * from t022hbm1;
- 
- A     B          
- ----  -----------
- 
- a               1
- 
- --- 1 row(s) selected.
- >>update t022hbm1 set b = b + 1;
- 
- --- 1 row(s) updated.
- >>select * from t022hbm1;
- 
- A     B          
- ----  -----------
- 
- a               2
- 
- --- 1 row(s) selected.
- >>insert into t022hbm1 values ('a', 1);
- 
- *** ERROR[8102] The operation is prevented by a unique constraint.
- 
- --- 0 row(s) inserted.
- >> -- should fail
- >>insert into t022hbm1 values ('b', null);
- 
- --- 1 row(s) inserted.
- >>select * from t022hbm1;
- 
- A     B          
- ----  -----------
- 
- a               2
- b               ?
- 
- --- 2 row(s) selected.
- >>delete from t022hbm1 where a = 'a';
- 
- --- 1 row(s) deleted.
- >>select * from t022hbm1;
- 
- A     B          
- ----  -----------
- 
- b               ?
- 
- --- 1 row(s) selected.
- >>update t022hbm1 set b = 10;
- 
- --- 1 row(s) updated.
- >>select * from t022hbm1;
- 
- A     B          
- ----  -----------
- 
- b              10
- 
- --- 1 row(s) selected.
- >>update t022hbm1 set b = null;
- 
- --- 1 row(s) updated.
- >>select * from t022hbm1;
- 
- A     B          
- ----  -----------
- 
- b               ?
- 
- --- 1 row(s) selected.
- >>delete from t022hbm1;
- 
- --- 1 row(s) deleted.
- >>select * from t022hbm1;
- 
- --- 0 row(s) selected.
+ >>--This part of the test is being commented out due to non deterministic results
+ >>--It needs to be renabled after this JIRA is fixed : TRAFODION-2613
+ >>--insert into t022hbm1 values ('a', 1);
+ >>--select * from t022hbm1;
+ >>--update t022hbm1 set b = b + 1;
+ >>--select * from t022hbm1;
+ >>--insert into t022hbm1 values ('a', 1); -- should fail
+ >>--insert into t022hbm1 values ('b', null);
+ >>--select * from t022hbm1;
+ >>--delete from t022hbm1 where a = 'a';
+ >>--select * from t022hbm1;
+ >>--update t022hbm1 set b = 10;
+ >>--select * from t022hbm1;
+ >>--update t022hbm1 set b = null;
+ >>--select * from t022hbm1;
+ >>--delete from t022hbm1;
+ >>--select * from t022hbm1;
  >>
  >>drop external table t022hbm1;
  
@@@ -969,15 -877,15 +906,15 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:53:41 2017
++-- Definition current  Mon May 15 01:29:41 2017
  
 - (
 - "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE
 - , "cf".B INT NO DEFAULT NOT NULL NOT DROPPABLE
 - , "cf".C INT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC, B ASC)
 +  (
 +    "cf".A                           INT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           INT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".C                           INT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC, B ASC)
  
  --- SQL operation complete.
  >>insert into t022hbm1 values (1,2,3);
@@@ -994,27 -902,27 +931,27 @@@
  >>insert into t022hbm1 values (-1, -2, -3);
  
  --- 1 row(s) inserted.
- >>select * from t022hbm1;
+ >>select * from t022hbm1 order by 1;
  
 -A B C
 -----------
 +A            B            C          
 +-----------  -----------  -----------
  
 - 1 1 1
 - 1 2 3
 - -1 -2 -3
 +          1            1            1
 +          1            2            3
 +         -1           -2           -3
  
  --- 3 row(s) selected.
  >>upsert into t022hbm1 values (1,2,4);
  
  --- 1 row(s) inserted.
- >>select * from t022hbm1;
+ >>select * from t022hbm1 order by 1;
  
 -A B C
 -----------
 +A            B            C          
 +-----------  -----------  -----------
  
 - 1 1 1
 - 1 2 4
 - -1 -2 -3
 +          1            1            1
 +          1            2            4
 +         -1           -2           -3
  
  --- 3 row(s) selected.
  >>
@@@ -1029,15 -937,15 +966,15 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:53:47 2017
++-- Definition current  Mon May 15 01:29:47 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B INT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           INT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -1052,15 -960,15 +989,15 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:53:52 2017
++-- Definition current  Mon May 15 01:29:52 2017
  
 - (
 - "cf".A CHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B INT DEFAULT NULL
 - )
 - PRIMARY KEY (A ASC)
 +  (
 +    "cf".A                           CHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           INT DEFAULT NULL
 +  )
 +  PRIMARY KEY (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -1074,15 -982,15 +1011,15 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:54:00 2017
++-- Definition current  Mon May 15 01:29:56 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B INT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           INT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -1096,15 -1004,15 +1033,15 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:54:05 2017
++-- Definition current  Mon May 15 01:30:01 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B INT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           INT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -1119,15 -1027,15 +1056,15 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:54:10 2017
++-- Definition current  Mon May 15 01:30:06 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B INT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           INT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -1143,15 -1051,15 +1080,15 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:54:15 2017
++-- Definition current  Mon May 15 01:30:11 2017
  
 - (
 - "cf".A CHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B INT DEFAULT NULL
 - )
 - PRIMARY KEY (A ASC)
 +  (
 +    "cf".A                           CHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           INT DEFAULT NULL
 +  )
 +  PRIMARY KEY (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -1166,15 -1074,15 +1103,15 @@@
  --- SQL operation complete.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:54:20 2017
++-- Definition current  Mon May 15 01:30:15 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B INT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           INT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>
@@@ -1218,351 -1126,26 +1155,354 @@@
  --- 1 row(s) inserted.
  >>invoke t022hbm2;
  
 --- Definition of TRAFODION HBase mapped table T022HBM2
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM2
- -- Definition current  Wed May 10 18:54:36 2017
++-- Definition current  Mon May 15 01:30:31 2017
  
 - (
 - "cf1".A INT DEFAULT NULL
 - , "cf2".B INT DEFAULT NULL
 - , "cf1".Z VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - )
 - PRIMARY KEY NOT SERIALIZED (Z ASC)
 +  (
 +    "cf1".A                          INT DEFAULT NULL
 +  , "cf2".B                          INT DEFAULT NULL
 +  , "cf1".Z                          VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  )
 +  PRIMARY KEY NOT SERIALIZED (Z ASC)
  
  --- SQL operation complete.
  >>select * from t022hbm2;
  
 -A B Z
 -----------
 +A            B            Z   
 +-----------  -----------  ----
  
 - 10 20 a11
 +         10           20  a11 
  
  --- 1 row(s) selected.
 +>>cleanup hbase table t022hbm2;
 +
 +--- SQL operation complete.
 +>>
 +>>-- registration of external hbase tables
 +>>drop external table if exists t022hbm2;
 +
 +--- SQL operation complete.
 +>>drop hbase table t022hbm2;
 +
 +--- SQL operation complete.
 +>>create hbase table t022hbm2 (column family 'cf1', column family 'cf2');
 +
 +--- SQL operation complete.
 +>>create external table t022hbm2 ("cf1".A int, "cf2".B int, 
 ++>                           "cf1".Z varchar(4) not null primary key) 
 ++>     map to hbase table t022hbm2;
 +
 +--- SQL operation complete.
 +>>
 +>>insert into hbase."_ROW_".t022hbm2 values ('a11', 
 ++>           column_create(('cf1:A', '10'), ('cf2:B', '20')));
 +
 +--- 1 row(s) inserted.
 +>>invoke t022hbm2;
 +
 +-- Definition of Trafodion HBase mapped table T022HBM2
- -- Definition current  Wed May 10 18:54:54 2017
++-- Definition current  Mon May 15 01:30:52 2017
 +
 +  (
 +    "cf1".A                          INT DEFAULT NULL
 +  , "cf2".B                          INT DEFAULT NULL
 +  , "cf1".Z                          VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  )
 +  PRIMARY KEY NOT SERIALIZED (Z ASC)
 +
 +--- SQL operation complete.
 +>>select * from t022hbm2;
 +
 +A            B            Z   
 +-----------  -----------  ----
 +
 +         10           20  a11 
 +
 +--- 1 row(s) selected.
 +>>
 +>>showddl hbase."_CELL_".t022hbm2;
 +
 +/*
 +CREATE TABLE HBASE."_CELL_".T022HBM2
 +  (
 +    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , PRIMARY KEY (ROW_ID ASC)
 +  )
 +;
 +*/
 +
 +/* HBase DDL */
 +CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 +
 +--- SQL operation complete.
 +>>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
 +
 +--- SQL operation complete.
 +>>register hbase table t022hbm2;
 +
 +--- SQL operation complete.
 +>>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
 +
 +HBase Registered Tables in Catalog TRAFODION
 +============================================
 +
 +"_CELL_".T022HBM2
 +"_ROW_".T022HBM2
 +
 +--- SQL operation complete.
 +>>showddl hbase."_CELL_".t022hbm2;
 +
 +/*
 +CREATE TABLE HBASE."_CELL_".T022HBM2
 +  (
 +    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , PRIMARY KEY (ROW_ID ASC)
 +  )
 +;
 +*/
 +
 +/* HBase DDL */
 +CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 +
 +REGISTER HBASE TABLE T022HBM2;
- /* ObjectUID = 8119556248046151337 */
++/* ObjectUID = 8642537124144485947 */
 +
 +--- SQL operation complete.
 +>>showddl hbase."_ROW_".t022hbm2;
 +
 +/*
 +CREATE TABLE HBASE."_ROW_".T022HBM2
 +  (
 +    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COLUMN_DETAILS                   VARCHAR(100000) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , PRIMARY KEY (ROW_ID ASC)
 +  )
 +;
 +*/
 +
 +/* HBase DDL */
 +CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 +
 +REGISTER HBASE TABLE T022HBM2;
- /* ObjectUID = 8119556248046151348 */
++/* ObjectUID = 8642537124144485957 */
 +
 +--- SQL operation complete.
 +>>unregister hbase table t022hbm2;
 +
 +--- SQL operation complete.
 +>>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
 +
 +--- SQL operation complete.
 +>>showddl hbase."_CELL_".t022hbm2;
 +
 +/*
 +CREATE TABLE HBASE."_CELL_".T022HBM2
 +  (
 +    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , PRIMARY KEY (ROW_ID ASC)
 +  )
 +;
 +*/
 +
 +/* HBase DDL */
 +CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 +
 +--- SQL operation complete.
 +>>
 +>>showstats for table hbase."_CELL_".t022hbm2 on every column;
 +
- *** ERROR[9200] UPDATE STATISTICS for table HBASE._CELL_.T022HBM2 encountered an error (4082) from statement .
++Histogram data for Table HBASE."_CELL_".T022HBM2
++Table ID: 0
++
++   Hist ID # Ints    Rowcount         UEC Colname(s)
++========== ====== =========== =========== ===========================
 +
- *** ERROR[4082] Object TRAFODION."_HBASESTATS_".SB_HISTOGRAMS does not exist or is inaccessible.
++No Histograms exist for the requested columns or groups
 +
- *** ERROR[8822] The statement was not prepared.
 +
- --- SQL operation failed with errors.
++--- SQL operation complete.
 +>>update statistics for table hbase."_CELL_".t022hbm2 on every column;
 +
 +--- SQL operation complete.
 +>>showstats for table hbase."_CELL_".t022hbm2 on every column;
 +
 +Histogram data for Table HBASE."_CELL_".T022HBM2
- Table ID: 8224264939402516521
++Table ID: 8849702707055529909
 +
 +   Hist ID # Ints    Rowcount         UEC Colname(s)
 +========== ====== =========== =========== ===========================
- 2014915224      1           2           1 ROW_ID
- 2014915219      2           2           2 COL_FAMILY
- 2014915214      2           2           2 COL_NAME
- 2014915209      1           2           1 COL_TIMESTAMP
- 2014915204      2           2           2 COL_VALUE
++2003317081      1           2           1 ROW_ID
++2003317076      2           2           2 COL_FAMILY
++2003317071      2           2           2 COL_NAME
++2003317066      1           2           1 COL_TIMESTAMP
++2003317061      2           2           2 COL_VALUE
 +
 +
 +--- SQL operation complete.
 +>>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
 +
 +HBase Registered Tables in Catalog TRAFODION
 +============================================
 +
 +"_CELL_".T022HBM2
 +
 +--- SQL operation complete.
 +>>showddl hbase."_CELL_".t022hbm2;
 +
 +/*
 +CREATE TABLE HBASE."_CELL_".T022HBM2
 +  (
 +    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , PRIMARY KEY (ROW_ID ASC)
 +  )
 +;
 +*/
 +
 +/* HBase DDL */
 +CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 +
 +--- SQL operation complete.
 +>>
 +>>showstats for table hbase."_ROW_".t022hbm2 on every column;
 +
 +Histogram data for Table HBASE."_ROW_".T022HBM2
 +Table ID: 0
 +
 +   Hist ID # Ints    Rowcount         UEC Colname(s)
 +========== ====== =========== =========== ===========================
 +
 +No Histograms exist for the requested columns or groups
 +
 +
 +--- SQL operation complete.
 +>>update statistics for table hbase."_CELL_".t022hbm2 on every column;
 +
 +--- SQL operation complete.
 +>>showstats for table hbase."_CELL_".t022hbm2 on every column;
 +
 +Histogram data for Table HBASE."_CELL_".T022HBM2
- Table ID: 8224264939402516521
++Table ID: 8849702707055529909
 +
 +   Hist ID # Ints    Rowcount         UEC Colname(s)
 +========== ====== =========== =========== ===========================
- 2014915225      1           2           1 ROW_ID
- 2014915218      2           2           2 COL_FAMILY
- 2014915215      2           2           2 COL_NAME
- 2014915208      1           2           1 COL_TIMESTAMP
- 2014915205      2           2           2 COL_VALUE
++2003317080      1           2           1 ROW_ID
++2003317077      2           2           2 COL_FAMILY
++2003317070      2           2           2 COL_NAME
++2003317067      1           2           1 COL_TIMESTAMP
++2003317060      2           2           2 COL_VALUE
 +
 +
 +--- SQL operation complete.
 +>>get hbase registered tables in catalog trafodion, match '%T022HBM2%';
 +
 +HBase Registered Tables in Catalog TRAFODION
 +============================================
 +
 +"_CELL_".T022HBM2
 +
 +--- SQL operation complete.
 +>>showddl hbase."_CELL_".t022hbm2;
 +
 +/*
 +CREATE TABLE HBASE."_CELL_".T022HBM2
 +  (
 +    ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_FAMILY                       VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_NAME                         VARCHAR(100) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_TIMESTAMP                    LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , COL_VALUE                        VARCHAR(100000) CHARACTER SET ISO88591
 +      COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , PRIMARY KEY (ROW_ID ASC)
 +  )
 +;
 +*/
 +
 +/* HBase DDL */
 +CREATE HBASE TABLE T022HBM2 ( COLUMN FAMILY '#1')
 +
 +--- SQL operation complete.
 +>>
 +>>showstats for table hbase."_MAP_".t022hbm2 on every column;
 +
 +Histogram data for Table HBASE."_MAP_".T022HBM2
- Table ID: 8119556248046150805
++Table ID: 8642537124144485432
 +
 +   Hist ID # Ints    Rowcount         UEC Colname(s)
 +========== ====== =========== =========== ===========================
 +
 +No Histograms exist for the requested columns or groups
 +
 +
 +--- SQL operation complete.
 +>>update statistics for table hbase."_MAP_".t022hbm2 on every column;
 +
 +--- SQL operation complete.
 +>>showstats for table hbase."_MAP_".t022hbm2 on every column;
 +
 +Histogram data for Table HBASE."_MAP_".T022HBM2
- Table ID: 8119556248046150805
++Table ID: 8642537124144485432
 +
 +   Hist ID # Ints    Rowcount         UEC Colname(s)
 +========== ====== =========== =========== ===========================
- 2035453721      1           1           1 A
- 2035453716      1           1           1 B
- 2035453711      1           1           1 Z
++2023711938      1           1           1 A
++2023711933      1           1           1 B
++2023711928      1           1           1 Z
 +
 +
 +--- SQL operation complete.
 +>>showddl hbase."_MAP_".t022hbm2;
 +
 +CREATE EXTERNAL TABLE T022HBM2
 +  (
 +    "cf1".A                          INT DEFAULT NULL
 +  , "cf2".B                          INT DEFAULT NULL
 +  , "cf1".Z                          VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , PRIMARY KEY NOT SERIALIZED (Z ASC)
 +  )
 +  MAP TO HBASE TABLE T022HBM2 DATA FORMAT VARCHAR
 +;
 +
 +--- SQL operation complete.
  >>
  >>-- error cases
  >>
@@@ -1584,15 -1167,15 +1524,15 @@@ a1             1
  --- SQL operation failed with errors.
  >>invoke t022hbm1;
  
 --- Definition of TRAFODION HBase mapped table T022HBM1
 --- Definition current
 +-- Definition of Trafodion HBase mapped table T022HBM1
- -- Definition current  Wed May 10 18:55:45 2017
++-- Definition current  Mon May 15 01:31:41 2017
  
 - (
 - "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 - DEFAULT NO @eof@ NULL NOT DROPPABLE
 - , "cf".B INT DEFAULT NULL
 - )
 - PRIMARY KEY NOT SERIALIZED (A ASC)
 +  (
 +    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
 +      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
 +  , "cf".B                           INT DEFAULT NULL
 +  )
 +  PRIMARY KEY NOT SERIALIZED (A ASC)
  
  --- SQL operation complete.
  >>

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a44a9093/core/sql/regress/seabase/TEST022
----------------------------------------------------------------------