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 2016/12/17 00:33:17 UTC

[1/7] incubator-trafodion git commit: TRAFODION-1586 Add support for external Traf tables mappedd to HBase tables

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 2581c0d4f -> 4d3383962


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLutil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLutil.cpp b/core/sql/sqlcomp/CmpSeabaseDDLutil.cpp
index 39ceae4..4b1fd68 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLutil.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLutil.cpp
@@ -137,10 +137,10 @@ defXLateFuncs(CmGetComAccPathTypeAsAccessPathType, CmGetComAccPathTypeAsLit, Com
 //
 const literalAndEnumStruct RowFormatXlateArray [] =
 {
-  {COM_ALIGNED_FORMAT_TYPE, COM_ALIGNED_FORMAT_LIT},
-  {COM_PACKED_FORMAT_TYPE, COM_PACKED_FORMAT_LIT},
   {COM_UNKNOWN_FORMAT_TYPE, COM_UNKNOWN_FORMAT_LIT},
-  {COM_HIVE_EXTERNAL_FORMAT_TYPE, COM_HIVE_EXTERNAL_FORMAT_TYPE_LIT}
+  {COM_ALIGNED_FORMAT_TYPE, COM_ALIGNED_FORMAT_LIT},
+  {COM_HBASE_FORMAT_TYPE, COM_HBASE_FORMAT_TYPE_LIT}
+  {COM_HBASE_STR_FORMAT_TYPE, COM_HBASE_STR_FORMAT_TYPE_LIT}
 };
 
 defXLateFuncs(CmGetComRowFormatAsRowFormat, CmGetRowFormatTypeAsLit, ComRowFormat, RowFormatXlateArray);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
index eeccb3b..04280e3 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLview.cpp
@@ -275,7 +275,7 @@ short CmpSeabaseDDL::buildViewTblColUsage(const StmtDDLCreateView * createViewPa
      const NAString objectNamePart = usedObjName.getObjectNamePartAsAnsiString(TRUE);
      CorrName cn(objectNamePart,STMTHEAP,schemaNamePart,catalogNamePart);
 
-     NATable *naTable = bindWA.getNATable(cn);
+     NATable *naTable = bindWA.getNATableInternal(cn);
      if (naTable == NULL)
      {
         SEABASEDDL_INTERNAL_ERROR("Bad NATable pointer in createSeabaseView");
@@ -647,7 +647,8 @@ void CmpSeabaseDDL::createSeabaseView(
      return;
     }
 
-  if ((isSeabaseReservedSchema(viewName)) &&
+  if (((isSeabaseReservedSchema(viewName)) ||
+       (ComIsTrafodionExternalSchemaName(schemaNamePart))) &&
       (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
      {
       *CmpCommon::diags() << DgSqlCode(-1118)
@@ -1057,58 +1058,28 @@ void CmpSeabaseDDL::dropSeabaseView(
   Lng32 cliRC = 0;
   Lng32 retcode = 0;
 
-  const NAString &tabName = dropViewNode->getViewName();
-
-  ComObjectName viewName(tabName);
-  ComAnsiNamePart currCatAnsiName(currCatName);
-  ComAnsiNamePart currSchAnsiName(currSchName);
-  viewName.applyDefaults(currCatAnsiName, currSchAnsiName);
-
-  const NAString catalogNamePart = viewName.getCatalogNamePartAsAnsiString();
-  const NAString schemaNamePart = viewName.getSchemaNamePartAsAnsiString(TRUE);
-  const NAString objectNamePart = viewName.getObjectNamePartAsAnsiString(TRUE);
-  const NAString extViewName = viewName.getExternalName(TRUE);
-
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
-
-  ExpHbaseInterface * ehi = allocEHI();
-  if (ehi == NULL)
-    return;
-
-  if ((isSeabaseReservedSchema(viewName)) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
-    {
-      *CmpCommon::diags() << DgSqlCode(-1119)
-			  << DgTableName(extViewName);
-      deallocEHI(ehi); 
-
-      processReturn();
-
-      return;
-    }
-
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-				   catalogNamePart, schemaNamePart, objectNamePart,
-				   COM_VIEW_OBJECT, TRUE, FALSE);
+                               CmpCommon::context()->sqlSession()->getParentQid());
+
+  NAString tabName = dropViewNode->getViewName();
+  NAString catalogNamePart, schemaNamePart, objectNamePart;
+  NAString extTableName, extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  QualifiedName qn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        qn,
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        NULL,
+                        FALSE, FALSE,
+                        &cliInterface,
+                        COM_VIEW_OBJECT);
   if (retcode < 0)
     {
-      deallocEHI(ehi); 
-
-      processReturn();
-
-      return;
-    }
-
-  if (retcode == 0) // does not exist
-    {
-      *CmpCommon::diags() << DgSqlCode(-1389)
-			  << DgString0(extViewName);
-
-      deallocEHI(ehi); 
-
       processReturn();
-      
       return;
     }
 
@@ -1126,8 +1097,6 @@ void CmpSeabaseDDL::dropSeabaseView(
       if (CmpCommon::diags()->getNumber(DgSqlCode::ERROR_) == 0)
         SEABASEDDL_INTERNAL_ERROR("getting object UID and owner for drop view");
 
-      deallocEHI(ehi); 
-
       processReturn();
 
       return;
@@ -1137,7 +1106,6 @@ void CmpSeabaseDDL::dropSeabaseView(
   if (!isDDLOperationAuthorized(SQLOperation::DROP_VIEW,objectOwnerID,schemaOwnerID))
   {
      *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
-     deallocEHI(ehi);
      processReturn ();
      return;
   }
@@ -1149,8 +1117,6 @@ void CmpSeabaseDDL::dropSeabaseView(
       cliRC = getUsingObject(&cliInterface, objUID, usingObjName);
       if (cliRC < 0)
 	{
-	  deallocEHI(ehi); 
-
 	  processReturn();
 	  
 	  return;
@@ -1161,8 +1127,6 @@ void CmpSeabaseDDL::dropSeabaseView(
 	  *CmpCommon::diags() << DgSqlCode(-1047)
 			      << DgTableName(usingObjName);
 
-	  deallocEHI(ehi); 
-
 	  processReturn();
 
 	  return;
@@ -1173,8 +1137,6 @@ void CmpSeabaseDDL::dropSeabaseView(
       cliRC = getUsingViews(&cliInterface, objUID, usingViewsQueue);
       if (cliRC < 0)
 	{
-	  deallocEHI(ehi); 
-
 	  processReturn();
 	  
 	  return;
@@ -1186,6 +1148,14 @@ void CmpSeabaseDDL::dropSeabaseView(
   NAList<objectRefdByMe> tablesRefdList(STMTHEAP);
   short status = getListOfReferencedTables(&cliInterface, objUID, tablesRefdList);
 
+  ExpHbaseInterface * ehi = allocEHI();
+  if (ehi == NULL)
+    {
+      processReturn();
+      
+      return;
+    }
+
   if (usingViewsQueue)
     {
       usingViewsQueue->position();
@@ -1199,8 +1169,7 @@ void CmpSeabaseDDL::dropSeabaseView(
                                 currCatName, currSchName, COM_VIEW_OBJECT,
                                 dropViewNode->ddlXns()))
 	    {
-	      deallocEHI(ehi); 
-
+              deallocEHI(ehi);
 	      processReturn();
 	      
 	      return;
@@ -1212,15 +1181,13 @@ void CmpSeabaseDDL::dropSeabaseView(
                         currCatName, currSchName, COM_VIEW_OBJECT,
                         dropViewNode->ddlXns()))
     {
-      deallocEHI(ehi); 
-
+      deallocEHI(ehi);
       processReturn();
 
       return;
     }
 
   // clear view definition from my cache only. 
-  CorrName cn(objectNamePart, STMTHEAP, schemaNamePart, catalogNamePart);
   ActiveSchemaDB()->getNATableDB()->removeNATable
     (cn,
      ComQiScope::REMOVE_MINE_ONLY, COM_VIEW_OBJECT,
@@ -1256,8 +1223,7 @@ void CmpSeabaseDDL::dropSeabaseView(
          dropViewNode->ddlXns(), FALSE);
     }
 
-  deallocEHI(ehi); 
-      
+  deallocEHI(ehi);
   processReturn();
 
   return;
@@ -1600,7 +1566,7 @@ static bool checkAccessPrivileges(
       if (isSeq)
         cn.setSpecialType(ExtendedQualName::SG_TABLE);
 
-      NATable *naTable = bindWA.getNATable(cn);
+      NATable *naTable = bindWA.getNATableInternal(cn);
       if (naTable == NULL)
       {
          SEABASEDDL_INTERNAL_ERROR("Bad NATable pointer in checkAccessPrivileges");

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/DefaultConstants.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/DefaultConstants.h b/core/sql/sqlcomp/DefaultConstants.h
index 1e08107..2831013 100644
--- a/core/sql/sqlcomp/DefaultConstants.h
+++ b/core/sql/sqlcomp/DefaultConstants.h
@@ -3774,6 +3774,10 @@ enum DefaultConstants
   // Currently syskey, _salt_, _division_.
   TRAF_ALLOW_RESERVED_COLNAMES,
 
+  // enable support for hbase tables mapped to relational traf tables
+  TRAF_HBASE_MAPPED_TABLES,
+  TRAF_HBASE_MAPPED_TABLES_IUD,
+
   //if 0, regular scanner is used. From 0.x to 1.0, percentage of regions that need to be scanned that will be done in parallel.
   //if >= 2, set a fixed number of thread, real DOP. 2.0 2 thread, 3.0 3 thread etc.
   HBASE_DOP_PARALLEL_SCANNER,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/nadefaults.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/nadefaults.cpp b/core/sql/sqlcomp/nadefaults.cpp
index 149f097..f6a6558 100644
--- a/core/sql/sqlcomp/nadefaults.cpp
+++ b/core/sql/sqlcomp/nadefaults.cpp
@@ -3321,6 +3321,9 @@ XDDkwd__(SUBQUERY_UNNESTING,			"ON"),
  
   DDkwd__(TRAF_ENABLE_ORC_FORMAT,                 "OFF"),   
 
+  DDkwd__(TRAF_HBASE_MAPPED_TABLES,             "ON"),   
+  DDkwd__(TRAF_HBASE_MAPPED_TABLES_IUD,         "OFF"),   
+
   DDkwd__(TRAF_INDEX_ALIGNED_ROW_FORMAT,        "ON"),   
   DDkwd__(TRAF_INDEX_CREATE_OPT,          "OFF"),
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
----------------------------------------------------------------------
diff --git a/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java b/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
index 3e14c76..3ee3f54 100644
--- a/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
+++ b/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
@@ -832,7 +832,6 @@ public class HBaseClient {
                     oneRegion += String.valueOf(writeRequestsCount) + "|";
                     
                     regionInfo[regionStatsEntries++] = oneRegion.getBytes();
-
                 }
             }
             finally {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/ustat/hs_la.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_la.cpp b/core/sql/ustat/hs_la.cpp
index 330fbd2..f765491 100644
--- a/core/sql/ustat/hs_la.cpp
+++ b/core/sql/ustat/hs_la.cpp
@@ -132,6 +132,8 @@ void HSTableDef::setNATable()
     ULng32 flagToSet = 0;  // don't turn on flag unless next 'if' is true
     if (CmpCommon::context()->sqlSession()->volatileSchemaInUse())
       flagToSet = ALLOW_VOLATILE_SCHEMA_IN_TABLE_NAME;
+    
+    flagToSet |= ALLOW_SPECIALTABLETYPE;
 
     // set ALLOW_VOLATILE_SCHEMA_IN_TABLE_NAME bit in Sql_ParserFlags
     // if needed, and return it to its entry value on exit


[6/7] incubator-trafodion git commit: updated known diff files

Posted by an...@apache.org.
updated known diff files


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

Branch: refs/heads/master
Commit: b1aabd6f6cad4ead16ef02d56fc42111b338f541
Parents: ac1cdd7
Author: Anoop Sharma <an...@esgyn.com>
Authored: Tue Dec 13 04:56:50 2016 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Tue Dec 13 04:56:50 2016 +0000

----------------------------------------------------------------------
 core/sql/regress/compGeneral/DIFF042.KNOWN | 106 ++++++++++++------------
 core/sql/regress/core/EXPECTED005.SB       |   2 +-
 2 files changed, 55 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/b1aabd6f/core/sql/regress/compGeneral/DIFF042.KNOWN
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/DIFF042.KNOWN b/core/sql/regress/compGeneral/DIFF042.KNOWN
index 088a99d..6e59931 100644
--- a/core/sql/regress/compGeneral/DIFF042.KNOWN
+++ b/core/sql/regress/compGeneral/DIFF042.KNOWN
@@ -1,88 +1,90 @@
-1865c1865
-<  22 0 22
+1863c1863
+<  23 0 23
 ---
->  32 0 32
-1877c1877
-<  22 0 22
+>  31 0 31
+1875c1875
+<  23 0 23
 ---
->  32 0 32
-1972a1973,1977
+>  31 0 31
+1970a1971,1974
 >  0 1
 >  0 1
 >  0 1
 >  0 1
->  0 1
-1982a1988,1992
->  1 1
+1981a1986,1989
 >  1 1
 >  1 1
 >  1 1
 >  1 1
-1992c2002
+1991c1999
 <  9 4
 ---
->  13 4
-1994c2004
-< --- 24 row(s) selected.
+>  12 4
+1993c2001
+< --- 25 row(s) selected.
 ---
-> --- 34 row(s) selected.
-2065a2076,2080
->  0 1
+> --- 33 row(s) selected.
+2064a2073,2076
 >  0 1
 >  0 1
 >  0 1
 >  0 1
-2087a2103,2107
+2087a2100,2103
 >  1 1
 >  1 1
 >  1 1
 >  1 1
->  1 1
-2101c2121
+2101c2117
 <  9 4
 ---
->  13 4
-2103c2123
-< --- 99 row(s) selected.
+>  12 4
+2103c2119
+< --- 100 row(s) selected.
+---
+> --- 108 row(s) selected.
+2121c2137
+<  23 23 5 211
 ---
-> --- 109 row(s) selected.
-2121c2141
-<  22 22 5 211
+>  29 31 5 211
+2133c2149
+<  23 23 5 211
 ---
->  32 32 5 211
-2133c2153
-<  22 22 5 211
+>  29 31 5 211
+2225,2226c2241,2248
+<  314 0 3 1
+<  314 0 3 1
 ---
->  32 32 5 211
-2223a2244,2251
->  227 0 1 0
->  227 1 1 0
->  233 0 1 0
->  233 1 1 0
 >  270 0 1 0
 >  270 1 1 0
 >  282 0 1 0
 >  282 1 1 0
-2226a2255,2256
->  336 0 1 14
->  336 1 1 14
-2235c2265
-< --- 24 row(s) selected.
+>  308 0 1 10
+>  308 0 1 10
+>  308 1 1 10
+>  308 1 1 10
+2227a2250,2251
+>  326 0 3 1
+>  326 0 3 1
+2236c2260
+< --- 25 row(s) selected.
+---
+> --- 33 row(s) selected.
+2320,2321c2344,2351
+<  314 0 3 1
+<  314 0 3 1
 ---
-> --- 34 row(s) selected.
-2317a2348,2355
->  227 0 1 0
->  227 1 1 0
->  233 0 1 0
->  233 1 1 0
 >  270 0 1 0
 >  270 1 1 0
 >  282 0 1 0
 >  282 1 1 0
-2320a2359,2360
->  336 0 1 14
->  336 1 1 14
-2329c2369
-< --- 84 row(s) selected.
+>  308 0 1 10
+>  308 0 1 10
+>  308 1 1 10
+>  308 1 1 10
+2322a2353,2354
+>  326 0 3 1
+>  326 0 3 1
+2331c2363
+< --- 85 row(s) selected.
 ---
-> --- 94 row(s) selected.
+> --- 93 row(s) selected.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/b1aabd6f/core/sql/regress/core/EXPECTED005.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/EXPECTED005.SB b/core/sql/regress/core/EXPECTED005.SB
index 58987e7..07f80dc 100644
--- a/core/sql/regress/core/EXPECTED005.SB
+++ b/core/sql/regress/core/EXPECTED005.SB
@@ -1568,7 +1568,7 @@ NONE              171             140           16        20971520
 NUM_LOOKUPS  NUM_CACHE_HITS  NUM_ENTRIES  MAX_CACHE_SIZE
 -----------  --------------  -----------  --------------
 
-        171             140            0        20971520
+        176             141            0        20971520
 
 --- 1 row(s) selected.
 >>


[3/7] incubator-trafodion git commit: TRAFODION-1586 Add support for external Traf tables mappedd to HBase tables

Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/seabase/EXPECTED022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED022 b/core/sql/regress/seabase/EXPECTED022
index bc10f77..fa3a3af 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  Thu Feb 25 09:47:53 2016
+-- Definition current  Mon Dec 12 23:03:22 2016
 
   (
     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  Thu Feb 25 09:47:53 2016
+-- Definition current  Mon Dec 12 23:03:23 2016
 
   (
     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  Thu Feb 25 09:47:53 2016
+-- Definition current  Mon Dec 12 23:03:23 2016
 
   (
     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  Thu Feb 25 09:47:53 2016
+-- Definition current  Mon Dec 12 23:03:24 2016
 
   (
     ROW_ID                           VARCHAR(100) CHARACTER SET ISO88591
@@ -568,15 +568,871 @@ ROW_ID      (EXPR)
 
 --- 2 row(s) selected.
 >>
->>?section cleanup
->>drop hbase table t022hbt1;
+>>
+>>-- tests to map hbase tables to relational traf tables
+>>cqd traf_hbase_mapped_tables 'ON';
+
+--- SQL operation complete.
+>>
+>>drop hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create hbase table t022hbm1 (column family 'cf');
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm1 values ('a1', 
++>                 column_create(('cf:B', '100 ')));
+
+--- 1 row(s) inserted.
+>>insert into hbase."_ROW_".t022hbm1 values ('a2', column_create(('cf:A', 'a2')));
+
+--- 1 row(s) inserted.
+>>
+>>drop table if exists t022hbm1 cascade;
+
+--- SQL operation complete.
+>>drop external table if exists t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, b char(4))
++>        primary key (a)
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:03:37 2016
+
+  (
+    "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  Mon Dec 12 23:03:38 2016
+
+  (
+    "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);
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion table TRAFODION.SCH.T022HBM1
+-- Definition current  Mon Dec 12 23:03:40 2016
+
+  (
+    SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+  , A                                INT DEFAULT NULL
+  )
+
+--- 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
+
+  (
+    "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.
+>>
+>>prepare s from select * from t022hbm1;
+
+--- SQL command prepared.
+>>execute s;
+
+A     B   
+----  ----
+
+a1    100 
+a2    ?   
+
+--- 2 row(s) selected.
+>>select * from t022hbm1 where a = 'a1';
+
+A     B   
+----  ----
+
+a1    100 
+
+--- 1 row(s) selected.
+>>select a, cast(b as int) from t022hbm1;
+
+A     (EXPR)     
+----  -----------
+
+a1            100
+a2              ?
+
+--- 2 row(s) selected.
+>>
+>>alter table t022hbm1 add column "cf".c int;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:03:53 2016
+
+  (
+    "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.
+>>
+>>-- create a traf table like a mapped table
+>>cqd schema reset;
+
+--- SQL operation complete.
+>>create table t022hbm1_like like t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1_like;
+
+-- Definition of Trafodion table TRAFODION.SCH.T022HBM1_LIKE
+-- Definition current  Mon Dec 12 23:03:58 2016
+
+  (
+    "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.
+>>
+>>insert into t022hbm1_like select * from t022hbm1;
+
+--- 2 row(s) inserted.
+>>select * from t022hbm1_like;
+
+A     B     C          
+----  ----  -----------
+
+a1    100             ?
+a2    ?               ?
+
+--- 2 row(s) selected.
+>>
+>>create table t022hbm1_ctas as select * from t022hbm1;
+
+--- 2 row(s) inserted.
+>>select * from t022hbm1_ctas;
+
+A     B     C          
+----  ----  -----------
+
+a1    100             ?
+a2    ?               ?
+
+--- 2 row(s) selected.
+>>
+>>-- create view on mapped table
+>>create view t022v1 as select * from t022hbm1;
+
+--- SQL operation complete.
+>>
+>>drop external table t022hbm1 cascade;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+*** ERROR[4082] Object TRAFODION.SCH.T022HBM1 does not exist or is inaccessible.
+
+--- SQL operation failed with errors.
+>>create external table t022hbm1 ("cf".a varchar(4) not null,
++>            b int)
++>        primary key (a)
++>        map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:04:14 2016
+
+  (
+    "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.
+>>
+>>alter table t022hbm1 drop column b;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:04:17 2016
+
+  (
+    "cf".A                           VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+      DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+  )
+  PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>alter table t022hbm1 add column "cf".b int;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:04:20 2016
+
+  (
+    "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.
+>>
+>>-- IUD operations on mapped tables
+>>cqd traf_hbase_mapped_tables_iud 'ON';
+
+--- SQL operation complete.
+>>
+>>cqd schema reset;
+
+--- SQL operation complete.
+>>delete from hbase."_ROW_".t022hbm1;
+
+--- 2 row(s) deleted.
+>>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;
+
+--- 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.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a int not null, b int not null, c int) 
++>        primary key (a, b)
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1
++>        data format native;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:04:35 2016
+
+  (
+    "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.
->>drop hbase table t022hbt2;
+>>insert into t022hbm1 values (1,2,3);
+
+--- 1 row(s) inserted.
+>>insert into t022hbm1 values (1,2,3);
+
+*** ERROR[8102] The operation is prevented by a unique constraint.
+
+--- 0 row(s) inserted.
+>>insert into t022hbm1 values (1, 1, 1);
+
+--- 1 row(s) inserted.
+>>insert into t022hbm1 values (-1, -2, -3);
+
+--- 1 row(s) inserted.
+>>select * from t022hbm1;
+
+A            B            C          
+-----------  -----------  -----------
+
+          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;
+
+A            B            C          
+-----------  -----------  -----------
+
+          1            1            1
+          1            2            4
+         -1           -2           -3
+
+--- 3 row(s) selected.
+>>
+>>-- various serialization options
+>>drop external table t022hbm1;
 
 --- SQL operation complete.
->>drop table t022t1;
+>>create external table t022hbm1 (a varchar(4) not null, primary key not serialized (a), b int) 
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1;
 
 --- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:04:41 2016
+
+  (
+    "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.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a char(4) not null, primary key serialized (a), b int) 
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1
++>        data format native;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:04:49 2016
+
+  (
+    "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.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, primary key(a), b int) 
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:04:54 2016
+
+  (
+    "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.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null primary key, b int) 
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:04:58 2016
+
+  (
+    "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.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, b int) 
++>        primary key not serialized (a)
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:05:03 2016
+
+  (
+    "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.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a char(4) not null, b int) 
++>        primary key serialized (a) 
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1
++>        data format native;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:05:07 2016
+
+  (
+    "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.
+>>
+>>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;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:05:15 2016
+
+  (
+    "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.
+>>
+>>drop hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create hbase table t022hbm1 (column family 'cf');
+
+--- SQL operation complete.
+>>drop external table if exists 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;
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm1 values ('a1', column_create(('cf:B', '10')));
+
+--- 1 row(s) inserted.
+>>
+>>-- multi column families in mapped table
+>>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  Mon Dec 12 23:05:29 2016
+
+  (
+    "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.
+>>
+>>-- error cases
+>>
+>>-- primary key cannot be missing
+>>select * from t022hbm1;
+
+A     B          
+----  -----------
+
+a1             10
+
+--- 1 row(s) selected.
+>>
+>>-- operations not allowed
+>>alter table t022hbm1 alter column "cf".b largeint;
+
+*** ERROR[3242] This statement is not supported. Reason: This feature not available for an HBase mapped table.
+
+--- SQL operation failed with errors.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current  Mon Dec 12 23:05:32 2016
+
+  (
+    "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.
+>>
+>>set schema trafodion."_HB_MAP_";
+
+--- SQL operation complete.
+>>
+>>-- cannot invoke using map schema name
+>>invoke "_HB_MAP_".t022hbm1;
+
+*** ERROR[4261] The schema name _HB_MAP_ is reserved for HBase mapped tables and cannot be explicitly specified.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>-- cannot use "_HB_MAP_" in a table name
+>>prepare s from select * from t022hbm1;
+
+*** ERROR[4261] The schema name _HB_MAP_ is reserved for HBase mapped tables and cannot be explicitly specified.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>prepare s from select * from "_HB_MAP_".t022hbm1;
+
+*** ERROR[4261] The schema name _HB_MAP_ is reserved for HBase mapped tables and cannot be explicitly specified.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>drop table "_HB_MAP_".t022hbm1;
+
+*** ERROR[4261] The schema name _HB_MAP_ is reserved for HBase mapped tables and cannot be explicitly specified.
+
+--- SQL operation failed with errors.
+>>alter table trafodion."_HB_MAP_".t022hbm1 drop column b;
+
+*** ERROR[4261] The schema name _HB_MAP_ is reserved for HBase mapped tables and cannot be explicitly specified.
+
+--- SQL operation failed with errors.
+>>
+>>set schema trafodion.sch;
+
+--- SQL operation complete.
+>>
+>>drop external table if exists t022hbm1;
+
+--- SQL operation complete.
+>>
+>>-- cannot specify serialized option
+>>create external table t022hbm1 (a varchar(4) not null, b int) 
++>        primary key serialized (a) 
++>        attribute default column family 'cf'
++>        map to hbase table t022hbm1;
+
+*** ERROR[3242] This statement is not supported. Reason: SERIALIZED option cannot be specified for primary key of this table.
+
+--- SQL operation failed with errors.
+>>
+>>-- cannot be aligned format
+>>create external table t022hbm1 (a varchar(4) not null primary key) 
++>  attribute aligned format map to hbase table t022hbm1;
+
+*** ERROR[3242] This statement is not supported. Reason: Aligned format cannot be specified for an HBase mapped table.
+
+--- SQL operation failed with errors.
+>>
+>>-- must specify pkey
+>>create external table t022hbm1 (a char(4)) map to hbase table t022hbm1;
+
+*** ERROR[4259] Primary Key clause must be specified for an HBase mapped table.
+
+--- SQL operation failed with errors.
+>>
+>>-- external and hbase table names must be the same
+>>create external table t022hbm11 (a char(4) not null primary key) 
++>        map to hbase table t022hbm1;
+
+*** ERROR[1180] Trying to create an external HBASE table with a different schema or table name (T022HBM11) than the source table (T022HBM1).  The external schema and table name must be the same as the source.
+
+--- SQL operation failed with errors.
+>>
+>>-- all non-pkey columns must be nullable
+>>create external table t022hbm1 (a varchar(4) not null primary key,
++>              b int not null)
++>              map to hbase table t022hbm1;
+
+*** ERROR[3242] This statement is not supported. Reason: Non-key columns of an HBase mapped table must be nullable with default value of NULL.
+
+--- SQL operation failed with errors.
+>>
+>>-- all non-pkey columns must have default value of null
+>>create external table t022hbm1 (a varchar(4) not null primary key,
++>              b int default 10)
++>              map to hbase table t022hbm1;
+
+*** ERROR[3242] This statement is not supported. Reason: Non-key columns of an HBase mapped table must be nullable with default value of NULL.
+
+--- SQL operation failed with errors.
+>>
+>>-- mapped table already exist
+>>create external table t022hbm1 (a varchar(4) not null primary key) 
++>              map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null primary key) 
++>              map to hbase table t022hbm1;
+
+*** ERROR[1390] Object TRAFODION."_HB_MAP_".T022HBM1 already exists in Trafodion.
+
+--- SQL operation failed with errors.
+>>
+>>-- hbase table doesn't exist
+>>create external table t022hbm11 (a char(4) not null primary key) 
++>                map to hbase table t022hbm11;
+
+*** ERROR[4260] HBase table(T022HBM11) to be mapped as an external table does not exist.
+
+--- SQL operation failed with errors.
+>>
+>>-- cannot create view in HB_MAP schema
+>>create view "_HB_MAP_".v as select * from t022hbm1;
+
+*** ERROR[1118] Creating object TRAFODION."_HB_MAP_".V is not allowed in a reserved system schema.
+
+--- SQL operation failed with errors.
+>>
+>>-- cannot create index on an hbase external table
+>>create index ti on t022hbm1 (a);
+
+*** ERROR[3242] This statement is not supported. Reason: Cannot create index on an HBase mapped table.
+
+--- SQL operation failed with errors.
+>>
+>>drop external table if exists t022hbm1;
+
+--- SQL operation complete.
+>>drop hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create hbase table t022hbm1 (column family 'cf');
+
+--- 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;
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm1 values ('a1', 
++>                               column_create(('cf:A', '10')));
+
+--- 1 row(s) inserted.
+>>-- rowID must match pkey col contents
+>>select * from t022hbm1;
+
+*** ERROR[8556] An error occurred while accessing HBase table T022HBM1.  Details: HBase rowID content must match the primary key column content.
+
+--- 0 row(s) selected.
+>>
+>>drop hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create hbase table t022hbm1 (column family 'cf');
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm1 values ('a1234567', 
++>                               column_create(('cf:B', '10')));
+
+--- 1 row(s) inserted.
+>>-- primary key col length must be big enough to hold rowID
+>>select * from t022hbm1;
+
+*** ERROR[8556] An error occurred while accessing HBase table T022HBM1.  Details: retrieved rowID of length 8 is larger than the specified key size of 4.
+
+--- 0 row(s) selected.
+>>
+>>drop hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create hbase table t022hbm1 (column family 'cf');
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm1 values ('a1', 
++>                               column_create(('cf:B', '1000000')));
+
+--- 1 row(s) inserted.
+>>-- buffer to retrieve column value must be big enough
+>>cqd hbase_max_column_val_length '5';
+
+--- SQL operation complete.
+>>select * from t022hbm1;
+
+*** ERROR[8556] An error occurred while accessing HBase table T022HBM1.  Details: actual column value length of 7 is greater than the expected max buffer size of 5.
+
+--- 0 row(s) selected.
 >>
 >>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/seabase/EXPECTED027
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED027 b/core/sql/regress/seabase/EXPECTED027
index 9cde4f7..1de53cc 100644
--- a/core/sql/regress/seabase/EXPECTED027
+++ b/core/sql/regress/seabase/EXPECTED027
@@ -1239,7 +1239,7 @@ SCH027.T027V1
 --- SQL operation failed with errors.
 >>alter table t027v1 alter column a smallint;
 
-*** ERROR[1146] Object TRAFODION.SCH027.T027V1 could not be altered because it either does not exist or is not a table.
+*** ERROR[1127] The specified table TRAFODION.SCH027.T027V1 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 
 --- SQL operation failed with errors.
 >>get all views on table t027t7;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/seabase/TEST022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST022 b/core/sql/regress/seabase/TEST022
index 58339b4..80fdaa0 100644
--- a/core/sql/regress/seabase/TEST022
+++ b/core/sql/regress/seabase/TEST022
@@ -20,7 +20,11 @@
 -- under the License.
 --
 -- @@@ END COPYRIGHT @@@
+
+obey TEST022(clean_up);
+
 cqd hbase_delete_costing 'off';
+
 log LOG022 clear;
 
 cqd hbase_native_iud 'ON';
@@ -184,9 +188,285 @@ select char_length(column_details) from hbase."_ROW_".t022hbt2;
 select left(row_id, 10) row_id, left(column_display(column_details), 40) 
            from hbase."_ROW_".t022hbt2;
 
-?section cleanup
+
+-- tests to map hbase tables to relational traf tables
+cqd traf_hbase_mapped_tables 'ON';
+
+drop hbase table t022hbm1;
+create hbase table t022hbm1 (column family 'cf');
+insert into hbase."_ROW_".t022hbm1 values ('a1', 
+                 column_create(('cf:B', '100 ')));
+insert into hbase."_ROW_".t022hbm1 values ('a2', column_create(('cf:A', 'a2')));
+
+drop table if exists t022hbm1 cascade;
+drop external table if exists t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, b char(4))
+        primary key (a)
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
+invoke t022hbm1;
+
+-- if no schema is specified, table is looked in regular and then mapped schema
+invoke t022hbm1;
+create table t022hbm1 (a int);
+invoke t022hbm1;
+drop table t022hbm1;
+invoke t022hbm1;
+
+prepare s from select * from t022hbm1;
+execute s;
+select * from t022hbm1 where a = 'a1';
+select a, cast(b as int) from t022hbm1;
+
+alter table t022hbm1 add column "cf".c int;
+invoke t022hbm1;
+
+-- create a traf table like a mapped table
+cqd schema reset;
+create table t022hbm1_like like t022hbm1;
+invoke t022hbm1_like;
+
+insert into t022hbm1_like select * from t022hbm1;
+select * from t022hbm1_like;
+
+create table t022hbm1_ctas as select * from t022hbm1;
+select * from t022hbm1_ctas;
+
+-- create view on mapped table
+create view t022v1 as select * from t022hbm1;
+
+drop external table t022hbm1 cascade;
+invoke t022hbm1;
+create external table t022hbm1 ("cf".a varchar(4) not null,
+            b int)
+        primary key (a)
+        map to hbase table t022hbm1;
+invoke t022hbm1;
+
+alter table t022hbm1 drop column b;
+invoke t022hbm1;
+
+alter table t022hbm1 add column "cf".b int;
+invoke t022hbm1;
+
+-- IUD operations on mapped tables
+cqd traf_hbase_mapped_tables_iud 'ON';
+
+cqd schema reset;
+delete from hbase."_ROW_".t022hbm1;
+drop external table t022hbm1;
+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;
+
+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;
+create external table t022hbm1 (a int not null, b int not null, c int) 
+        primary key (a, b)
+        attribute default column family 'cf'
+        map to hbase table t022hbm1
+        data format native;
+invoke t022hbm1;
+insert into t022hbm1 values (1,2,3);
+insert into t022hbm1 values (1,2,3);
+insert into t022hbm1 values (1, 1, 1);
+insert into t022hbm1 values (-1, -2, -3);
+select * from t022hbm1;
+upsert into t022hbm1 values (1,2,4);
+select * from t022hbm1;
+
+-- various serialization options
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, primary key not serialized (a), b int) 
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a char(4) not null, primary key serialized (a), b int) 
+        attribute default column family 'cf'
+        map to hbase table t022hbm1
+        data format native;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, primary key(a), b int) 
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null primary key, b int) 
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, b int) 
+        primary key not serialized (a)
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a char(4) not null, b int) 
+        primary key serialized (a) 
+        attribute default column family 'cf'
+        map to hbase table t022hbm1
+        data format native;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, b int) 
+        primary key (a)
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
+invoke t022hbm1;
+
+drop hbase table t022hbm1;
+create hbase table t022hbm1 (column family 'cf');
+drop external table if exists t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, b int) 
+        primary key (a) 
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
+insert into hbase."_ROW_".t022hbm1 values ('a1', column_create(('cf:B', '10')));
+
+-- multi column families in mapped table
+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;
+
+-- error cases
+
+-- primary key cannot be missing
+select * from t022hbm1;
+
+-- operations not allowed
+alter table t022hbm1 alter column "cf".b largeint;
+invoke t022hbm1;
+
+set schema trafodion."_HB_MAP_";
+
+-- cannot invoke using map schema name
+invoke "_HB_MAP_".t022hbm1;
+
+-- cannot use "_HB_MAP_" in a table name
+prepare s from select * from t022hbm1;
+prepare s from select * from "_HB_MAP_".t022hbm1;
+
+drop table "_HB_MAP_".t022hbm1;
+alter table trafodion."_HB_MAP_".t022hbm1 drop column b;
+
+set schema trafodion.sch;
+
+drop external table if exists t022hbm1;
+
+-- cannot specify serialized option
+create external table t022hbm1 (a varchar(4) not null, b int) 
+        primary key serialized (a) 
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
+
+-- cannot be aligned format
+create external table t022hbm1 (a varchar(4) not null primary key) 
+  attribute aligned format map to hbase table t022hbm1;
+
+-- must specify pkey
+create external table t022hbm1 (a char(4)) map to hbase table t022hbm1;
+
+-- external and hbase table names must be the same
+create external table t022hbm11 (a char(4) not null primary key) 
+        map to hbase table t022hbm1;
+
+-- all non-pkey columns must be nullable
+create external table t022hbm1 (a varchar(4) not null primary key,
+              b int not null)
+              map to hbase table t022hbm1;
+
+-- all non-pkey columns must have default value of null
+create external table t022hbm1 (a varchar(4) not null primary key,
+              b int default 10)
+              map to hbase table t022hbm1;
+
+-- mapped table already exist
+create external table t022hbm1 (a varchar(4) not null primary key) 
+              map to hbase table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null primary key) 
+              map to hbase table t022hbm1;
+
+-- hbase table doesn't exist
+create external table t022hbm11 (a char(4) not null primary key) 
+                map to hbase table t022hbm11;
+
+-- cannot create view in HB_MAP schema
+create view "_HB_MAP_".v as select * from t022hbm1;
+
+-- cannot create index on an hbase external table
+create index ti on t022hbm1 (a);
+
+drop external table if exists t022hbm1;
+drop hbase table t022hbm1;
+create hbase table t022hbm1 (column family 'cf');
+create external table t022hbm1 (a varchar(4) not null, b int) 
+        primary key (a) 
+        attribute default column family 'cf'
+        map to hbase table t022hbm1;
+insert into hbase."_ROW_".t022hbm1 values ('a1', 
+                               column_create(('cf:A', '10')));
+-- rowID must match pkey col contents
+select * from t022hbm1;
+
+drop hbase table t022hbm1;
+create hbase table t022hbm1 (column family 'cf');
+insert into hbase."_ROW_".t022hbm1 values ('a1234567', 
+                               column_create(('cf:B', '10')));
+-- primary key col length must be big enough to hold rowID
+select * from t022hbm1;
+
+drop hbase table t022hbm1;
+create hbase table t022hbm1 (column family 'cf');
+insert into hbase."_ROW_".t022hbm1 values ('a1', 
+                               column_create(('cf:B', '1000000')));
+-- buffer to retrieve column value must be big enough
+cqd hbase_max_column_val_length '5';
+select * from t022hbm1;
+
+log;
+
+?section clean_up
+cqd schema reset;
+drop view t022v1;
 drop hbase table t022hbt1;
 drop hbase table t022hbt2;
+drop hbase table t022hbm1;
+drop hbase table t022hbm11;
+drop table t022hbm1_like;
+drop table t022hbm1_ctas;
 drop table t022t1;
+drop table t022hbm1 cascade;
 
-log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/tools/regress-filter-linux
----------------------------------------------------------------------
diff --git a/core/sql/regress/tools/regress-filter-linux b/core/sql/regress/tools/regress-filter-linux
index addb947..15ce771 100755
--- a/core/sql/regress/tools/regress-filter-linux
+++ b/core/sql/regress/tools/regress-filter-linux
@@ -280,8 +280,8 @@ s/\(EXTERNAL PATH\) '[^']*'/\1 '@path@'/
 # For SHOWLABEL COMPRESSION
 s/\\(ATTRIBUTES \\([^,][^,]*, \\)\\{0,1\\}\\)[ NO]*COMPRESSION/\1@compress@/g
 
-s/ SERIALIZED//
-s/ NOT SERIALIZED//
+#s/ SERIALIZED//
+#s/ NOT SERIALIZED//
 
 # For error 11205 (Java class not found)
 /ERROR\[11205\]/s/\(external path\) '[^']*'/\1 '@path@'/

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/smdio/CmUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/smdio/CmUtil.cpp b/core/sql/smdio/CmUtil.cpp
index aa2acbb..7a0c96d 100644
--- a/core/sql/smdio/CmUtil.cpp
+++ b/core/sql/smdio/CmUtil.cpp
@@ -140,7 +140,6 @@ defXLateFuncs(CmGetComAccPathTypeAsAccessPathType, CmGetComAccPathTypeAsLit, Com
 const literalAndEnumStruct RowFormatXlateArray [] =
 {
   {COM_ALIGNED_FORMAT_TYPE, COM_ALIGNED_FORMAT_LIT},
-  {COM_PACKED_FORMAT_TYPE, COM_PACKED_FORMAT_LIT},
   {COM_UNKNOWN_FORMAT_TYPE, COM_UNKNOWN_FORMAT_LIT}
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcat/TrafDDLdesc.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcat/TrafDDLdesc.h b/core/sql/sqlcat/TrafDDLdesc.h
index 34c1d2f..601ad96 100644
--- a/core/sql/sqlcat/TrafDDLdesc.h
+++ b/core/sql/sqlcat/TrafDDLdesc.h
@@ -363,13 +363,18 @@ public:
 
   enum ConstrntsDescFlags
     { 
-      ENFORCED           = 0x0001
+      ENFORCED           = 0x0001,
+      NOT_SERIALIZED     = 0x0002
     };
 
   void setEnforced(NABoolean v) 
   {(v ? constrntsDescFlags |= ENFORCED : constrntsDescFlags &= ~ENFORCED); };
   NABoolean isEnforced() { return (constrntsDescFlags & ENFORCED) != 0; };
 
+  void setNotSerialized(NABoolean v) 
+  {(v ? constrntsDescFlags |= NOT_SERIALIZED : constrntsDescFlags &= ~NOT_SERIALIZED); };
+  NABoolean notSerialized() { return (constrntsDescFlags & NOT_SERIALIZED) != 0; };
+
   char* constrntname;
   char* tablename;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcat/desc.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcat/desc.h b/core/sql/sqlcat/desc.h
deleted file mode 100644
index 0575b73..0000000
--- a/core/sql/sqlcat/desc.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/**********************************************************************
-// @@@ 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 @@@
-//
-**********************************************************************/
-#ifndef DESC_H
-#define DESC_H
-
-obsolete file, should not be included. Will give syntax error if it is.
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index a8337ee..32fdd27 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -191,26 +191,27 @@ short CmpDescribeHiveTable (
                              CollHeap *heap);
 
 short CmpDescribeSeabaseTable ( 
-                             const CorrName  &dtName,
-                             short type, // 1, invoke. 2, showddl. 3, createLike
-                             char* &outbuf,
-                             ULng32 &outbuflen,
-                             CollHeap *heap,
-                             const char * pkeyStr = NULL,
-                             NABoolean withPartns = FALSE,
-                             NABoolean withoutSalt = FALSE,
-                             NABoolean withoutDivisioning = FALSE,
-                             UInt32 columnLengthLimit = UINT_MAX,
-                             NABoolean noTrailingSemi = FALSE,
-
-                             // used to add,rem,alter column definition from col list.
-                             // valid for 'createLike' mode. 
-                             // Used for 'alter add/drop/alter col'.
-                             char * colName = NULL,
-                             short ada = 0, // 0,add. 1,drop. 2,alter
-                             const NAColumn * nacol = NULL,
-                             const NAType * natype = NULL,
-                             Space *inSpace = NULL);
+     const CorrName  &dtName,
+     short type, // 1, invoke. 2, showddl. 3, createLike
+     char* &outbuf,
+     ULng32 &outbuflen,
+     CollHeap *heap,
+     const char * pkeyStr = NULL,
+     NABoolean withPartns = FALSE,
+     NABoolean withoutSalt = FALSE,
+     NABoolean withoutDivisioning = FALSE,
+     NABoolean withoutRowFormat = FALSE,
+     UInt32 columnLengthLimit = UINT_MAX,
+     NABoolean noTrailingSemi = FALSE,
+     
+     // used to add,rem,alter column definition from col list.
+     // valid for 'createLike' mode. 
+     // Used for 'alter add/drop/alter col'.
+     char * colName = NULL,
+     short ada = 0, // 0,add. 1,drop. 2,alter
+     const NAColumn * nacol = NULL,
+     const NAType * natype = NULL,
+     Space *inSpace = NULL);
 
 short CmpDescribeSequence ( 
                              const CorrName  &dtName,
@@ -2354,7 +2355,8 @@ short CmpDescribeHiveTable (
                                          type,
                                          dummyBuf, dummyLen, heap, 
                                          NULL, 
-                                         TRUE, FALSE, FALSE, UINT_MAX, TRUE,
+                                         TRUE, FALSE, FALSE, FALSE, 
+                                         UINT_MAX, TRUE,
                                          NULL, 0, NULL, NULL, &space);
 
       outputShortLine(space, ";");
@@ -2404,14 +2406,24 @@ short cmpDisplayColumn(const NAColumn *nac,
     colFam = "";
   else if (nac->getNATable() && nac->getNATable()->isSeabaseTable())
     {
-      int index = 0;
-      CmpSeabaseDDL::extractTrafColFam(nac->getHbaseColFam(), index);
-
-      if (index >= naTable->allColFams().entries())
-        return -1;
+      const char * col_fam = NULL;
+      if (nac->getNATable()->isHbaseMapTable())
+        {
+          col_fam = nac->getHbaseColFam().data();
+        }
+      else
+        {
+          int index = 0;
+          CmpSeabaseDDL::extractTrafColFam(nac->getHbaseColFam(), index);
+          
+          if (index >= naTable->allColFams().entries())
+            return -1;
 
-      colFam = ANSI_ID(naTable->allColFams()[index].data());
+          col_fam = naTable->allColFams()[index].data();
+        }
       
+      colFam = ANSI_ID(col_fam);
+
       colFam += ".";
     }
 
@@ -2722,6 +2734,7 @@ short CmpDescribeSeabaseTable (
                                NABoolean withPartns,
                                NABoolean withoutSalt,
                                NABoolean withoutDivisioning,
+                               NABoolean withoutRowFormat,
                                UInt32 columnLengthLimit,
                                NABoolean noTrailingSemi,
                                char * colName,
@@ -2745,8 +2758,9 @@ short CmpDescribeSeabaseTable (
 
   // set isExternalTable to allow Hive External tables to be described
   BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  bindWA.setAllowExternalTables (TRUE);
-  NATable *naTable = bindWA.getNATable((CorrName&)dtName); 
+
+  NATable *naTable = bindWA.getNATableInternal((CorrName&)dtName); 
+
   TableDesc *tdesc = NULL;
   if (naTable == NULL || bindWA.errStatus())
     return -1;
@@ -2766,6 +2780,7 @@ short CmpDescribeSeabaseTable (
 
   NABoolean isVolatile = naTable->isVolatileTable();
   NABoolean isExternalTable = naTable->isExternalTable();
+  NABoolean isHbaseMapTable = naTable->isHbaseMapTable();
 
   NABoolean isExternalHbaseTable = FALSE;
   NABoolean isExternalHiveTable = FALSE;
@@ -2924,16 +2939,28 @@ short CmpDescribeSeabaseTable (
       else
         sprintf(buf,  "-- Definition of Trafodion%stable %s\n"
                 "-- Definition current  %s",
-                (isVolatile ? " volatile " : isExternalTable ? " external " : " "), 
-                tableName.data(), 
+                (isVolatile ? " volatile " : 
+                 (isHbaseMapTable ? " HBase mapped " :
+                  (isExternalTable ? " external " : " "))), 
+                (isHbaseMapTable ? objectName.data() : 
+                 tableName.data()),
                 ctime(&tp));
       outputShortLine(*space, buf);
     }
   else if (type == 2)
     {
-      sprintf(buf,  "CREATE%sTABLE %s",
-              (isVolatile ? " VOLATILE " : isExternalTable ? " EXTERNAL " : " "), 
-              (isExternalTable ? objectName.data() : tableName.data()));
+      NAString tabType;
+      if (isVolatile)
+        tabType = " VOLATILE ";
+      else if (isExternalTable)
+        tabType = " EXTERNAL ";
+      else
+        tabType = " ";
+
+      sprintf(
+           buf,  "CREATE%sTABLE %s",
+           tabType.data(),
+           (isExternalTable ? objectName.data() : tableName.data()));
       outputShortLine(*space, buf);
     }
 
@@ -2942,7 +2969,8 @@ short CmpDescribeSeabaseTable (
   NAList<const NAColumn *> truncatedColumnList(heap);
   if ((NOT isExternalTable) ||
       ((isExternalTable) && 
-       ((isExternalHbaseTable && (type == 1)) ||
+       ((isExternalHbaseTable && ((type == 1) || (type == 3))) ||
+        (isExternalHbaseTable && naTable->isHbaseMapTable() && (type == 2)) ||
         (isExternalHiveTable && (type != 2)) ||
         (isExternalHiveTable && (type == 2) && (naTable->hiveExtColAttrs())))))
     {
@@ -2952,7 +2980,8 @@ short CmpDescribeSeabaseTable (
                         displaySystemCols, 
                         FALSE,
                         identityColPos,
-                        isExternalTable, naTable->isSQLMXAlignedTable(),
+                        (isExternalTable && (NOT isHbaseMapTable)),
+                        naTable->isSQLMXAlignedTable(),
                         colName, ada, nacol, natype,
                         columnLengthLimit,
                         &truncatedColumnList);
@@ -3045,6 +3074,22 @@ short CmpDescribeSeabaseTable (
           else
             sprintf(buf,  "  , PRIMARY KEY ");
           
+          // if all primary key columns are 'not serialized primary key',
+          // then display that.
+          NABoolean serialized = FALSE;
+          for (Int32 jj = 0; 
+               ((NOT serialized) && (jj <  naf->getIndexKeyColumns().entries())); jj++)
+            {
+              NAColumn * nac = (naf->getIndexKeyColumns())[jj];
+              if (NOT nac->isPrimaryKeyNotSerialized())
+                serialized = TRUE;
+            }
+
+          if (((type == 1) || (type == 2)) && (NOT serialized))
+            {
+              strcat(&buf[strlen(buf)], "NOT SERIALIZED ");
+            }
+
           cmpDisplayPrimaryKey(naf->getIndexKeyColumns(), 
                                naf->getIndexKeyColumns().entries(),
                                displaySystemCols,
@@ -3171,17 +3216,30 @@ short CmpDescribeSeabaseTable (
         }
 
       NABoolean attributesSet = FALSE;
-      if ((((NOT isAudited) || (isAligned))) ||
+      NABoolean formatSet = FALSE;
+      char attrs[2000];
+      if ((type == 3/*create like*/) && (NOT withoutRowFormat))
+        {
+          strcpy(attrs, " ATTRIBUTES ");
+          if (isAligned)
+            strcat(attrs, "ALIGNED FORMAT ");
+          else
+            strcat(attrs, "HBASE FORMAT ");
+          attributesSet = TRUE;
+          formatSet = TRUE;
+        }
+
+      if (((NOT isAudited) || (isAligned)) ||
           ((sqlmxRegr) && (type == 3) && ((NOT isAudited) || (isAligned))) ||
           ((NOT naTable->defaultColFam().isNull()) && 
            (naTable->defaultColFam() != SEABASE_DEFAULT_COL_FAMILY)))
         {
-          char attrs[2000];
-          strcpy(attrs, " ATTRIBUTES ");
+          if (NOT attributesSet)
+            strcpy(attrs, " ATTRIBUTES ");
 
           if (NOT isAudited)
             strcat(attrs, "NO AUDIT ");
-          if (isAligned)
+          if ((NOT formatSet) && isAligned)
             strcat(attrs, "ALIGNED FORMAT ");
           if ((NOT naTable->defaultColFam().isNull()) &&
               (naTable->defaultColFam() != SEABASE_DEFAULT_COL_FAMILY))
@@ -3190,9 +3248,13 @@ short CmpDescribeSeabaseTable (
               strcat(attrs, naTable->defaultColFam());
               strcat(attrs, "'");
             }
-          outputShortLine(*space, attrs);
+
+          attributesSet = TRUE;
         }
 
+      if (attributesSet)
+        outputShortLine(*space, attrs);
+        
       if (!isView && (naTable->hbaseCreateOptions()) &&
           (naTable->hbaseCreateOptions()->entries() > 0))
         {
@@ -3215,12 +3277,21 @@ short CmpDescribeSeabaseTable (
         }
 
       if ((isExternalTable) &&
+          (NOT isHbaseMapTable) &&
           (type == 2))
         {
           sprintf(buf, "  FOR %s", extName.data());
           outputShortLine(*space, buf);
         }
 
+      if ((isHbaseMapTable) && (type != 3))
+        {
+          sprintf(buf, "  MAP TO HBASE TABLE %s DATA FORMAT %s",
+                  dtName.getQualifiedNameObj().getObjectName().data(),
+                  (naTable->isHbaseDataFormatString() ? "VARCHAR" : "NATIVE"));
+          outputShortLine(*space, buf);
+        }
+
       if (NOT noTrailingSemi)
         outputShortLine(*space, ";");
     }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDL.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDL.h b/core/sql/sqlcomp/CmpSeabaseDDL.h
index ae5a31f..d18b0c2 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDL.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDL.h
@@ -443,6 +443,10 @@ class CmpSeabaseDDL
     READ_OBJECT_DESC  = 0x0008
   };
 
+  enum 
+    {
+      MD_TABLE_CONSTRAINTS_PKEY_NOT_SERIALIZED_FLG  = 0x0001
+    };
 protected:
   
   void setFlags(ULng32 &flags, ULng32 flagbits)
@@ -973,8 +977,23 @@ protected:
                                const NAString &schName,
                                const NAString &objName,
                                const ComObjectType objectType,
-                               NABoolean dontForceCleanup);
+                               NABoolean ddlXns);
 
+  short setupAndErrorChecks(NAString &tabName, QualifiedName &origTableName, 
+                            NAString &currCatName, NAString &currSchName,
+                            NAString &catalogNamePart, 
+                            NAString &schemaNamePart, 
+                            NAString &objectNamePart,
+                            NAString &extTableName, NAString &extNameForHbase,
+                            CorrName &cn,
+                            NATable* *naTable,
+                            NABoolean volTabSupported, 
+                            NABoolean hbaseMapSupported,
+                            ExeCliInterface *cliInterface,
+                            const ComObjectType objectType = COM_BASE_TABLE_OBJECT,
+                            SQLOperation operation = SQLOperation::ALTER_TABLE,
+                            NABoolean isExternal = FALSE);
+  
   void purgedataObjectAfterError(
                                ExeCliInterface &cliInterface,
                                const NAString &catName, 
@@ -1005,11 +1024,13 @@ protected:
        const NAString &likeTabName,
        NABoolean withPartns = FALSE,
        NABoolean withoutSalt = FALSE,
-       NABoolean withoutDivision = FALSE);
+       NABoolean withoutDivision = FALSE,
+       NABoolean withoutRowFormat = FALSE);
 
   void createSeabaseTableLike(
-			      StmtDDLCreateTable                  * createTableNode,
-			      NAString &currCatName, NAString &currSchName);
+       ExeCliInterface *cliInterface,
+       StmtDDLCreateTable                  * createTableNode,
+       NAString &currCatName, NAString &currSchName);
 
   short createSeabaseTableExternal(
                                    ExeCliInterface &cliInterface,
@@ -1494,6 +1515,13 @@ protected:
                          NAString& hco); // out
   
 
+  short lookForTableInMD(
+       ExeCliInterface *cliInterface,
+       NAString &catNamePart, NAString &schNamePart, NAString &objNamePart,
+       NABoolean schNameSpecified, NABoolean isHbaseMapSpecified,
+       ComObjectName &tableName, NAString &tabName, NAString &extTableName,
+       const ComObjectType objectType = COM_BASE_TABLE_OBJECT);
+
 private:
   enum
   {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
index a2afca3..47c18b9 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
@@ -1099,7 +1099,8 @@ short CmpSeabaseMDcleanup::cleanupOrphanObjectsEntries(ExeCliInterface *cliInter
   char query[1000];
   NABoolean errorSeen = FALSE;
 
-  // find out all entries which do not have corresponsing hbase objects
+  // find out all entries which do not have corresponding hbase objects.
+  // Do not include metadata, repository and external tables.
   str_sprintf(query, "select object_uid, trim(catalog_name) || '.'  || trim(schema_name) || '.' || trim(object_name)  from %s.\"%s\".%s where catalog_name = '%s' and schema_name not in ( '_MD_', '_REPOS_', '_PRIVMGR_MD_') and schema_name not like '|_HV|_%%|_' escape '|'  and schema_name not like '|_HB|_%%|_' escape '|' and (object_type = 'BT' or object_type = 'IX') ",
               getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
               getSystemCatalog());

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index af4d287..8d28d38 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -4840,6 +4840,8 @@ short CmpSeabaseDDL::updateSeabaseMDTable(
           isAudited = tableInfo->isAudited;
           if (tableInfo->rowFormat == COM_ALIGNED_FORMAT_TYPE)
             strcpy(rowFormat, COM_ALIGNED_FORMAT_LIT);
+          else if (tableInfo->rowFormat == COM_HBASE_STR_FORMAT_TYPE)
+            strcpy(rowFormat, COM_HBASE_STR_FORMAT_LIT);
           numSaltPartns = tableInfo->numSaltPartns;
           hbaseCreateOptions = tableInfo->hbaseCreateOptions;
         }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLindex.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLindex.cpp b/core/sql/sqlcomp/CmpSeabaseDDLindex.cpp
index 6f0ecd0..d0cabd9 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLindex.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLindex.cpp
@@ -407,6 +407,10 @@ void CmpSeabaseDDL::createSeabaseIndex( StmtDDLCreateIndex * createIndexNode,
   NAString extTableName = tableName.getExternalName(TRUE);
   NAString extTableNameForHbase = 
     btCatalogNamePart + "." + btSchemaNamePart + "." + btObjectNamePart;
+  NAString tabName = (NAString&)createIndexNode->getTableName();
+
+  NABoolean schNameSpecified = 
+    (NOT createIndexNode->getOrigTableNameAsQualifiedName().getSchemaName().isNull());
 
   ComObjectName indexName(createIndexNode->getIndexName());
   indexName.applyDefaults(btCatalogNamePart, btSchemaNamePart); 
@@ -421,7 +425,8 @@ void CmpSeabaseDDL::createSeabaseIndex( StmtDDLCreateIndex * createIndexNode,
   if (ehi == NULL)
     return;
 
-  if ((isSeabaseReservedSchema(indexName)) &&
+  if (((isSeabaseReservedSchema(indexName)) ||
+       (ComIsTrafodionExternalSchemaName(schemaNamePart))) &&
       (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
     {
       *CmpCommon::diags() << DgSqlCode(-1118)
@@ -503,12 +508,10 @@ void CmpSeabaseDDL::createSeabaseIndex( StmtDDLCreateIndex * createIndexNode,
 
      }
 
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   btCatalogNamePart, btSchemaNamePart, btObjectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
+  retcode = lookForTableInMD(&cliInterface, 
+                             btCatalogNamePart, btSchemaNamePart, btObjectNamePart,
+                             schNameSpecified, FALSE,
+                             tableName, tabName, extTableName);
   if (retcode < 0)
     {
       processReturn();
@@ -518,20 +521,13 @@ void CmpSeabaseDDL::createSeabaseIndex( StmtDDLCreateIndex * createIndexNode,
 
   ActiveSchemaDB()->getNATableDB()->useCache();
 
-  // save the current parserflags setting
-  ULng32 savedParserFlags = Get_SqlParser_Flags (0xFFFFFFFF);
-  Set_SqlParser_Flags(ALLOW_VOLATILE_SCHEMA_IN_TABLE_NAME);
-
   BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
   CorrName cn(tableName.getObjectNamePart().getInternalName(),
 	      STMTHEAP,
 	      btSchemaNamePart,
 	      btCatalogNamePart);
 
-  NATable *naTable = bindWA.getNATable(cn); 
-
-  // Save parser flags settings so they can be restored later
-  Set_SqlParser_Flags (savedParserFlags);
+  NATable *naTable = bindWA.getNATableInternal(cn); 
 
   if (naTable == NULL || bindWA.errStatus())
     {
@@ -557,6 +553,18 @@ void CmpSeabaseDDL::createSeabaseIndex( StmtDDLCreateIndex * createIndexNode,
 
   Int64 btObjUID = naTable->objectUid().castToInt64();
 
+  if (naTable->isHbaseMapTable())
+    {
+      // not supported
+      *CmpCommon::diags() << DgSqlCode(-3242)
+                          << DgString0("Cannot create index on an HBase mapped table.");
+
+      deallocEHI(ehi); 
+      processReturn();
+      
+      return;
+    }
+
   NAString &indexColFam = naTable->defaultColFam();
   NAString trafColFam;
   if (indexColFam != SEABASE_DEFAULT_COL_FAMILY)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index 836ea47..e016768 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -1699,11 +1699,15 @@ ULng32 savedParserFlags = Get_SqlParser_Flags(0xFFFFFFFF);
    }
    
 // Restore parser flags settings to what they originally were
-   Assign_SqlParser_Flags(savedParserFlags); 
+   Assign_SqlParser_Flags(savedParserFlags);
 
    if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
-      someObjectsCouldNotBeDropped = true;
-   
+     {
+       cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+
+       someObjectsCouldNotBeDropped = true;
+     }
+
 // remove NATable entry for this table
    CorrName cn(objectName,STMTHEAP,schemaName,catalogName);
 


[5/7] incubator-trafodion git commit: TRAFODION-1586 Add support for external Traf tables mappedd to HBase tables

Posted by an...@apache.org.
TRAFODION-1586 Add support for external Traf tables mappedd to HBase tables

This is the initial support for HBase mapped tables.
A doc for external manuals will be added later.
regress/seabase/TEST022 contains various testcases.


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

Branch: refs/heads/master
Commit: ac1cdd7d803a48c2e6bba408d6ad0047c4379277
Parents: 8d09100
Author: Anoop Sharma <an...@esgyn.com>
Authored: Tue Dec 13 00:35:38 2016 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Tue Dec 13 00:35:38 2016 +0000

----------------------------------------------------------------------
 core/sql/bin/SqlciErrors.txt                    |    8 +-
 core/sql/comexe/ComTdb.h                        |    2 +
 core/sql/comexe/ComTdbHbaseAccess.cpp           |   17 +-
 core/sql/comexe/ComTdbHbaseAccess.h             |   25 +-
 core/sql/common/ComMisc.cpp                     |    8 +
 core/sql/common/ComMisc.h                       |    2 +
 core/sql/common/ComResWords.cpp                 |    1 -
 core/sql/common/ComSmallDefs.h                  |   26 +-
 core/sql/common/OperTypeEnum.h                  |    1 +
 core/sql/executor/ExExeUtil.h                   |    4 +-
 core/sql/executor/ExExeUtilGet.cpp              |   35 +-
 core/sql/executor/ExHbaseAccess.cpp             |  303 ++-
 core/sql/executor/ExHbaseAccess.h               |    7 +-
 core/sql/executor/ExHbaseIUD.cpp                |   22 +-
 core/sql/executor/ExHbaseSelect.cpp             |    4 +-
 core/sql/executor/HBaseClient_JNI.cpp           |   26 +-
 core/sql/exp/ExpErrorEnums.h                    |    1 +
 core/sql/exp/exp_function.cpp                   |    9 +-
 core/sql/generator/GenExpGenerator.cpp          |  159 +-
 core/sql/generator/GenExpGenerator.h            |   57 +-
 core/sql/generator/GenKey.cpp                   |  140 +-
 core/sql/generator/GenPreCode.cpp               |   19 +-
 core/sql/generator/GenRelScan.cpp               |  271 ++-
 core/sql/generator/GenRelUpdate.cpp             |   77 +-
 core/sql/generator/Generator.cpp                |    1 +
 core/sql/optimizer/BindRelExpr.cpp              |  129 +-
 core/sql/optimizer/BindWA.h                     |    5 +
 core/sql/optimizer/NAColumn.h                   |    9 +-
 core/sql/optimizer/NAFileSet.cpp                |    7 +
 core/sql/optimizer/NAFileSet.h                  |    2 +-
 core/sql/optimizer/NATable.cpp                  |   29 +-
 core/sql/optimizer/NATable.h                    |   20 +-
 core/sql/optimizer/ObjectNames.cpp              |   10 +
 core/sql/optimizer/ObjectNames.h                |    3 +
 core/sql/optimizer/RelScan.h                    |    9 +-
 core/sql/parser/BindStmtDDL.cpp                 |    4 +
 core/sql/parser/ElemDDLConstraintPK.h           |   37 +-
 core/sql/parser/ElemDDLLikeOptions.cpp          |   23 +
 core/sql/parser/ElemDDLLikeOptions.h            |   28 +
 core/sql/parser/ElemDDLNode.cpp                 |    5 +
 core/sql/parser/ElemDDLNode.h                   |    2 +
 core/sql/parser/ElemDDLStoreOptions.cpp         |    3 +-
 core/sql/parser/ElemDDLStoreOptions.h           |   14 +
 core/sql/parser/ParDDLLikeOpts.cpp              |   16 +
 core/sql/parser/ParDDLLikeOptsCreateTable.h     |   14 +-
 core/sql/parser/ParKeyWords.cpp                 |    3 +-
 core/sql/parser/SqlParserAux.h                  |    2 +
 core/sql/parser/StmtDDLAlterTable.h             |   18 +
 core/sql/parser/StmtDDLCleanupObjects.h         |   18 +
 core/sql/parser/StmtDDLCreate.cpp               |    7 +-
 core/sql/parser/StmtDDLCreateTable.h            |   42 +-
 core/sql/parser/StmtDDLMisc.cpp                 |    4 +
 core/sql/parser/sqlparser.y                     |  123 +-
 core/sql/regress/core/EXPECTED061.SB            |   10 +-
 core/sql/regress/executor/EXPECTED013.SB        |    2 +-
 core/sql/regress/hive/EXPECTED009               |    4 +-
 core/sql/regress/hive/TEST009                   |    4 +-
 core/sql/regress/privs2/EXPECTED138             |    6 +-
 core/sql/regress/seabase/EXPECTED022            |  872 ++++++++-
 core/sql/regress/seabase/EXPECTED027            |    2 +-
 core/sql/regress/seabase/TEST022                |  284 ++-
 core/sql/regress/tools/regress-filter-linux     |    4 +-
 core/sql/smdio/CmUtil.cpp                       |    1 -
 core/sql/sqlcat/TrafDDLdesc.h                   |    7 +-
 core/sql/sqlcat/desc.h                          |   29 -
 core/sql/sqlcomp/CmpDescribe.cpp                |  153 +-
 core/sql/sqlcomp/CmpSeabaseDDL.h                |   36 +-
 core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp       |    3 +-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp        |    2 +
 core/sql/sqlcomp/CmpSeabaseDDLindex.cpp         |   38 +-
 core/sql/sqlcomp/CmpSeabaseDDLschema.cpp        |   10 +-
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp         | 1813 +++++++++---------
 core/sql/sqlcomp/CmpSeabaseDDLutil.cpp          |    6 +-
 core/sql/sqlcomp/CmpSeabaseDDLview.cpp          |  100 +-
 core/sql/sqlcomp/DefaultConstants.h             |    4 +
 core/sql/sqlcomp/nadefaults.cpp                 |    3 +
 .../java/org/trafodion/sql/HBaseClient.java     |    1 -
 core/sql/ustat/hs_la.cpp                        |    2 +
 78 files changed, 3565 insertions(+), 1642 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------
diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt
index 1e65033..fe4c028 100644
--- a/core/sql/bin/SqlciErrors.txt
+++ b/core/sql/bin/SqlciErrors.txt
@@ -126,7 +126,7 @@
 1124 ZZZZZ 99999 BEGINNER MINOR DBADMIN Metadata version is at $0~Int0. Upgrade/Downgrade to current version cannot be performed.
 1125 ZZZZZ 99999 ADVANCED CRTCL DIALOUT API request version number mismatch.
 1126 ZZZZZ 99999 BEGINNER MINOR DBADMIN $0~String0 failed.
-1127 ZZZZZ 99999 BEGINNER MINOR DBADMIN The specified table $0~TableName is not a base table.  Please verify that the correct table was specified.
+1127 ZZZZZ 99999 BEGINNER MINOR DBADMIN The specified table $0~TableName does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 1128 ZZZZZ 99999 ADVANCED CRTCL DIALOUT An invalid API request was encountered.  Details: $0~String0.
 1129 ZZZZZ 99999 BEGINNER MINOR DBADMIN This operation is not allowed on a vertically partitioned table.
 1130 ZZZZZ 99999 BEGINNER MINOR DBADMIN The column requires a default value.
@@ -1307,6 +1307,9 @@ $1~String1 --------------------------------
 4256 ZZZZZ 99999 BEGINNER MINOR DBADMIN Object type specified for this object does not match the object type stored in metadata.
 4257 ZZZZZ 99999 BEGINNER MINOR DBADMIN DIVISION BY with an approximate numeric data type is not supported.
 4258 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Trying to access external table $0~TableName through its external name format. Please use the native table name.
+4259 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Primary Key clause must be specified for an HBase mapped table.
+4260 ZZZZZ 99999 BEGINNER MAJOR DBADMIN HBase table($0~String0) to be mapped as an external table does not exist.
+4261 ZZZZZ 99999 BEGINNER MAJOR DBADMIN The schema name $0~SchemaName is reserved for HBase mapped tables and cannot be explicitly specified.
 4300 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Use of procedure $0~TableName was not valid - a UDR was invoked within a trigger.
 4301 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Use of routine $0~TableName was not valid - return of result sets is not allowed within a trigger.
 4302 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Procedure $0~TableName expects $1~Int0 parameters but was called with $1~int1 parameters.
@@ -1504,7 +1507,7 @@ $1~String1 --------------------------------
 8031 HY018 99999 BEGINNER INFRM LOGONLY Server declined cancel request for query ID $0~String0. $1~String1.
 8032 ZZZZZ 99999 ADVANCED MAJOR DBADMIN Explain information for the provided query id is not available in repository.
 8033 ZZZZZ 99999 ADVANCED MAJOR DBADMIN Explain information is too large to be stored in repository.
-8034 ZZZZZ 99999 ADVANCED MAJOR DBADMIN Column $0~String0 of object $1~string0 does not have a default clause but it is missing in database. This indicates inconsistent data.
+8034 ZZZZZ 99999 ADVANCED MAJOR DBADMIN Column $0~String0 of object $1~string1 does not have a default clause but it is missing in database. This indicates inconsistent data.
 8035 ZZZZZ 99999 ADVANCED MAJOR DBADMIN Truncation of hive table failed. $0~String0
 8036 ZZZZZ 99999 ADVANCED MINOR LOGONLY Error while creating the error logging file or logging the error row to file $0~String0: Details :$1~String1 
 8100 ZZZZZ 99999 BEGINNER MINOR LOGONLY Define $1~string0 does not exist
@@ -1588,6 +1591,7 @@ $1~String1 --------------------------------
 8553 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Stream overflow; subscription rate has fallen too far behind publishing rate.
 8554 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU -- unused, although the error number reservation doc says it is used ---
 8555 ZZZZZ 99999 ADVANCED CRTCL DIALOUT An internal error occurred in the SQL executor in the disk process.
+8556 ZZZZZ 99999 BEGINNER MAJOR DBADMIN An error occurred while accessing HBase table $0~string0. $1~string1 
 8570 ZZZZZ 99999 ADVANCED MAJOR DBADMIN SQL could not allocate sufficient memory to build query.
 8571 ZZZZZ 99999 ADVANCED MAJOR DBADMIN SQL could not allocate sufficient memory to execute query.
 8572 ZZZZZ 99999 ADVANCED CRTCL DIALOUT The statement has incurred a fatal error and must be deallocated.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/comexe/ComTdb.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdb.h b/core/sql/comexe/ComTdb.h
index 6e803d5..eb42be9 100644
--- a/core/sql/comexe/ComTdb.h
+++ b/core/sql/comexe/ComTdb.h
@@ -1041,6 +1041,8 @@ class ComTdbVirtTableConstraintInfo : public ComTdbVirtTableBase
   // if constrType == 2
   Lng32 checkConstrLen;
   char * checkConstrText;
+
+  Lng32 notSerialized;
 };
 
 class ComTdbVirtTableViewInfo : ComTdbVirtTableBase

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/comexe/ComTdbHbaseAccess.cpp
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbHbaseAccess.cpp b/core/sql/comexe/ComTdbHbaseAccess.cpp
index e30787d..676f2b2 100644
--- a/core/sql/comexe/ComTdbHbaseAccess.cpp
+++ b/core/sql/comexe/ComTdbHbaseAccess.cpp
@@ -102,7 +102,9 @@ ComTdbHbaseAccess::ComTdbHbaseAccess(
 				     Float32 samplingRate,
 				     HbaseSnapshotScanAttributes * hbaseSnapshotScanAttributes,
 
-                                     HbaseAccessOptions * hbaseAccessOptions
+                                     HbaseAccessOptions * hbaseAccessOptions,
+
+                                     char * pkeyColName
 
 				     )
 : ComTdb( ComTdb::ex_HBASE_ACCESS,
@@ -194,7 +196,9 @@ ComTdbHbaseAccess::ComTdbHbaseAccess(
   sampleLocation_(NULL),
   hbaseRowsetVsbbSize_(0),
   trafLoadFlushSize_(0),
-  hbaseAccessOptions_(hbaseAccessOptions)
+  hbaseAccessOptions_(hbaseAccessOptions),
+
+  pkeyColName_(pkeyColName)
 {};
 
 ComTdbHbaseAccess::ComTdbHbaseAccess(
@@ -304,7 +308,9 @@ ComTdbHbaseAccess::ComTdbHbaseAccess(
   sampleLocation_(NULL),
   hbaseRowsetVsbbSize_(0),
   trafLoadFlushSize_(0),
-  hbaseAccessOptions_(NULL)
+  hbaseAccessOptions_(NULL),
+
+  pkeyColName_(NULL)
 {
 }
 
@@ -451,6 +457,8 @@ Long ComTdbHbaseAccess::pack(void * space)
   hbaseSnapshotScanAttributes_.pack(space);
   hbaseAccessOptions_.pack(space);
 
+  pkeyColName_.pack(space);
+
   // pack elements in listOfScanRows_
   if (listOfScanRows() && listOfScanRows()->numEntries() > 0)
     {
@@ -521,6 +529,7 @@ Lng32 ComTdbHbaseAccess::unpack(void * base, void * reallocator)
   if(LoadPrepLocation_.unpack(base)) return -1;
   if (hbaseSnapshotScanAttributes_.unpack(base,reallocator)) return -1;
   if (hbaseAccessOptions_.unpack(base, reallocator)) return -1;
+  if(pkeyColName_.unpack(base)) return -1;
 
   // unpack elements in listOfScanRows_
   if(listOfScanRows_.unpack(base, reallocator)) return -1;
@@ -970,7 +979,7 @@ void ComTdbHbaseAccess::displayContents(Space * space,ULng32 flag)
 		      listOfFetchedColNames()->numEntries());
 	  space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
 
-	  if (sqHbaseTable())
+	  if ((sqHbaseTable()) && (NOT hbaseMapTable()))
 	    showColNames(listOfFetchedColNames(), space);
 	  else
 	    showStrColNames(listOfFetchedColNames(), space);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/comexe/ComTdbHbaseAccess.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbHbaseAccess.h b/core/sql/comexe/ComTdbHbaseAccess.h
index e2645a7..c0c3f1f 100644
--- a/core/sql/comexe/ComTdbHbaseAccess.h
+++ b/core/sql/comexe/ComTdbHbaseAccess.h
@@ -488,7 +488,9 @@ public:
 		    Float32 samplingRate = -1,
 		    HbaseSnapshotScanAttributes * hbaseSnapshotScanAttributes = NULL,
 
-                    HbaseAccessOptions * hbaseAccessOptions = NULL
+                    HbaseAccessOptions * hbaseAccessOptions = NULL,
+
+                    char * pkeyColName = NULL
 	       );
   
   ComTdbHbaseAccess(
@@ -658,6 +660,8 @@ public:
   HbaseAccessOptions * getHbaseAccessOptions() 
   { return (HbaseAccessOptions*)hbaseAccessOptions_.getPointer(); }
 
+  char * getPkeyColName() { return pkeyColName_; }
+
   NABoolean multiVersions() 
   {
     return 
@@ -722,7 +726,7 @@ public:
 
  void setUpdelColnameIsStr(NABoolean v)
   {(v ? flags_ |= UPDEL_COLNAME_IS_STR : flags_ &= ~UPDEL_COLNAME_IS_STR); };
-  NABoolean updelColnameIsStr() { return (flags_ & UPDEL_COLNAME_IS_STR) != 0; };
+  NABoolean updelColnameIsStr() { return (flags_ & UPDEL_COLNAME_IS_STR) != 0;};
 
   void setUseHbaseXn(NABoolean v)
   {(v ? flags_ |= USE_HBASE_XN : flags_ &= ~USE_HBASE_XN); };
@@ -736,6 +740,14 @@ public:
   {(v ? flags_ |= ALIGNED_FORMAT : flags_ &= ~ALIGNED_FORMAT); };
   NABoolean alignedFormat() { return (flags_ & ALIGNED_FORMAT) != 0; };
 
+  void setHbaseMapTable(NABoolean v)
+  {(v ? flags_ |= HBASE_MAP_TABLE : flags_ &= ~HBASE_MAP_TABLE); };
+  NABoolean hbaseMapTable() { return (flags_ & HBASE_MAP_TABLE) != 0; };
+
+  void setKeyInVCformat(NABoolean v)
+  {(v ? flags_ |= KEY_IN_VC_FRMT : flags_ &= ~KEY_IN_VC_FRMT); };
+  NABoolean keyInVCformat() { return (flags_ & KEY_IN_VC_FRMT) != 0; };
+
   void setAsyncOperations(NABoolean v)
   {(v ? flags_ |= ASYNC_OPERATIONS : flags_ &= ~ASYNC_OPERATIONS); };
   NABoolean asyncOperations() { return (flags_ & ASYNC_OPERATIONS) != 0; };
@@ -909,7 +921,9 @@ public:
     ALIGNED_FORMAT                   = 0x4000,
     ASYNC_OPERATIONS                 = 0x8000,
     USE_CIF                          = 0x10000,
-    USE_REGION_XN                    = 0x20000
+    HBASE_MAP_TABLE                  = 0x20000,
+    KEY_IN_VC_FRMT                   = 0x40000,
+    USE_REGION_XN                    = 0x80000
   };
 
   enum
@@ -1030,6 +1044,11 @@ public:
   UInt16 hbaseRowsetVsbbSize_; 
   UInt16 trafLoadFlushSize_; 
   HbaseAccessOptionsPtr hbaseAccessOptions_;
+
+  // col name of primary key. Format colFam:colName.
+  // Currently used for HbaseMapped tables with a single primary key.
+  NABasicPtr pkeyColName_;
+
   char fillers[2];
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/common/ComMisc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/ComMisc.cpp b/core/sql/common/ComMisc.cpp
index 76313a2..b4a1f6b 100644
--- a/core/sql/common/ComMisc.cpp
+++ b/core/sql/common/ComMisc.cpp
@@ -124,6 +124,14 @@ NABoolean ComIsTrafodionExternalSchemaName (
   return FALSE;
 }
 
+// schema name "_HB_MAP_" is used to store external hbase table mapped
+// to trafodion relational table
+NABoolean ComIsHbaseMappedSchemaName (
+     const NAString &schName)
+{
+  return (schName == HBASE_EXT_MAP_SCHEMA);
+}
+
 // ----------------------------------------------------------------------------
 // function: ComConvertNativeNameToTrafName
 //

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/common/ComMisc.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComMisc.h b/core/sql/common/ComMisc.h
index 8049209..ec078e2 100644
--- a/core/sql/common/ComMisc.h
+++ b/core/sql/common/ComMisc.h
@@ -55,6 +55,8 @@ NABoolean ComIsTrafodionReservedSchema(
 NABoolean ComIsTrafodionExternalSchemaName (
                                             const NAString &schName);
 
+NABoolean ComIsHbaseMappedSchemaName (const NAString &schName);
+
 NAString ComConvertNativeNameToTrafName ( 
                                          const NAString &catalogName,
                                          const NAString &schemaName,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/common/ComResWords.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/ComResWords.cpp b/core/sql/common/ComResWords.cpp
index 89dd01e..593a91a 100644
--- a/core/sql/common/ComResWords.cpp
+++ b/core/sql/common/ComResWords.cpp
@@ -229,7 +229,6 @@ const ComResWord ComResWords::resWords_[] = {
   ComResWord("LOCATOR",          COMPAQ_|RESWORD_),
   ComResWord("LOOP",             POTANS_|RESWORD_),
   ComResWord("LOWER",            ANS_|RESWORD_),
-  ComResWord("MAP",              COMPAQ_|RESWORD_),
   ComResWord("MATCH",            ANS_|RESWORD_),
   ComResWord("MAX",              ANS_|RESWORD_|MPWORD_),
   ComResWord("MIN",              ANS_|RESWORD_),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 67cabfb..662b19d 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -113,6 +113,7 @@ typedef NABoolean               ComBoolean;
 #define HIVE_STATS_SCHEMA            "\"_HIVESTATS_\""
 #define HIVE_STATS_SCHEMA_NO_QUOTES  "_HIVESTATS_"
 #define HIVE_EXT_SCHEMA_PREFIX       "_HV_"
+#define HBASE_EXT_MAP_SCHEMA         "_HB_MAP_"
 
 #define HBASE_SYSTEM_CATALOG          "HBASE"
 #define HBASE_SYSTEM_SCHEMA           "HBASE"
@@ -1107,20 +1108,23 @@ enum ComPartitioningScheme { COM_UNSPECIFIED_PARTITIONING
 #define COM_UNKNOWN_PARTITIONING_LIT         COM_UNSPECIFIED_PARTITIONING_LIT
 
 
+// aligned_format:   All columns are stored in an internal row aligned format,
+//                   and the whole row is stored in one hbase cell.
+// hbase_format:     each col is stored as one hbase cell with data in native
+//                   format (for ex: INT datatype is stored as 4-byte integer)
+// hbase_str_format: same as hbase_format except data is stored in displayable
+//                   string format(for ex: 100 is stored as string '100')
 enum ComRowFormat {  COM_UNKNOWN_FORMAT_TYPE
-                     , COM_PACKED_FORMAT_TYPE
                      , COM_ALIGNED_FORMAT_TYPE
                      , COM_HBASE_FORMAT_TYPE
-                     , COM_HIVE_EXTERNAL_FORMAT_TYPE
-                     , COM_HBASE_EXTERNAL_FORMAT_TYPE
+                     , COM_HBASE_STR_FORMAT_TYPE
 };
 
 #define COM_ROWFORMAT_LIT_LEN                2
 #define COM_UNKNOWN_FORMAT_LIT               "  "
-#define COM_PACKED_FORMAT_LIT                "PF"
 #define COM_ALIGNED_FORMAT_LIT               "AF"
-#define COM_HBASE_FORMAT_LIT                   "HF"
-#define COM_HIVE_EXTERNAL_FORMAT_TYPE_LIT    "EV"
+#define COM_HBASE_FORMAT_LIT                 "HF"
+#define COM_HBASE_STR_FORMAT_LIT             "HS"
 
 // table load action: regular, SET or MULTISET.
 // Regular:  will error out if duplicate key is inserted.
@@ -1778,7 +1782,15 @@ enum ComTransformDependent { COM_TR_DROP_DEPENDENT
 enum ComPrivilegeChecks { COM_PRIV_CHECK_PASS = 0,
                           COM_PRIV_NO_CHECK   = 1,
                           COM_PRIV_CHECK_FAIL = 2 };
-                          
+        
+// for serialization of primary keys
+enum ComPkeySerialization
+  { COM_SER_NOT_SPECIFIED =  0,    // not specified, will be set based on
+                                   // the table type
+    COM_SERIALIZED        =  1,    // pkey is serialized
+    COM_NOT_SERIALIZED    =  2     // pkey is not serialized
+  };
+                  
 // DDL Operation literals
 
 #define COM_OP_NONE_LIT                            "  "

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/common/OperTypeEnum.h
----------------------------------------------------------------------
diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h
index 4668fb3..51ba34e 100644
--- a/core/sql/common/OperTypeEnum.h
+++ b/core/sql/common/OperTypeEnum.h
@@ -1081,6 +1081,7 @@ enum OperatorTypeEnum {
                         ELM_LIKE_OPT_SALT_CLAUSE_ELEM,
                         ELM_LIKE_OPT_WITHOUT_DIVISION_ELEM,
                         ELM_LIKE_OPT_LIMIT_COLUMN_LENGTH,
+                        ELM_LIKE_OPT_WITHOUT_ROW_FORMAT_ELEM,
                         ELM_LOCATION_ELEM,
                         ELM_OPTION_LIST,
                         ELM_PARALLEL_EXEC_ELEM,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/executor/ExExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h
index 9a8915f..add4596 100755
--- a/core/sql/executor/ExExeUtil.h
+++ b/core/sql/executor/ExExeUtil.h
@@ -3788,7 +3788,7 @@ protected:
                             NABoolean adjustLen = TRUE);
 
   short collectStats(char * tableName);
-  short populateStats(Int32 currIndex, NABoolean nullTerminate = FALSE);
+  short populateStats(Int32 currIndex);
 
   char * hbaseRootdir_;
 
@@ -3811,6 +3811,8 @@ protected:
   char * schName_;
   char * objName_;
   char * regionName_;
+
+  NAString extNameForHbase_;
 };
 
 //////////////////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/executor/ExExeUtilGet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilGet.cpp b/core/sql/executor/ExExeUtilGet.cpp
index 0081cb0..af3c8fa 100644
--- a/core/sql/executor/ExExeUtilGet.cpp
+++ b/core/sql/executor/ExExeUtilGet.cpp
@@ -5478,10 +5478,13 @@ short ExExeUtilRegionStatsTcb::collectStats(char * tableName)
   // collect stats from ehi.
   HbaseStr tblName;
   
-  NAString extNameForHbase = 
-    NAString(catName_) + "." + NAString(schName_) + "." + NAString(objName_);
-  tblName.val = (char*)extNameForHbase.data();
-  tblName.len = extNameForHbase.length();
+  if (NAString(catName_) == HBASE_SYSTEM_CATALOG)
+    extNameForHbase_ = NAString(objName_);
+  else
+    extNameForHbase_ =
+      NAString(catName_) + "." + NAString(schName_) + "." + NAString(objName_);
+  tblName.val = (char*)extNameForHbase_.data();
+  tblName.len = extNameForHbase_.length();
   
   regionInfoList_ = ehi_->getRegionStats(tblName);
   if (! regionInfoList_)
@@ -5495,22 +5498,16 @@ short ExExeUtilRegionStatsTcb::collectStats(char * tableName)
 }
 
 short ExExeUtilRegionStatsTcb::populateStats
-(Int32 currIndex, NABoolean nullTerminate)
+(Int32 currIndex)
 {
   str_pad(stats_->catalogName, sizeof(stats_->catalogName), ' ');
   str_cpy_all(stats_->catalogName, catName_, strlen(catName_));
-  if (nullTerminate)
-    stats_->catalogName[strlen(catName_)] = 0;
 
   str_pad(stats_->schemaName, sizeof(stats_->schemaName), ' ');
   str_cpy_all(stats_->schemaName, schName_, strlen(schName_));
-  if (nullTerminate)
-    stats_->schemaName[strlen(schName_)] = 0;
 
   str_pad(stats_->objectName, sizeof(stats_->objectName), ' ');
   str_cpy_all(stats_->objectName, objName_, strlen(objName_));
-  if (nullTerminate)
-    stats_->objectName[strlen(objName_)] = 0;
   
   str_pad(stats_->regionServer, sizeof(stats_->regionServer), ' ');
 
@@ -5538,9 +5535,6 @@ short ExExeUtilRegionStatsTcb::populateStats
     {
       str_cpy_all(stats_->regionServer, regionInfo, 
                   (Lng32)(sep1 - regionInfo)); 
-
-      if (nullTerminate)
-        stats_->regionServer[sep1 - regionInfo] = 0;
     }
 
   char * sepStart = sep1+1;
@@ -5549,9 +5543,6 @@ short ExExeUtilRegionStatsTcb::populateStats
     {
       str_cpy_all(stats_->regionName, sepStart, 
                   (Lng32)(sep1 - sepStart)); 
-
-      if (nullTerminate)
-        stats_->regionName[sep1 - sepStart] = 0;
     }
   
   sepStart = sep1;
@@ -5955,15 +5946,7 @@ short ExExeUtilRegionStatsFormatTcb::work()
 	    if (moveRowToUpQueue(buf, strlen(buf), &rc))
 	      return rc;
 
-            NAString objName = 
-              removeTrailingBlanks(statsTotals_->catalogName, STATS_NAME_MAX_LEN);
-            objName += ".";
-            objName +=
-              removeTrailingBlanks(statsTotals_->schemaName, STATS_NAME_MAX_LEN);
-            objName += ".";
-            objName += 
-              removeTrailingBlanks(statsTotals_->objectName, STATS_NAME_MAX_LEN);
-
+            NAString objName = extNameForHbase_;
             str_sprintf(buf, "  ObjectName:              %s", objName.data());
 	    if (moveRowToUpQueue(buf, strlen(buf), &rc))
 	      return rc;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/executor/ExHbaseAccess.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExHbaseAccess.cpp b/core/sql/executor/ExHbaseAccess.cpp
index a7b7f4e..a74de89 100644
--- a/core/sql/executor/ExHbaseAccess.cpp
+++ b/core/sql/executor/ExHbaseAccess.cpp
@@ -689,6 +689,7 @@ short ExHbaseAccessTcb::moveRowToUpQueue(const char * row, Lng32 len,
 short ExHbaseAccessTcb::setupError(NAHeap *heap, ex_queue_pair &qparent, Lng32 retcode, const char * str, const char * str2)
 {
   ContextCli *currContext = GetCliGlobals()->currContext();
+
   // Make sure retcode is positive.
   if (retcode < 0)
     retcode = -retcode;
@@ -746,6 +747,27 @@ short ExHbaseAccessTcb::setupError(Lng32 retcode, const char * str, const char *
   return 0;
 }
 
+short ExHbaseAccessTcb::raiseError(Lng32 errcode, 
+                                   Lng32 * intParam1,
+                                   const char * str1, 
+                                   const char * str2)
+{
+  // Make sure retcode is positive.
+  if (errcode < 0)
+    errcode = -errcode;
+    
+  ex_queue_entry *pentry_down = qparent_.down->getHeadEntry();
+  
+  ComDiagsArea * diagsArea = NULL;
+  ExRaiseSqlError(getHeap(), &diagsArea, 
+                  (ExeErrorCode)(errcode), NULL,
+                  intParam1, NULL, NULL,
+                  str1, str2, NULL);
+  pentry_down->setDiagsArea(diagsArea);
+
+  return 0;
+}
+
 short ExHbaseAccessTcb::handleError(short &rc)
 {
   if (qparent_.up->isFull())
@@ -1028,7 +1050,6 @@ short ExHbaseAccessTcb::getColPos(char * colName, Lng32 colNameLen, Lng32 &idx)
       short len = *(short*)currNamePtr;
       currNamePtr += sizeof(short);
       char * currName = currNamePtr;
-      //	&((char*)hbaseAccessTdb().listOfFetchedColNames()->getCurr())[sizeof(short)];
 
       if ((colNameLen == len) &&
 	  (memcmp(colName, currName, len) == 0))
@@ -1100,6 +1121,8 @@ Lng32 ExHbaseAccessTcb::createSQRowFromHbaseFormat(Int64 *latestRowTimestamp)
   hbaseAccessTdb().listOfFetchedColNames()->position();
   Lng32 idx = -1;
 
+  NABoolean hbmTab = hbaseAccessTdb().hbaseMapTable();
+
   BYTE *colVal; 
   Lng32 colValLen;
   long timestamp;
@@ -1116,6 +1139,35 @@ Lng32 ExHbaseAccessTcb::createSQRowFromHbaseFormat(Int64 *latestRowTimestamp)
      setupError(retcode, "", "getNumCellsPerRow()");
      return retcode;
   }
+
+  // For an hbase mapped table, the primary key column may not exist as
+  // a separate hbase cell/column. In that case, the rowID of the retrieved row
+  // is the primary key column value.
+  // Also, if a primary key col value exists as a separate cell/column, then
+  // the contents of rowID and pkey col value must be the same.
+  // Retrieve rowID for hbase mapped table. It will be used later to validate
+  // the abovementioned 2 cases.
+  char * pkeyColInfo = hbaseAccessTdb().getPkeyColName();
+  Lng32 pkeyColInfoLen = 0;
+  HbaseStr rowID;
+  NABoolean hbmPkeyColCheck = FALSE;
+  if ((hbaseAccessTdb().hbaseMapTable()) &&
+      (pkeyColInfo))
+    {
+      hbmPkeyColCheck = TRUE;
+
+      pkeyColInfo = hbaseAccessTdb().getPkeyColName();
+      pkeyColInfoLen = *(short*)pkeyColInfo;
+      pkeyColInfo += sizeof(short);
+
+      retcode = ehi_->getRowID(rowID);
+      if (retcode != HBASE_ACCESS_SUCCESS)
+        {
+          setupError(retcode, "", "getRowID()");
+          return retcode;
+        }
+    }      
+ 
   for (int colNo= 0; colNo < numCells; colNo++)
   {
       retcode = ehi_->getColName(colNo, &colName, colNameLen, timestamp);
@@ -1152,13 +1204,48 @@ Lng32 ExHbaseAccessTcb::createSQRowFromHbaseFormat(Int64 *latestRowTimestamp)
          colValLen = attr->getLength();
          BYTE nullVal;
 
+         if (hbmTab)
+           {
+             Lng32 ij = 0;
+           }
+
          retcode = ehi_->getColVal(colNo, colVal, colValLen, 
-                     attr->getNullFlag(), nullVal);
+                                   (NOT hbaseAccessTdb().hbaseMapTable() 
+                                    ? attr->getNullFlag() : FALSE), nullVal);
          if (retcode != HBASE_ACCESS_SUCCESS)
          {
             setupError(retcode, "", "getColVal()");
             return retcode;
          }
+
+         if (colValLen > attr->getLength())
+         {
+           // col val wont fit. Return error.
+           char buf[1000];
+           str_sprintf(buf, " Details: actual column value length of %d is greater than the expected max buffer size of %d.",
+                       colValLen, attr->getLength());
+           raiseError(EXE_HBASE_ACCESS_ERROR, NULL, 
+                      hbaseAccessTdb().getTableName(), buf);
+           return -1;
+         }
+
+         if ((hbmPkeyColCheck) &&
+             (pkeyColInfoLen == colNameLen) &&
+             (str_cmp(pkeyColInfo, colName, colNameLen) == 0))
+         {
+           // validate that this col value is same as the pkey value for this
+           // hbase mapped table.
+           if (NOT ((rowID.len == colValLen) &&
+                    (str_cmp(rowID.val, (char*)colVal, colValLen) == 0)))
+             {
+               char buf[1000];
+               str_sprintf(buf, " Details: HBase rowID content must match the primary key column content.");
+               raiseError(EXE_HBASE_ACCESS_ERROR, NULL, 
+                          hbaseAccessTdb().getTableName(), buf);
+               return -1;
+             }
+         }
+         
          if (attr->getNullFlag())
          {
             if (nullVal)
@@ -1174,7 +1261,8 @@ Lng32 ExHbaseAccessTcb::createSQRowFromHbaseFormat(Int64 *latestRowTimestamp)
                 *(Lng32*)&asciiRow_[attr->getVCLenIndOffset()] = colValLen; 
          }
       }
-  }
+  } // for
+
   // fill in null or default values for missing cols.
   for (idx = 0; idx < asciiSourceTD->numAttrs(); idx++)
     {
@@ -1183,66 +1271,116 @@ Lng32 ExHbaseAccessTcb::createSQRowFromHbaseFormat(Int64 *latestRowTimestamp)
 	  attr = asciiSourceTD->getAttr(idx);
 	  if (! attr)
              ex_assert(FALSE, "Attr not found -2");
-	  
+
 	  char * defVal = attr->getDefaultValue();
-          if (! defVal)
+          char * colInfo = NULL;
+          Lng32 colInfoLen = 0;
+          if (hbmPkeyColCheck || (! defVal))
             {
-              char * colVal = (char*)
-                hbaseAccessTdb().listOfFetchedColNames()->get(idx);
-
-              Text colFam, colName;
-              extractColFamilyAndName(colVal, colFam, colName);
-
-              Int64 v = 0;
-              if (colName.length() == sizeof(char))
-                v = *(char*)colName.data();
-              else if (colName.length() == sizeof(UInt16))
-                v = *(UInt16*)colName.data();
-              else if (colName.length() == sizeof(ULng32))
-                v = *(ULng32*)colName.data();
-
-              char buf[20];
-              str_sprintf(buf, "%Ld", v);
-              ComDiagsArea * diagsArea = NULL;
-              ExRaiseSqlError(getHeap(), &diagsArea,
-                              (ExeErrorCode)(EXE_DEFAULT_VALUE_INCONSISTENT_ERROR),
-                              NULL, NULL, NULL, NULL, buf, hbaseAccessTdb().getTableName());
-              pentry_down->setDiagsArea(diagsArea);
-              return -1;
+              colInfo = 
+                (char*)hbaseAccessTdb().listOfFetchedColNames()->get(idx);
+              colInfoLen = *(short*)colInfo;
+              colInfo += sizeof(short);
             }
 
-	  char * defValPtr = defVal;
-	  short nullVal = 0;
-	  if (attr->getNullFlag())
-	    {
-	      nullVal = *(short*)defVal;
-	      *(short*)&asciiRow_[attr->getNullIndOffset()] = nullVal;
-	      
-	      defValPtr += 2;
-	    }
-	  
-          Lng32 copyLen;
-	  if (! nullVal)
-	    {
-	      if (attr->getVCIndicatorLength() > 0)
-		{
-		 copyLen = *(short*)defValPtr;
-		  if (attr->getVCIndicatorLength() == sizeof(short))
-		    *(short*)&asciiRow_[attr->getVCLenIndOffset()] = copyLen; 
-		  else
-		    *(Lng32*)&asciiRow_[attr->getVCLenIndOffset()] = copyLen;
-		  defValPtr += attr->getVCIndicatorLength();
-		}
-	        else
-		{
-		  copyLen = attr->getLength();
+          // if this missing col is the pkey col, fill in values
+          // from the retrieved rowID.
+          if (hbmPkeyColCheck &&
+              (pkeyColInfoLen == colInfoLen) &&
+              (str_cmp(pkeyColInfo, colInfo, colInfoLen) == 0))
+            {
+              char * colValLoc = (char *)&asciiRow_[attr->getOffset()];
+              Lng32  colValMaxLen = attr->getLength();
+              if (rowID.len > colValMaxLen)
+                {
+                  // rowID val wont fit. Return error.
+                  char buf[1000];
+                  str_sprintf(buf, " Details: retrieved rowID of length %d is larger than the specified key size of %d.",
+                              rowID.len, colValMaxLen);
+                  raiseError(EXE_HBASE_ACCESS_ERROR, NULL, 
+                             hbaseAccessTdb().getTableName(), buf);
+                  return -1;
                 }
-		char *destPtr = &asciiRow_[attr->getOffset()];
-		str_cpy_all(destPtr, defValPtr, copyLen);
-	    } // not nullVal
-	} // missing col
-    }
 
+              str_cpy_all(colValLoc, rowID.val, rowID.len);
+
+              *(short*)&asciiRow_[attr->getNullIndOffset()] = 0;
+              if (attr->getVCIndicatorLength() > 0)
+                {
+                  if (attr->getVCIndicatorLength() == sizeof(short))
+                    *(short*)&asciiRow_[attr->getVCLenIndOffset()] = rowID.len; 
+                  else
+                    *(Lng32*)&asciiRow_[attr->getVCLenIndOffset()] = rowID.len; 
+                }
+
+              // dont check for other columns once pkey col has been found.
+              hbmPkeyColCheck = FALSE;
+            } // missing pkey val
+          else 
+            {
+              if (! defVal)
+                {
+                  Text colFam, colName;
+                  extractColFamilyAndName(colInfo, colFam, colName);
+
+                  char buf[20];
+                  if (NOT hbaseAccessTdb().hbaseMapTable())
+                    {
+                      Int64 v = 0;
+                      if (colName.length() == sizeof(char))
+                        v = *(char*)colName.data();
+                      else if (colName.length() == sizeof(UInt16))
+                        v = *(UInt16*)colName.data();
+                      else if (colName.length() == sizeof(ULng32))
+                        v = *(ULng32*)colName.data();
+                      
+                      str_sprintf(buf, "%Ld", v);
+                    }
+                  
+                  ComDiagsArea * diagsArea = NULL;
+                  ExRaiseSqlError(
+                       getHeap(), &diagsArea,
+                       (ExeErrorCode) EXE_DEFAULT_VALUE_INCONSISTENT_ERROR,
+                       NULL, NULL, NULL, NULL, 
+                       (hbaseAccessTdb().hbaseMapTable() ? colName.data() : buf),
+                       hbaseAccessTdb().getTableName());
+                  pentry_down->setDiagsArea(diagsArea);
+                  return -1;
+                }
+
+              char * defValPtr = defVal;
+              short nullVal = 0;
+              if (attr->getNullFlag())
+                {
+                  nullVal = *(short*)defVal;
+                  *(short*)&asciiRow_[attr->getNullIndOffset()] = nullVal;
+                  
+                  defValPtr += 2;
+                }
+              
+              Lng32 copyLen;
+              if (! nullVal)
+                {
+                  if (attr->getVCIndicatorLength() > 0)
+                    {
+                      copyLen = *(short*)defValPtr;
+                      if (attr->getVCIndicatorLength() == sizeof(short))
+                        *(short*)&asciiRow_[attr->getVCLenIndOffset()] = copyLen; 
+                      else
+                        *(Lng32*)&asciiRow_[attr->getVCLenIndOffset()] = copyLen;
+                      defValPtr += attr->getVCIndicatorLength();
+                    }
+                  else
+                    {
+                      copyLen = attr->getLength();
+                    }
+                  char *destPtr = &asciiRow_[attr->getOffset()];
+                  str_cpy_all(destPtr, defValPtr, copyLen);
+                } // not nullVal
+            }
+        } // missing col
+    } // for
+  
   workAtp_->getTupp(hbaseAccessTdb().convertTuppIndex_)
     .setDataPointer(convertRow_);
   workAtp_->getTupp(hbaseAccessTdb().asciiTuppIndex_) 
@@ -1900,7 +2038,7 @@ short ExHbaseAccessTcb::evalEncodedKeyExpr()
   return 0;
 }
 
-short ExHbaseAccessTcb::evalRowIdExpr(NABoolean noVarchar)
+short ExHbaseAccessTcb::evalRowIdExpr(NABoolean isVarchar)
 {
   if (! rowIdExpr())
     return 0;
@@ -1920,17 +2058,17 @@ short ExHbaseAccessTcb::evalRowIdExpr(NABoolean noVarchar)
       return -1;
     }
   
-  if (NOT noVarchar)
+  if (isVarchar)
     {
       rowId_.val = &rowIdRow_[SQL_VARCHAR_HDR_SIZE];
       rowId_.len = *(short*)rowIdRow_;
     }
   else
-   {
-     rowId_.val = rowIdRow_;
-     rowId_.len = hbaseAccessTdb().rowIdLen_;
+    {
+      rowId_.val = rowIdRow_;
+      rowId_.len = hbaseAccessTdb().rowIdLen_;
     }
-    
+
   return 0;
 }
 
@@ -2066,8 +2204,17 @@ short ExHbaseAccessTcb::evalRowIdAsciiExpr(const char * inputRowIdVals,
   // If exclude flag is set, then add a null byte and increment the length by 1.
   if (hbaseAccessTdb().sqHbaseTable())
     {
-      outputRowIdPtr = rowIdBuf; 
-      outputRowIdLen = hbaseAccessTdb().getRowIDLen();
+      if (hbaseAccessTdb().keyInVCformat())
+        {
+          // Key is in varchar format.
+          outputRowIdLen = *(short*)rowIdBuf;
+          outputRowIdPtr = rowIdBuf + sizeof(short);
+        }
+      else
+        {
+          outputRowIdPtr = rowIdBuf; 
+          outputRowIdLen = hbaseAccessTdb().getRowIDLen();
+        }
     }
   else
     {
@@ -2302,18 +2449,19 @@ Lng32 ExHbaseAccessTcb::setupUniqueKeyAndCols(NABoolean doInit)
   char * beginKeyRow = keyData.getDataPointer();
 
   HbaseStr rowIdRowText;
-  if (hbaseAccessTdb().sqHbaseTable())
+  if ((NOT hbaseAccessTdb().sqHbaseTable()) ||
+      (hbaseAccessTdb().keyInVCformat()))
     {
-      rowIdRowText.val = beginKeyRow;
-      rowIdRowText.len = hbaseAccessTdb().keyLen_;
-    }
-  else
-    {
-      // hbase table. Key is in varchar format.
+      // Key is in varchar format.
       short keyLen = *(short*)beginKeyRow;
       rowIdRowText.val = beginKeyRow + sizeof(short);
       rowIdRowText.len = keyLen;
     }
+  else
+    {
+      rowIdRowText.val = beginKeyRow;
+      rowIdRowText.len = hbaseAccessTdb().keyLen_;
+    }
 
   if (keyRangeStatus == keyRangeEx::NO_MORE_RANGES)
     {
@@ -2359,9 +2507,10 @@ keyRangeEx::getNextKeyRangeReturnType ExHbaseAccessTcb::setupSubsetKeys
   short beginKeyLen = hbaseAccessTdb().keyLen_;
   short endKeyLen = hbaseAccessTdb().keyLen_;
 
-  if (NOT hbaseAccessTdb().sqHbaseTable())
+  if ((NOT hbaseAccessTdb().sqHbaseTable()) ||
+      (hbaseAccessTdb().keyInVCformat()))
     {
-      // key in varchar formar
+      // key in varchar format
       beginKeyLen = *(short*)beginKeyRow;
       beginKeyRow += sizeof(short);
       if (beginKeyRow[0] == '\0')
@@ -2776,8 +2925,10 @@ short ExHbaseAccessTcb::createDirectRowBuffer( UInt16 tuppIndex,
 	    {
 	      nullVal = *(short*)&tuppRow[attr->getNullIndOffset()];
 
-	      if ((attr->getDefaultClass() != Attributes::DEFAULT_NULL) &&
-		  (nullVal))
+              if (hbaseAccessTdb().hbaseMapTable())
+                prependNullVal = FALSE;
+	      else if ((attr->getDefaultClass() != Attributes::DEFAULT_NULL) &&
+                       (nullVal))
 		prependNullVal = TRUE;
 	      else if (isUpdate && nullVal)
 		prependNullVal = TRUE;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/executor/ExHbaseAccess.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExHbaseAccess.h b/core/sql/executor/ExHbaseAccess.h
index 03cb052..a233d9f 100644
--- a/core/sql/executor/ExHbaseAccess.h
+++ b/core/sql/executor/ExHbaseAccess.h
@@ -288,6 +288,11 @@ protected:
 			 short * rc, NABoolean isVarchar);
   short moveRowToUpQueue(short * rc);
   
+  short raiseError(Lng32 errcode, 
+                   Lng32 * intParam1 = NULL,
+                   const char * str1 = NULL, 
+                   const char * str2 = NULL);
+
   short setupError(Lng32 retcode, const char * str, const char * str2 = NULL);
   short handleError(short &rc);
   short handleDone(ExWorkProcRetcode &rc, Int64 rowsAffected = 0);
@@ -316,7 +321,7 @@ protected:
   short evalConstraintExpr(ex_expr *expr, UInt16 tuppIndex = 0,
                   char * tuppRow = NULL);
   short evalEncodedKeyExpr();
-  short evalRowIdExpr(NABoolean noVarchar = FALSE);
+  short evalRowIdExpr(NABoolean isVarchar);
   short evalRowIdAsciiExpr(NABoolean noVarchar = FALSE);
   short evalRowIdAsciiExpr(const char * inputRowIdVals,
 			   char * rowIdBuf, // input: buffer where rowid is created

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/executor/ExHbaseIUD.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExHbaseIUD.cpp b/core/sql/executor/ExHbaseIUD.cpp
index d3106f3..15df81d 100644
--- a/core/sql/executor/ExHbaseIUD.cpp
+++ b/core/sql/executor/ExHbaseIUD.cpp
@@ -514,7 +514,8 @@ ExWorkProcRetcode ExHbaseAccessInsertSQTcb::work()
 
 	case EVAL_ROWID_EXPR:
 	  {
-	    if (evalRowIdExpr(TRUE) == -1)
+            NABoolean isVC = hbaseAccessTdb().keyInVCformat();
+	    if (evalRowIdExpr(isVC) == -1)
 	      {
 		step_ = HANDLE_ERROR;
 		break;
@@ -901,7 +902,8 @@ ExWorkProcRetcode ExHbaseAccessUpsertVsbbSQTcb::work()
 
 	case EVAL_ROWID_EXPR:
 	  {
-	    if (evalRowIdExpr(TRUE) == -1)
+            NABoolean isVC = hbaseAccessTdb().keyInVCformat();
+	    if (evalRowIdExpr(isVC) == -1)
 	      {
 		step_ = HANDLE_ERROR;
 		break;
@@ -1422,7 +1424,8 @@ ExWorkProcRetcode ExHbaseAccessBulkLoadPrepSQTcb::work()
 
       case EVAL_ROWID_EXPR:
       {
-        if (evalRowIdExpr(TRUE) == -1)
+        NABoolean isVC = hbaseAccessTdb().keyInVCformat();
+        if (evalRowIdExpr(isVC) == -1)
         {
           step_ = HANDLE_ERROR;
           break;
@@ -3858,15 +3861,18 @@ Lng32 ExHbaseAccessSQRowsetTcb::setupUniqueKey()
   char * beginKeyRow = keyData.getDataPointer();
   HbaseStr rowIdRowText;
 
-  if (hbaseAccessTdb().sqHbaseTable()) {
-      rowIdRowText.val = beginKeyRow;
-      rowIdRowText.len = hbaseAccessTdb().keyLen_;
-  } else {
-      // hbase table. Key is in varchar format.
+  if ((NOT hbaseAccessTdb().sqHbaseTable()) ||
+      (hbaseAccessTdb().keyInVCformat())) {
+      // Key is in varchar format.
       short keyLen = *(short*)beginKeyRow;
       rowIdRowText.val = beginKeyRow + sizeof(short);
       rowIdRowText.len = keyLen;
+   }
+  else {
+    rowIdRowText.val = beginKeyRow;
+    rowIdRowText.len = hbaseAccessTdb().keyLen_;
   }
+
   if (keyRangeStatus == keyRangeEx::NO_MORE_RANGES)		
   {		
       // To ensure no row is found, add extra byte with "0" value 		

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/executor/ExHbaseSelect.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExHbaseSelect.cpp b/core/sql/executor/ExHbaseSelect.cpp
index f7d1ba7..ed3c1ed 100644
--- a/core/sql/executor/ExHbaseSelect.cpp
+++ b/core/sql/executor/ExHbaseSelect.cpp
@@ -757,7 +757,7 @@ ExWorkProcRetcode ExHbaseGetTaskTcb::work(short &rc)
 	    tcb_->table_.val = tcb_->hbaseAccessTdb().getTableName();
 	    tcb_->table_.len = strlen(tcb_->hbaseAccessTdb().getTableName());
 
-	    if (tcb_->evalRowIdExpr() == -1)
+	    if (tcb_->evalRowIdExpr(TRUE) == -1)
 	      {
 		step_ = HANDLE_ERROR;
 		break;
@@ -941,7 +941,7 @@ ExWorkProcRetcode ExHbaseGetRowwiseTaskTcb::work(short &rc)
 	    tcb_->table_.val = tcb_->hbaseAccessTdb().getTableName();
 	    tcb_->table_.len = strlen(tcb_->hbaseAccessTdb().getTableName());
 
-	    if (tcb_->evalRowIdExpr() == -1)
+	    if (tcb_->evalRowIdExpr(TRUE) == -1)
 	      {
 		step_ = HANDLE_ERROR;
 		break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/executor/HBaseClient_JNI.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/HBaseClient_JNI.cpp b/core/sql/executor/HBaseClient_JNI.cpp
index 603c42e..2d52c05 100644
--- a/core/sql/executor/HBaseClient_JNI.cpp
+++ b/core/sql/executor/HBaseClient_JNI.cpp
@@ -4621,27 +4621,33 @@ HTC_RetCode HTableClient_JNI::getColVal(int colNo, BYTE *colVal,
     jint kvValLen = p_kvValLen_[idx];
     jint kvValOffset = p_kvValOffset_[idx];
     Lng32 copyLen;
+    Lng32 dataLen;
     jbyte nullByte;
     // If the column is nullable, get the first byte
     // The first byte determines if the column is null(0xff) or not (0)
     if (nullable)
     {
-       copyLen = MINOF(kvValLen-1, colValLen);
-       jenv_->GetByteArrayRegion(jba_kvBuffer_, kvValOffset, 1, &nullByte); 
-       jenv_->GetByteArrayRegion(jba_kvBuffer_, kvValOffset+1, copyLen, 
-               (jbyte *)colVal); 
+      dataLen = kvValLen - 1; 
+      copyLen = MINOF(dataLen, colValLen);
+      jenv_->GetByteArrayRegion(jba_kvBuffer_, kvValOffset, 1, &nullByte); 
+      jenv_->GetByteArrayRegion(jba_kvBuffer_, kvValOffset+1, copyLen, 
+                                (jbyte *)colVal); 
     }
     else 
     {
-        copyLen = MINOF(kvValLen, colValLen);
-        nullByte = 0;
-    	jenv_->GetByteArrayRegion(jba_kvBuffer_, kvValOffset, copyLen,
-             (jbyte *)colVal); 
+      dataLen = kvValLen;
+      copyLen = MINOF(dataLen, colValLen);
+      nullByte = 0;
+      jenv_->GetByteArrayRegion(jba_kvBuffer_, kvValOffset, copyLen,
+                                (jbyte *)colVal); 
     }
     nullVal = nullByte;
-    colValLen = copyLen;
+    if (dataLen > colValLen)
+      colValLen = dataLen;
+    else
+      colValLen = copyLen;
     if (hbs_)
-      hbs_->incBytesRead(colValLen);
+      hbs_->incBytesRead(copyLen);
     return HTC_OK;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/exp/ExpErrorEnums.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpErrorEnums.h b/core/sql/exp/ExpErrorEnums.h
index b6d50bc..c8d2ba2 100644
--- a/core/sql/exp/ExpErrorEnums.h
+++ b/core/sql/exp/ExpErrorEnums.h
@@ -172,6 +172,7 @@ enum ExeErrorCode
   EXE_FS2_FETCH_VERSION_ERROR		= 8552,
   EXE_ERROR_STREAM_OVERFLOW             = 8553,
   EXE_EID_INTERNAL_ERROR                = 8555,
+  EXE_HBASE_ACCESS_ERROR                = 8556,
   EXE_LAST_ERROR_FROM_FS_DP2		= 8569,
 
   // ---------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/exp/exp_function.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp
index 5b7c008..b310a5e 100644
--- a/core/sql/exp/exp_function.cpp
+++ b/core/sql/exp/exp_function.cpp
@@ -6738,10 +6738,11 @@ ex_expr::exp_return_type ExFunctionRowNum::eval(char *op_data[],
   return ex_expr::EXPR_OK;
 }
 
-short ExFunctionHbaseColumnLookup::extractColFamilyAndName(const char * input, 
-                                                           short len,
-							   NABoolean isVarchar,
-							   std::string &colFam, std::string &colName)
+short ExFunctionHbaseColumnLookup::extractColFamilyAndName(
+     const char * input, 
+     short len,
+     NABoolean isVarchar,
+     std::string &colFam, std::string &colName)
 {
   if (! input)
     return -1;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/generator/GenExpGenerator.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenExpGenerator.cpp b/core/sql/generator/GenExpGenerator.cpp
index d22bff5..b360f51 100644
--- a/core/sql/generator/GenExpGenerator.cpp
+++ b/core/sql/generator/GenExpGenerator.cpp
@@ -2520,8 +2520,7 @@ short ExpGenerator::generateContiguousMoveExpr(
     for( Int32 i = 0; i < (Int32)colArray->entries(); i++ )
     {
       col = (*colArray)[i];
-      if ( col->isAddedColumn() )
-        attrs[i]->setAddedCol();
+      addDefaultValue(col, attrs[i], CmpCommon::diags()); 
     }
   }
 
@@ -3063,7 +3062,8 @@ short ExpGenerator::generateKeyEncodeExpr(const IndexDesc * indexDesc,
 	desc_flag = FALSE;
       
       if ((tf == ExpTupleDesc::SQLMX_KEY_FORMAT) &&
-	  (col_node->getValueId().getType().getVarLenHdrSize() > 0))
+	  (col_node->getValueId().getType().getVarLenHdrSize() > 0) &&
+          (NOT ((indexDesc->getNAFileSet()->getIndexKeyColumns()[i])->isPrimaryKeyNotSerialized())))
 	{
 	  // Explode varchars by moving them to a fixed field
 	  // whose length is equal to the max length of varchar.
@@ -3111,9 +3111,15 @@ short ExpGenerator::generateKeyEncodeExpr(const IndexDesc * indexDesc,
 	    } // encoding/decoding needed
 	} // handleSerialization
 
-       if (enode == NULL)
-	 enode = new(wHeap()) CompEncode(col_node, desc_flag);
-
+      if (enode == NULL)
+        {
+          if (NOT ((indexDesc->getNAFileSet()->getIndexKeyColumns()[i])->isPrimaryKeyNotSerialized()))
+            enode = new(wHeap()) CompEncode(col_node, desc_flag);
+          else 
+            enode = 
+              new(generator->wHeap()) Cast(col_node, &col_node->getValueId().getType());
+        }            
+      
       enode->bindNode(generator->getBindWA());
 
       encode_val_id_list.insert(enode->getValueId());
@@ -3256,8 +3262,8 @@ ItemExpr * ExpGenerator::generateKeyCast(const ValueId vid,
 					 NABoolean desc_flag,
 					 ExpTupleDesc::TupleDataFormat tf,
 					 Lng32 &possibleErrorCount,
-					 NABoolean &canDoKeyEncodeOpt,
-					 NABoolean allChosenPredsAreEqualPreds)
+					 NABoolean allChosenPredsAreEqualPreds,
+                                         NABoolean castVarcharToAnsiChar)
 {
 
   ItemExpr * eq_node = (vid.getValueDesc())->getItemExpr();
@@ -3271,15 +3277,6 @@ ItemExpr * ExpGenerator::generateKeyCast(const ValueId vid,
   const NAType * sourceType = &(keyval->getValueId().getType());
   const NAType * targetType = &(keycol->getValueId().getType());
 
-  if ((targetType->isEncodingNeeded()) ||
-      ((targetType->getTypeQualifier() == NA_CHARACTER_TYPE) &&
-       (((CharType*)targetType)->isCaseinsensitive()) || 
-       CollationInfo::isSystemCollation(((CharType*)targetType)->getCollation())) ||
-      (targetType->supportsSQLnull()) ||
-      (keyval->getOperatorType() == ITM_CONSTANT) ||
-      (desc_flag))
-    canDoKeyEncodeOpt = FALSE;
-
   NABoolean caseinsensitiveEncode = FALSE;
 
   ItemExpr * knode = 0;  // the node to be returned
@@ -3306,18 +3303,33 @@ ItemExpr * ExpGenerator::generateKeyCast(const ValueId vid,
 	      {
 		if (!CollationInfo::isSystemCollation(char_t.getCollation()))
 		{
-		  targetType = new(wHeap())
-		  SQLChar(CharLenInfo(char_t.getStrCharLimit(), char_t.getDataStorageSize()),
-			  keycol->getValueId().getType().supportsSQLnull(),
-			  FALSE,
-			  ((CharType*)targetType)->isCaseinsensitive(),
-			  FALSE,
-			  char_t.getCharSet(),
-			  char_t.getCollation(),
-			  char_t.getCoercibility()
-			  );
+                  if ((castVarcharToAnsiChar) &&
+                      (keycol->getValueId().getType().getVarLenHdrSize() > 0))
+                    {
+                      targetType = new(wHeap())
+                        ANSIChar(char_t.getDataStorageSize(),
+                                 keycol->getValueId().getType().supportsSQLnull(),
+                                 FALSE,
+                                 FALSE,
+                                 char_t.getCharSet(),
+                                 char_t.getCollation(),
+                                 char_t.getCoercibility()
+                                 );
+                    }
+                  else
+                    {
+                      targetType = new(wHeap())
+                        SQLChar(CharLenInfo(char_t.getStrCharLimit(), char_t.getDataStorageSize()),
+                                keycol->getValueId().getType().supportsSQLnull(),
+                                FALSE,
+                                ((CharType*)targetType)->isCaseinsensitive(),
+                                FALSE,
+                                char_t.getCharSet(),
+                                char_t.getCollation(),
+                                char_t.getCoercibility()
+                                );
+                    }
 		}
-		canDoKeyEncodeOpt = FALSE;
 	      }
 	  }
 
@@ -3326,7 +3338,6 @@ ItemExpr * ExpGenerator::generateKeyCast(const ValueId vid,
 	  {
 	    cnode = new(wHeap()) Narrow (keyval,dataConversionErrorFlag,targetType,
                                          ITM_NARROW, desc_flag);
-	    canDoKeyEncodeOpt = FALSE;
 	  }
 	else
 	  {
@@ -3335,25 +3346,18 @@ ItemExpr * ExpGenerator::generateKeyCast(const ValueId vid,
 		// if source & target are exactly the same and normal scaling
 		// is being done, then generate the encode node. This avoids
 		// an extra conversion node.
-#pragma nowarn(1506)   // warning elimination
 		cnode = new(wHeap()) CompEncode(keyval, desc_flag);
-#pragma warn(1506)  // warning elimination
 		compEncodeGenerated = TRUE;
 	      }
 	    else
 	      {
 		cnode = new(wHeap()) Cast (keyval,targetType);
-		canDoKeyEncodeOpt = FALSE;
 	      }
 	  }
 
         cnode = cnode->bindNode(generator->getBindWA());
         cnode = cnode->preCodeGen(generator);
 
-	if ((canDoKeyEncodeOpt) &&
-	    (cnode->child(0)->castToItemExpr() != keyval))
-	  canDoKeyEncodeOpt = FALSE;
-
 	// if both source and target are caseinsensitive, then
 	// do caseinsensitive encode.
 	if ((targetType->getTypeQualifier() == NA_CHARACTER_TYPE) &&
@@ -3365,16 +3369,15 @@ ItemExpr * ExpGenerator::generateKeyCast(const ValueId vid,
 	  }
 
 	// encode the key for byte comparison.
+        knode = cnode;
 	if (compEncodeGenerated)
 	  {
 	    knode = cnode;
 	    ((CompEncode*)knode)->setCaseinsensitiveEncode(caseinsensitiveEncode);
 	  }
-	else
+	else if (NOT castVarcharToAnsiChar)
 	  {
-#pragma nowarn(1506)   // warning elimination
 	    knode = new(wHeap()) CompEncode(cnode, desc_flag);
-#pragma warn(1506)  // warning elimination
             knode = knode->bindNode(generator->getBindWA());
 	    ((CompEncode*)knode)->setCaseinsensitiveEncode(caseinsensitiveEncode);
 	    knode = knode->preCodeGen(generator);
@@ -3450,12 +3453,8 @@ short ExpGenerator::generateKeyExpr(const NAColumnArray & indexKeyColumns,
 				    ExpTupleDesc::TupleDataFormat tf,
 				    ULng32 &keyLen,
 				    ex_expr ** key_expr,
-				    NABoolean doKeyEncodeOpt,
-				    Lng32 * firstKeyColumnOffset,
 				    NABoolean allChosenPredsAreEqualPreds)
 {
-  NABoolean canDoKeyEncodeOpt = (doKeyEncodeOpt ? TRUE : FALSE);
-
   // generate key expression.
   // Key value id list has entries of the form:
   //    col1 = value1, col2 = value2, ... colN = valueN
@@ -3480,7 +3479,10 @@ short ExpGenerator::generateKeyExpr(const NAColumnArray & indexKeyColumns,
 	  ItemExpr * knode = NULL;
 
 	  if ((indexKeyColumns[i]->getNATable()->isHbaseCellTable()) ||
-	      (indexKeyColumns[i]->getNATable()->isHbaseRowTable()))
+	      (indexKeyColumns[i]->getNATable()->isHbaseRowTable()) ||
+              (indexKeyColumns[i]->isPrimaryKeyNotSerialized()) ||
+              ((indexKeyColumns[i]->getNATable()->isHbaseMapTable()) &&
+               (indexKeyColumns[i]->getNATable()->getClusteringIndex()->hasSingleColVarcharKey())))
 	    {
 	      ItemExpr * eq_node = (val_id_list[i].getValueDesc())->getItemExpr();
 	      
@@ -3505,75 +3507,18 @@ short ExpGenerator::generateKeyExpr(const NAColumnArray & indexKeyColumns,
 				!indexKeyColumns.isAscending(i),
 				tf,
 				possibleErrorCount /* in/out */,
-				canDoKeyEncodeOpt  /* in/out */,
-				allChosenPredsAreEqualPreds);
+				allChosenPredsAreEqualPreds,
+                                FALSE);
 	    }
 
 	  key_val_id_list.insert(knode->getValueId());
 
-	  if (canDoKeyEncodeOpt)
-	    {
-	      MapInfo * map_info =
-		generator->getMapInfoAsIs(knode->child(0)->castToItemExpr()->getValueId());
-	      if (! map_info)
-		canDoKeyEncodeOpt = FALSE;
-	      else
-		{
-		  Attributes * attr = map_info->getAttr();
-		  if (i == 0)
-		    {
-		      firstOffset = attr->getOffset();
-		      prevAtp = attr->getAtp();
-		      prevAtpIndex = attr->getAtpIndex();
-		      prevOffset = attr->getOffset();
-		      prevStorageLength = (UInt32)attr->getStorageLength();
-		    }
-		  else
-		    {
-		      if ((prevAtp == attr->getAtp()) &&
-			  (prevAtpIndex == attr->getAtpIndex()) &&
-			  (attr->getOffset() >= prevOffset) &&
-			  ((attr->getOffset() - prevOffset) ==
-			   prevStorageLength))
-			//(uLong)attr->getStorageLength()))
-			{
-			  prevAtp = attr->getAtp();
-			  prevAtpIndex = attr->getAtpIndex();
-			  prevOffset = attr->getOffset();
-			  prevStorageLength = (UInt32)attr->getStorageLength();
-			}
-		      else
-			{
-			  canDoKeyEncodeOpt = FALSE;
-			}
-		    }
-		}
-	    }
-	}
-
-      if ((doKeyEncodeOpt) &&
-	  (canDoKeyEncodeOpt) &&
-	  (firstKeyColumnOffset))
-	{
-	  // call this method to get the keyLen but do not generate any
-	  // key_expr.
-	  generateContiguousMoveExpr(key_val_id_list,
-				     0, // don't add convert nodes,
-				     atp, atp_index, tf, keyLen,
-				     NULL);
-	  *firstKeyColumnOffset = (Lng32)firstOffset;
-	  *key_expr = NULL;
 	}
-      else
-	{
-	  if (firstKeyColumnOffset)
-	    *firstKeyColumnOffset = -1;
 
-	  generateContiguousMoveExpr(key_val_id_list,
-				     0, // don't add convert nodes,
-				     atp, atp_index, tf, keyLen,
-				     key_expr);
-	}
+      generateContiguousMoveExpr(key_val_id_list,
+                                 0, // don't add convert nodes,
+                                 atp, atp_index, tf, keyLen,
+                                 key_expr);
     }
 
   return 0;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/generator/GenExpGenerator.h
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenExpGenerator.h b/core/sql/generator/GenExpGenerator.h
index a96190b..6ec022e 100644
--- a/core/sql/generator/GenExpGenerator.h
+++ b/core/sql/generator/GenExpGenerator.h
@@ -498,8 +498,8 @@ public:
 			     NABoolean desc_flag,
 			     ExpTupleDesc::TupleDataFormat tf,
 			     Lng32 &possibleErrorCount,
-			     NABoolean &canDoKeyEncodeOpt,
-			     NABoolean allChosenPredsAreEqualPreds);
+			     NABoolean allChosenPredsAreEqualPreds,
+                             NABoolean castVarcharToAnsiChar);
 
   // get the key value. Currently used during hbase checkAndDelete/Update
   // calls. Used to validate that this value exists in the database.
@@ -538,19 +538,6 @@ public:
 			ExpTupleDesc::TupleDataFormat tf,
 			ULng32 &keyLen,
 			ex_expr ** key_expr,
-
-			// if TRUE, check to see that the optimization of
-			// doing a source buffer to target key buffer move
-			// without encoding could be done.
-			// The firstKeyColOffset contains the offset of the
-			// first key in the source buffer.
-			// keyLen bytes need to be copied starting at
-			// firstKeyColOffset.
-			// If firstKeyColumnOffset is passed in then the
-			// return value of -1 indicates that this opt could
-			// not be done.
-			NABoolean doKeyEncodeOpt,
-			Lng32 * firstKeyColumnOffset,
 			NABoolean allChosenPredsAreEqualPreds
 			);
 
@@ -1086,45 +1073,7 @@ public:
 		     const SearchKey * searchKey,
 		     const MdamKey * mdamKey,
 		     const NABoolean reverseScan,
-		     unsigned short keytag,
-		     const ExpTupleDesc::TupleDataFormat tf,
-
-		     // the next few parameters are here
-		     // as part of a horrible kludge for
-		     // the PartitionAccess::codeGen()
-		     // method, which lacks a SearchKey
-		     // object and therefore exposes
-		     // things like the exclusion
-		     // expressions; with luck, later work
-		     // in the Optimizer will result in a
-		     // much cleaner interface
-		     const NABoolean useTheHorribleKludge = FALSE,
-		     ItemExpr * beginKeyExclusionExpr = NULL,
-		     ItemExpr * endKeyExclusionExpr = NULL,
-
-		     // this param, if passed in, indicates that this
-		     // is a unique key pred and 'lean' expr is being
-		     // generated.
-		     // Only generate "ex_expr_lean" and return it.
-		     ex_expr_lean ** unique_key_expr = NULL,
-		     ULng32 * uniqueKeyLen = NULL,
-
-		     // if TRUE, check to see that the optimization of
-		     // doing a source buffer to target key buffer move
-		     // without encoding could be done.
-		     // The firstKeyColOffset contains the offset of the
-		     // first key in the source buffer.
-		     // uniqueKeyLen bytes need to be copied starting at
-		     // firstKeyColOffset.
-		     // If firstKeyColumnOffset is passed in then the
-		     // return value of -1 indicates that this opt could
-		     // not be done.
-		     NABoolean doKeyEncodeOpt = FALSE,
-		     Lng32 * firstKeyColumnOffset = NULL,
-
-		     Int32 in_key_atp_index = -1
-		     );		     
-   
+		     const ExpTupleDesc::TupleDataFormat tf);
 };
 
 // The next class is a helper used in the mdamCodeGen methods on

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/generator/GenKey.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenKey.cpp b/core/sql/generator/GenKey.cpp
index 21e0420..5df1d24 100644
--- a/core/sql/generator/GenKey.cpp
+++ b/core/sql/generator/GenKey.cpp
@@ -70,33 +70,14 @@ short ExpGenerator::buildKeyInfo(keyRangeGen ** keyInfo, // out -- generated obj
                                  const SearchKey * searchKey,
                                  const MdamKey * mdamKeyPtr,
                                  const NABoolean reverseScan,
-                                 unsigned short keytag,
-                                 const ExpTupleDesc::TupleDataFormat tf,
-                                 // the next few parameters are here
-                                 // as part of a horrible kludge for
-                                 // the PartitionAccess::codeGen()
-                                 // method, which lacks a SearchKey
-                                 // object and therefore exposes
-                                 // things like the exclusion
-                                 // expressions; with luck, later work
-                                 // in the Optimizer will result in a
-                                 // much cleaner interface
-                                 const NABoolean useTheHorribleKludge,
-                                 ItemExpr * beginKeyExclusionExpr,
-                                 ItemExpr * endKeyExclusionExpr,
-
-                                 ex_expr_lean ** unique_key_expr,
-                                 ULng32 *uniqueKeyLen,
-                                 NABoolean doKeyEncodeOpt,
-                                 Lng32 * firstKeyColOffset,
-				 Int32 in_key_atp_index
+                                 const ExpTupleDesc::TupleDataFormat tf
                                  )
 
 {
   Space * space = generator->getSpace();
 
   const Int32 work_atp = 1;
-  const Int32 key_atp_index = (in_key_atp_index <= 0 ? 2 : in_key_atp_index);
+  const Int32 key_atp_index = 2;
   const Int32 exclude_flag_atp_index = 3;
   const Int32 data_conv_error_atp_index = 4;
   const Int32 key_column_atp_index = 5; // used only for Mdam
@@ -155,29 +136,25 @@ short ExpGenerator::buildKeyInfo(keyRangeGen ** keyInfo, // out -- generated obj
           short ekey_excluded = 0;
           
           generateKeyExpr(keyColumns,
-              beginKeyPred,
-              work_atp,
-              key_atp_index,
-              dataConversionErrorFlag,
-              tf,
-              keyLen, // out
-              &bk_expr,  // out
-              doKeyEncodeOpt,
-              firstKeyColOffset,
-              doEquiKeyPredOpt);
-              
+                          beginKeyPred,
+                          work_atp,
+                          key_atp_index,
+                          dataConversionErrorFlag,
+                          tf,
+                          keyLen, // out
+                          &bk_expr,  // out
+                          doEquiKeyPredOpt);
+          
           if (&endKeyPred)
              generateKeyExpr(keyColumns,
-                 endKeyPred,
-                 work_atp,
-                 key_atp_index,
-                 dataConversionErrorFlag,
-                 tf,
-                 keyLen, // out -- should be the same as above
-                 &ek_expr,  // out
-                 doKeyEncodeOpt,
-                 firstKeyColOffset,
-                 doEquiKeyPredOpt);
+                             endKeyPred,
+                             work_atp,
+                             key_atp_index,
+                             dataConversionErrorFlag,
+                             tf,
+                             keyLen, // out -- should be the same as above
+                             &ek_expr,  // out
+                             doEquiKeyPredOpt);
               
           if (reverseScan)
             {
@@ -220,62 +197,30 @@ short ExpGenerator::buildKeyInfo(keyRangeGen ** keyInfo, // out -- generated obj
                   bk_excluded_expr = temp;
                 }
             } // if searchKey
-          else if (useTheHorribleKludge)
-            {
-              generateExclusionExpr(beginKeyExclusionExpr,
-                    work_atp,
-                    exclude_flag_atp_index,
-                    &bk_excluded_expr); // out
-              
-              generateExclusionExpr(endKeyExclusionExpr,
-                    work_atp,
-                    exclude_flag_atp_index,
-                    &ek_excluded_expr); // out
-              
-              // note that the old PartitionAccess::codeGen() code didn't
-              // set values for bkey_excluded and ekey_excluded, so the
-              // safest choice is to choose inclusion, i.e. let the flags
-              // retain their initial value of 0.
-            }
           
           // Build key info
-          if (keytag > 0)
-            keyLen += sizeof(short);
 
-          if ((unique_key_expr == NULL) ||
-              (NOT generator->genLeanExpr()))
-            {
-              // the work cri desc is used to build key values (entry 2) and
-              // to compute the exclusion flag (entry 3) to monitor for data
-              // conversion errors (entry 4) and to compute values on a column
-              // basis (entry 5 - Mdam only)
-              ex_cri_desc * work_cri_desc 
-                        = new(space) ex_cri_desc(6, space);
-              
-              *keyInfo = new(space) keySingleSubsetGen(
-                   keyLen,
-                   work_cri_desc,
-                   key_atp_index,
-                   exclude_flag_atp_index,
-                   data_conv_error_atp_index,
-                   bk_expr,
-                   ek_expr,
-                   bk_excluded_expr,
-                   ek_excluded_expr,
-                   // static exclude flags (if exprs are NULL)
-                   bkey_excluded,
-                   ekey_excluded); 
-              if (unique_key_expr)
-                *unique_key_expr = NULL;
-            }
-          else
-            {
-              if (keyInfo)
-                *keyInfo = NULL;
-              *unique_key_expr = (ex_expr_lean*)bk_expr;
-              *uniqueKeyLen = keyLen;
-            }
-        }
+          // the work cri desc is used to build key values (entry 2) and
+          // to compute the exclusion flag (entry 3) to monitor for data
+          // conversion errors (entry 4) and to compute values on a column
+          // basis (entry 5 - Mdam only)
+          ex_cri_desc * work_cri_desc 
+            = new(space) ex_cri_desc(6, space);
+          
+          *keyInfo = new(space) keySingleSubsetGen(
+               keyLen,
+               work_cri_desc,
+               key_atp_index,
+               exclude_flag_atp_index,
+               data_conv_error_atp_index,
+               bk_expr,
+               ek_expr,
+               bk_excluded_expr,
+               ek_excluded_expr,
+               // static exclude flags (if exprs are NULL)
+               bkey_excluded,
+               ekey_excluded); 
+    }
     }  // end of non-mdam case
   else // Mdam case
     {
@@ -658,8 +603,6 @@ short ExpGenerator::buildKeyInfo(keyRangeGen ** keyInfo, // out -- generated obj
         } // for every column order list in the array (of disjuncts)
 
       // build the Mdam key info
-      if (keytag > 0)
-        keyLen += sizeof(short);
       *keyInfo = new(space) keyMdamGen(keyLen,
                                        work_cri_desc,
                                        key_atp_index,
@@ -673,9 +616,6 @@ short ExpGenerator::buildKeyInfo(keyRangeGen ** keyInfo, // out -- generated obj
 
     }  // end of mdam case
 
-  if (*keyInfo)
-    (*keyInfo)->setKeytag(keytag);
-
   // reset map table to forget about the key object's work Atp
   
   // aside: this logic is more bloody than it should be because the

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/generator/GenPreCode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenPreCode.cpp b/core/sql/generator/GenPreCode.cpp
index 2e0ae24..10f9bf5 100644
--- a/core/sql/generator/GenPreCode.cpp
+++ b/core/sql/generator/GenPreCode.cpp
@@ -4895,6 +4895,7 @@ RelExpr * HbaseDelete::preCodeGen(Generator * generator,
                           << DgString0("Reason: Cannot return values from an hbase insert, update or delete.");
       GenExit();
     }
+
    NABoolean isAlignedFormat = getTableDesc()->getNATable()->isAlignedFormat(getIndexDesc());
 
   if  (producesOutputs()) 
@@ -4991,12 +4992,17 @@ RelExpr * HbaseDelete::preCodeGen(Generator * generator,
 	isUnique = TRUE;
     }
  
+  NABoolean hbaseRowsetVSBBopt = 
+    (CmpCommon::getDefault(HBASE_ROWSET_VSBB_OPT) == DF_ON);
+  if (getTableDesc()->getNATable()->isHbaseMapTable())
+    hbaseRowsetVSBBopt = FALSE;
+
   if (getInliningInfo().isIMGU()) {
      // There is no need to do checkAndDelete for IM
      canDoCheckAndUpdel() = FALSE;
      uniqueHbaseOper() = FALSE;
      if ((generator->oltOptInfo()->multipleRowsReturned()) &&
-	  (CmpCommon::getDefault(HBASE_ROWSET_VSBB_OPT) == DF_ON) &&
+	  (hbaseRowsetVSBBopt) &&
          (NOT generator->isRIinliningForTrafIUD()) &&
          (NOT getTableDesc()->getNATable()->hasLobColumn()))
        uniqueRowsetHbaseOper() = TRUE;
@@ -5015,7 +5021,7 @@ RelExpr * HbaseDelete::preCodeGen(Generator * generator,
           (executorPred().isEmpty()))
 	{
 	  if ((generator->oltOptInfo()->multipleRowsReturned()) &&
-	      (CmpCommon::getDefault(HBASE_ROWSET_VSBB_OPT) == DF_ON) &&
+	      (hbaseRowsetVSBBopt) &&
 	      (NOT generator->isRIinliningForTrafIUD()) &&
               (NOT getTableDesc()->getNATable()->hasLobColumn()))
 	    uniqueRowsetHbaseOper() = TRUE;
@@ -5100,6 +5106,15 @@ RelExpr * HbaseUpdate::preCodeGen(Generator * generator,
   if (nodeIsPreCodeGenned())
     return this;
 
+  if (getTableDesc()->getNATable()->isHbaseMapTable())
+    {
+      *CmpCommon::diags() << DgSqlCode(-1425)
+			  << DgTableName(getTableDesc()->getNATable()->getTableName().
+					 getQualifiedNameAsAnsiString())
+                          << DgString0("Reason: update not yet supported.");
+      GenExit();
+    }
+
   if (!processConstHBaseKeys(
            generator,
            this,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/generator/GenRelScan.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelScan.cpp b/core/sql/generator/GenRelScan.cpp
index 1755482..c027916 100644
--- a/core/sql/generator/GenRelScan.cpp
+++ b/core/sql/generator/GenRelScan.cpp
@@ -278,36 +278,6 @@ int HbaseAccess::createAsciiColAndCastExpr(Generator * generator,
   return result;
 }
 
-NABoolean HbaseAccess::columnEnabledForSerialization(ItemExpr * colNode)
-{
-  NAColumn *nac = NULL;
-  if (colNode->getOperatorType() == ITM_BASECOLUMN)
-    {
-      nac = ((BaseColumn*)colNode)->getNAColumn();
-    }
-  else if (colNode->getOperatorType() == ITM_INDEXCOLUMN)
-    {
-      nac = ((IndexColumn*)colNode)->getNAColumn();
-    }
-
-  return CmpSeabaseDDL::enabledForSerialization(nac);
-}
-
-NABoolean HbaseAccess::isEncodingNeededForSerialization(ItemExpr * colNode)
-{
-  NAColumn *nac = NULL;
-  if (colNode->getOperatorType() == ITM_BASECOLUMN)
-    {
-      nac = ((BaseColumn*)colNode)->getNAColumn();
-    }
-  else if (colNode->getOperatorType() == ITM_INDEXCOLUMN)
-    {
-      nac = ((IndexColumn*)colNode)->getNAColumn();
-    }
-
-  return CmpSeabaseDDL::isEncodingNeededForSerialization(nac);
-}
-
 int HbaseAccess::createAsciiColAndCastExpr2(Generator * generator,
 					    ItemExpr * colNode,
 					    const NAType &givenType,
@@ -344,6 +314,86 @@ int HbaseAccess::createAsciiColAndCastExpr2(Generator * generator,
   return 1;
 }
 
+int HbaseAccess::createAsciiColAndCastExpr3(Generator * generator,
+					    const NAType &givenType,
+					    ItemExpr *&asciiValue,
+					    ItemExpr *&castValue)
+{
+  asciiValue = NULL;
+  castValue = NULL;
+  CollHeap * h = generator->wHeap();
+
+  // if this is an upshifted datatype, remove the upshift attr.
+  // We dont want to upshift data during retrievals or while building keys.
+  // Data is only upshifted during insert or updates.
+  const NAType * newGivenType = &givenType;
+  if (newGivenType->getTypeQualifier() == NA_CHARACTER_TYPE &&
+      ((CharType *)newGivenType)->isUpshifted())
+    {
+      newGivenType = newGivenType->newCopy(h);
+      ((CharType*)newGivenType)->setUpshifted(FALSE);
+    }
+
+  NAType *asciiType = NULL;
+
+  // source data is in string format.
+  // Use cqd to determine max len of source if source type is not string.
+  // If cqd is not set, use displayable length for the given datatype.
+  Lng32 cvl = 0;
+  if (NOT (DFS2REC::isAnyCharacter(newGivenType->getFSDatatype())))
+    {
+      cvl = 
+        (Lng32) CmpCommon::getDefaultNumeric(HBASE_MAX_COLUMN_VAL_LENGTH);
+      if (cvl <= 0)
+        {
+          // compute col val length
+          cvl = newGivenType->getDisplayLength();
+        }
+    }
+  else
+    {
+      cvl = newGivenType->getNominalSize();
+    }
+
+  asciiType = new (h) SQLVarChar(cvl, newGivenType->supportsSQLnull());
+
+  //  asciiValue = new (h) NATypeToItem(newGivenType->newCopy(h));
+  asciiValue = new (h) NATypeToItem(asciiType);
+  castValue = new(h) Cast(asciiValue, newGivenType); 
+
+  return 1;
+}
+
+NABoolean HbaseAccess::columnEnabledForSerialization(ItemExpr * colNode)
+{
+  NAColumn *nac = NULL;
+  if (colNode->getOperatorType() == ITM_BASECOLUMN)
+    {
+      nac = ((BaseColumn*)colNode)->getNAColumn();
+    }
+  else if (colNode->getOperatorType() == ITM_INDEXCOLUMN)
+    {
+      nac = ((IndexColumn*)colNode)->getNAColumn();
+    }
+
+  return CmpSeabaseDDL::enabledForSerialization(nac);
+}
+
+NABoolean HbaseAccess::isEncodingNeededForSerialization(ItemExpr * colNode)
+{
+  NAColumn *nac = NULL;
+  if (colNode->getOperatorType() == ITM_BASECOLUMN)
+    {
+      nac = ((BaseColumn*)colNode)->getNAColumn();
+    }
+  else if (colNode->getOperatorType() == ITM_INDEXCOLUMN)
+    {
+      nac = ((IndexColumn*)colNode)->getNAColumn();
+    }
+
+  return CmpSeabaseDDL::isEncodingNeededForSerialization(nac);
+}
+
 short FileScan::genForTextAndSeq(Generator * generator,
                                 Queue * &hdfsFileInfoList,
                                 Queue * &hdfsFileRangeBeginList,
@@ -1636,7 +1686,8 @@ short HbaseAccess::genRowIdExpr(Generator * generator,
 				ULng32 &rowIdAsciiRowLen,
 				ExpTupleDesc* &rowIdAsciiTupleDesc,
 				UInt32 &rowIdLength,
-				ex_expr* &rowIdExpr)
+				ex_expr* &rowIdExpr,
+                                NABoolean encodeKeys)
 {
   Space * space          = generator->getSpace();
   ExpGenerator * expGen = generator->getExpGenerator();
@@ -1671,7 +1722,8 @@ short HbaseAccess::genRowIdExpr(Generator * generator,
 	  rowIdAsciiVids.insert(asciiVal->getValueId());
 	  
 	  ItemExpr * ie = castVal;
-	  if (givenType.getVarLenHdrSize() > 0)
+	  if ((givenType.getVarLenHdrSize() > 0) &&
+              (encodeKeys))
 	    {
 	      // Explode varchars by moving them to a fixed field
 	      // whose length is equal to the max length of varchar.
@@ -1692,21 +1744,24 @@ short HbaseAccess::genRowIdExpr(Generator * generator,
 	  NABoolean descFlag = TRUE;
 	  if (keyColumns.isAscending(i))
 	    descFlag = FALSE;
-	  ie = new(generator->wHeap())
-	    CompEncode(ie, descFlag);
-	  
+          if (encodeKeys)
+            {
+              ie = new(generator->wHeap())
+                CompEncode(ie, descFlag);
+            }
+
 	  ie->bindNode(generator->getBindWA());
 	  keyConvVIDList.insert(ie->getValueId());
 	} // for
       
       expGen->processValIdList(
-			       rowIdAsciiVids,                             // [IN] ValueIdList
-			       ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
-			       rowIdAsciiRowLen,                        // [OUT] tuple length 
-			       work_atp,                                      // [IN] atp number
-			       rowIdAsciiTuppIndex,                    // [IN] index into atp
-			       &rowIdAsciiTupleDesc,                  // [optional OUT] tuple desc
-			       ExpTupleDesc::LONG_FORMAT);    // [optional IN] desc format
+           rowIdAsciiVids,                             // [IN] ValueIdList
+           ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
+           rowIdAsciiRowLen,                        // [OUT] tuple length 
+           work_atp,                                      // [IN] atp number
+           rowIdAsciiTuppIndex,                    // [IN] index into atp
+           &rowIdAsciiTupleDesc,                  // [optional OUT] tuple desc
+           ExpTupleDesc::LONG_FORMAT);    // [optional IN] desc format
       
       work_cri_desc->setTupleDescriptor(rowIdAsciiTuppIndex, rowIdAsciiTupleDesc);
       
@@ -1784,13 +1839,13 @@ short HbaseAccess::genRowIdExprForNonSQ(Generator * generator,
 	} // for
       
       expGen->processValIdList(
-			       rowIdAsciiVids,                             // [IN] ValueIdList
-			       ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
-			       rowIdAsciiRowLen,                        // [OUT] tuple length 
-			       work_atp,                                      // [IN] atp number
-			       rowIdAsciiTuppIndex,                    // [IN] index into atp
-			       &rowIdAsciiTupleDesc,                  // [optional OUT] tuple desc
-			       ExpTupleDesc::LONG_FORMAT);    // [optional IN] desc format
+           rowIdAsciiVids,                             // [IN] ValueIdList
+           ExpTupleDesc::SQLARK_EXPLODED_FORMAT,
+           rowIdAsciiRowLen,                        // [OUT] tuple length 
+           work_atp,                                      // [IN] atp number
+           rowIdAsciiTuppIndex,                    // [IN] index into atp
+           &rowIdAsciiTupleDesc,                  // [optional OUT] tuple desc
+           ExpTupleDesc::LONG_FORMAT);    // [optional IN] desc format
       
       work_cri_desc->setTupleDescriptor(rowIdAsciiTuppIndex, rowIdAsciiTupleDesc);
       
@@ -2015,7 +2070,14 @@ short HbaseAccess::createHbaseColId(const NAColumn * nac,
     cid = SEABASE_DEFAULT_COL_FAMILY;
   cid += ":";
 
-  if (nac)
+  if (nac && nac->getNATable() && nac->getNATable()->isHbaseMapTable())
+    {
+      char * colQualPtr = (char*)nac->getColName().data();
+      Lng32 colQualLen = nac->getHbaseColQual().length();
+
+      cid.append(colQualPtr, colQualLen);
+    }
+  else if (nac)
     {
       char * colQualPtr = (char*)nac->getHbaseColQual().data();
       Lng32 colQualLen = nac->getHbaseColQual().length();
@@ -2365,6 +2427,7 @@ short HbaseAccess::codeGen(Generator * generator)
     hasAddedColumns = TRUE;
 
   NABoolean isAlignedFormat = getTableDesc()->getNATable()->isAlignedFormat(getIndexDesc());
+  NABoolean isHbaseMapFormat = getTableDesc()->getNATable()->isHbaseMapTable();
 
   // If CIF is not OFF use aligned format, except when table is
   // not aligned and it has added columns. Support for added columns
@@ -2387,7 +2450,6 @@ short HbaseAccess::codeGen(Generator * generator)
 		       searchKey(),
 		       getMdamKeyPtr(),
 		       reverseScan,
-		       0,
 		       ExpTupleDesc::SQLMX_KEY_FORMAT);
 
   const ValueIdList &retColumnList = retColRefSet_; 
@@ -2397,7 +2459,8 @@ short HbaseAccess::codeGen(Generator * generator)
   char * snapshotName = NULL;
   LatestSnpSupportEnum  latestSnpSupport=  latest_snp_supported;
   if ((getTableDesc()->getNATable()->isHbaseRowTable()) ||
-      (getTableDesc()->getNATable()->isHbaseCellTable()))
+      (getTableDesc()->getNATable()->isHbaseCellTable()) ||
+      (getTableName().getQualifiedNameObj().isHbaseMappedName()))
     {
       tablename =
         space->AllocateAndCopyToAlignedSpace(
@@ -2428,7 +2491,8 @@ short HbaseAccess::codeGen(Generator * generator)
 
   ValueIdList columnList;
   if ((getTableDesc()->getNATable()->isSeabaseTable()) &&
-      (NOT isAlignedFormat))
+      (NOT isAlignedFormat) &&
+      (NOT isHbaseMapFormat))
     sortValues(retColumnList, columnList,
 	       (getIndexDesc()->getNAFileSet()->getKeytag() != 0));
   else
@@ -2486,15 +2550,31 @@ short HbaseAccess::codeGen(Generator * generator)
      ItemExpr *asciiValue = NULL;
      ItemExpr *castValue = NULL;
      
-     res = createAsciiColAndCastExpr2(
-				     generator,        // for heap
-				     col_node,
-				     givenType,         // [IN] Actual type of HDFS column
-				     asciiValue,         // [OUT] Returned expression for ascii rep.
-				     castValue,        // [OUT] Returned expression for binary rep.
-                                     isAlignedFormat
-				     );
-     
+     if ((isHbaseMapFormat) && 
+         (getTableDesc()->getNATable()->isHbaseDataFormatString()))
+       {
+         res = createAsciiColAndCastExpr3
+           (
+                generator,       // for heap
+                givenType,       // [IN] Actual type of column
+                asciiValue,      // [OUT] Returned expression for ascii rep.
+                castValue        // [OUT] Returned expression for binary rep.
+            );
+
+       }
+     else
+       {
+         res = createAsciiColAndCastExpr2
+           (
+                generator,       // for heap
+                col_node,
+                givenType,       // [IN] Actual type of HDFS column
+                asciiValue,      // [OUT] Returned expression for ascii rep.
+                castValue,       // [OUT] Returned expression for binary rep.
+                isAlignedFormat
+            );
+       }
+
      GenAssert(res == 1 && castValue != NULL,
 	       "Error building expression tree for cast output value");
      if (asciiValue)
@@ -2690,6 +2770,7 @@ short HbaseAccess::codeGen(Generator * generator)
     }
 
   Queue * listOfFetchedColNames = NULL;
+  char * pkeyColName = NULL;
   if ((getTableDesc()->getNATable()->isSeabaseTable()) &&
       (isAlignedFormat))
     {
@@ -2707,7 +2788,8 @@ short HbaseAccess::codeGen(Generator * generator)
       
       listOfFetchedColNames->insert(colNameInList);
     }
-  else if (getTableDesc()->getNATable()->isSeabaseTable())
+  else if ((getTableDesc()->getNATable()->isSeabaseTable()) &&
+           (NOT isHbaseMapFormat))
     {
       listOfFetchedColNames = new(space) Queue(space);
 
@@ -2755,6 +2837,47 @@ short HbaseAccess::codeGen(Generator * generator)
 	  listOfFetchedColNames->insert(colNameInList);
 	}
     }
+  else if ((getTableDesc()->getNATable()->isSeabaseTable()) &&
+           (isHbaseMapFormat))
+    {
+      listOfFetchedColNames = new(space) Queue(space);
+
+      for (CollIndex c = 0; c < numColumns; c++)
+	{
+	  ItemExpr * col_node = ((columnList[c]).getValueDesc())->getItemExpr();
+
+	  NAString cnInList;
+	  char * colNameInList = NULL;
+	  if ((col_node->getOperatorType() == ITM_BASECOLUMN) ||
+              (col_node->getOperatorType() == ITM_INDEXCOLUMN))
+	    {
+	      const NAColumn *nac = NULL;
+              if (col_node->getOperatorType() == ITM_BASECOLUMN)
+		nac = ((BaseColumn*)col_node)->getNAColumn();
+              else
+                nac = ((IndexColumn*)col_node)->getNAColumn();
+
+              cnInList = nac->getHbaseColFam();
+              cnInList += ":";
+              cnInList += nac->getColName();
+
+              short len = cnInList.length();
+              cnInList.prepend((char*)&len, sizeof(short));
+	      colNameInList = 
+		space->AllocateAndCopyToAlignedSpace(cnInList, 0);
+
+              if ((nac->isPrimaryKey()) &&
+                  (getTableDesc()->getNATable()->isHbaseDataFormatString()))
+                pkeyColName = colNameInList;
+	    }
+	  else if (col_node->getOperatorType() == ITM_REFERENCE)
+	    {
+              GenAssert(0, "HbaseAccess::codeGen. Should not reach here.");
+	    }
+	  
+	  listOfFetchedColNames->insert(colNameInList);
+	}
+    }
   else if ((getTableDesc()->getNATable()->isHbaseRowTable()) &&
 	   (retHbaseColRefSet_.entries() > 0))
     {
@@ -2843,6 +2966,12 @@ short HbaseAccess::codeGen(Generator * generator)
 
   if (getTableDesc()->getNATable()->isSeabaseTable())
     {
+      // dont encode keys for hbase mapped tables since these tables
+      // could be populated from outside of traf.
+      NABoolean encodeKeys = TRUE;
+      if (getTableDesc()->getNATable()->isHbaseMapTable())
+        encodeKeys = FALSE;
+
       genRowIdExpr(generator,
 		   getIndexDesc()->getNAFileSet()->getIndexKeyColumns(),
 		   getHbaseSearchKeys(), 
@@ -2850,7 +2979,8 @@ short HbaseAccess::codeGen(Generator * generator)
 		   rowIdAsciiTuppIndex, rowIdTuppIndex,
 		   rowIdAsciiRowLen, rowIdAsciiTupleDesc,
 		   rowIdLength, 
-		   rowIdExpr);
+		   rowIdExpr,
+                   encodeKeys);
     }
   else
     {
@@ -3083,7 +3213,9 @@ short HbaseAccess::codeGen(Generator * generator)
 		      samplePercent(),
 		      snapAttrs,
 
-                      hbo
+                      hbo,
+
+                      pkeyColName
 		      );
 
   generator->initTdbFields(hbasescan_tdb);
@@ -3101,6 +3233,14 @@ short HbaseAccess::codeGen(Generator * generator)
       if (isAlignedFormat)
         hbasescan_tdb->setAlignedFormat(TRUE);
 
+      if (isHbaseMapFormat)
+        {
+          hbasescan_tdb->setHbaseMapTable(TRUE);
+
+          if (getTableDesc()->getNATable()->getClusteringIndex()->hasSingleColVarcharKey())
+            hbasescan_tdb->setKeyInVCformat(TRUE);
+        }
+
       if (getTableDesc()->getNATable()->isEnabledForDDLQI())
         generator->objectUids().insert(
           getTableDesc()->getNATable()->objectUid().get_value());
@@ -3203,7 +3343,6 @@ short HbaseAccessCoProcAggr::codeGen(Generator * generator)
 		       searchKey(),
 		       getMdamKeyPtr(),
 		       reverseScan,
-		       0,
 		       ExpTupleDesc::SQLMX_KEY_FORMAT);
 
   //  const ValueIdList &retColumnList = getIndexDesc()->getIndexColumns();



[2/7] incubator-trafodion git commit: TRAFODION-1586 Add support for external Traf tables mappedd to HBase tables

Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 6af00b0..4b4d33b 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -57,26 +57,27 @@
 
 // defined in CmpDescribe.cpp
 extern short CmpDescribeSeabaseTable ( 
-                             const CorrName  &dtName,
-                             short type, // 1, invoke. 2, showddl. 3, createLike
-                             char* &outbuf,
-                             ULng32 &outbuflen,
-                             CollHeap *heap,
-                             const char * pkeyStr = NULL,
-                             NABoolean withPartns = FALSE,
-                             NABoolean withoutSalt = FALSE,
-                             NABoolean withoutDivisioning = FALSE,
-                             UInt32 columnLengthLimit = UINT_MAX,
-                             NABoolean noTrailingSemi = FALSE,
-
-                             // used to add,rem,alter column definition from col list.
-                             // valid for 'createLike' mode. 
-                             // Used for 'alter add/drop/alter col'.
-                             char * colName = NULL,
-                             short ada = 0, // 0,add. 1,drop. 2,alter
-                             const NAColumn * nacol = NULL,
-                             const NAType * natype = NULL,
-                             Space *inSpace = NULL);
+     const CorrName  &dtName,
+     short type, // 1, invoke. 2, showddl. 3, createLike
+     char* &outbuf,
+     ULng32 &outbuflen,
+     CollHeap *heap,
+     const char * pkeyStr = NULL,
+     NABoolean withPartns = FALSE,
+     NABoolean withoutSalt = FALSE,
+     NABoolean withoutDivisioning = FALSE,
+     NABoolean withoutRowFormat = FALSE,
+     UInt32 columnLengthLimit = UINT_MAX,
+     NABoolean noTrailingSemi = FALSE,
+     
+     // used to add,rem,alter column definition from col list.
+     // valid for 'createLike' mode. 
+     // Used for 'alter add/drop/alter col'.
+     char * colName = NULL,
+     short ada = 0, // 0,add. 1,drop. 2,alter
+     const NAColumn * nacol = NULL,
+     const NAType * natype = NULL,
+     Space *inSpace = NULL);
 
 // type:  1, invoke. 2, showddl. 3, create_like
 extern short cmpDisplayColumn(const NAColumn *nac,
@@ -254,7 +255,7 @@ TrafDesc * CmpSeabaseDDL::convertVirtTableKeyInfoArrayToDescStructs(
   return first_key_desc;
 }
 
-void CmpSeabaseDDL::createSeabaseTableLike(
+void CmpSeabaseDDL::createSeabaseTableLike(ExeCliInterface * cliInterface,
                                            StmtDDLCreateTable * createTableNode,
                                            NAString &currCatName, NAString &currSchName)
 {
@@ -269,10 +270,30 @@ void CmpSeabaseDDL::createSeabaseTableLike(
   ComObjectName srcTableName(createTableNode->getLikeSourceTableName(), COM_TABLE_NAME);
   srcTableName.applyDefaults(currCatAnsiName, currSchAnsiName);
   
-  CorrName cn(srcTableName.getObjectNamePart().getInternalName(),
+  NABoolean srcSchNameSpecified = 
+    (NOT createTableNode->getOrigLikeSourceTableName().getSchemaName().isNull());
+
+  NAString srcCatNamePart = srcTableName.getCatalogNamePartAsAnsiString();
+  NAString srcSchNamePart = srcTableName.getSchemaNamePartAsAnsiString(TRUE);
+  NAString srcObjNamePart = srcTableName.getObjectNamePartAsAnsiString(TRUE);
+  NAString extSrcTableName = srcTableName.getExternalName(TRUE);
+  NAString srcTabName = srcTableName.getExternalName(TRUE);
+
+  retcode = lookForTableInMD(cliInterface, 
+                             srcCatNamePart, srcSchNamePart, srcObjNamePart,
+                             srcSchNameSpecified, FALSE,
+                             srcTableName, srcTabName, extSrcTableName);
+  if (retcode < 0)
+    {
+      processReturn();
+
+      return;
+    }
+
+  CorrName cn(srcObjNamePart,
               STMTHEAP,
-              srcTableName.getSchemaNamePart().getInternalName(),
-              srcTableName.getCatalogNamePart().getInternalName());
+              srcSchNamePart,
+              srcCatNamePart);
 
   ElemDDLColRefArray &keyArray = 
     (createTableNode->getIsConstraintPKSpecified() ?
@@ -350,6 +371,7 @@ void CmpSeabaseDDL::createSeabaseTableLike(
                                     likeOptions.getIsWithHorizontalPartitions(),
                                     likeOptions.getIsWithoutSalt(),
                                     likeOptions.getIsWithoutDivision(),
+                                    likeOptions.getIsWithoutRowFormat(),
                                     likeOptions.getIsLikeOptColumnLengthLimit(),
                                     TRUE);
   if (retcode)
@@ -389,15 +411,12 @@ void CmpSeabaseDDL::createSeabaseTableLike(
   // send any user CQDs down 
   Lng32 retCode = sendAllControls(FALSE, FALSE, TRUE);
 
-  ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
-
   Lng32 cliRC = 0;
 
-  cliRC = cliInterface.executeImmediate((char*)query.data());
+  cliRC = cliInterface->executeImmediate((char*)query.data());
   if (cliRC < 0)
     {
-      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+      cliInterface->retrieveSQLDiagnostics(CmpCommon::diags());
       return;
     }
   
@@ -468,6 +487,9 @@ short CmpSeabaseDDL::createSeabaseTableExternal(
      return -1;
   }
 
+  if (createTableNode->mapToHbaseTable())
+    return 0;
+
   const NAString extTgtTableName = tgtTableName.getExternalName(TRUE);
 
   CorrName cnSrc(srcTableName.getObjectNamePart().getInternalName(),
@@ -486,8 +508,7 @@ short CmpSeabaseDDL::createSeabaseTableExternal(
   tableInfo->validDef = 1;
   tableInfo->hbaseCreateOptions = NULL;
   tableInfo->numSaltPartns = 0;
-  tableInfo->rowFormat = (isHive) ?  COM_HIVE_EXTERNAL_FORMAT_TYPE : 
-                                     COM_HBASE_EXTERNAL_FORMAT_TYPE;
+  tableInfo->rowFormat = COM_UNKNOWN_FORMAT_TYPE;
   tableInfo->objectFlags = (isHive) ?  SEABASE_OBJECT_IS_EXTERNAL_HIVE : 
                                        SEABASE_OBJECT_IS_EXTERNAL_HBASE;
   tableInfo->tablesFlags = 0;
@@ -848,8 +869,27 @@ short CmpSeabaseDDL::updatePKeyInfo(
 
   Int64 validatedTime = NA_JulianTimestamp();
 
+  Int64 flags = 0;
+
+  // if pkey is specified to be not_serialized, then set it.
+  // if this is an hbase mapped table and pkey serialization is not specified, 
+  // then set to not_serialized.
+  NABoolean notSerializedPK = FALSE;
+  if ((addPKNode->getAlterTableAction()->castToElemDDLConstraintPK()->ser() == 
+       ComPkeySerialization::COM_NOT_SERIALIZED) ||
+      (ComIsHbaseMappedSchemaName(schName) && 
+       (addPKNode->getAlterTableAction()->castToElemDDLConstraintPK()->ser() == 
+        ComPkeySerialization::COM_SER_NOT_SPECIFIED)))
+    notSerializedPK = TRUE;
+  
+  if (notSerializedPK)
+    {
+      CmpSeabaseDDL::setMDflags
+        (flags, CmpSeabaseDDL::MD_TABLE_CONSTRAINTS_PKEY_NOT_SERIALIZED_FLG);
+    }
+ 
   Int64 indexUID = 0;
-  str_sprintf(buf, "insert into %s.\"%s\".%s values (%Ld, %Ld, '%s', '%s', '%s', '%s', '%s', '%s', %Ld, %d, %Ld, 0 )",
+  str_sprintf(buf, "insert into %s.\"%s\".%s values (%Ld, %Ld, '%s', '%s', '%s', '%s', '%s', '%s', %Ld, %d, %Ld, %Ld )",
               getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TABLE_CONSTRAINTS,
               tableUID, pkeyUID,
               COM_PRIMARY_KEY_CONSTRAINT_LIT,
@@ -860,7 +900,8 @@ short CmpSeabaseDDL::updatePKeyInfo(
               COM_YES_LIT,
               validatedTime,
               numKeys,
-              indexUID);
+              indexUID,
+              flags);
   cliRC = cliInterface->executeImmediate(buf);
   
   if (cliRC < 0)
@@ -1444,6 +1485,152 @@ short CmpSeabaseDDL::updateIndexInfo(
   return 0;
 }
 
+short CmpSeabaseDDL::setupAndErrorChecks
+(NAString &tabName, QualifiedName &origTableName, 
+ NAString &currCatName, NAString &currSchName,
+ NAString &catalogNamePart, NAString &schemaNamePart, NAString &objectNamePart,
+ NAString &extTableName, NAString &extNameForHbase,
+ CorrName &cn,
+ NATable* *naTable,
+ NABoolean volTabSupported,
+ NABoolean hbaseMapSupported,
+ ExeCliInterface *cliInterface,
+ const ComObjectType objectType,
+ SQLOperation operation,
+ NABoolean isExternal)
+{
+  Lng32 cliRC = 0;
+  Lng32 retcode = 0;
+
+  ComObjectName tableName(tabName, COM_TABLE_NAME);
+  ComAnsiNamePart currCatAnsiName(currCatName);
+  ComAnsiNamePart currSchAnsiName(currSchName);
+  tableName.applyDefaults(currCatAnsiName, currSchAnsiName);
+
+  NABoolean schNameSpecified = (NOT origTableName.getSchemaName().isNull());
+
+  if (isExternal)
+    {
+      // Convert the native name to its Trafodion form
+      tabName = ComConvertNativeNameToTrafName
+        (tableName.getCatalogNamePartAsAnsiString(),
+         tableName.getSchemaNamePartAsAnsiString(),
+         tableName.getObjectNamePartAsAnsiString());
+                               
+      ComObjectName adjustedName(tabName, COM_TABLE_NAME);
+      tableName = adjustedName;
+    }
+
+  catalogNamePart = tableName.getCatalogNamePartAsAnsiString();
+  schemaNamePart = tableName.getSchemaNamePartAsAnsiString(TRUE);
+  objectNamePart = tableName.getObjectNamePartAsAnsiString(TRUE);
+  extTableName = tableName.getExternalName(TRUE);
+  extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
+
+  if ((isSeabaseReservedSchema(tableName)) &&
+      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
+    {
+      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_DEFINITION_METADATA_SCHEMA);
+      processReturn();
+      return -1;
+    }
+
+  retcode = lookForTableInMD(cliInterface, 
+                             catalogNamePart, schemaNamePart, objectNamePart,
+                             schNameSpecified, FALSE,
+                             tableName, tabName, extTableName,
+                             objectType);
+  if (retcode < 0)
+    {
+      processReturn();
+
+      return -1;
+    }
+
+  if (retcode == 0) // doesn't exist
+    {
+      if (objectType == COM_BASE_TABLE_OBJECT)
+        *CmpCommon::diags() << DgSqlCode(-1127)
+                            << DgTableName(extTableName);
+      else 
+        *CmpCommon::diags() << DgSqlCode(-1389)
+                            << DgString0(extTableName);
+
+      processReturn();
+      
+      return -1;
+    }
+
+  Int32 objectOwnerID = 0;
+  Int32 schemaOwnerID = 0;
+  if (naTable)
+    {
+      ActiveSchemaDB()->getNATableDB()->useCache();
+      
+      BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
+      cn = CorrName(objectNamePart, STMTHEAP, schemaNamePart, catalogNamePart);
+      
+      *naTable = bindWA.getNATableInternal(cn); 
+      if (*naTable == NULL || bindWA.errStatus())
+        {
+          *CmpCommon::diags()
+            << DgSqlCode(-4082)
+            << DgTableName(cn.getExposedNameAsAnsiString());
+          
+          processReturn();
+          
+          return -1;
+        }
+
+      objectOwnerID = (*naTable)->getOwner();
+      schemaOwnerID = (*naTable)->getSchemaOwner();
+
+      // Make sure user has the privilege to perform the alter column
+      if (!isDDLOperationAuthorized(operation,
+                                    objectOwnerID, schemaOwnerID))
+        {
+          *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
+          
+          processReturn ();
+          
+          return -1;
+        }
+      
+      // return an error if trying to alter a column from a volatile table
+      if ((NOT volTabSupported) && (naTable && (*naTable)->isVolatileTable()))
+        {
+          *CmpCommon::diags() << DgSqlCode(-CAT_REGULAR_OPERATION_ON_VOLATILE_OBJECT);
+          
+          processReturn ();
+          
+          return -1;
+        }
+      
+      if ((NOT hbaseMapSupported) && (naTable && (*naTable)->isHbaseMapTable()))
+        {
+          // not supported
+          *CmpCommon::diags() << DgSqlCode(-3242)
+                              << DgString0("This feature not available for an HBase mapped table.");
+          
+          processReturn();
+          
+          return -1;
+        }
+    }
+
+  return 0;
+}
+
+static void resetHbaseSerialization(NABoolean hbaseSerialization,
+                                    NAString &hbVal)
+{
+  if (hbaseSerialization)
+    {
+      ActiveSchemaDB()->getDefaults().validateAndInsert
+        ("hbase_serialization", hbVal, FALSE);
+    }
+}
+
 // RETURN:  -1, no need to cleanup.  -2, caller need to call cleanup 
 //                  0, all ok.
 short CmpSeabaseDDL::createSeabaseTable2(
@@ -1461,6 +1648,13 @@ short CmpSeabaseDDL::createSeabaseTable2(
   ComAnsiNamePart currSchAnsiName(currSchName);
   tableName.applyDefaults(currCatAnsiName, currSchAnsiName);
 
+  // external table to be mapped to an existing hbase table
+  NABoolean hbaseMapFormat = FALSE;
+
+  // format of data in hbase mapped table: native or string.
+  // See ComRowFormat in common/ComSmallDefs.h for details.
+  NABoolean hbaseMappedDataFormatIsString = FALSE;
+
   // Make some additional checks if creating an external table
   ComObjectName *srcTableName = NULL;
   if (createTableNode->isExternal())
@@ -1472,7 +1666,27 @@ short CmpSeabaseDDL::createSeabaseTable2(
 
       srcTableName = new(STMTHEAP) ComObjectName
           (createTableNode->getLikeSourceTableName(), COM_TABLE_NAME);
-      srcTableName->applyDefaults(currCatAnsiName, currSchAnsiName);
+
+      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);
+
+          hbaseMapFormat = TRUE;
+          hbaseMappedDataFormatIsString = 
+            createTableNode->isHbaseDataFormatString();
+        }
+      else
+        srcTableName->applyDefaults(currCatAnsiName, currSchAnsiName);
 
       // Convert the native table name to its trafodion name
       NAString tabName = ComConvertNativeNameToTrafName 
@@ -1519,13 +1733,15 @@ short CmpSeabaseDDL::createSeabaseTable2(
             << DgString1((srcTableName->getObjectNamePart().getExternalName()));
           return -1;
         }
-    }
+    } // external table
 
   const NAString catalogNamePart = tableName.getCatalogNamePartAsAnsiString();
   const NAString schemaNamePart = tableName.getSchemaNamePartAsAnsiString(TRUE);
   const NAString objectNamePart = tableName.getObjectNamePartAsAnsiString(TRUE);
   const NAString extTableName = tableName.getExternalName(TRUE);
-  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
+  const NAString extNameForHbase = 
+    (hbaseMapFormat ? "" :
+     catalogNamePart + "." + schemaNamePart + "." + objectNamePart);
   
   ExpHbaseInterface * ehi = allocEHI();
   if (ehi == NULL)
@@ -1586,9 +1802,30 @@ short CmpSeabaseDDL::createSeabaseTable2(
       if (retcode != 0 && CmpCommon::diags()->getNumber(DgSqlCode::ERROR_) == 0)
         SEABASEDDL_INTERNAL_ERROR("creating external HIVE table");
 
-      deallocEHI(ehi);
-      processReturn();
-      return retcode;
+      if (NOT hbaseMapFormat)
+        {
+          deallocEHI(ehi);
+          processReturn();
+          return retcode;
+        }
+    }
+
+  // make sure the table to be mapped exists
+  if (hbaseMapFormat)
+    {
+      HbaseStr hbaseTable;
+      hbaseTable.val = (char*)objectNamePart.data();
+      hbaseTable.len = objectNamePart.length();
+      if (ehi->exists(hbaseTable) == 0) // does not exist in hbase
+        {
+          *CmpCommon::diags() << DgSqlCode(-4260)
+                              << DgString0(objectNamePart);
+          
+          deallocEHI(ehi); 
+          processReturn();
+          
+          return -1;
+        }
     }
 
   ElemDDLColDefArray &colArray = createTableNode->getColDefArray();
@@ -1599,6 +1836,18 @@ short CmpSeabaseDDL::createSeabaseTable2(
       createTableNode->getKeyColumnArray() :
       createTableNode->getPrimaryKeyColRefArray()));
 
+  if ((NOT ((createTableNode->isExternal()) && 
+            (createTableNode->mapToHbaseTable()))) &&
+      ((createTableNode->getIsConstraintPKSpecified()) &&
+       (createTableNode->getAddConstraintPK()) &&
+       (createTableNode->getAddConstraintPK()->getAlterTableAction()->castToElemDDLConstraintPK()->notSerialized())))
+    {
+      *CmpCommon::diags() << DgSqlCode(-3242)
+                          << DgString0("NOT SERIALIZED option cannot be specified for primary key of this table.");
+      
+      return -1;
+    }
+
   Int32 objectOwnerID = SUPER_USER;
   Int32 schemaOwnerID = SUPER_USER;
   ComSchemaClass schemaClass;
@@ -1621,7 +1870,8 @@ short CmpSeabaseDDL::createSeabaseTable2(
   // If the schema name specified is external HIVE or HBase name, users cannot 
   // create them.
   if (ComIsTrafodionExternalSchemaName(schemaNamePart) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
+      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)) &&
+      (NOT hbaseMapFormat))
     {
       // error.
       *SqlParser_Diags << DgSqlCode(-CAT_CREATE_TABLE_NOT_ALLOWED_IN_SMD)
@@ -1631,7 +1881,8 @@ short CmpSeabaseDDL::createSeabaseTable2(
 
   if (createTableNode->getIsLikeOptionSpecified())
     {
-      createSeabaseTableLike(createTableNode, currCatName, currSchName);
+      createSeabaseTableLike(&cliInterface,
+                             createTableNode, currCatName, currSchName);
       deallocEHI(ehi);
       processReturn();
       return -1;
@@ -1664,19 +1915,42 @@ short CmpSeabaseDDL::createSeabaseTable2(
   ElemDDLColDef syskeyColDef(NULL, &syskeyColName, syskeyType, NULL,
                              STMTHEAP);
   ElemDDLColRef edcr("SYSKEY", COM_ASCENDING_ORDER);
+  syskeyColDef.setColumnClass(COM_SYSTEM_COLUMN);
+
+  NAString hbRowIdColName("ROW_ID");
+  SQLVarChar * hbRowIdType = new(STMTHEAP) SQLVarChar(1000, FALSE);
+  ElemDDLColDef hbRowIdColDef(NULL, &hbRowIdColName, hbRowIdType, NULL,
+                              STMTHEAP);
+  ElemDDLColRef hbcr("ROW_ID", COM_ASCENDING_ORDER);
+  hbRowIdColDef.setColumnClass(COM_SYSTEM_COLUMN);
+
   CollIndex numSysCols = 0;
   CollIndex numSaltCols = 0;
   CollIndex numDivCols = 0;
 
-  syskeyColDef.setColumnClass(COM_SYSTEM_COLUMN);
-
   if (((createTableNode->getStoreOption() == COM_KEY_COLUMN_LIST_STORE_OPTION) &&
        (NOT createTableNode->getIsConstraintPKSpecified())) ||
       (keyArray.entries() == 0))
     {
-      colArray.insertAt(0, &syskeyColDef);
+      if (hbaseMapFormat)
+        {
+          // for now, return error if pkey is not specified.
+          *CmpCommon::diags() << DgSqlCode(-4259);
+          
+          deallocEHI(ehi); 
+          
+          processReturn();
+          
+          return -1;
 
-      keyArray.insert(&edcr);
+          colArray.insertAt(0, &hbRowIdColDef);
+          keyArray.insert(&hbcr);
+        }
+      else
+        {
+          colArray.insertAt(0, &syskeyColDef);
+          keyArray.insert(&edcr);
+        }
 
       implicitPK = TRUE;
       numSysCols++;
@@ -1692,6 +1966,15 @@ short CmpSeabaseDDL::createSeabaseTable2(
       ((numSaltPartnsFromCQD > 0) &&
        (NOT implicitPK)))
     {
+      if (hbaseMapFormat)
+        {
+          // salt option not supported on hbase map table
+          *CmpCommon::diags() << DgSqlCode(-4259);
+          deallocEHI(ehi); 
+          processReturn();
+          return -1;
+        }
+
       // add a system column SALT INTEGER NOT NULL with a computed
       // default value HASH2PARTFUNC(<salting cols> FOR <num salt partitions>)
       ElemDDLSaltOptionsClause * saltOptions = createTableNode->getSaltOptions();
@@ -1817,6 +2100,41 @@ short CmpSeabaseDDL::createSeabaseTable2(
       numSaltCols++;
       numSplits = numSaltPartns - 1;
     }
+  
+  // is hbase data stored in varchar format
+  if (hbaseMapFormat && hbaseMappedDataFormatIsString)
+    {
+      // cannot specify serialized primary key
+
+      if (createTableNode->getAddConstraintPK()->getAlterTableAction()->
+          castToElemDDLConstraintPK()->serialized())
+        {
+          *CmpCommon::diags() << DgSqlCode(-3242)
+                              << DgString0("SERIALIZED option cannot be specified for primary key of this table.");
+          
+          return -1;
+        }
+
+      // must have only one varchar primary key col
+      if (keyArray.entries() > 1)
+        {
+          *CmpCommon::diags() << DgSqlCode(-3242)
+                              << DgString0("Only one column can be specified as the primary key of this table.");
+          
+          return -1;
+        }
+
+      Lng32 tableColNum = 
+        (Lng32)colArray.getColumnIndex(keyArray[0]->getColumnName());
+      NAType *colType = colArray[tableColNum]->getColumnDataType();
+      if (NOT DFS2REC::isAnyVarChar(colType->getFSDatatype()))
+        {
+          *CmpCommon::diags() << DgSqlCode(-3242)
+                              << DgString0("Primary key column must be specified as varchar datatype for this table.");
+          
+          return -1;
+        }
+    }
 
   // create table in seabase
   ParDDLFileAttrsCreateTable &fileAttribs =
@@ -1833,7 +2151,23 @@ short CmpSeabaseDDL::createSeabaseTable2(
   else if(CmpCommon::getDefault(TRAF_ALIGNED_ROW_FORMAT) == DF_ON)
     {
       if ( NOT isSeabaseReservedSchema(tableName))
-        alignedFormat = TRUE;
+        {
+          // aligned format default does not apply to hbase map tables
+          if (NOT hbaseMapFormat)
+            alignedFormat = TRUE;
+        }
+    }
+
+  if (hbaseMapFormat && alignedFormat)
+    {
+      // not supported
+      *CmpCommon::diags() << DgSqlCode(-3242)
+                          << DgString0("Aligned format cannot be specified for an HBase mapped table.");
+
+      deallocEHI(ehi); 
+      processReturn();
+      
+      return -1;
     }
 
   const NAString &defaultColFam = fileAttribs.getColFam();
@@ -1858,6 +2192,21 @@ short CmpSeabaseDDL::createSeabaseTable2(
   std::vector<NAString> userColFamVec;
   std::vector<NAString> trafColFamVec;
 
+  // if hbase map format, turn off global serialization default.
+  NABoolean hbaseSerialization = FALSE;
+  NAString hbVal;
+  if (hbaseMapFormat)
+    {
+      if (CmpCommon::getDefault(HBASE_SERIALIZATION) == DF_ON)
+        {
+          NAString value("OFF");
+          hbVal = "ON";
+          ActiveSchemaDB()->getDefaults().validateAndInsert(
+               "hbase_serialization", value, FALSE);
+          hbaseSerialization = TRUE;
+        }
+    }
+
   // build colInfoArray and keyInfoArray, this may take two
   // iterations if we need to add a divisioning column
   for (int iter=0; iter < numIterationsToCompleteColumnList; iter++)
@@ -1871,8 +2220,12 @@ short CmpSeabaseDDL::createSeabaseTable2(
       if (buildColInfoArray(COM_BASE_TABLE_OBJECT,
                             &colArray, colInfoArray, implicitPK,
                             alignedFormat, &identityColPos,
-                            &userColFamVec, &trafColFamVec, defaultColFam.data()))
+                            (hbaseMapFormat ? NULL : &userColFamVec), 
+                            &trafColFamVec, 
+                            defaultColFam.data()))
         {
+          resetHbaseSerialization(hbaseSerialization, hbVal);
+
           processReturn();
 
           return -1;
@@ -1882,6 +2235,8 @@ short CmpSeabaseDDL::createSeabaseTable2(
                             &keyArray, colInfoArray, keyInfoArray, 
                             allowNullableUniqueConstr))
         {
+          resetHbaseSerialization(hbaseSerialization, hbVal);
+
           processReturn();
 
           return -1;
@@ -1918,6 +2273,8 @@ short CmpSeabaseDDL::createSeabaseTable2(
                                           STMTHEAP);
               if (!boundDivExpr)
                 {
+                  resetHbaseSerialization(hbaseSerialization, hbVal);
+
                   processReturn();
 
                   return -1;
@@ -1955,6 +2312,8 @@ short CmpSeabaseDDL::createSeabaseTable2(
               if (exceptionOccurred ||
                   boundDivExpr->getValueId() == NULL_VALUE_ID)
                 {
+                  resetHbaseSerialization(hbaseSerialization, hbVal);
+
                   processReturn();
 
                   return -1;
@@ -1962,6 +2321,8 @@ short CmpSeabaseDDL::createSeabaseTable2(
 
               if (validateDivisionByExprForDDL(boundDivExpr))
                 {
+                  resetHbaseSerialization(hbaseSerialization, hbVal);
+
                   processReturn();
 
                   return -1;
@@ -2004,6 +2365,12 @@ short CmpSeabaseDDL::createSeabaseTable2(
 
      } // iterate 1 or 2 times to get all columns, including divisioning columns
 
+  if (hbaseSerialization)
+    {
+      ActiveSchemaDB()->getDefaults().validateAndInsert
+        ("hbase_serialization", hbVal, FALSE);
+    }
+
   Int32 keyLength = 0;
 
   for(CollIndex i = 0; i < keyArray.entries(); i++) 
@@ -2038,6 +2405,46 @@ short CmpSeabaseDDL::createSeabaseTable2(
       keyLength += colType->getEncodedKeyLength();
     }
 
+  if (hbaseMapFormat)
+    {
+      for(CollIndex i = 0; i < colArray.entries(); i++) 
+        {
+          const NAString colName = colInfoArray[i].colName;
+          Lng32      colIx    = keyArray.getColumnIndex(colName);
+          if (colIx < 0) // not a key col
+            {
+              if (colInfoArray[i].defaultClass != COM_NULL_DEFAULT)
+                {
+                  *CmpCommon::diags() << DgSqlCode(-3242)
+                                      << DgString0("Non-key columns of an HBase mapped table must be nullable with default value of NULL.");
+                  
+                  deallocEHI(ehi); 
+                  
+                  processReturn();
+                  
+                  return -1;
+                }
+
+              // must have a default value if not nullable
+              if (! colInfoArray[i].nullable)
+                {
+                  if (colInfoArray[i].defaultClass == COM_NO_DEFAULT)
+                    {
+                      *CmpCommon::diags() << DgSqlCode(-3242)
+                                          << DgString0("Non-key non-nullable columns of an HBase mapped table must have a default value.");
+                      
+                      deallocEHI(ehi); 
+                      
+                      processReturn();
+                      
+                      return -1;
+                    }
+
+                }
+            }          
+        } // for
+    }
+
   char ** encodedKeysBuffer = NULL;
   if (numSplits > 0) {
 
@@ -2112,7 +2519,12 @@ short CmpSeabaseDDL::createSeabaseTable2(
   tableInfo->schemaOwnerID = schemaOwnerID;
 
   tableInfo->numSaltPartns = (numSplits > 0 ? numSplits+1 : 0);
-  tableInfo->rowFormat = (alignedFormat ? COM_ALIGNED_FORMAT_TYPE : COM_HBASE_FORMAT_TYPE);
+  if (hbaseMapFormat && hbaseMappedDataFormatIsString)
+    tableInfo->rowFormat = COM_HBASE_STR_FORMAT_TYPE;
+  else if (alignedFormat)
+    tableInfo->rowFormat = COM_ALIGNED_FORMAT_TYPE;
+  else
+    tableInfo->rowFormat = COM_HBASE_FORMAT_TYPE;
 
   NAList<HbaseCreateOption*> hbaseCreateOptions(STMTHEAP);
   NAString hco;
@@ -2298,25 +2710,28 @@ short CmpSeabaseDDL::createSeabaseTable2(
     }
   
   NABoolean ddlXns = createTableNode->ddlXns();
-  HbaseStr hbaseTable;
-  hbaseTable.val = (char*)extNameForHbase.data();
-  hbaseTable.len = extNameForHbase.length();
-  if (createHbaseTable(ehi, &hbaseTable, trafColFamVec,
-                       &hbaseCreateOptions, 
-                       numSplits, keyLength,
-                       encodedKeysBuffer,
-                       FALSE, ddlXns
-                       ) == -1)
+  if (NOT extNameForHbase.isNull())
     {
-      deallocEHI(ehi); 
-      
-      processReturn();
-      
-      return -2;
-    }
-  
-  // if this table has lob columns, create the lob files
-  short *lobNumList = new (STMTHEAP) short[numCols];
+      HbaseStr hbaseTable;
+      hbaseTable.val = (char*)extNameForHbase.data();
+      hbaseTable.len = extNameForHbase.length();
+      if (createHbaseTable(ehi, &hbaseTable, trafColFamVec,
+                           &hbaseCreateOptions, 
+                           numSplits, keyLength,
+                           encodedKeysBuffer,
+                           FALSE, ddlXns
+                           ) == -1)
+        {
+          deallocEHI(ehi); 
+          
+          processReturn();
+          
+          return -2;
+        }
+    }
+
+  // if this table has lob columns, create the lob files
+  short *lobNumList = new (STMTHEAP) short[numCols];
   short *lobTypList = new (STMTHEAP) short[numCols];
   char  **lobLocList = new (STMTHEAP) char*[numCols];
   Lng32 j = 0;
@@ -2439,6 +2854,14 @@ short CmpSeabaseDDL::createSeabaseTable2(
   processReturn();
 
   return 0;
+
+ label_error:
+  if (hbaseSerialization)
+    {
+      ActiveSchemaDB()->getDefaults().validateAndInsert
+        ("hbase_serialization", hbVal, FALSE);
+    }
+  return -1;
 }
 
 void CmpSeabaseDDL::createSeabaseTable(
@@ -2909,6 +3332,74 @@ void CmpSeabaseDDL::createSeabaseTableCompound(
     }
 }
 
+// return: 0, does not exist. 1, exists. -1, error.
+short CmpSeabaseDDL::lookForTableInMD(
+     ExeCliInterface *cliInterface,
+     NAString &catNamePart, NAString &schNamePart, NAString &objNamePart,
+     NABoolean schNameSpecified, NABoolean hbaseMapSpecified,
+     ComObjectName &tableName, NAString &tabName, NAString &extTableName,
+     const ComObjectType objectType)
+{
+  short retcode = 0;
+
+  if ((schNamePart == HBASE_EXT_MAP_SCHEMA) &&
+      (! Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
+    {
+      *CmpCommon::diags() << DgSqlCode(-4261)
+                          << DgSchemaName(schNamePart);
+    
+      return -1;
+    }
+
+  if (NOT hbaseMapSpecified)
+    retcode = existsInSeabaseMDTable
+      (cliInterface, 
+       catNamePart, schNamePart, objNamePart,
+       objectType, //COM_BASE_TABLE_OBJECT,
+       (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
+        ? FALSE : TRUE),
+       TRUE, TRUE);
+  if (retcode < 0)
+    {
+      return -1; // error
+    }
+  
+  if (retcode == 1)
+    return 1; // exists
+
+  if ((retcode == 0) && // does not exist
+      (NOT schNameSpecified))
+    {
+      // if explicit schema name was not specified, 
+      // check to see if this is an hbase mapped table.
+      retcode = existsInSeabaseMDTable
+        (cliInterface, 
+         catNamePart, HBASE_EXT_MAP_SCHEMA, objNamePart,
+         objectType, //COM_BASE_TABLE_OBJECT,
+         (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
+          ? FALSE : TRUE),
+         TRUE, TRUE);
+      if (retcode < 0)
+        {
+          return -1; // error
+        }
+      
+      if (retcode != 0) // exists
+        {
+          schNamePart = HBASE_EXT_MAP_SCHEMA;
+          ComAnsiNamePart mapSchAnsiName
+            (schNamePart, ComAnsiNamePart::INTERNAL_FORMAT);
+          tableName.setSchemaNamePart(mapSchAnsiName);
+          extTableName = tableName.getExternalName(TRUE);
+          tabName = tableName.getExternalName();
+
+          return 1; // exists
+        }
+    }
+
+  return 0; // does not exist
+}
+
 // RETURN:  -1, no need to cleanup.  -2, caller need to call cleanup 
 //                  0, all ok.
 short CmpSeabaseDDL::dropSeabaseTable2(
@@ -2925,6 +3416,10 @@ short CmpSeabaseDDL::dropSeabaseTable2(
   ComObjectName volTabName; 
   ComAnsiNamePart currCatAnsiName(currCatName);
   ComAnsiNamePart currSchAnsiName(currSchName);
+
+  NABoolean schNameSpecified = 
+    (NOT dropTableNode->getOrigTableNameAsQualifiedName().getSchemaName().isNull());
+
   tableName.applyDefaults(currCatAnsiName, currSchAnsiName);
 
   if (dropTableNode->isExternal())
@@ -2942,13 +3437,12 @@ short CmpSeabaseDDL::dropSeabaseTable2(
   NAString catalogNamePart = tableName.getCatalogNamePartAsAnsiString();
   NAString schemaNamePart = tableName.getSchemaNamePartAsAnsiString(TRUE);
   NAString objectNamePart = tableName.getObjectNamePartAsAnsiString(TRUE);
-  const NAString extTableName = tableName.getExternalName(TRUE);
+  NAString extTableName = tableName.getExternalName(TRUE);
   const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
 
   // allowExternalTables: true to allow an NATable entry to be created for an external table
   BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  bindWA.setAllowExternalTables(TRUE);
- 
+
   ExpHbaseInterface * ehi = allocEHI();
   if (ehi == NULL)
     {
@@ -3054,12 +3548,12 @@ short CmpSeabaseDDL::dropSeabaseTable2(
           }
       }
 
-  retcode = existsInSeabaseMDTable(cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
+  retcode = lookForTableInMD(cliInterface, 
+                             catalogNamePart, schemaNamePart, objectNamePart,
+                             schNameSpecified,
+                             (dropTableNode->isExternal() &&
+                              (schemaNamePart == HBASE_EXT_MAP_SCHEMA)),
+                             tableName, tabName, extTableName);
   if (retcode < 0)
     {
       deallocEHI(ehi); 
@@ -3116,6 +3610,9 @@ short CmpSeabaseDDL::dropSeabaseTable2(
   else
      verifyName = tableName;
 
+  if (CmpCommon::getDefault(TRAF_RELOAD_NATABLE_CACHE) == DF_OFF)
+    ActiveSchemaDB()->getNATableDB()->useCache();
+
  // save the current parserflags setting
   ULng32 savedParserFlags = Get_SqlParser_Flags (0xFFFFFFFF);
   Set_SqlParser_Flags(ALLOW_VOLATILE_SCHEMA_IN_TABLE_NAME);
@@ -3126,21 +3623,16 @@ short CmpSeabaseDDL::dropSeabaseTable2(
               catalogNamePart);
 
   bindWA.setExternalTableDrop(TRUE);
-  NATable *naTable = bindWA.getNATable(cn); 
+  NATable *naTable = bindWA.getNATableInternal(cn, TRUE, NULL, TRUE); 
   bindWA.setExternalTableDrop(FALSE);
 
   const NAColumnArray &nacolArr =  naTable->getNAColumnArray();
   // Restore parser flags settings to what they originally were
   Set_SqlParser_Flags (savedParserFlags);
-
   if (naTable == NULL || bindWA.errStatus())
     {
-      CmpCommon::diags()->clear();
-
       if (NOT dropTableNode->dropIfExists())
         {
-          CmpCommon::diags()->clear();
-          
           if (isVolatile)
             *CmpCommon::diags() << DgSqlCode(-CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
                                 << DgString0(objectNamePart);
@@ -3148,7 +3640,9 @@ short CmpSeabaseDDL::dropSeabaseTable2(
             *CmpCommon::diags() << DgSqlCode(-CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
                                 << DgString0(extTableName);
         }
-      
+      else
+        CmpCommon::diags()->clear();
+
       deallocEHI(ehi); 
       processReturn();
 
@@ -3808,10 +4302,15 @@ short CmpSeabaseDDL::dropSeabaseTable2(
     }
      
   //Finally drop the table
+  NABoolean dropFromMD = TRUE;
+  NABoolean dropFromHbase = (NOT tableName.isExternalHbase());
 
+  if (dropTableNode->getDropBehavior() == COM_NO_CHECK_DROP_BEHAVIOR)
+    dropFromHbase = FALSE;
   if (dropSeabaseObject(ehi, tabName,
                         currCatName, currSchName, COM_BASE_TABLE_OBJECT,
-                        dropTableNode->ddlXns()))
+                        dropTableNode->ddlXns(),
+                        dropFromMD, dropFromHbase))
     {
       deallocEHI(ehi); 
       processReturn();
@@ -3931,105 +4430,32 @@ void CmpSeabaseDDL::renameSeabaseTable(
   Lng32 retcode = 0;
   Lng32 cliRC = 0;
 
-  ComObjectName tableName(renameTableNode->getTableName());
-  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);
-  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
-
-  ComObjectName newTableName(renameTableNode->getNewNameAsAnsiString());
-  //  newTableName.applyDefaults(currCatAnsiName, currSchAnsiName);
-  newTableName.applyDefaults(catalogNamePart, schemaNamePart);
-  const NAString newObjectNamePart = newTableName.getObjectNamePartAsAnsiString(TRUE);
-  const NAString newExtTableName = newTableName.getExternalName(TRUE);
-  const NAString newExtNameForHbase = catalogNamePart + "." + schemaNamePart + "." + newObjectNamePart;
-
-  ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
-  
-  ExpHbaseInterface * ehi = allocEHI();
-  if (ehi == NULL)
-    {
-      processReturn();
-
-      return;
-    }
-
   // variables needed to find identity column (have to be declared before
   // the first goto or C++ will moan because of the initializers)
   NABoolean found = FALSE;
   Lng32 idPos = 0;
   NAColumn *col = NULL;
 
-  if ((isSeabaseReservedSchema(tableName)) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CREATE_TABLE_NOT_ALLOWED_IN_SMD)
-                          << DgTableName(extTableName);
-      deallocEHI(ehi); 
-
-      processReturn();
+  ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
+                               CmpCommon::context()->sqlSession()->getParentQid());
 
-      return;
-    }
-  
-  if (CmpCommon::context()->sqlSession()->volatileSchemaInUse())
-    {
-      QualifiedName *qn =
-        CmpCommon::context()->sqlSession()->
-        updateVolatileQualifiedName
-        (renameTableNode->getTableNameAsQualifiedName().getObjectName());
-      
-      if (qn == NULL)
-        {
-          *CmpCommon::diags()
-            << DgSqlCode(-1427);
-          
-          processReturn();
-          
-          return;
-        }
-      
-      ComObjectName volTabName (qn->getQualifiedNameAsAnsiString());
-      volTabName.applyDefaults(currCatAnsiName, currSchAnsiName);
-      
-      NAString vtCatNamePart = volTabName.getCatalogNamePartAsAnsiString();
-      NAString vtSchNamePart = volTabName.getSchemaNamePartAsAnsiString(TRUE);
-      NAString vtObjNamePart = volTabName.getObjectNamePartAsAnsiString(TRUE);
-      
-      retcode = existsInSeabaseMDTable(&cliInterface, 
-                                       vtCatNamePart, vtSchNamePart, vtObjNamePart,
-                                       COM_BASE_TABLE_OBJECT);
-      
-      if (retcode < 0)
-        {
-          processReturn();
-          
-          return;
-        }
-      
-      if (retcode == 1)
-        {
-          // table found in volatile schema. cannot rename it.
-          *CmpCommon::diags()
-            << DgSqlCode(-1427)
-            << DgString0("Reason: Operation not allowed on volatile tables.");
-          
-          processReturn();
-          return;
-        }
-    }
-  
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
+  NAString tabName = renameTableNode->getTableName();
+  NAString catalogNamePart;
+  NAString schemaNamePart;
+  NAString objectNamePart;
+  NAString extTableName;
+  NAString extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        renameTableNode->getOrigTableNameAsQualifiedName(),
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        &naTable, 
+                        FALSE, FALSE,
+                        &cliInterface);
   if (retcode < 0)
     {
       processReturn();
@@ -4037,42 +4463,19 @@ void CmpSeabaseDDL::renameSeabaseTable(
       return;
     }
 
-  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  
-  CorrName cn(objectNamePart,
-              STMTHEAP,
-              schemaNamePart,
-              catalogNamePart);
-  
-  NATable *naTable = bindWA.getNATable(cn); 
-  if (naTable == NULL || bindWA.errStatus())
-    {
-      CmpCommon::diags()->clear();
-      
-      *CmpCommon::diags() << DgSqlCode(-CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
-                          << DgString0(extTableName);
-  
-      processReturn();
-      
-      return;
-    }
- 
-  // Make sure user has the privilege to perform the rename
-  if (!isDDLOperationAuthorized(SQLOperation::ALTER_TABLE,
-                                naTable->getOwner(),naTable->getSchemaOwner()))
-  {
-     *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
-
-     processReturn ();
-
-     return;
-  }
+  ComObjectName newTableName(renameTableNode->getNewNameAsAnsiString());
+  newTableName.applyDefaults(catalogNamePart, schemaNamePart);
+  const NAString newObjectNamePart = newTableName.getObjectNamePartAsAnsiString(TRUE);
+  const NAString newExtTableName = newTableName.getExternalName(TRUE);
+  const NAString newExtNameForHbase = catalogNamePart + "." + schemaNamePart + "." + newObjectNamePart;
 
   CorrName newcn(newObjectNamePart,
                  STMTHEAP,
                  schemaNamePart,
                  catalogNamePart);
   
+  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
+
   NATable *newNaTable = bindWA.getNATable(newcn); 
   if (newNaTable != NULL && (NOT bindWA.errStatus()))
     {
@@ -4199,6 +4602,14 @@ void CmpSeabaseDDL::renameSeabaseTable(
   newHbaseTable.val = (char*)newExtNameForHbase.data();
   newHbaseTable.len = newExtNameForHbase.length();
 
+  ExpHbaseInterface * ehi = allocEHI();
+  if (ehi == NULL)
+    {
+      processReturn();
+      
+      return;
+    }
+
   NABoolean xnWasStartedHere = FALSE;
   if (beginXnIfNotInProgress(&cliInterface, xnWasStartedHere))
     return;
@@ -4297,10 +4708,6 @@ void CmpSeabaseDDL::renameSeabaseTable(
     (cn,
      ComQiScope::REMOVE_FROM_ALL_USERS, COM_BASE_TABLE_OBJECT,
      renameTableNode->ddlXns(), FALSE);
-  ActiveSchemaDB()->getNATableDB()->removeNATable
-    (newcn,
-     ComQiScope::REMOVE_FROM_ALL_USERS, COM_BASE_TABLE_OBJECT,
-     renameTableNode->ddlXns(), FALSE);
 
   deallocEHI(ehi); 
 
@@ -4517,118 +4924,64 @@ void CmpSeabaseDDL::alterSeabaseTableHBaseOptions(
   Lng32 retcode = 0;
   Lng32 cliRC = 0;
 
-  ComObjectName tableName(hbaseOptionsNode->getTableName());
-  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);
-  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
-
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
-  
-  ExpHbaseInterface * ehi = allocEHI();
-  if (ehi == NULL)
+                               CmpCommon::context()->sqlSession()->getParentQid());
+
+  NAString tabName = hbaseOptionsNode->getTableName();
+  NAString catalogNamePart, schemaNamePart, objectNamePart;
+  NAString extTableName, extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        hbaseOptionsNode->getOrigTableNameAsQualifiedName(),
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        &naTable, 
+                        FALSE, FALSE,
+                        &cliInterface);
+  if (retcode < 0)
     {
       processReturn();
       return;
     }
 
-  // Disallow this ALTER on system metadata schema objects
+  CmpCommon::diags()->clear();
 
-  if ((isSeabaseReservedSchema(tableName)) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
+  // Get the object UID so we can update the metadata
+
+  Int64 objUID = getObjectUID(&cliInterface,
+                              catalogNamePart.data(), schemaNamePart.data(), 
+                              objectNamePart.data(),
+                              COM_BASE_TABLE_OBJECT_LIT);
+  if (objUID < 0)
     {
-      *CmpCommon::diags() << DgSqlCode(-CAT_ALTER_NOT_ALLOWED_IN_SMD)
-                          << DgTableName(extTableName);
-      deallocEHI(ehi); 
       processReturn();
       return;
     }
+
+  // update HBase options in the metadata
+
+  ElemDDLHbaseOptions * edhbo = hbaseOptionsNode->getHBaseOptions();
+  short result = updateHbaseOptionsInMetadata(&cliInterface,objUID,edhbo);
   
-  // Note: In the rename code (CmpSeabaseDDL::renameSeabaseTable), there
-  // is logic about here to forbid a rename on a volatile table. There doesn't
-  // seem to be any reason to forbid changing HBASE_OPTIONS on a volatile
-  // table (and indeed it appears to work fine), so we don't have this
-  // 'forbid' logic here.
-  
-  // Make sure this object exists
+  if (result < 0)
+    {
+      processReturn();
+      return;
+    }
 
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
-  if (retcode < 0)
+  // tell HBase to change the options
+
+  ExpHbaseInterface * ehi = allocEHI();
+  if (ehi == NULL)
     {
-      deallocEHI(ehi);
       processReturn();
+      
       return;
     }
 
-  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  
-  CorrName cn(objectNamePart,
-              STMTHEAP,
-              schemaNamePart,
-              catalogNamePart);
-  
-  NATable *naTable = bindWA.getNATable(cn); 
-  if (naTable == NULL || bindWA.errStatus())
-    {
-      CmpCommon::diags()->clear();
-      
-      *CmpCommon::diags() << DgSqlCode(-CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
-                          << DgString0(extTableName);
-      deallocEHI(ehi); 
-      processReturn();     
-      return;
-    }
- 
-  // Make sure user has the privilege to perform the ALTER
-
-  if (!isDDLOperationAuthorized(SQLOperation::ALTER_TABLE,
-                                naTable->getOwner(),naTable->getSchemaOwner()))
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
-      deallocEHI(ehi);
-      processReturn ();
-      return;
-    }
-
-  CmpCommon::diags()->clear();
-
-  // Get the object UID so we can update the metadata
-
-  Int64 objUID = getObjectUID(&cliInterface,
-                              catalogNamePart.data(), schemaNamePart.data(), 
-                              objectNamePart.data(),
-                              COM_BASE_TABLE_OBJECT_LIT);
-  if (objUID < 0)
-    {
-      deallocEHI(ehi);
-      processReturn();
-      return;
-    }
-
-  // update HBase options in the metadata
-
-  ElemDDLHbaseOptions * edhbo = hbaseOptionsNode->getHBaseOptions();
-  short result = updateHbaseOptionsInMetadata(&cliInterface,objUID,edhbo);
-  
-  if (result < 0)
-    {
-      deallocEHI(ehi);
-      processReturn();
-      return;
-    }
-
-  // tell HBase to change the options
-
   HbaseStr hbaseTable;
   hbaseTable.val = (char*)extNameForHbase.data();
   hbaseTable.len = extNameForHbase.length();
@@ -4639,8 +4992,9 @@ void CmpSeabaseDDL::alterSeabaseTableHBaseOptions(
                            hbaseOptionsNode->ddlXns());
   if (result < 0)
     {
-      deallocEHI(ehi);
       processReturn();
+      deallocEHI(ehi);
+
       return;
     }   
 
@@ -4673,7 +5027,8 @@ short CmpSeabaseDDL::createSeabaseTableLike2(
      const NAString &likeTableName,
      NABoolean withPartns,
      NABoolean withoutSalt,
-     NABoolean withoutDivision)
+     NABoolean withoutDivision,
+     NABoolean withoutRowFormat)
 {
   Lng32 retcode = 0;
 
@@ -4682,6 +5037,7 @@ short CmpSeabaseDDL::createSeabaseTableLike2(
   retcode = CmpDescribeSeabaseTable(cn, 3/*createlike*/, buf, buflen, STMTHEAP,
                                     NULL,
                                     withPartns, withoutSalt, withoutDivision,
+                                    withoutRowFormat,
                                     UINT_MAX,
                                     TRUE);
   if (retcode)
@@ -4865,30 +5221,37 @@ void CmpSeabaseDDL::alterSeabaseTableAddColumn(
   Lng32 cliRC = 0;
   Lng32 retcode = 0;
 
-  const NAString &tabName = alterAddColNode->getTableName();
-
-  ComObjectName tableName(tabName, COM_TABLE_NAME);
-  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);
-  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
-
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
                                CmpCommon::context()->sqlSession()->getParentQid());
 
-  if ((isSeabaseReservedSchema(tableName)) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
+  NAString tabName = alterAddColNode->getTableName();
+  NAString catalogNamePart;
+  NAString schemaNamePart;
+  NAString objectNamePart;
+  NAString extTableName;
+  NAString extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        alterAddColNode->getOrigTableNameAsQualifiedName(),
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        &naTable, 
+                        FALSE, TRUE,
+                        &cliInterface);
+  if (retcode < 0)
     {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_DEFINITION_METADATA_SCHEMA);
       processReturn();
       return;
     }
 
+  ComObjectName tableName(tabName, COM_TABLE_NAME);
+  ComAnsiNamePart currCatAnsiName(currCatName);
+  ComAnsiNamePart currSchAnsiName(currSchName);
+  tableName.applyDefaults(currCatAnsiName, currSchAnsiName);
+
   ExpHbaseInterface * ehi = allocEHI();
   if (ehi == NULL)
     {
@@ -4897,72 +5260,6 @@ void CmpSeabaseDDL::alterSeabaseTableAddColumn(
       return;
     }
 
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
-  if (retcode < 0)
-    {
-      processReturn();
-
-      return;
-    }
-
-  if (retcode == 0) // does not exist
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_WRONG_TYPE)
-                          << DgString0(extTableName);
-
-      processReturn();
-
-      return;
-    }
-
-  ActiveSchemaDB()->getNATableDB()->useCache();
-
-  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  CorrName cn(tableName.getObjectNamePart().getInternalName(),
-              STMTHEAP,
-              tableName.getSchemaNamePart().getInternalName(),
-              tableName.getCatalogNamePart().getInternalName());
-
-  NATable *naTable = bindWA.getNATable(cn); 
-  if (naTable == NULL || bindWA.errStatus())
-    {
-      CmpCommon::diags()->clear();
-
-      *CmpCommon::diags()
-        << DgSqlCode(-4082)
-        << DgTableName(cn.getExposedNameAsAnsiString());
-
-      processReturn();
-
-      return;
-    }
-
-  // Make sure user has the privilege to perform the add column
-  if (!isDDLOperationAuthorized(SQLOperation::ALTER_TABLE,
-                                naTable->getOwner(),naTable->getSchemaOwner()))
-  {
-     *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
-
-     processReturn ();
-
-     return;
-  }
-
-  // return an error if trying to add a column to a volatile table
-  if (naTable->isVolatileTable())
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_REGULAR_OPERATION_ON_VOLATILE_OBJECT);
-
-      processReturn ();
-
-      return;
-    }
-
   const NAColumnArray &nacolArr = naTable->getNAColumnArray();
 
   ElemDDLColDefArray ColDefArray = alterAddColNode->getColDefArray();
@@ -5029,18 +5326,37 @@ void CmpSeabaseDDL::alterSeabaseTableAddColumn(
   ULng32 hbaseColFlags;
   Int64 colFlags;
   LobsStorage lobStorage;
-  if (getColInfo(pColDef,
-                 colFamily,
-		 colName, 
-                 naTable->isSQLMXAlignedTable(),
-		 datatype, length, precision, scale, dt_start, dt_end, upshifted, nullable,
-		 charset, colClass, defaultClass, defVal, heading, lobStorage, hbaseColFlags, colFlags))
+
+  // if hbase map format, turn off global serialization default to off.
+  NABoolean hbaseSerialization = FALSE;
+  NAString hbVal;
+  if (naTable->isHbaseMapTable())
     {
-      processReturn();
-      
-      return;
+      if (CmpCommon::getDefault(HBASE_SERIALIZATION) == DF_ON)
+        {
+          NAString value("OFF");
+          hbVal = "ON";
+          ActiveSchemaDB()->getDefaults().validateAndInsert(
+               "hbase_serialization", value, FALSE);
+          hbaseSerialization = TRUE;
+        }
     }
 
+  retcode = getColInfo(pColDef,
+                       colFamily,
+                       colName, 
+                       naTable->isSQLMXAlignedTable(),
+                       datatype, length, precision, scale, dt_start, dt_end, upshifted, nullable,
+                       charset, colClass, defaultClass, defVal, heading, lobStorage, hbaseColFlags, colFlags);
+
+  if (hbaseSerialization)
+    {
+      ActiveSchemaDB()->getDefaults().validateAndInsert
+        ("hbase_serialization", hbVal, FALSE);
+    }
+  if (retcode)
+    return;
+
   if ((CmpCommon::getDefault(TRAF_ALLOW_RESERVED_COLNAMES) == DF_OFF) &&
       (ComTrafReservedColName(colName)))
     {
@@ -5060,7 +5376,8 @@ void CmpSeabaseDDL::alterSeabaseTableAddColumn(
   NABoolean addFam = FALSE;
   NAString trafColFam;
 
-  if (colFamily == SEABASE_DEFAULT_COL_FAMILY)
+  if ((colFamily == SEABASE_DEFAULT_COL_FAMILY) ||
+      (naTable->isHbaseMapTable()))
     trafColFam = colFamily;
   else
     {
@@ -5644,7 +5961,7 @@ short CmpSeabaseDDL::hbaseFormatTableDropColumn(
      const NAString &schemaNamePart,
      const NAString &objectNamePart,
      const NATable * naTable,
-     const NAString &altColName,
+     const NAString &dropColName,
      const NAColumn * nacol,
      NABoolean ddlXns,
      NAList<NAString> &viewNameList,
@@ -5653,7 +5970,8 @@ short CmpSeabaseDDL::hbaseFormatTableDropColumn(
   Lng32 cliRC = 0;
 
   const NAString extNameForHbase = 
-    catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
+    (naTable->isHbaseMapTable() ? objectNamePart :
+     (catalogNamePart + "." + schemaNamePart + "." + objectNamePart));
 
   ExeCliInterface cliInterface(
        STMTHEAP, NULL, NULL, 
@@ -5682,28 +6000,35 @@ short CmpSeabaseDDL::hbaseFormatTableDropColumn(
   {
     NAString column(nacol->getHbaseColFam(), heap_);
     column.append(":");
-    
-    char * colQualPtr = (char*)nacol->getHbaseColQual().data();
-    Lng32 colQualLen = nacol->getHbaseColQual().length();
-    Int64 colQval = str_atoi(colQualPtr, colQualLen);
-    if (colQval <= UCHAR_MAX)
-      {
-        unsigned char c = (unsigned char)colQval;
-        column.append((char*)&c, 1);
-      }
-    else if (colQval <= USHRT_MAX)
+   
+    if (naTable->isHbaseMapTable())
       {
-        unsigned short s = (unsigned short)colQval;
-        column.append((char*)&s, 2);
+        column.append(dropColName);
       }
-    else if (colQval <= ULONG_MAX)
+    else
       {
-        Lng32 l = (Lng32)colQval;
-        column.append((char*)&l, 4);
+        char * colQualPtr = (char*)nacol->getHbaseColQual().data();
+        Lng32 colQualLen = nacol->getHbaseColQual().length();
+        Int64 colQval = str_atoi(colQualPtr, colQualLen);
+        if (colQval <= UCHAR_MAX)
+          {
+            unsigned char c = (unsigned char)colQval;
+            column.append((char*)&c, 1);
+          }
+        else if (colQval <= USHRT_MAX)
+          {
+            unsigned short s = (unsigned short)colQval;
+            column.append((char*)&s, 2);
+          }
+        else if (colQval <= ULONG_MAX)
+          {
+            Lng32 l = (Lng32)colQval;
+            column.append((char*)&l, 4);
+          }
+        else
+          column.append((char*)&colQval, 8);
       }
-    else
-      column.append((char*)&colQval, 8);
-    
+        
     HbaseStr colNameStr;
     char * col = (char *) heap_->allocateMemory(column.length() + 1, FALSE);
     if (col)
@@ -5739,7 +6064,7 @@ short CmpSeabaseDDL::hbaseFormatTableDropColumn(
     {
       NAString reason = "Error occurred while recreating views due to dependency on older column definition. Drop dependent views before doing the alter.";
       *CmpCommon::diags() << DgSqlCode(-1404)
-                          << DgColumnName(altColName)
+                          << DgColumnName(dropColName)
                           << DgString0(reason);
       goto label_error;
     }
@@ -5761,98 +6086,26 @@ void CmpSeabaseDDL::alterSeabaseTableDropColumn(
   Lng32 cliRC = 0;
   Lng32 retcode = 0;
 
-  const NAString &tabName = alterDropColNode->getTableName();
-
-  ComObjectName tableName(tabName, COM_TABLE_NAME);
-  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);
-  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
-
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
-
-  if ((isSeabaseReservedSchema(tableName)) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_DEFINITION_METADATA_SCHEMA);
-      processReturn();
-      return;
-    }
-
-  ExpHbaseInterface * ehi = allocEHI();
-  if (ehi == NULL)
-    {
-      processReturn();
-      return;
-    }
+                               CmpCommon::context()->sqlSession()->getParentQid());
 
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
+  NAString tabName = alterDropColNode->getTableName();
+  NAString catalogNamePart, schemaNamePart, objectNamePart;
+  NAString extTableName, extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        alterDropColNode->getOrigTableNameAsQualifiedName(),
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        &naTable, 
+                        FALSE, TRUE,
+                        &cliInterface);
   if (retcode < 0)
     {
       processReturn();
-
-      return;
-    }
-
-  if (retcode == 0) // does not exist
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_WRONG_TYPE)
-                          << DgString0(extTableName);
-
-      processReturn();
-
-      return;
-    }
-
-  ActiveSchemaDB()->getNATableDB()->useCache();
-
-  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  CorrName cn(tableName.getObjectNamePart().getInternalName(),
-              STMTHEAP,
-              tableName.getSchemaNamePart().getInternalName(),
-              tableName.getCatalogNamePart().getInternalName());
-
-  const NATable *naTable = bindWA.getNATable(cn); 
-  if (naTable == NULL || bindWA.errStatus())
-    {
-      *CmpCommon::diags()
-        << DgSqlCode(-4082)
-        << DgTableName(cn.getExposedNameAsAnsiString());
-    
-      processReturn();
-
-      return;
-    }
-
-  // Make sure user has the privilege to perform the drop column
-  if (!isDDLOperationAuthorized(SQLOperation::ALTER_TABLE,
-                                naTable->getOwner(),naTable->getSchemaOwner()))
-  {
-     *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
-
-     processReturn ();
-
-     return;
-  }
-
-  // return an error if trying to drop a column from a volatile table
-  if (naTable->isVolatileTable())
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_REGULAR_OPERATION_ON_VOLATILE_OBJECT);
-     
-      processReturn ();
-
       return;
     }
 
@@ -5942,6 +6195,8 @@ void CmpSeabaseDDL::alterSeabaseTableDropColumn(
       return;
     }
 
+  ExpHbaseInterface * ehi = NULL;
+
   Int64 objUID = naTable->objectUid().castToInt64();
 
   NAList<NAString> viewNameList(STMTHEAP);
@@ -5978,6 +6233,7 @@ void CmpSeabaseDDL::alterSeabaseTableDropColumn(
      }
   else
     {
+      ehi = allocEHI();
       if (hbaseFormatTableDropColumn
           (
                ehi,
@@ -6042,49 +6298,26 @@ void CmpSeabaseDDL::alterSeabaseTableAlterIdentityColumn(
   Lng32 cliRC = 0;
   Lng32 retcode = 0;
 
-  const NAString &tabName = alterIdentityColNode->getTableName();
-
-  ComObjectName tableName(tabName, COM_TABLE_NAME);
-  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);
-
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
+                               CmpCommon::context()->sqlSession()->getParentQid());
 
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
+  NAString tabName = alterIdentityColNode->getTableName();
+  NAString catalogNamePart, schemaNamePart, objectNamePart;
+  NAString extTableName, extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        alterIdentityColNode->getOrigTableNameAsQualifiedName(),
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        &naTable, 
+                        FALSE, FALSE,
+                        &cliInterface);
   if (retcode < 0)
     {
       processReturn();
-
-      return;
-    }
-
-  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  CorrName cn(tableName.getObjectNamePart().getInternalName(),
-              STMTHEAP,
-              tableName.getSchemaNamePart().getInternalName(),
-              tableName.getCatalogNamePart().getInternalName());
-
-  NATable *naTable = bindWA.getNATable(cn); 
-  if (naTable == NULL || bindWA.errStatus())
-    {
-      *CmpCommon::diags()
-        << DgSqlCode(-4082)
-        << DgTableName(cn.getExposedNameAsAnsiString());
-    
-      processReturn();
-
       return;
     }
 
@@ -6834,36 +7067,23 @@ void CmpSeabaseDDL::alterSeabaseTableAlterColumnDatatype(
   Lng32 cliRC = 0;
   Lng32 retcode = 0;
 
-  const NAString &tabName = alterColNode->getTableName();
-
-  ComObjectName tableName(tabName, COM_TABLE_NAME);
-  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);
-  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
-
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
-
-  if ((isSeabaseReservedSchema(tableName)) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_DEFINITION_METADATA_SCHEMA);
-      processReturn();
-      return;
-    }
+                               CmpCommon::context()->sqlSession()->getParentQid());
 
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
+  NAString tabName = alterColNode->getTableName();
+  NAString catalogNamePart, schemaNamePart, objectNamePart;
+  NAString extTableName, extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        alterColNode->getOrigTableNameAsQualifiedName(),
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        &naTable, 
+                        FALSE, FALSE,
+                        &cliInterface);
   if (retcode < 0)
     {
       processReturn();
@@ -6871,57 +7091,6 @@ void CmpSeabaseDDL::alterSeabaseTableAlterColumnDatatype(
       return;
     }
 
-  if (retcode == 0) // does not exist
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_WRONG_TYPE)
-                          << DgString0(extTableName);
-
-      processReturn();
-
-      return;
-    }
-
-  ActiveSchemaDB()->getNATableDB()->useCache();
-
-  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  CorrName cn(tableName.getObjectNamePart().getInternalName(),
-              STMTHEAP,
-              tableName.getSchemaNamePart().getInternalName(),
-              tableName.getCatalogNamePart().getInternalName());
-
-  NATable *naTable = bindWA.getNATable(cn); 
-  if (naTable == NULL || bindWA.errStatus())
-    {
-      *CmpCommon::diags()
-        << DgSqlCode(-4082)
-        << DgTableName(cn.getExposedNameAsAnsiString());
-    
-      processReturn();
-
-      return;
-    }
-
-  // Make sure user has the privilege to perform the alter column
-  if (!isDDLOperationAuthorized(SQLOperation::ALTER_TABLE,
-                                naTable->getOwner(),naTable->getSchemaOwner()))
-  {
-     *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
-
-     processReturn ();
-
-     return;
-  }
-
-  // return an error if trying to alter a column from a volatile table
-  if (naTable->isVolatileTable())
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_REGULAR_OPERATION_ON_VOLATILE_OBJECT);
-     
-      processReturn ();
-
-      return;
-    }
-
   ElemDDLColDef *pColDef = alterColNode->getColToAlter()->castToElemDDLColDef();
   
   const NAColumnArray &nacolArr = naTable->getNAColumnArray();
@@ -7477,7 +7646,7 @@ void CmpSeabaseDDL::alterSeabaseTableAlterColumnRename(
     {
       return;
     }
-  
+
   ActiveSchemaDB()->getNATableDB()->removeNATable
     (cn,
      ComQiScope::REMOVE_FROM_ALL_USERS,
@@ -7496,29 +7665,8 @@ void CmpSeabaseDDL::alterSeabaseTableAddPKeyConstraint(
   Lng32 cliRC = 0;
   Lng32 retcode = 0;
 
-  const NAString &tabName = alterAddConstraint->getTableName();
-
-  ComObjectName tableName(tabName, COM_TABLE_NAME);
-  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);
-  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
-
-  if ((isSeabaseReservedSchema(tableName)) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_DEFINITION_METADATA_SCHEMA);
-      processReturn();
-      return;
-    }
-
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
+                               CmpCommon::context()->sqlSession()->getParentQid());
 
   ExpHbaseInterface * ehi = allocEHI();
   if (ehi == NULL)
@@ -7527,52 +7675,26 @@ void CmpSeabaseDDL::alterSeabaseTableAddPKeyConstraint(
       return;
     }
 
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
+  NAString tabName = alterAddConstraint->getTableName();
+  NAString catalogNamePart, schemaNamePart, objectNamePart;
+  NAString extTableName, extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        alterAddConstraint->getOrigTableNameAsQualifiedName(),
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        &naTable, 
+                        FALSE, FALSE,
+                        &cliInterface);
   if (retcode < 0)
     {
       processReturn();
-
-      return;
-    }
-
-  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  CorrName cn(tableName.getObjectNamePart().getInternalName(),
-              STMTHEAP,
-              tableName.getSchemaNamePart().getInternalName(),
-              tableName.getCatalogNamePart().getInternalName());
-
-  NATable *naTable = bindWA.getNATable(cn); 
-  if (naTable == NULL || bindWA.errStatus())
-    {
-      *CmpCommon::diags()
-        << DgSqlCode(-4082)
-        << DgTableName(cn.getExposedNameAsAnsiString());
-
-      deallocEHI(ehi); 
-
-      processReturn();
-      
       return;
     }
 
-  // Make sure user has the privilege to perform the add pk constraint
-  if (!isDDLOperationAuthorized(SQLOperation::ALTER_TABLE,
-                                naTable->getOwner(),naTable->getSchemaOwner()))
-  {
-     *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
-
-     deallocEHI(ehi); 
-
-     processReturn ();
-
-     return;
-  }
-
   ElemDDLColRefArray &keyColumnArray = alterAddConstraint->getConstraint()->castToElemDDLConstraintPK()->getKeyColumnArray();
 
   NAList<NAString> keyColList(HEAP, keyColumnArray.entries());
@@ -7769,8 +7891,6 @@ void CmpSeabaseDDL::alterSeabaseTableAddPKeyConstraint(
     {
       processReturn();
 
-      deallocEHI(ehi);
-
       return;
     }
 
@@ -7794,29 +7914,8 @@ void CmpSeabaseDDL::alterSeabaseTableAddUniqueConstraint(
   Lng32 cliRC = 0;
   Lng32 retcode = 0;
 
-  const NAString &tabName = alterAddConstraint->getTableName();
-
-  ComObjectName tableName(tabName, COM_TABLE_NAME);
-  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);
-  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
-
-  if ((isSeabaseReservedSchema(tableName)) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_DEFINITION_METADATA_SCHEMA);
-      processReturn();
-      return;
-    }
-
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
+                               CmpCommon::context()->sqlSession()->getParentQid());
 
   ExpHbaseInterface * ehi = allocEHI();
   if (ehi == NULL)
@@ -7825,52 +7924,26 @@ void CmpSeabaseDDL::alterSeabaseTableAddUniqueConstraint(
       return;
     }
 
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
+  NAString tabName = alterAddConstraint->getTableName();
+  NAString catalogNamePart, schemaNamePart, objectNamePart;
+  NAString extTableName, extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        alterAddConstraint->getOrigTableNameAsQualifiedName(),
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        &naTable, 
+                        FALSE, FALSE,
+                        &cliInterface);
   if (retcode < 0)
     {
       processReturn();
-
-      return;
-    }
-
-  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  CorrName cn(tableName.getObjectNamePart().getInternalName(),
-              STMTHEAP,
-              tableName.getSchemaNamePart().getInternalName(),
-              tableName.getCatalogNamePart().getInternalName());
-
-  NATable *naTable = bindWA.getNATable(cn); 
-  if (naTable == NULL || bindWA.errStatus())
-    {
-      *CmpCommon::diags()
-        << DgSqlCode(-4082)
-        << DgTableName(cn.getExposedNameAsAnsiString());
-
-      deallocEHI(ehi); 
-
-      processReturn();
-      
       return;
     }
 
-  // Make sure user has the privilege to perform the create unique constraint
-  if (!isDDLOperationAuthorized(SQLOperation::ALTER_TABLE,
-                                naTable->getOwner(),naTable->getSchemaOwner()))
-  {
-     *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
-
-     deallocEHI(ehi); 
-
-     processReturn ();
-
-     return;
-  }
-
   ElemDDLColRefArray &keyColumnArray = alterAddConstraint->getConstraint()->castToElemDDLConstraintUnique()->getKeyColumnArray();
 
   NAList<NAString> keyColList(HEAP, keyColumnArray.entries());
@@ -7949,8 +8022,6 @@ void CmpSeabaseDDL::alterSeabaseTableAddUniqueConstraint(
     {
       processReturn();
 
-      deallocEHI(ehi);
-
       return;
     }
 
@@ -8101,6 +8172,18 @@ void CmpSeabaseDDL::alterSeabaseTableAddRIConstraint(
      return;
   }
 
+  if (ringNaTable->isHbaseMapTable())
+    {
+      // not supported
+      *CmpCommon::diags() << DgSqlCode(-3242)
+                          << DgString0("This alter option cannot be used for an HBase mapped table.");
+
+      deallocEHI(ehi); 
+      processReturn();
+      
+      return;
+    }
+
   const ElemDDLConstraintRI *constraintNode = 
     alterAddConstraint->getConstraint()->castToElemDDLConstraintRI();
   ComObjectName referencedTableName( constraintNode->getReferencedTableName()
@@ -8160,6 +8243,18 @@ void CmpSeabaseDDL::alterSeabaseTableAddRIConstraint(
       return;
     }
 
+  if (refdNaTable->isHbaseMapTable())
+    {
+      // not supported
+      *CmpCommon::diags() << DgSqlCode(-3242)
+                          << DgString0("This alter option cannot be used for an HBase mapped table.");
+
+      deallocEHI(ehi); 
+      processReturn();
+      
+      return;
+    }
+
   // If the referenced and referencing tables are the same, 
   // reject the request.  At this time, we do not allow self
   // referencing constraints.
@@ -8810,83 +8905,29 @@ void CmpSeabaseDDL::alterSeabaseTableAddCheckConstraint(
   Lng32 cliRC = 0;
   Lng32 retcode = 0;
 
-  const NAString &tabName = alterAddConstraint->getTableName();
-
-  ComObjectName tableName(tabName, COM_TABLE_NAME);
-  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);
-  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
-
-  if ((isSeabaseReservedSchema(tableName)) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_DEFINITION_METADATA_SCHEMA);
-      processReturn();
-      return;
-    }
-
-  ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
-
-  ExpHbaseInterface * ehi = allocEHI();
-  if (ehi == NULL)
-    {
-      processReturn();
-      return;
-    }
+ ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
+                               CmpCommon::context()->sqlSession()->getParentQid());
 
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
+  NAString tabName = alterAddConstraint->getTableName();
+  NAString catalogNamePart, schemaNamePart, objectNamePart;
+  NAString extTableName, extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        alterAddConstraint->getOrigTableNameAsQualifiedName(),
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        &naTable, 
+                        FALSE, FALSE,
+                        &cliInterface);
   if (retcode < 0)
     {
       processReturn();
-
-      return;
-    }
-
-  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  CorrName cn(tableName.getObjectNamePart().getInternalName(),
-              STMTHEAP,
-              tableName.getSchemaNamePart().getInternalName(),
-              tableName.getCatalogNamePart().getInternalName());
-
-  NATable *naTable = bindWA.getNATable(cn); 
-  if (naTable == NULL || bindWA.errStatus())
-    {
-      *CmpCommon::diags()
-        << DgSqlCode(-4082)
-        << DgTableName(cn.getExposedNameAsAnsiString());
-
-      deallocEHI(ehi); 
-
-      processReturn();
-      
       return;
     }
 
-  // Make sure user has the privilege to perform the add check constraint
-  if (!isDDLOperationAuthorized(SQLOperation::ALTER_TABLE,
-                                naTable->getOwner(),naTable->getSchemaOwner()))
-  {
-     *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
-
-     deallocEHI(ehi); 
-
-     processReturn ();
-
-     return;
-  }
-
   const ParCheckConstraintColUsageList &colList = 
     alterAddCheckNode->getColumnUsageList();
   for (CollIndex cols = 0; cols < colList.entries(); cols++)
@@ -8901,8 +8942,6 @@ void CmpSeabaseDDL::alterSeabaseTableAddCheckConstraint(
                               << DgTableName(extTableName);
           
           processReturn();
-          
-          deallocEHI(ehi); 
 
           return;
         }
@@ -8941,9 +8980,9 @@ void CmpSeabaseDDL::alterSeabaseTableAddCheckConstraint(
       char * validQry = new(STMTHEAP) char[checkConstrText.length() + 2000];
       
       str_sprintf(validQry, "select count(*) from \"%s\".\"%s\".\"%s\" where not %s",
-                  tableName.getCatalogNamePart().getInternalName().data(),
-                  tableName.getSchemaNamePart().getInternalName().data(),
-                  tableName.getObjectNamePart().getInternalName().data(),
+                  catalogNamePart.data(), 
+                  schemaNamePart.data(), 
+                  objectNamePart.data(),
                   checkConstrText.data());
       
       Lng32 len = 0;
@@ -8996,8 +9035,6 @@ void CmpSeabaseDDL::alterSeabaseTableAddCheckConstraint(
     {
       processReturn();
 
-      deallocEHI(ehi);
-
       return;
     }
 
@@ -9021,84 +9058,29 @@ void CmpSeabaseDDL::alterSeabaseTableDropConstraint(
   Lng32 cliRC = 0;
   Lng32 retcode = 0;
 
-  const NAString &tabName = alterDropConstraint->getTableName();
-
-  ComObjectName tableName(tabName, COM_TABLE_NAME);
-  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);
-  const NAString extNameForHbase = catalogNamePart + "." + schemaNamePart + "." + objectNamePart;
-
-  if ((isSeabaseReservedSchema(tableName)) &&
-      (!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
-    {
-      *CmpCommon::diags() << DgSqlCode(-CAT_CANNOT_ALTER_DEFINITION_METADATA_SCHEMA);
-      processReturn();
-      return;
-    }
-
   ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, 
-  CmpCommon::context()->sqlSession()->getParentQid());
-
-  ExpHbaseInterface * ehi = allocEHI();
-  if (ehi == NULL)
-    {
-      processReturn();
-      return;
-    }
+                               CmpCommon::context()->sqlSession()->getParentQid());
 
-  retcode = existsInSeabaseMDTable(&cliInterface, 
-                                   catalogNamePart, schemaNamePart, objectNamePart,
-                                   COM_BASE_TABLE_OBJECT,
-                                   (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL) 
-                                    ? FALSE : TRUE),
-                                   TRUE, TRUE);
+  NAString tabName = alterDropConstraint->getTableName();
+  NAString catalogNamePart, schemaNamePart, objectNamePart;
+  NAString extTableName, extNameForHbase;
+  NATable * naTable = NULL;
+  CorrName cn;
+  retcode = 
+    setupAndErrorChecks(tabName, 
+                        alterDropConstraint->getOrigTableNameAsQualifiedName(),
+                        currCatName, currSchName,
+                        catalogNamePart, schemaNamePart, objectNamePart,
+                        extTableName, extNameForHbase, cn,
+                        &naTable, 
+                        FALSE, FALSE,
+                        &cliInterface);
   if (retcode < 0)
     {
       processReturn();
-
-      return;
-    }
-
-  ActiveSchemaDB()->getNATableDB()->useCache();
-
-  BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
-  CorrName cn(tableName.getObjectNamePart().getInternalName(),
-              STMTHEAP,
-              tableName.getSchemaNamePart().getInternalName(),
-              tableName.getCatalogNamePart().getInternalName());
-
-  NATable *naTable = bindWA.getNATable(cn); 
-  if (naTable == NULL || bindWA.errStatus())
-    {
-      *CmpCommon::diags()
-        << DgSqlCode(-4082)
-        << DgTableName(cn.getExposedNameAsAnsiString());
-
-      deallocEHI(ehi); 
-
-      processReturn();
       return;
     }
 
-  // Make sure user has the privilege to perform the drop constraint
-  if (!isDDLOperationAuthorized(SQLOperation::ALTER_TABLE,
-                                naTable->getOwner(),naTable->getSchemaOwner()))
-  {
-     *CmpCommon::diags() << DgSqlCode(-CAT_NOT_AUTHORIZED);
-
-     deallocEHI(ehi); 
-
-     processReturn ();
-
-     return;
-  }
-
   const NAString &dropConstrName = alterDropConstraint->
     getConstraintNameAsQualifiedName().getQualifiedNameAsAnsiString();
   const NAString &constrCatName = alterDropConstraint->
@@ -9156,7 +9138,6 @@ void CmpSeabaseDDL::alterSeabaseTableDropConstraint(
                   *CmpCommon::diags()
                     << DgSqlCode(-1050);
                   
-                  deallocEHI(ehi);
                   processReturn();
                   return;
                 }
@@ -9217,11 +9198,11 @@ void CmpSeabaseDDL::alterSeabaseTableDropConstraint(
         }
 
       CorrName otherCN(refConstr->getUniqueConstraintReferencedByMe().getTableName());
+      BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
+
       otherNaTable = bindWA.getNATable(otherCN);
       if (otherNaTable == NULL || bindWA.errStatus())
         {
-          deallocEHI(ehi); 
-          
           processReturn();
           
           return;
@@ -9351,8 +9332,6 @@ void CmpSeabaseDDL::alterSeabaseTableDropConstraint(
     {
       processReturn();
 
-      deallocEHI(ehi);
-
       return;
     }
 
@@ -9377,8 +9356,6 @@ void CmpSeabaseDDL::alterSeabaseTableDropConstraint(
         {
           processReturn();
           
-          deallocEHI(ehi);
-          
           return;
         }
       
@@ -10858,6 +10835,7 @@ TrafDesc * CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName,
   NABoolean isAudited = TRUE;
   Lng32 numSaltPartns = 0;
   NABoolean alignedFormat = FALSE;
+  NABoolean hbaseStrDataFormat = FALSE;
   NAString *  hbaseCreateOptions = new(STMTHEAP) NAString();
   NAString colFamStr;
   if (cliRC == 0) // read some rows
@@ -10878,9 +10856,9 @@ TrafDesc * CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName,
 
       char * format = vi->get(2);
       alignedFormat = (memcmp(format, COM_ALIGNED_FORMAT_LIT, 2) == 0);
-     
+      hbaseStrDataFormat = (memcmp(format, COM_HBASE_STR_FORMAT_LIT, 2) == 0);
+      
       tablesFlags = *(Int64*)vi->get(3);
-
       if (getTextFromMD(&cliInterface, objUID, COM_HBASE_OPTIONS_TEXT, 0,
                         *hbaseCreateOptions))
         {
@@ -11033,9 +11011,6 @@ TrafDesc * CmpSeabaseDDL::getSeabaseUserTableDesc(const NAString &catName,


<TRUNCATED>


[4/7] incubator-trafodion git commit: TRAFODION-1586 Add support for external Traf tables mappedd to HBase tables

Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/generator/GenRelUpdate.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelUpdate.cpp b/core/sql/generator/GenRelUpdate.cpp
index 6d3975b..f3dbf58 100644
--- a/core/sql/generator/GenRelUpdate.cpp
+++ b/core/sql/generator/GenRelUpdate.cpp
@@ -690,6 +690,7 @@ short HbaseDelete::codeGen(Generator * generator)
   NABoolean returnRow = getReturnRow(this, getIndexDesc());
 
   NABoolean isAlignedFormat = getTableDesc()->getNATable()->isAlignedFormat(getIndexDesc());
+  NABoolean isHbaseMapFormat = getTableDesc()->getNATable()->isHbaseMapTable();
 
   ExpTupleDesc::TupleDataFormat asciiRowFormat = 
     (isAlignedFormat ?
@@ -735,7 +736,6 @@ short HbaseDelete::codeGen(Generator * generator)
 		       getSearchKey(),
 		       NULL, //getMdamKeyPtr(),
 		       FALSE,
-		       0,
 		       ExpTupleDesc::SQLMX_KEY_FORMAT);
 
   UInt32 keyColValLen = 0;
@@ -964,6 +964,12 @@ short HbaseDelete::codeGen(Generator * generator)
   ULng32 rowIdLength = 0;
   if (getTableDesc()->getNATable()->isSeabaseTable())
     {
+      // dont encode keys for hbase mapped tables since these tables
+      // could be populated from outside of traf.
+      NABoolean encodeKeys = TRUE;
+      if (getTableDesc()->getNATable()->isHbaseMapTable())
+        encodeKeys = FALSE;
+
       HbaseAccess::genRowIdExpr(generator,
 				getIndexDesc()->getNAFileSet()->getIndexKeyColumns(),
 				getHbaseSearchKeys(), 
@@ -971,7 +977,8 @@ short HbaseDelete::codeGen(Generator * generator)
 				rowIdAsciiTuppIndex, rowIdTuppIndex,
 				rowIdAsciiRowLen, rowIdAsciiTupleDesc,
 				rowIdLength, 
-				rowIdExpr);
+				rowIdExpr,
+                                encodeKeys);
     }
   else
     {
@@ -1076,7 +1083,8 @@ short HbaseDelete::codeGen(Generator * generator)
 
   char * tablename = NULL;
   if ((getTableDesc()->getNATable()->isHbaseRowTable()) ||
-      (getTableDesc()->getNATable()->isHbaseCellTable()))
+      (getTableDesc()->getNATable()->isHbaseCellTable()) ||
+      (getTableName().getQualifiedNameObj().isHbaseMappedName()))
     {
       if (getIndexDesc() && getIndexDesc()->getNAFileSet())
 	tablename = space->AllocateAndCopyToAlignedSpace(GenGetQualifiedName(getIndexDesc()->getNAFileSet()->getFileSetName().getObjectName()), 0);
@@ -1197,6 +1205,14 @@ short HbaseDelete::codeGen(Generator * generator)
       if (isAlignedFormat)
         hbasescan_tdb->setAlignedFormat(TRUE);
 
+      if (isHbaseMapFormat)
+        {
+          hbasescan_tdb->setHbaseMapTable(TRUE);
+
+          if (getTableDesc()->getNATable()->getClusteringIndex()->hasSingleColVarcharKey())
+            hbasescan_tdb->setKeyInVCformat(TRUE);
+        }
+
       if ((CmpCommon::getDefault(HBASE_SQL_IUD_SEMANTICS) == DF_ON) &&
 	  (NOT noCheck()))
 	hbasescan_tdb->setHbaseSqlIUD(TRUE);
@@ -1361,7 +1377,6 @@ short HbaseUpdate::codeGen(Generator * generator)
 		       getSearchKey(),
 		       NULL, //getMdamKeyPtr(),
 		       FALSE,
-		       0,
 		       ExpTupleDesc::SQLMX_KEY_FORMAT);
 
   UInt32 keyColValLen = 0;
@@ -1606,6 +1621,12 @@ short HbaseUpdate::codeGen(Generator * generator)
   ULng32 rowIdLength = 0;
   if (getTableDesc()->getNATable()->isSeabaseTable())
     {
+      // dont encode keys for hbase mapped tables since these tables
+      // could be populated from outside of traf.
+      NABoolean encodeKeys = TRUE;
+      if (getTableDesc()->getNATable()->isHbaseMapTable())
+        encodeKeys = FALSE;
+
       HbaseAccess::genRowIdExpr(generator,
 				getIndexDesc()->getNAFileSet()->getIndexKeyColumns(),
 				getHbaseSearchKeys(), 
@@ -1613,7 +1634,8 @@ short HbaseUpdate::codeGen(Generator * generator)
 				rowIdAsciiTuppIndex, rowIdTuppIndex,
 				rowIdAsciiRowLen, rowIdAsciiTupleDesc,
 				rowIdLength, 
-				rowIdExpr);
+				rowIdExpr,
+                                encodeKeys);
    }
   else
     {
@@ -2187,6 +2209,7 @@ short HbaseInsert::codeGen(Generator *generator)
   Queue *listOfOmittedColNames = NULL;
 
   NABoolean isAlignedFormat = getTableDesc()->getNATable()->isAlignedFormat(getIndexDesc());
+  NABoolean isHbaseMapFormat = getTableDesc()->getNATable()->isHbaseMapTable();
 
   for (CollIndex ii = 0; ii < newRecExprArray().entries(); ii++)
   {
@@ -2215,7 +2238,7 @@ short HbaseInsert::codeGen(Generator *generator)
       colArray.insert( col );
 
       if (returnRow)
-           returnRowVIDList.insert(tgtValueId);
+        returnRowVIDList.insert(tgtValueId);
 
       ItemExpr * child1Expr = assignExpr->child(1);
       const NAType &givenType = tgtValueId.getType();
@@ -2223,6 +2246,17 @@ short HbaseInsert::codeGen(Generator *generator)
       ItemExpr * ie = new(generator->wHeap())
 	Cast(child1Expr, &givenType);
 
+      if ((isHbaseMapFormat) &&
+          (getTableDesc()->getNATable()->isHbaseDataFormatString()) &&
+          (NOT (DFS2REC::isAnyCharacter(givenType.getFSDatatype()))))
+        {
+          Lng32 cvl = givenType.getDisplayLength();
+
+          NAType * asciiType = 
+            new (generator->wHeap()) SQLVarChar(cvl, givenType.supportsSQLnull());
+          ie = new(generator->wHeap()) Cast(ie, asciiType);
+        }
+
       if ((NOT isAlignedFormat) && HbaseAccess::isEncodingNeededForSerialization
 	  (assignExpr->child(0)->castToItemExpr()))
 	{
@@ -2459,10 +2493,22 @@ short HbaseInsert::codeGen(Generator *generator)
           const NAColumn * nac = colArray[c];
           
           NAString cnInList;
-          HbaseAccess::createHbaseColId(nac, cnInList,
-                                        (getIndexDesc()->getNAFileSet()->getKeytag() != 0));
-          
-          if (this->getIsTrafLoadPrep())
+          if (isHbaseMapFormat)
+            {
+              cnInList = nac->getHbaseColFam();
+              cnInList += ":";
+              cnInList += nac->getColName();
+
+              short len = cnInList.length();
+              cnInList.prepend((char*)&len, sizeof(short));
+            }
+          else
+            {
+              HbaseAccess::createHbaseColId(nac, cnInList,
+                                            (getIndexDesc()->getNAFileSet()->getKeytag() != 0));
+            }
+
+          if (getIsTrafLoadPrep())
             {
               UInt32 pos = (UInt32)c +1;
               cnInList.prepend((char*)&pos, sizeof(UInt32));
@@ -2611,7 +2657,8 @@ short HbaseInsert::codeGen(Generator *generator)
   }
   char * tablename = NULL;
   if ((getTableDesc()->getNATable()->isHbaseRowTable()) ||
-      (getTableDesc()->getNATable()->isHbaseCellTable()))
+      (getTableDesc()->getNATable()->isHbaseCellTable()) ||
+      (getTableName().getQualifiedNameObj().isHbaseMappedName()))
     {
       tablename = space->AllocateAndCopyToAlignedSpace(GenGetQualifiedName(getIndexDesc()->getIndexName().getObjectName()), 0);
     }
@@ -2737,6 +2784,14 @@ short HbaseInsert::codeGen(Generator *generator)
       if (isAlignedFormat)
         hbasescan_tdb->setAlignedFormat(TRUE);
 
+      if (isHbaseMapFormat)
+        {
+          hbasescan_tdb->setHbaseMapTable(TRUE);
+          
+          if (getTableDesc()->getNATable()->getClusteringIndex()->hasSingleColVarcharKey())
+            hbasescan_tdb->setKeyInVCformat(TRUE);
+        }
+
       if (CmpCommon::getDefault(HBASE_SQL_IUD_SEMANTICS) == DF_ON)
 	hbasescan_tdb->setHbaseSqlIUD(TRUE);
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/generator/Generator.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/Generator.cpp b/core/sql/generator/Generator.cpp
index ca4346c..b6b113e 100644
--- a/core/sql/generator/Generator.cpp
+++ b/core/sql/generator/Generator.cpp
@@ -2079,6 +2079,7 @@ TrafDesc * Generator::createVirtualTableDesc
 	  
 	  curr_constr_desc->constrntsDesc()->check_constrnts_desc = NULL;
 	  curr_constr_desc->constrntsDesc()->setEnforced(constrInfo[i].isEnforced);
+	  curr_constr_desc->constrntsDesc()->setNotSerialized(constrInfo[i].notSerialized);
 
 	  switch (constrInfo[i].constrType)
 	    {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp
index da1ab29..1f68c37 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -1337,7 +1337,6 @@ TrafDesc *generateSpecialDesc(const CorrName& corrName)
 // -----------------------------------------------------------------------
 // member functions for class BindWA
 // -----------------------------------------------------------------------
-
 NARoutine *BindWA::getNARoutine ( const QualifiedName &name )
 {
   NARoutineDBKey key(name, wHeap());
@@ -1396,7 +1395,8 @@ NATable *BindWA::getNATable(CorrName& corrName,
   NAString userName;
   if ((CmpCommon::context()->sqlSession()->volatileSchemaInUse()) &&
       (! inTableDescStruct) &&
-      (corrName.getSpecialType() != ExtendedQualName::VIRTUAL_TABLE))
+      (corrName.getSpecialType() != ExtendedQualName::VIRTUAL_TABLE) &&
+      (corrName.getSpecialType() != ExtendedQualName::HBMAP_TABLE))
     {
       CorrName newCorrName = 
         CmpCommon::context()->sqlSession()->getVolatileCorrName
@@ -1469,7 +1469,7 @@ NATable *BindWA::getNATable(CorrName& corrName,
       NABoolean schNameSpecified =
               (NOT corrName.getQualifiedNameObj().getSchemaName().isNull());
 
-      // try PUBLIC SCHEMA only when no schema was specified
+     // try PUBLIC SCHEMA only when no schema was specified
       // and CQD PUBLIC_SCHEMA_NAME is specified
       NAString publicSchema = "";
       CmpCommon::getDefault(PUBLIC_SCHEMA_NAME, publicSchema, FALSE);
@@ -1484,6 +1484,26 @@ NATable *BindWA::getNATable(CorrName& corrName,
       if (bindWA->errStatus())
         return NULL;      // prototype value parse error
 
+      // cannot use hbase map schema as table name
+      if ((corrName.getQualifiedNameObj().getSchemaName() == HBASE_EXT_MAP_SCHEMA) &&
+          (! Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)) &&
+          (! Get_SqlParser_Flags(ALLOW_SPECIALTABLETYPE)))
+         {
+          *CmpCommon::diags() << DgSqlCode(-4261)
+                              << DgSchemaName(corrName.getQualifiedNameObj().getSchemaName());
+          
+          bindWA->setErrStatus();
+          return NULL;
+        }
+
+      // if this is an HBase mapped table and schema name is not specified, 
+      // then set schema to hbase map schema.
+      if ((corrName.getSpecialType() == ExtendedQualName::HBMAP_TABLE) &&
+          (NOT schNameSpecified))
+        {
+          corrName.getQualifiedNameObj().setSchemaName(HBASE_EXT_MAP_SCHEMA);
+        }
+ 
       // override schema
       if ( ( overrideSchemaEnabled() )
            // not volatile table
@@ -1543,6 +1563,34 @@ NATable *BindWA::getNATable(CorrName& corrName,
         }
       }
 
+      // if sch name was not specified and table is not found in default schema, then
+      // look for it in HBase mapped schema.
+      if ( !table && ! schNameSpecified)
+        {
+          CorrName pCorrName(corrName);
+          pCorrName.getQualifiedNameObj().setSchemaName(HBASE_EXT_MAP_SCHEMA);
+          
+          bindWA->resetErrStatus();
+          Lng32 diagsMark = CmpCommon::diags()->mark();
+          table = bindWA->getSchemaDB()->getNATableDB()->
+            get(pCorrName, bindWA, inTableDescStruct);
+          if ( !bindWA->errStatus() && table )
+            { // if found in mapped schema, do not show previous error
+              // and replace corrName
+              CmpCommon::diags()->clear();
+              corrName.getQualifiedNameObj().setCatalogName(
+                   pCorrName.getQualifiedNameObj().getCatalogName());
+              corrName.getQualifiedNameObj().setSchemaName(
+                   pCorrName.getQualifiedNameObj().getSchemaName());
+            }
+          else
+            {
+              // discard the errors from failed map table name lookup and only return
+              // the previous error.
+              CmpCommon::diags()->rewind(diagsMark);
+            }
+         }
+
       // 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).
@@ -1583,11 +1631,14 @@ NATable *BindWA::getNATable(CorrName& corrName,
   // native HIVE or HBASE objects unless the allowExternalTables flag is set.  
   // allowExternalTables is set for drop table and SHOWDDL statements.  
   // TDB - may want to merge the Trafodion version with the native version.
-  if ((table) && table->isExternalTable() && (! bindWA->allowExternalTables()))
+  if ((table) && 
+      (table->isExternalTable() && 
+       (NOT table->getTableName().isHbaseMappedName()) &&
+       (! bindWA->allowExternalTables())))    
     {
       *CmpCommon::diags() << DgSqlCode(-4258)
-                          << DgTableName(table->getTableName().getQualifiedNameAsAnsiString());
-
+			  << DgTableName(table->getTableName().getQualifiedNameAsAnsiString());
+      
       bindWA->setErrStatus();
       return NULL;
     }
@@ -1595,7 +1646,8 @@ NATable *BindWA::getNATable(CorrName& corrName,
   // If the table is an external table and has an associated native table, 
   // check to see if the external table structure still matches the native table.
   // If not, return an error
-  if ((table) && table->isExternalTable()) 
+  if ((table) && table->isExternalTable() &&
+      (NOT table->getTableName().isHbaseMappedName()))
     {
       NAString adjustedName =ComConvertTrafNameToNativeName 
            (table->getTableName().getCatalogName(),
@@ -1608,10 +1660,16 @@ NATable *BindWA::getNATable(CorrName& corrName,
       CorrName externalCorrName(adjustedQualName, STMTHEAP);
       NATable *nativeNATable = bindWA->getSchemaDB()->getNATableDB()->
                                   get(externalCorrName, bindWA, inTableDescStruct);
-  
+      if ((bindWA->externalTableDrop()) &&
+          (bindWA->errStatus()))
+        {
+          return NULL;
+        }
+      
       // Compare column lists
       // TBD - return what mismatches
-      if ( nativeNATable && !(table->getNAColumnArray() == nativeNATable->getNAColumnArray()) &&
+      if ( nativeNATable && 
+           !(table->getNAColumnArray() == nativeNATable->getNAColumnArray()) &&
            (NOT bindWA->externalTableDrop()))
         {
           *CmpCommon::diags() << DgSqlCode(-3078)
@@ -1639,6 +1697,31 @@ NATable *BindWA::getNATable(CorrName& corrName,
   return table;
 } // BindWA::getNATable()
 
+NATable *BindWA::getNATableInternal(
+     CorrName& corrName,
+     NABoolean catmanCollectTableUsages, // default TRUE
+     TrafDesc *inTableDescStruct,     // default NULL
+     NABoolean extTableDrop)
+{
+  ULng32 savedParserFlags = Get_SqlParser_Flags (0xFFFFFFFF);
+  Set_SqlParser_Flags(ALLOW_VOLATILE_SCHEMA_IN_TABLE_NAME);
+  Set_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL);
+  
+  setAllowExternalTables(TRUE);
+  if (extTableDrop)
+    setExternalTableDrop(TRUE);
+
+  NATable * nat = 
+    getNATable(corrName, catmanCollectTableUsages, inTableDescStruct);
+
+  // Restore parser flags settings to what they originally were
+  Assign_SqlParser_Flags (savedParserFlags);
+  setAllowExternalTables(FALSE);
+  setExternalTableDrop(FALSE);
+
+  return nat;
+}
+
 static TableDesc *createTableDesc2(BindWA *bindWA,
                                    const NATable *naTable,
                                    CorrName &corrName, Hint *hint)
@@ -9649,7 +9732,9 @@ RelExpr *Insert::bindNode(BindWA *bindWA)
   //   The top value ids are target value ids, the bottom value ids
   //   are those of the source.
   //
-  NABoolean view = bindWA->getNATable(getTableName())->getViewText() != NULL;
+
+  NABoolean view = bindWA->getNATableInternal(getTableName())->getViewText() != NULL;
+
   ValueIdList tgtColList, userColList, sysColList, *userColListPtr;
   CollIndexList colnoList(STMTHEAP);
   CollIndex totalColCount, defaultColCount, i;
@@ -11299,11 +11384,20 @@ RelExpr *Update::bindNode(BindWA *bindWA)
        {
          xnsfrmHbaseUpdate = TRUE;
        }
+      else if (getTableDesc()->getNATable()->isHbaseMapTable())
+       {
+         xnsfrmHbaseUpdate = TRUE;
+       }
      }  
   
   if (xnsfrmHbaseUpdate)
     {
+      ULng32 savedParserFlags = Get_SqlParser_Flags (0xFFFFFFFF);
+      Set_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL);
+
       boundExpr = transformHbaseUpdate(bindWA);
+
+      Assign_SqlParser_Flags (savedParserFlags);
     }
   else 
   // till here and remove the function transformHbaseUpdate also
@@ -12313,7 +12407,7 @@ NABoolean GenericUpdate::checkForHalloweenR2(Int32 numScansToFind)
 // whole stack of views) is *exactly one* wbase table -- i.e., no joins
 // allowed.
 //
-RelExpr *GenericUpdate::bindNode(BindWA *bindWA)
+RelExpr * GenericUpdate::bindNode(BindWA *bindWA)
 {
   if (nodeIsBound())
   {
@@ -12496,6 +12590,16 @@ RelExpr *GenericUpdate::bindNode(BindWA *bindWA)
   if (naTable && naTable->isHbaseTable())
     hbaseOper() = TRUE;
 
+  if (naTable && naTable->isHbaseMapTable() &&
+      (CmpCommon::getDefault(TRAF_HBASE_MAPPED_TABLES_IUD) == DF_OFF))
+    {
+      *CmpCommon::diags() << DgSqlCode(-4223)
+			  << DgString0("Insert/Update/Delete on HBase mapped tables is");
+      
+      bindWA->setErrStatus();
+      return this;
+    }
+
   if ((CmpCommon::getDefault(ALLOW_DML_ON_NONAUDITED_TABLE) == DF_OFF) &&
       naTable && naTable->getClusteringIndex() && 
       (!naTable->getClusteringIndex()->isAudited())
@@ -12632,7 +12736,7 @@ RelExpr *GenericUpdate::bindNode(BindWA *bindWA)
       (CmpCommon::getDefault(HBASE_NATIVE_IUD) == DF_OFF))
     {
       *CmpCommon::diags() << DgSqlCode(-4223)
-			  << DgString0("Insert/Update/Delete on native hbase tables or in CELL/ROW format is");
+			  << DgString0("Insert/Update/Delete on native HBase tables or in CELL/ROW format is");
       
       bindWA->setErrStatus();
       return this;
@@ -14407,6 +14511,7 @@ RelExpr *Describe::bindNode(BindWA *bindWA)
                   (CmpCommon::diags()->mainSQLCODE() == -4155) || // define not supported
                   (CmpCommon::diags()->mainSQLCODE() == -4086) || // catch Define Not Found error
                   (CmpCommon::diags()->mainSQLCODE() == -30044)|| // default schema access error
+                  (CmpCommon::diags()->mainSQLCODE() == -4261) || // reserved schema
                   (CmpCommon::diags()->mainSQLCODE() == -1398))   // uninit hbase
                     return this;
       

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/optimizer/BindWA.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindWA.h b/core/sql/optimizer/BindWA.h
index c074814..ce1c73e 100644
--- a/core/sql/optimizer/BindWA.h
+++ b/core/sql/optimizer/BindWA.h
@@ -1350,6 +1350,11 @@ public:
 		      NABoolean catmanCollectTableUsages = TRUE,
 		      TrafDesc *inTableDesc = NULL);
 
+  NATable *getNATableInternal(CorrName &corrName,
+                              NABoolean catmanCollectTableUsages = TRUE,
+                              TrafDesc *inTableDesc = NULL,
+                              NABoolean extTableDrop = FALSE);
+
   TableDesc *createTableDesc(const NATable *naTable,
                              CorrName &corrName,
                              NABoolean catmanCollectUsages = FALSE,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/optimizer/NAColumn.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAColumn.h b/core/sql/optimizer/NAColumn.h
index 4c3d928..b1250d8 100644
--- a/core/sql/optimizer/NAColumn.h
+++ b/core/sql/optimizer/NAColumn.h
@@ -79,7 +79,9 @@ class NAColumn : public NABasicObject
 public:
 
   enum KeyKind	  { NON_KEY = 0,
-		    INDEX_KEY = 0x1, PARTITIONING_KEY = 0x2 , PRIMARY_KEY = 0x4
+		    INDEX_KEY = 0x1, PARTITIONING_KEY = 0x2,
+                    PRIMARY_KEY = 0x4,
+                    PRIMARY_KEY_NOT_SERIALIZED = 0x8
 		  };
   enum NAColumnAssert { MustBeBaseColumn, MustBeColumn, NoError };
 
@@ -266,8 +268,11 @@ public:
   inline void setIndexKey()                    { keyKind_ |= INDEX_KEY; }
   inline NABoolean isPartitioningKey() const   { return keyKind_ & PARTITIONING_KEY; }
   inline void setPartitioningKey()             { keyKind_ |= PARTITIONING_KEY; }
-  inline NABoolean isPrimaryKey() const        { return keyKind_ & PRIMARY_KEY; }
+  inline NABoolean isPrimaryKey() const        { return keyKind_ & PRIMARY_KEY;}
+  inline NABoolean isPrimaryKeyNotSerialized() const 
+  { return keyKind_ & PRIMARY_KEY_NOT_SERIALIZED;}
   inline void setPrimaryKey()                  { keyKind_ |= PRIMARY_KEY; }
+  inline void setPrimaryKeyNotSerialized()     { keyKind_ |= PRIMARY_KEY_NOT_SERIALIZED; }
   inline void setIsStoredOnDisk(NABoolean x)   { storedOnDisk_ = x; }
   inline NABoolean isReferenced() const        { return (referenced_ != NOT_REFERENCED); }
   inline NABoolean isReferencedForHistogram() const

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/optimizer/NAFileSet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAFileSet.cpp b/core/sql/optimizer/NAFileSet.cpp
index 72fb562..51bb6fb 100644
--- a/core/sql/optimizer/NAFileSet.cpp
+++ b/core/sql/optimizer/NAFileSet.cpp
@@ -234,6 +234,13 @@ NABoolean NAFileSet::hasOnlySyskey() const
           (indexKeyColumns_[0]->isSyskeyColumn()));
 }
 
+NABoolean NAFileSet::hasSingleColVarcharKey() const
+{
+  // clustering key is single column varchar 
+  return ((indexKeyColumns_.entries() == 1) &&
+          (indexKeyColumns_[0]->getType()->isVaryingLen()));
+}
+
 //cleanup after statement, so that this can be used for the next statement
 void NAFileSet::resetAfterStatement()
 {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/optimizer/NAFileSet.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAFileSet.h b/core/sql/optimizer/NAFileSet.h
index 6143af1..754d2c4 100644
--- a/core/sql/optimizer/NAFileSet.h
+++ b/core/sql/optimizer/NAFileSet.h
@@ -207,6 +207,7 @@ public:
   Int32 getSysKeyPosition()  const;
   NABoolean hasSyskey() const;
   NABoolean hasOnlySyskey() const;
+  NABoolean hasSingleColVarcharKey() const;
 
   NABoolean isDecoupledRangePartitioned() const
                     { return isDecoupledRangePartitioned_; }
@@ -279,7 +280,6 @@ public:
   //For NATable caching, prepare for use by a statement.
   void setupForStatement();
 
-  NABoolean isSqlmxRowFormat() { return rowFormat_ == COM_PACKED_FORMAT_TYPE; }
   NABoolean isSqlmxAlignedRowFormat() const { return rowFormat_ == COM_ALIGNED_FORMAT_TYPE; }
 
   void setRowFormat(ComRowFormat rowFormat) { rowFormat_ = rowFormat; }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index a801434..19dc27a 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -4590,7 +4590,12 @@ NABoolean createNAFileSets(TrafDesc * table_desc       /*IN*/,
        // Lookup by name (not position: key->position is pos *within the PK*)
        NAColumn *nacol = columnArray.getColumn(key->colname);
        if(nacol != NULL)
-         nacol->setPrimaryKey();
+         {
+           nacol->setPrimaryKey();
+           if (((TrafConstrntsDesc*)constrnt)->notSerialized())
+             nacol->setPrimaryKeyNotSerialized();
+         }
+
        keycols_desc = keycols_desc->next;
      }
  } // static markPKCols
@@ -4953,24 +4958,24 @@ NABoolean createNAFileSets(TrafDesc * table_desc       /*IN*/,
 
    isTrigTempTable_ = (qualifiedName_.getSpecialType() == ExtendedQualName::TRIGTEMP_TABLE);
 
+   if (table_desc->tableDesc()->isVolatileTable())
+   {
+     setVolatileTable( TRUE );
+   }
+
    switch(table_desc->tableDesc()->rowFormat())
      {
-     case COM_PACKED_FORMAT_TYPE:
-       setSQLMXTable(TRUE);
-       break;
      case COM_ALIGNED_FORMAT_TYPE:
        setSQLMXAlignedTable(TRUE);
        break;
      case COM_HBASE_FORMAT_TYPE:
      case COM_UNKNOWN_FORMAT_TYPE:
        break;
+     case COM_HBASE_STR_FORMAT_TYPE:
+       setHbaseDataFormatString(TRUE);
+       break;
      }
 
-   if (table_desc->tableDesc()->isVolatileTable())
-   {
-     setVolatileTable( TRUE );
-   }
-
    if (table_desc->tableDesc()->isInMemoryObject())
    {
      setInMemoryObjectDefn( TRUE );
@@ -8043,6 +8048,7 @@ NATable * NATableDB::get(CorrName& corrName, BindWA * bindWA,
       NABoolean isUserUpdatableSeabaseMD = FALSE;
       NABoolean isHbaseCell = corrName.isHbaseCell();
       NABoolean isHbaseRow = corrName.isHbaseRow();
+      NABoolean isHbaseMap = corrName.isHbaseMap();
       if (isHbaseCell || isHbaseRow)// explicit cell or row format specification
 	{
 	  const char* extHBaseName = corrName.getQualifiedNameObj().getObjectName();
@@ -8163,6 +8169,11 @@ NATable * NATableDB::get(CorrName& corrName, BindWA * bindWA,
       table->setIsSeabaseTable(isSeabase);
       table->setIsSeabaseMDTable(isSeabaseMD);
       table->setIsUserUpdatableSeabaseMDTable(isUserUpdatableSeabaseMD);
+      if (isHbaseMap)
+        {
+          table->setIsHbaseMapTable(TRUE);
+          table->setIsExternalTable(TRUE);
+        }
     }
     else if (isHiveTable(corrName) &&
 	(!isSQUmdTable(corrName)) &&

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/optimizer/NATable.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.h b/core/sql/optimizer/NATable.h
index c2b3730..f6b8d85 100644
--- a/core/sql/optimizer/NATable.h
+++ b/core/sql/optimizer/NATable.h
@@ -732,6 +732,18 @@ public:
   NABoolean hasExternalTable() const
   {  return (flags_ & HAS_EXTERNAL_TABLE) != 0; }
 
+  void setIsHbaseMapTable( NABoolean value )
+  {  value ? flags_ |= HBASE_MAP_TABLE : flags_ &= ~HBASE_MAP_TABLE; }
+
+  NABoolean isHbaseMapTable() const
+  {  return (flags_ & HBASE_MAP_TABLE) != 0; }
+
+  void setHbaseDataFormatString( NABoolean value )
+  {  value ? flags_ |= HBASE_DATA_FORMAT_STRING : flags_ &= ~HBASE_DATA_FORMAT_STRING; }
+
+  NABoolean isHbaseDataFormatString() const
+  {  return (flags_ & HBASE_DATA_FORMAT_STRING) != 0; }
+
   void setIsHistogramTable( NABoolean value )
   {  value ? flags_ |= IS_HISTOGRAM_TABLE : flags_ &= ~IS_HISTOGRAM_TABLE; }
 
@@ -971,9 +983,11 @@ private:
     IS_EXTERNAL_TABLE         = 0x00080000,
     HAS_EXTERNAL_TABLE        = 0x00100000,
     IS_HISTOGRAM_TABLE        = 0x00200000,
-    HAS_HIVE_EXT_TABLE        = 0x00400000,
-    HIVE_EXT_COL_ATTRS        = 0x00800000,
-    HIVE_EXT_KEY_ATTRS        = 0x01000000,
+    HBASE_MAP_TABLE           = 0x00400000,
+    HBASE_DATA_FORMAT_STRING  = 0x00800000,
+    HAS_HIVE_EXT_TABLE        = 0x01000000,
+    HIVE_EXT_COL_ATTRS        = 0x02000000,
+    HIVE_EXT_KEY_ATTRS        = 0x04000000
   };
     
   UInt32 flags_;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/optimizer/ObjectNames.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ObjectNames.cpp b/core/sql/optimizer/ObjectNames.cpp
index 462faf7..e271481 100644
--- a/core/sql/optimizer/ObjectNames.cpp
+++ b/core/sql/optimizer/ObjectNames.cpp
@@ -670,6 +670,11 @@ NABoolean QualifiedName::isSeabasePrivMgrMD() const
     (getCatalogName(), getSchemaName());
 }
 
+NABoolean QualifiedName::isHbaseMappedName() const
+{
+  return ((isSeabase(getCatalogName())) &&
+          (ComIsHbaseMappedSchemaName(getSchemaName())));
+}
 
 // -----------------------------------------------------------------------
 // Methods for class CorrName
@@ -980,6 +985,11 @@ NABoolean CorrName::isHbaseRow() const
     return FALSE;
 }
 
+NABoolean CorrName::isHbaseMap() const
+{
+  return getQualifiedNameObj().isHbaseMappedName();
+}
+
 NAString CorrName::getCorrNameAsString() const
 {
   return FORMAT(corrName_);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/optimizer/ObjectNames.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ObjectNames.h b/core/sql/optimizer/ObjectNames.h
index 86a7bf6..21ca61e 100644
--- a/core/sql/optimizer/ObjectNames.h
+++ b/core/sql/optimizer/ObjectNames.h
@@ -321,6 +321,7 @@ public:
   NABoolean isHbase() const;
   NABoolean isSeabaseMD() const;
   NABoolean isSeabasePrivMgrMD() const;
+  NABoolean isHbaseMappedName() const;
 
   NABoolean isHistograms() const;
   NABoolean isHistogramIntervals() const;
@@ -473,6 +474,7 @@ public:
 			  VIRTUAL_TABLE,
 			  IUD_LOG_TABLE, 
 			  RANGE_LOG_TABLE,
+                          HBMAP_TABLE,
 			  MVS_UMD,
 			  MV_TABLE,
 			  TRIGTEMP_TABLE,      // Temporary Tables for Triggers
@@ -877,6 +879,7 @@ public:
   NABoolean isSeabasePrivMgrMD() const;
   NABoolean isHbaseCell() const;
   NABoolean isHbaseRow() const;
+  NABoolean isHbaseMap() const;
 
   NABoolean isExternal() const { return (flagbits_ & IS_EXTERNAL) != 0; }
   void setIsExternal(NABoolean v) 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/optimizer/RelScan.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelScan.h b/core/sql/optimizer/RelScan.h
index 70f6d64..b2c7add 100644
--- a/core/sql/optimizer/RelScan.h
+++ b/core/sql/optimizer/RelScan.h
@@ -1386,6 +1386,12 @@ public:
 				       ItemExpr *&castValue,
                                        NABoolean alignedFormat = FALSE);
 
+  // used for hbase map table where data is stored in string format
+  static int createAsciiColAndCastExpr3(Generator * generator,
+				       const NAType &givenType,
+				       ItemExpr *&asciiValue,
+                                        ItemExpr *&castValue);
+
   static short genRowIdExpr(Generator * generator,
 			    const NAColumnArray & keyColumns,				
 			    NAList<HbaseSearchKey*>& searchKeys,
@@ -1396,7 +1402,8 @@ public:
 			    ULng32 &rowIdAsciiRowLen,
 			    ExpTupleDesc* &rowIdAsciiTupleDesc,
 			    UInt32 &rowIdLength,
-			    ex_expr* &rowIdExpr);
+			    ex_expr* &rowIdExpr,
+                            NABoolean encodeKeys);
   
  static short genRowIdExprForNonSQ(Generator * generator,
 			    const NAColumnArray & keyColumns,				

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/BindStmtDDL.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/BindStmtDDL.cpp b/core/sql/parser/BindStmtDDL.cpp
index f01d746..2163d83 100644
--- a/core/sql/parser/BindStmtDDL.cpp
+++ b/core/sql/parser/BindStmtDDL.cpp
@@ -1377,6 +1377,7 @@ StmtDDLCreateTable::bindNode(BindWA * pBindWA)
 
   if (getIsLikeOptionSpecified())
   {
+    origLikeSourceTableQualName_ = likeSourceTableCorrName_.getQualifiedNameObj();
     likeSourceTableCorrName_.getQualifiedNameObj().applyDefaultsValidate(pBindWA->getDefaultSchema());
     if (pBindWA->violateAccessDefaultSchemaOnly(likeSourceTableCorrName_.getQualifiedNameObj()))
       return this;
@@ -2114,6 +2115,9 @@ StmtDDLAlterTable::bindNode(BindWA * pBindWA)
 
   ComASSERT(pBindWA);
 
+  // remember the original table name specified by user
+  origTableQualName_ = tableQualName_;
+
   //  tableQualName_.applyDefaults(pBindWA->getDefaultSchema());
   if (applyDefaultsAndValidateObject(pBindWA, &tableQualName_))
     {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/ElemDDLConstraintPK.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLConstraintPK.h b/core/sql/parser/ElemDDLConstraintPK.h
index f7817ab..d675094 100644
--- a/core/sql/parser/ElemDDLConstraintPK.h
+++ b/core/sql/parser/ElemDDLConstraintPK.h
@@ -61,15 +61,18 @@ class ElemDDLConstraintPK : public ElemDDLConstraintUnique
 {
 
 public:
-
   // constructors
-  ElemDDLConstraintPK(ElemDDLNode * pColumnRefList = NULL)
+  ElemDDLConstraintPK(ElemDDLNode * pColumnRefList = NULL,
+                      ComPkeySerialization ser = COM_SER_NOT_SPECIFIED)
   : ElemDDLConstraintUnique(ELM_CONSTRAINT_PRIMARY_KEY_ELEM,
-                          pColumnRefList)
+                            pColumnRefList),
+    ser_(ser)
   { }
-  ElemDDLConstraintPK(OperatorTypeEnum operatorType)
+  ElemDDLConstraintPK(OperatorTypeEnum operatorType,
+                      ComPkeySerialization ser = COM_SER_NOT_SPECIFIED)
   : ElemDDLConstraintUnique(operatorType,
-                          NULL /*column_reference_list*/)
+                            NULL /*column_reference_list*/),
+    ser_(ser)
   { }
 
   // virtual destructor
@@ -82,8 +85,20 @@ public:
   virtual const NAString displayLabel2() const;
   virtual const NAString getText() const;
 
+  ComPkeySerialization ser() { return ser_; }
+  NABoolean notSerialized() 
+  { return (ser_ == ComPkeySerialization::COM_NOT_SERIALIZED); }
+  NABoolean serialized() 
+  { return (ser_ == ComPkeySerialization::COM_SERIALIZED); }
 
 private:
+  // if set to SERIALIZED, then pkey will be encoded before passint to hbase.
+  // if set to NOT_SERIALIZED, then primary key will not be encoded before 
+  // passing on to HBase.
+  // Used when accessing external HBase tables where data may not be stored
+  // in serialized mode.
+  // if not specified, then will be determined based on table type.
+  ComPkeySerialization ser_;
 
 }; // class ElemDDLConstraintPK
 
@@ -96,12 +111,11 @@ class ElemDDLConstraintPKColumn : public ElemDDLConstraintPK
 public:
 
   // constructor
-  ElemDDLConstraintPKColumn(ComColumnOrdering orderingSpec =
-                                   COM_ASCENDING_ORDER)
-  : ElemDDLConstraintPK(ELM_CONSTRAINT_PRIMARY_KEY_COLUMN_ELEM),
-  columnOrdering_(orderingSpec)
+  ElemDDLConstraintPKColumn(ComColumnOrdering orderingSpec = COM_ASCENDING_ORDER)
+       : ElemDDLConstraintPK(ELM_CONSTRAINT_PRIMARY_KEY_COLUMN_ELEM),
+         columnOrdering_(orderingSpec)
   { }
-
+  
   // virtual destructor
   virtual ~ElemDDLConstraintPKColumn();
 
@@ -113,12 +127,9 @@ public:
 
   // methods for tracing
   virtual const NAString getText() const;
-
-
 private:
 
   ComColumnOrdering columnOrdering_;
-
 }; // class ElemDDLConstraintPKColumn
 
 // -----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/ElemDDLLikeOptions.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLLikeOptions.cpp b/core/sql/parser/ElemDDLLikeOptions.cpp
index f97e34e..b4970bc 100644
--- a/core/sql/parser/ElemDDLLikeOptions.cpp
+++ b/core/sql/parser/ElemDDLLikeOptions.cpp
@@ -248,6 +248,29 @@ const NAString ElemDDLLikeLimitColumnLength::getText() const
   return "ElemDDLLikeLimitColumnLength";
 }
 
+// -----------------------------------------------------------------------
+// methods for class ElemDDLLikeOptWithoutRowFormat
+// -----------------------------------------------------------------------
+
+// virtual destructor
+ElemDDLLikeOptWithoutRowFormat::~ElemDDLLikeOptWithoutRowFormat()
+{
+}
+
+// casting
+ElemDDLLikeOptWithoutRowFormat * ElemDDLLikeOptWithoutRowFormat::castToElemDDLLikeOptWithoutRowFormat()
+{
+  return this;
+}
+
+//
+// methods for tracing
+//
+
+const NAString ElemDDLLikeOptWithoutRowFormat::getText() const
+{
+  return "ElemDDLLikeOptWithoutRowFormat";
+}
 
 //
 // End of File

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/ElemDDLLikeOptions.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLLikeOptions.h b/core/sql/parser/ElemDDLLikeOptions.h
index 8d118a3..acc2534 100644
--- a/core/sql/parser/ElemDDLLikeOptions.h
+++ b/core/sql/parser/ElemDDLLikeOptions.h
@@ -292,4 +292,32 @@ private:
 
 }; // class ElemDDLLikeLimitColumnLength
 
+// -----------------------------------------------------------------------
+// definition of class ElemDDLLikeOptWithoutRowFormat
+// -----------------------------------------------------------------------
+class ElemDDLLikeOptWithoutRowFormat : public ElemDDLLikeOpt
+{
+
+public:
+
+  // constructor
+  ElemDDLLikeOptWithoutRowFormat()
+    : ElemDDLLikeOpt(ELM_LIKE_OPT_WITHOUT_ROW_FORMAT_ELEM)
+  { }
+
+  // virtual destructor
+  virtual ~ElemDDLLikeOptWithoutRowFormat();
+
+  // cast
+  virtual ElemDDLLikeOptWithoutRowFormat *
+    castToElemDDLLikeOptWithoutRowFormat();
+
+  // method for tracing
+  virtual const NAString getText() const;
+
+
+private:
+
+}; // class ElemDDLLikeOptWithoutRowFormat
+
 #endif // ELEMDDLLIKEOPTIONS_H

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/ElemDDLNode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.cpp b/core/sql/parser/ElemDDLNode.cpp
index e59c8d3..4284c08 100644
--- a/core/sql/parser/ElemDDLNode.cpp
+++ b/core/sql/parser/ElemDDLNode.cpp
@@ -573,6 +573,11 @@ ElemDDLLikeLimitColumnLength * ElemDDLNode::castToElemDDLLikeLimitColumnLength()
   return NULL;
 }
 
+ElemDDLLikeOptWithoutRowFormat * ElemDDLNode::castToElemDDLLikeOptWithoutRowFormat()
+{
+  return NULL;
+}
+
 ElemDDLList *
 ElemDDLNode::castToElemDDLList()
 {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/ElemDDLNode.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.h b/core/sql/parser/ElemDDLNode.h
index 4c400a9..94dc54a 100644
--- a/core/sql/parser/ElemDDLNode.h
+++ b/core/sql/parser/ElemDDLNode.h
@@ -138,6 +138,7 @@ class ElemDDLLikeOptWithoutSalt;
 class ElemDDLLikeSaltClause;
 class ElemDDLLikeOptWithoutDivision;
 class ElemDDLLikeLimitColumnLength;
+class ElemDDLLikeOptWithoutRowFormat;
 class ElemDDLList;
 class ElemDDLLocation;
 class ElemDDLOptionList;
@@ -462,6 +463,7 @@ public:
   virtual ElemDDLLikeSaltClause         * castToElemDDLLikeSaltClause();
   virtual ElemDDLLikeOptWithoutDivision * castToElemDDLLikeOptWithoutDivision();
   virtual ElemDDLLikeLimitColumnLength  * castToElemDDLLikeLimitColumnLength();
+  virtual ElemDDLLikeOptWithoutRowFormat* castToElemDDLLikeOptWithoutRowFormat();
   virtual ElemDDLList                   * castToElemDDLList();
   virtual ElemDDLLocation               * castToElemDDLLocation();
   virtual ElemDDLOptionList             * castToElemDDLOptionList();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/ElemDDLStoreOptions.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLStoreOptions.cpp b/core/sql/parser/ElemDDLStoreOptions.cpp
index 2f00b2b..c951b0e 100644
--- a/core/sql/parser/ElemDDLStoreOptions.cpp
+++ b/core/sql/parser/ElemDDLStoreOptions.cpp
@@ -162,7 +162,8 @@ ElemDDLStoreOptKeyColumnList::ElemDDLStoreOptKeyColumnList(
   keyColumnArray_(heap),
   uniqueStoreBy_(uniqueStoreBy),
   uniqueStoreByKeylist_(uniqueStoreByKeylist),
-  pkeyStoreByKeylist_(pkeyStoreByKeylist)
+  pkeyStoreByKeylist_(pkeyStoreByKeylist),
+  ser_(ComPkeySerialization::COM_SER_NOT_SPECIFIED)
 {
   setChild(INDEX_KEY_COLUMN_LIST, pKeyColumnList);
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/ElemDDLStoreOptions.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLStoreOptions.h b/core/sql/parser/ElemDDLStoreOptions.h
index a312797..157b919 100644
--- a/core/sql/parser/ElemDDLStoreOptions.h
+++ b/core/sql/parser/ElemDDLStoreOptions.h
@@ -179,6 +179,12 @@ public:
 
   inline NABoolean isPkeyStoreByKeylist() { return pkeyStoreByKeylist_; }
 
+  NABoolean isPkeyNotSerialized()
+  { return (ser_ == ComPkeySerialization::COM_NOT_SERIALIZED); }
+  void setSerializedOption(ComPkeySerialization ser) 
+  { ser_ = ser; }
+  ComPkeySerialization getSerializedOption() { return ser_; }
+
   // mutator
   virtual void setChild(Lng32 index, ExprNode * pElemDDLNode);
 
@@ -208,6 +214,14 @@ private:
 
   ElemDDLNode * children_[MAX_ELEM_DDL_STORE_OPT_KEY_COLUMN_LIST_ARITY];
 
+  // if set to SERIALIZED, then pkey will be encoded before passint to hbase.
+  // if set to NOT_SERIALIZED, then primary key will not be encoded before 
+  // passing on to HBase.
+  // Used when accessing external HBase tables where data may not be stored
+  // in serialized mode.
+  // if not specified, then will be determined based on table type.
+  ComPkeySerialization ser_;
+
 }; // class ElemDDLStoreOptKeyColumnList
 
 // -----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/ParDDLLikeOpts.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ParDDLLikeOpts.cpp b/core/sql/parser/ParDDLLikeOpts.cpp
index 5e8b932..9b37d99 100644
--- a/core/sql/parser/ParDDLLikeOpts.cpp
+++ b/core/sql/parser/ParDDLLikeOpts.cpp
@@ -114,6 +114,7 @@ ParDDLLikeOptsCreateTable::operator=(
   isLikeOptSaltClauseSpec_      = likeOptions.isLikeOptSaltClauseSpec_;
   isLikeOptWithoutDivisionSpec_ = likeOptions.isLikeOptWithoutDivisionSpec_;
   isLikeOptLimitColumnLengthSpec_ = likeOptions.isLikeOptLimitColumnLengthSpec_;
+  isLikeOptWithoutRowFormatSpec_  = likeOptions.isLikeOptWithoutRowFormatSpec_;
 
   isLikeOptWithComments_        = likeOptions.isLikeOptWithComments_;
   isLikeOptWithoutConstraints_  = likeOptions.isLikeOptWithoutConstraints_;
@@ -123,6 +124,7 @@ ParDDLLikeOptsCreateTable::operator=(
   isLikeOptWithoutSalt_         = likeOptions.isLikeOptWithoutSalt_;
   isLikeOptWithoutDivision_     = likeOptions.isLikeOptWithoutDivision_;
   isLikeOptColumnLengthLimit_   = likeOptions.isLikeOptColumnLengthLimit_;
+  isLikeOptWithoutRowFormat_    = likeOptions.isLikeOptWithoutRowFormat_;
 
   if (this != &likeOptions)  // make sure not assigning to self
     {
@@ -158,6 +160,7 @@ ParDDLLikeOptsCreateTable::initializeDataMembers()
   isLikeOptSaltClauseSpec_      = FALSE;
   isLikeOptWithoutDivisionSpec_ = FALSE;
   isLikeOptLimitColumnLengthSpec_ = FALSE;
+  isLikeOptWithoutRowFormatSpec_  = FALSE;
 
   isLikeOptWithComments_        = FALSE;
   isLikeOptWithoutConstraints_  = FALSE;
@@ -168,6 +171,7 @@ ParDDLLikeOptsCreateTable::initializeDataMembers()
   isLikeOptSaltClause_          = NULL;
   isLikeOptWithoutDivision_     = FALSE;
   isLikeOptColumnLengthLimit_   = UINT_MAX;
+  isLikeOptWithoutRowFormat_    = FALSE;
 }
 
 void
@@ -281,6 +285,18 @@ ParDDLLikeOptsCreateTable::setLikeOption(ElemDDLLikeOpt * pLikeOption)
     }
     break;
 
+  case ELM_LIKE_OPT_WITHOUT_ROW_FORMAT_ELEM :
+    if (isLikeOptWithoutRowFormatSpec_)
+    {
+      // ERROR[3152] Duplicate WITHOUT ROW FORMAT phrases were specified
+      //             in LIKE clause in CREATE TABLE statement.
+      *SqlParser_Diags << DgSqlCode(-3152) << DgString0("ROW FORMAT");
+    }
+    ComASSERT(pLikeOption->castToElemDDLLikeOptWithoutRowFormat() != NULL);
+    isLikeOptWithoutRowFormat_ = TRUE;
+    isLikeOptWithoutRowFormatSpec_ = TRUE;
+    break;
+
   default :
     NAAbort("ParDDLLikeOpts.C", __LINE__, "internal logic error");
     break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/ParDDLLikeOptsCreateTable.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ParDDLLikeOptsCreateTable.h b/core/sql/parser/ParDDLLikeOptsCreateTable.h
index 32e2518..4851d33 100644
--- a/core/sql/parser/ParDDLLikeOptsCreateTable.h
+++ b/core/sql/parser/ParDDLLikeOptsCreateTable.h
@@ -137,6 +137,12 @@ public:
     return isLikeOptColumnLengthLimit_;
   }
 
+  const NABoolean
+  getIsWithoutRowFormat() const
+  {
+    return isLikeOptWithoutRowFormat_;
+  }
+
   // mutators
 
   void setLikeOption(ElemDDLLikeOpt * pLikeOptParseNode);
@@ -189,7 +195,11 @@ public:
     isLikeOptColumnLengthLimit_ = setting;
   }
 
-
+  void
+  setIsWithoutRowFormat(const NABoolean setting)
+  {
+    isLikeOptWithoutRowFormat_ = setting;
+  }
 
 private:
 
@@ -216,6 +226,7 @@ private:
   NABoolean isLikeOptSaltClauseSpec_;
   NABoolean isLikeOptWithoutDivisionSpec_;
   NABoolean isLikeOptLimitColumnLengthSpec_;
+  NABoolean isLikeOptWithoutRowFormatSpec_;
 
   // legal Like options in DDL Create Table statements
 
@@ -228,6 +239,7 @@ private:
   NAString * isLikeOptSaltClause_;
   NABoolean isLikeOptWithoutDivision_;
   UInt32 isLikeOptColumnLengthLimit_;  // in bytes; max UInt32 if no limit specified
+  NABoolean isLikeOptWithoutRowFormat_;
 
 }; // class ParDDLLikeOptsCreateTable
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/ParKeyWords.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ParKeyWords.cpp b/core/sql/parser/ParKeyWords.cpp
index 7e41ad7..768d8bb 100644
--- a/core/sql/parser/ParKeyWords.cpp
+++ b/core/sql/parser/ParKeyWords.cpp
@@ -481,6 +481,7 @@ ParKeyWord ParKeyWords::keyWords_[] = {
   ParKeyWord("HBASE_OPTIONS",  TOK_HBASE_OPTIONS,      NONRESTOKEN_),
   ParKeyWord("HBASE_TIMESTAMP",  TOK_HBASE_TIMESTAMP,      NONRESTOKEN_),
   ParKeyWord("HBASE_VERSION",  TOK_HBASE_VERSION,      NONRESTOKEN_),
+  ParKeyWord("HBMAP_TABLE",    TOK_HBMAP_TABLE, NONRESTOKEN_),
   ParKeyWord("HEADER",             TOK_HEADER,      NONRESTOKEN_),
   ParKeyWord("HEADING",            TOK_HEADING,     NONRESTOKEN_),
   ParKeyWord("HEADINGS",           TOK_HEADINGS,    NONRESTOKEN_),
@@ -630,7 +631,7 @@ ParKeyWord ParKeyWords::keyWords_[] = {
   ParKeyWord("MAINTAIN",           TOK_MAINTAIN,    SECOND_|COMPAQ_|RESWORD_),
   ParKeyWord("MANAGEMENT",         TOK_MANAGEMENT,  NONRESTOKEN_),
   ParKeyWord("MANUAL",             TOK_MANUAL,      FLAGSNONE_),
-  ParKeyWord("MAP",                TOK_MAP,         COMPAQ_|RESWORD_),
+  ParKeyWord("MAP",                TOK_MAP,         NONRESTOKEN_),
   ParKeyWord("MASTER",             TOK_MASTER,      NONRESTOKEN_),
   ParKeyWord("MATCH",              TOK_MATCH,       ANS_|RESWORD_),
   ParKeyWord("MATCHED",            TOK_MATCHED,     ANS_|RESWORD_),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/SqlParserAux.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/SqlParserAux.h b/core/sql/parser/SqlParserAux.h
index 449daae..5c52bea 100644
--- a/core/sql/parser/SqlParserAux.h
+++ b/core/sql/parser/SqlParserAux.h
@@ -785,6 +785,8 @@ public:
   {}
 
   TableType getType() { return type_; }
+  void setType(TableType t) { type_ = t; }
+
   NABoolean isVolatile()
    { return (type_ == TYPE_VOLATILE_TABLE ||
              type_ == TYPE_VOLATILE_TABLE_MODE_SPECIAL1 ||

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/StmtDDLAlterTable.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLAlterTable.h b/core/sql/parser/StmtDDLAlterTable.h
index f23a590..5fd47a6 100644
--- a/core/sql/parser/StmtDDLAlterTable.h
+++ b/core/sql/parser/StmtDDLAlterTable.h
@@ -81,6 +81,8 @@ public:
 
   inline ElemDDLNode * getAlterTableAction() const;
   inline const NAString getTableName() const;
+  inline const QualifiedName & getOrigTableNameAsQualifiedName() const;
+  inline       QualifiedName & getOrigTableNameAsQualifiedName();
   inline const QualifiedName & getTableNameAsQualifiedName() const;
   inline       QualifiedName & getTableNameAsQualifiedName();
   
@@ -132,6 +134,10 @@ private:
   // private data members
   // ---------------------------------------------------------------------
   
+  // the tablename specified by user in the alter stmt.
+  // This name is not fully qualified during bind phase.
+  QualifiedName origTableQualName_;
+
   QualifiedName tableQualName_;
 
   //
@@ -207,6 +213,18 @@ StmtDDLAlterTable::getTableName() const
   return tableQualName_.getQualifiedNameAsAnsiString();
 }
 
+inline QualifiedName &
+StmtDDLAlterTable::getOrigTableNameAsQualifiedName()
+{
+  return origTableQualName_;
+}
+
+inline const QualifiedName &
+StmtDDLAlterTable::getOrigTableNameAsQualifiedName() const
+{
+  return origTableQualName_;
+}
+
 inline const QualifiedName &
 StmtDDLAlterTable::getTableNameAsQualifiedName() const
 {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/StmtDDLCleanupObjects.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCleanupObjects.h b/core/sql/parser/StmtDDLCleanupObjects.h
index e75252d..3f33826 100644
--- a/core/sql/parser/StmtDDLCleanupObjects.h
+++ b/core/sql/parser/StmtDDLCleanupObjects.h
@@ -92,6 +92,8 @@ public:
   virtual Int32 getArity() const;
   virtual ExprNode * getChild(Lng32 index);
 
+  inline const QualifiedName & getOrigTableNameAsQualifiedName() const;
+  inline       QualifiedName & getOrigTableNameAsQualifiedName();
   inline const QualifiedName * getTableNameAsQualifiedName() const;
   inline       QualifiedName * getTableNameAsQualifiedName() ;
 
@@ -142,6 +144,10 @@ private:
   // private data members
   // ---------------------------------------------------------------------
 
+  // the tablename specified by user in the drop stmt.
+  // This name is not fully qualified during bind phase.
+  QualifiedName origTableQualName_;
+
   // The syntax of table name is
   // [ [ catalog-name . ] schema-name . ] table-name
   QualifiedName * tableQualName_;
@@ -158,6 +164,18 @@ private:
 // -----------------------------------------------------------------------
 // definitions of inline methods for class StmtDDLCleanupObjects
 // -----------------------------------------------------------------------
+inline QualifiedName &
+StmtDDLCleanupObjects::getOrigTableNameAsQualifiedName()
+{
+  return origTableQualName_;
+}
+
+inline const QualifiedName &
+StmtDDLCleanupObjects::getOrigTableNameAsQualifiedName() const
+{
+  return origTableQualName_;
+}
+
 inline QualifiedName * 
 StmtDDLCleanupObjects::getTableNameAsQualifiedName()
 {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/StmtDDLCreate.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCreate.cpp b/core/sql/parser/StmtDDLCreate.cpp
index 4340ffc..47973b3 100644
--- a/core/sql/parser/StmtDDLCreate.cpp
+++ b/core/sql/parser/StmtDDLCreate.cpp
@@ -3820,7 +3820,9 @@ StmtDDLCreateTable::StmtDDLCreateTable(const QualifiedName & aTableQualName,
 	  isDroppable_(TRUE),
           isInsertOnly_(FALSE),
 	  pSGOptions_(NULL),
-	  createIfNotExists_(FALSE)
+	  createIfNotExists_(FALSE),
+          mapToHbaseTable_(FALSE),
+          hbaseDataFormat_(FALSE)
 {
   setChild(INDEX_TABLE_DEFINITION, pTableDefBody);
   setChild(INDEX_ATTRIBUTE_LIST, pCreateTableAttrList);
@@ -4446,7 +4448,8 @@ StmtDDLCreateTable::synthesize()
 	    {
 	      // make the storeby list the primary key
 	      ElemDDLConstraintPK * pk = 
-		new (PARSERHEAP()) ElemDDLConstraintPK();
+		new (PARSERHEAP()) ElemDDLConstraintPK
+                (NULL, sbkcl->getSerializedOption());
 	      pk->setColumnRefList(keyColsList);
 	      pk->setConstraintKind(ElemDDLConstraint::TABLE_CONSTRAINT_DEF);
 	      pk->setConstraintAttributes(NULL);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/StmtDDLCreateTable.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCreateTable.h b/core/sql/parser/StmtDDLCreateTable.h
index 9606c70..43e52da 100644
--- a/core/sql/parser/StmtDDLCreateTable.h
+++ b/core/sql/parser/StmtDDLCreateTable.h
@@ -249,12 +249,17 @@ public:
 
   inline const CorrName & getLikeSourceTableCorrName() const;
   inline const NAString getLikeSourceTableName() const;
-  inline const ExtendedQualName::SpecialTableType getLikeSourceTableType() const; //++ MV
+  inline const ExtendedQualName::SpecialTableType getLikeSourceTableType() const; 
+  inline const QualifiedName & getOrigLikeSourceTableName() const;
+  inline       QualifiedName & getOrigLikeSourceTableName();
 
         // returns the name of the source table in the LIKE
         // clause.  If LIKE clause is not specified, an
         // empty string is returned.
 
+
+  void setLikeSourceTableName(CorrName &srcName);
+
   inline const ParDDLLikeOptsCreateTable & getLikeOptions() const;
   inline       ParDDLLikeOptsCreateTable & getLikeOptions();
 
@@ -532,6 +537,12 @@ public:
   NABoolean createIfNotExists() { return createIfNotExists_; }
   void setCreateIfNotExists(NABoolean v) { createIfNotExists_ = v; }
 
+  NABoolean mapToHbaseTable() { return mapToHbaseTable_; }
+  void setMapToHbaseTable(NABoolean v) { mapToHbaseTable_ = v; }
+
+  NABoolean isHbaseDataFormatString() { return (hbaseDataFormat_ == TRUE); }
+  void setHbaseDataFormat(NABoolean v) { hbaseDataFormat_ = v; }
+
 private:
 
   // ---------------------------------------------------------------------
@@ -632,7 +643,8 @@ private:
   // LIKE clause related information
 
   NABoolean isLikeClauseSpec_;
-  CorrName likeSourceTableCorrName_; //++ MV
+  CorrName likeSourceTableCorrName_; 
+  QualifiedName origLikeSourceTableQualName_;
   ParDDLLikeOptsCreateTable likeOptions_;
 
   // ATTRIBUTES clause
@@ -740,6 +752,15 @@ private:
   // Aligned or Packed table data format
   NABoolean isAlignedTableFormatSpecified_;
 
+  // external table to be mapped to hbase table
+  NABoolean mapToHbaseTable_;
+
+  // data format of external mapped table.
+  // TRUE:  data is in string/varchar format
+  // FALSE: data is in native type format (for ex: 2 byte short for integer...)
+  // This field is only valid if mapToHbaseTable_ is set.
+  NABoolean hbaseDataFormat_;
+
   // Each element of the following arrays is a pointer
   // pointing to a StmtDDLAddConstraint parse node in
   // the parse sub-tree containing the table body
@@ -1039,6 +1060,23 @@ StmtDDLCreateTable::getLikeSourceTableName() const
   return likeSourceTableCorrName_.getQualifiedNameObj().getQualifiedNameAsAnsiString();
 }
 
+inline void StmtDDLCreateTable::setLikeSourceTableName(CorrName &srcName)
+{
+  likeSourceTableCorrName_ = srcName;
+}
+
+inline QualifiedName &
+StmtDDLCreateTable::getOrigLikeSourceTableName()
+{
+  return origLikeSourceTableQualName_;
+}
+
+inline const QualifiedName &
+StmtDDLCreateTable::getOrigLikeSourceTableName() const
+{
+  return origLikeSourceTableQualName_;
+}
+
 //++ MV
 inline const ExtendedQualName::SpecialTableType 
 StmtDDLCreateTable::getLikeSourceTableType() const

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/StmtDDLMisc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLMisc.cpp b/core/sql/parser/StmtDDLMisc.cpp
index 810dbbd..095c7a9 100644
--- a/core/sql/parser/StmtDDLMisc.cpp
+++ b/core/sql/parser/StmtDDLMisc.cpp
@@ -105,6 +105,10 @@ StmtDDLCleanupObjects::bindNode(BindWA * pBindWA)
                       tableName.getObjectNamePart().getInternalName(),
                       tableName.getSchemaNamePart().getInternalName(),
                       tableName.getCatalogNamePart().getInternalName());
+
+      // remember the original table name specified by user
+      origTableQualName_ = *tableQualName_;
+
       if (applyDefaultsAndValidateObject(pBindWA, tableQualName_))
         {
           pBindWA->setErrStatus();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 905eb58..5fff4f0 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -1379,6 +1379,7 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %token <tokval> TOK_STORE               /* Tandem extension */
 %token <tokval> TOK_STORAGE
 %token <tokval> TOK_STATISTICS          /* Tandem extension non-reserved word */
+%token <tokval> TOK_HBMAP_TABLE
 %token <tokval> TOK_STATS
 %token <tokval> TOK_UNBOUNDED           /* Tandem extension */
 %token <tokval> TOK_VIEW
@@ -2705,6 +2706,8 @@ static void enableMakeQuotedStringISO88591Mechanism()
 %type <item>                    range_n_args
 %type <item>                    range_n_arg
 %type <boolean>                 optional_in_memory_clause
+%type <stringval>               optional_map_to_hbase_clause
+%type <boolean>                 optional_hbase_data_format
 %type <dropBehaviorEnum>  	extension_drop_behavior
 %type <dropBehaviorEnum>  	optional_drop_behavior
 %type <dropBehaviorEnum>  	optional_drop_index_behavior
@@ -5288,6 +5291,13 @@ special_table_name : special_regular_table_name
                 else
                   { yyerror(""); YYERROR; /*internal syntax only!*/}
               }
+
+	   /* Hbase Mapped tables */
+	   | TOK_TABLE '(' TOK_HBMAP_TABLE actual_table_name ')'
+	      {
+                $4->setSpecialType(ExtendedQualName::HBMAP_TABLE);
+                $$ = $4;  // actual_table_name
+              }
 		
 exception_table_name :  TOK_EXCEPTION TOK_TABLE actual_table_name 
 		{
@@ -5427,6 +5437,7 @@ actual_table_name : qualified_name
 		     //
 		     $$ = corrNameFromStrings($1);
 		     if ($$ == NULL) YYABORT;
+
                      //ct-bug-10-030102-3803 -Begin
                      NAString *tmpName = new (PARSERHEAP()) NAString((""),PARSERHEAP()); 
                      NAString *tmp =new (PARSERHEAP()) NAString(( $$->getQualifiedNameObj().getCatalogName()),PARSERHEAP());
@@ -24895,6 +24906,8 @@ table_definition : create_table_start_tokens ddl_qualified_name
                         table_definition_body
                         optional_create_table_attribute_list
                         optional_in_memory_clause
+                        optional_map_to_hbase_clause
+                        optional_hbase_data_format
 	  	   {
                      $1->setOptions(TableTokens::OPT_NONE);
 		     QualifiedName * qn;
@@ -24905,6 +24918,29 @@ table_definition : create_table_start_tokens ddl_qualified_name
 		     if (! qn)
                        YYABORT;
 
+                     if ($6) // map to hbase table
+                       {
+                         if ($1->getType() != TableTokens::TYPE_EXTERNAL_TABLE)
+                           YYERROR;
+
+                         // cannot be create like
+                         if ($3->castToElemDDLLikeCreateTable())
+                           {
+                             *SqlParser_Diags << DgSqlCode(-3242)
+                                              << DgString0("Cannot specify LIKE clause with mapped hbase tables.");
+                             YYERROR;
+                           }
+                         
+                         // cannot specify cat/schema names
+                         if ((NOT qn->getCatalogName().isNull()) ||
+                             (NOT qn->getSchemaName().isNull()))
+                           {
+                             *SqlParser_Diags << DgSqlCode(-3242)
+                                              << DgString0("Cannot specify catalog or schema names with mapped hbase tables.");
+                             YYERROR;
+                           }
+                       }
+
 		     StmtDDLCreateTable *pNode =
 		       new (PARSERHEAP())
 		       StmtDDLCreateTable(
@@ -24916,6 +24952,16 @@ table_definition : create_table_start_tokens ddl_qualified_name
 			    NULL,
 			    PARSERHEAP());
 
+                     if ($6)
+                       {
+                         CorrName cn(*$6);
+                         pNode->setLikeSourceTableName(cn);
+
+                         pNode->setMapToHbaseTable(TRUE);
+
+                         pNode->setHbaseDataFormat($7);
+                       }
+
                      $1->setTableTokens(pNode);
 		     pNode->synthesize();
 
@@ -25736,7 +25782,18 @@ unique_constraint_specification : TOK_UNIQUE
 unique_specification : unique_constraint_specification
                       | TOK_PRIMARY TOK_KEY
                                 {
-                                  $$ = new (PARSERHEAP()) ElemDDLConstraintPK();
+                                  $$ = new (PARSERHEAP()) 
+                                    ElemDDLConstraintPK(NULL, ComPkeySerialization::COM_SER_NOT_SPECIFIED);
+                                }
+                      | TOK_PRIMARY TOK_KEY TOK_SERIALIZED
+                                {
+                                  $$ = new (PARSERHEAP()) 
+                                    ElemDDLConstraintPK(NULL, ComPkeySerialization::COM_SERIALIZED);
+                                }
+                      | TOK_PRIMARY TOK_KEY TOK_NOT TOK_SERIALIZED
+                                {
+                                  $$ = new (PARSERHEAP()) 
+                                    ElemDDLConstraintPK(NULL, ComPkeySerialization::COM_NOT_SERIALIZED);
                                 }
 
 /* type pElemDDLConstraint */
@@ -26324,6 +26381,11 @@ like_option : TOK_WITHOUT TOK_CONSTRAINTS
                                   $$ = new (PARSERHEAP())
                                     ElemDDLLikeLimitColumnLength($5);
                                 }
+                      | TOK_WITHOUT TOK_ROW TOK_FORMAT
+                                {
+                                  $$ = new (PARSERHEAP())
+				    ElemDDLLikeOptWithoutRowFormat();
+                                }
 
 /* type pElemDDL */
 optional_create_table_attribute_list : create_table_as_attr_list_start
@@ -27081,6 +27143,33 @@ optional_in_memory_clause : empty
 			       $$ = TRUE; 
 			     }
 
+/* type stringval */
+optional_map_to_hbase_clause : empty
+                             {   
+                               $$ = NULL;
+			     }
+                            | TOK_MAP TOK_TO TOK_HBASE TOK_TABLE identifier
+                             { 
+			       $$ = $5; 
+			     }
+/* type int */
+optional_hbase_data_format : empty
+                             {   
+                               $$ = TRUE; // varchar format
+			     }
+                            | TOK_DATA TOK_FORMAT TOK_VARCHAR
+                             { 
+			       // data is stored in var length string format 
+			       // For ex, 123 is stored as a 3 byte string "123"
+			       $$ = TRUE; 
+			     }
+                            | TOK_DATA TOK_FORMAT TOK_NATIVE
+                             { 
+			       // data is stored in native format.
+			       // For ex, smallint is stored as 2 byte binary
+			       $$ = FALSE;
+			     }
+
 hbase_table_options : TOK_HBASE_OPTIONS '('  hbase_options_list ')'
                               {
 				$$ = new (PARSERHEAP()) 
@@ -27409,14 +27498,32 @@ store_by_clause : TOK_STORE TOK_BY store_option_clause
                                     ElemDDLStoreOptKeyColumnList(
                                        $3 /*column_reference_list*/);
                                 }
+                  | TOK_PRIMARY TOK_KEY TOK_NOT TOK_SERIALIZED '(' column_reference_list ')' 
+                                {
+                                  $$ = new (PARSERHEAP())
+                                    ElemDDLStoreOptKeyColumnList(
+                                       $6 /*column_reference_list*/,
+				       TRUE, FALSE, TRUE);
+                                  ((ElemDDLStoreOptKeyColumnList*)$$)->
+                                    setSerializedOption(ComPkeySerialization::COM_NOT_SERIALIZED);
+                                }
+
+                  | TOK_PRIMARY TOK_KEY TOK_SERIALIZED '(' column_reference_list ')' 
+                                {
+                                  $$ = new (PARSERHEAP())
+                                    ElemDDLStoreOptKeyColumnList(
+                                       $5 /*column_reference_list*/,
+				       TRUE, FALSE, TRUE);
+                                  ((ElemDDLStoreOptKeyColumnList*)$$)->
+                                    setSerializedOption(ComPkeySerialization::COM_SERIALIZED);
+                                }
+
                   | TOK_PRIMARY TOK_KEY  '(' column_reference_list ')'
                                 {
                                   $$ = new (PARSERHEAP())
                                     ElemDDLStoreOptKeyColumnList(
                                        $4 /*column_reference_list*/,
 				       TRUE, FALSE, TRUE);
-				       //                                       TRUE, FALSE,
-				       //				       TRUE);
                                 }
 
 /* type pElemDDL */
@@ -32270,7 +32377,13 @@ drop_table_statement : TOK_DROP special_table_name optional_drop_behavior
                      $$->castToStmtDDLDropTable()->setTableType(ExtendedQualName::GHOST_TABLE);
                    }
 
-                   if ($1 == 2 || $1 == 4)
+                  if ($1 == 3 || $1 == 4)
+                     $$->castToStmtDDLDropTable()->setIsExternal(TRUE);
+
+                  if ($1 == 5 || $1 == 6)
+                     $$->castToStmtDDLDropTable()->setIsExternal(TRUE);
+
+                   if ($1 == 2 || $1 == 4 || $1 == 6)
                      {
                        $$->castToStmtDDLDropTable()->setDropIfExists(TRUE);
                      }
@@ -33458,6 +33571,7 @@ nonreserved_word :      TOK_ABORT
                       | TOK_LOW_VALUE
      //                 | TOK_LSDECIMAL  //->nonreserved_datatype         
                       | TOK_M
+                      | TOK_MAP
                       | TOK_MASTER
                       | TOK_MATERIALIZED  
 		      | TOK_MAXEXTENTS // Extent Changes : Swati Ambulkar
@@ -33660,6 +33774,7 @@ nonreserved_word :      TOK_ABORT
                       | TOK_STYLE
                       | TOK_SUBCLASS_ORIGIN
                       | TOK_SUBSYSTEM_ID
+                      | TOK_HBMAP_TABLE
                       | TOK_SUSPEND
                       | TOK_SYNONYMS
                       | TOK_T                 /* ODBC extension  */

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/core/EXPECTED061.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/EXPECTED061.SB b/core/sql/regress/core/EXPECTED061.SB
index 339643e..6aacb34 100755
--- a/core/sql/regress/core/EXPECTED061.SB
+++ b/core/sql/regress/core/EXPECTED061.SB
@@ -234,34 +234,34 @@ N1                    C2    C4
 >>
 >>create index  t061i1 on vut4495(a);
 
-*** ERROR[1127] The specified table TRAFODION.SCH.VUT4495 is not a base table.  Please verify that the correct table was specified.
+*** ERROR[1127] The specified table TRAFODION.SCH.VUT4495 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 
 --- SQL operation failed with errors.
 >>
 >>create table t061t33(t061t3_c int references vut4495);
 
-*** ERROR[1127] The specified table TRAFODION.SCH.VUT4495 is not a base table.  Please verify that the correct table was specified.
+*** ERROR[1127] The specified table TRAFODION.SCH.VUT4495 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 
 *** ERROR[1029] Object TRAFODION.SCH.T061T33 could not be created.
 
 --- SQL operation failed with errors.
 >>create table t061t4(t061t4_c int references vut4495(a));
 
-*** ERROR[1127] The specified table TRAFODION.SCH.VUT4495 is not a base table.  Please verify that the correct table was specified.
+*** ERROR[1127] The specified table TRAFODION.SCH.VUT4495 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 
 *** ERROR[1029] Object TRAFODION.SCH.T061T4 could not be created.
 
 --- SQL operation failed with errors.
 >>create table t061t5(t061t5_c int, foreign key(t061t5_c) references vut4495);
 
-*** ERROR[1127] The specified table TRAFODION.SCH.VUT4495 is not a base table.  Please verify that the correct table was specified.
+*** ERROR[1127] The specified table TRAFODION.SCH.VUT4495 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 
 *** ERROR[1029] Object TRAFODION.SCH.T061T5 could not be created.
 
 --- SQL operation failed with errors.
 >>create table t061t6(t061t6_c int, foreign key(t061t6_c) references vut4495(a));
 
-*** ERROR[1127] The specified table TRAFODION.SCH.VUT4495 is not a base table.  Please verify that the correct table was specified.
+*** ERROR[1127] The specified table TRAFODION.SCH.VUT4495 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 
 *** ERROR[1029] Object TRAFODION.SCH.T061T6 could not be created.
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/executor/EXPECTED013.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/executor/EXPECTED013.SB b/core/sql/regress/executor/EXPECTED013.SB
index 1c488f3..5c0011a 100644
--- a/core/sql/regress/executor/EXPECTED013.SB
+++ b/core/sql/regress/executor/EXPECTED013.SB
@@ -349,7 +349,7 @@ CREATE VIEW TRAFODION.T013_SCH.TEMPV AS
 >>-- this will return an error, no permanent table exists
 >>alter table t013t2 add column z int default 0 not null;
 
-*** ERROR[1146] Object TRAFODION.T013_SCH.T013T2 could not be altered because it either does not exist or is not a table.
+*** ERROR[1127] The specified table TRAFODION.T013_SCH.T013T2 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 
 --- SQL operation failed with errors.
 >>

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/hive/EXPECTED009
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED009 b/core/sql/regress/hive/EXPECTED009
index 372d5de..c4c038c 100644
--- a/core/sql/regress/hive/EXPECTED009
+++ b/core/sql/regress/hive/EXPECTED009
@@ -1,13 +1,13 @@
 >>obey TEST009(set_up);
 >>prepare get_hv_schemas from
 +>select schema_name from "_MD_".objects
-+>where schema_name like '_HV_%' and object_type = 'PS';
++>where schema_name like '\_HV\_%' escape '\' and object_type = 'PS';
 
 --- SQL command prepared.
 >>
 >>prepare get_hb_schemas from
 +>select schema_name from "_MD_".objects
-+>where schema_name like '_HB_%' and object_type = 'PS';
++>where schema_name like '\_HB\_\_%' escape '\' and object_type = 'PS';
 
 --- SQL command prepared.
 >>

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/hive/TEST009
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/TEST009 b/core/sql/regress/hive/TEST009
index a36acb4..eda1f42 100755
--- a/core/sql/regress/hive/TEST009
+++ b/core/sql/regress/hive/TEST009
@@ -97,11 +97,11 @@ execute get_hb_schemas;
 ?section set_up
 prepare get_hv_schemas from
 select schema_name from "_MD_".objects
-where schema_name like '_HV_%' and object_type = 'PS';
+where schema_name like '\_HV\_%' escape '\' and object_type = 'PS';
 
 prepare get_hb_schemas from
 select schema_name from "_MD_".objects
-where schema_name like '_HB_%' and object_type = 'PS';
+where schema_name like '\_HB\_\_%' escape '\' and object_type = 'PS';
 
 ?section test_hive1
 -- create external tables for precreated tables

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/privs2/EXPECTED138
----------------------------------------------------------------------
diff --git a/core/sql/regress/privs2/EXPECTED138 b/core/sql/regress/privs2/EXPECTED138
index 96f88f4..9643889 100644
--- a/core/sql/regress/privs2/EXPECTED138
+++ b/core/sql/regress/privs2/EXPECTED138
@@ -380,7 +380,7 @@ CREATE TABLE TRAFODION.T138SCH.USER1_T2
 
 >>alter table user1_t4 rename to user1_t1;
 
-*** ERROR[1389] Object TRAFODION.T138SCH.USER1_T4 does not exist in Trafodion.
+*** ERROR[1127] The specified table TRAFODION.T138SCH.USER1_T4 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 
 --- SQL operation failed with errors.
 >>
@@ -794,7 +794,7 @@ CREATE TABLE TRAFODION.T138SCH.USER1_T2
 
 >>alter table user1_t4 rename to user1_t1;
 
-*** ERROR[1389] Object TRAFODION.T138SCH.USER1_T4 does not exist in Trafodion.
+*** ERROR[1127] The specified table TRAFODION.T138SCH.USER1_T4 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 
 --- SQL operation failed with errors.
 >>
@@ -1206,7 +1206,7 @@ CREATE TABLE TRAFODION.T138SCH.USER1_T2
 
 >>alter table user1_t4 rename to user1_t1;
 
-*** ERROR[1389] Object TRAFODION.T138SCH.USER1_T4 does not exist in Trafodion.
+*** ERROR[1127] The specified table TRAFODION.T138SCH.USER1_T4 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
 
 --- SQL operation failed with errors.
 >>


[7/7] incubator-trafodion git commit: Merge [TRAFODION-1586] PR-878 Support for external traf tables mapped to native hbase tables

Posted by an...@apache.org.
Merge [TRAFODION-1586] PR-878 Support for external traf tables mapped to native hbase tables


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

Branch: refs/heads/master
Commit: 4d33839625d0415c16d89dcedd0ab269b58a635c
Parents: 2581c0d b1aabd6
Author: Anoop Sharma <an...@esgyn.com>
Authored: Sat Dec 17 00:32:49 2016 +0000
Committer: Anoop Sharma <an...@esgyn.com>
Committed: Sat Dec 17 00:32:49 2016 +0000

----------------------------------------------------------------------
 core/sql/bin/SqlciErrors.txt                    |    8 +-
 core/sql/comexe/ComTdb.h                        |    2 +
 core/sql/comexe/ComTdbHbaseAccess.cpp           |   17 +-
 core/sql/comexe/ComTdbHbaseAccess.h             |   25 +-
 core/sql/common/ComMisc.cpp                     |    8 +
 core/sql/common/ComMisc.h                       |    2 +
 core/sql/common/ComResWords.cpp                 |    1 -
 core/sql/common/ComSmallDefs.h                  |   26 +-
 core/sql/common/OperTypeEnum.h                  |    1 +
 core/sql/executor/ExExeUtil.h                   |    4 +-
 core/sql/executor/ExExeUtilGet.cpp              |   35 +-
 core/sql/executor/ExHbaseAccess.cpp             |  303 ++-
 core/sql/executor/ExHbaseAccess.h               |    7 +-
 core/sql/executor/ExHbaseIUD.cpp                |   22 +-
 core/sql/executor/ExHbaseSelect.cpp             |    4 +-
 core/sql/executor/HBaseClient_JNI.cpp           |   26 +-
 core/sql/exp/ExpErrorEnums.h                    |    1 +
 core/sql/exp/exp_function.cpp                   |    9 +-
 core/sql/generator/GenExpGenerator.cpp          |  159 +-
 core/sql/generator/GenExpGenerator.h            |   57 +-
 core/sql/generator/GenKey.cpp                   |  140 +-
 core/sql/generator/GenPreCode.cpp               |   19 +-
 core/sql/generator/GenRelScan.cpp               |  271 ++-
 core/sql/generator/GenRelUpdate.cpp             |   77 +-
 core/sql/generator/Generator.cpp                |    1 +
 core/sql/optimizer/BindRelExpr.cpp              |  129 +-
 core/sql/optimizer/BindWA.h                     |    5 +
 core/sql/optimizer/NAColumn.h                   |    9 +-
 core/sql/optimizer/NAFileSet.cpp                |    7 +
 core/sql/optimizer/NAFileSet.h                  |    2 +-
 core/sql/optimizer/NATable.cpp                  |   29 +-
 core/sql/optimizer/NATable.h                    |   20 +-
 core/sql/optimizer/ObjectNames.cpp              |   10 +
 core/sql/optimizer/ObjectNames.h                |    3 +
 core/sql/optimizer/RelScan.h                    |    9 +-
 core/sql/parser/BindStmtDDL.cpp                 |    4 +
 core/sql/parser/ElemDDLConstraintPK.h           |   37 +-
 core/sql/parser/ElemDDLLikeOptions.cpp          |   23 +
 core/sql/parser/ElemDDLLikeOptions.h            |   28 +
 core/sql/parser/ElemDDLNode.cpp                 |    5 +
 core/sql/parser/ElemDDLNode.h                   |    2 +
 core/sql/parser/ElemDDLStoreOptions.cpp         |    3 +-
 core/sql/parser/ElemDDLStoreOptions.h           |   14 +
 core/sql/parser/ParDDLLikeOpts.cpp              |   16 +
 core/sql/parser/ParDDLLikeOptsCreateTable.h     |   14 +-
 core/sql/parser/ParKeyWords.cpp                 |    3 +-
 core/sql/parser/SqlParserAux.h                  |    2 +
 core/sql/parser/StmtDDLAlterTable.h             |   18 +
 core/sql/parser/StmtDDLCleanupObjects.h         |   18 +
 core/sql/parser/StmtDDLCreate.cpp               |    7 +-
 core/sql/parser/StmtDDLCreateTable.h            |   42 +-
 core/sql/parser/StmtDDLMisc.cpp                 |    4 +
 core/sql/parser/sqlparser.y                     |  123 +-
 core/sql/regress/compGeneral/DIFF042.KNOWN      |  106 +-
 core/sql/regress/core/EXPECTED005.SB            |    2 +-
 core/sql/regress/core/EXPECTED061.SB            |   10 +-
 core/sql/regress/executor/EXPECTED013.SB        |    2 +-
 core/sql/regress/hive/EXPECTED009               |    4 +-
 core/sql/regress/hive/TEST009                   |    4 +-
 core/sql/regress/privs2/EXPECTED138             |    6 +-
 core/sql/regress/seabase/EXPECTED022            |  872 ++++++++-
 core/sql/regress/seabase/EXPECTED027            |    2 +-
 core/sql/regress/seabase/TEST022                |  284 ++-
 core/sql/regress/tools/regress-filter-linux     |    4 +-
 core/sql/smdio/CmUtil.cpp                       |    1 -
 core/sql/sqlcat/TrafDDLdesc.h                   |    7 +-
 core/sql/sqlcat/desc.h                          |   29 -
 core/sql/sqlcomp/CmpDescribe.cpp                |  153 +-
 core/sql/sqlcomp/CmpSeabaseDDL.h                |   36 +-
 core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp       |    3 +-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp        |    2 +
 core/sql/sqlcomp/CmpSeabaseDDLindex.cpp         |   38 +-
 core/sql/sqlcomp/CmpSeabaseDDLschema.cpp        |   10 +-
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp         | 1813 +++++++++---------
 core/sql/sqlcomp/CmpSeabaseDDLutil.cpp          |    6 +-
 core/sql/sqlcomp/CmpSeabaseDDLview.cpp          |  100 +-
 core/sql/sqlcomp/DefaultConstants.h             |    4 +
 core/sql/sqlcomp/nadefaults.cpp                 |    3 +
 .../java/org/trafodion/sql/HBaseClient.java     |    1 -
 core/sql/ustat/hs_la.cpp                        |    2 +
 80 files changed, 3620 insertions(+), 1695 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4d338396/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4d338396/core/sql/common/OperTypeEnum.h
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4d338396/core/sql/exp/ExpErrorEnums.h
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4d338396/core/sql/exp/exp_function.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4d338396/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4d338396/core/sql/parser/ParKeyWords.cpp
----------------------------------------------------------------------

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

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4d338396/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4d338396/core/sql/sqlcomp/DefaultConstants.h
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4d338396/core/sql/sqlcomp/nadefaults.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/4d338396/core/sql/src/main/java/org/trafodion/sql/HBaseClient.java
----------------------------------------------------------------------