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:21 UTC

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

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();