trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ansha...@apache.org
Subject [4/6] trafodion git commit: TRAFODION-3086 Further enhancements to 'DDL on Hive objects'
Date Wed, 20 Jun 2018 18:53:46 GMT
TRAFODION-3086 Further enhancements to 'DDL on Hive objects'

-- Hive CTAS enhancements
  -- CTAS will do create through Hive and insert...select in Traf
  -- a cqd can be set if CTAS need to be passed in completely to Hive
  -- CTAS 'no load' option can be used to create a Hive
     table LIKE a traf table.
     Older 'create hive like traf' is removed.

-- explain for CTAS to show ddl, insert...select, upd...stats stmts

-- Truncate enhancements.
  -- traf: purgedata, truncate, truncate table
  -- Hive: truncate, truncate table
  -- 'if exists' option has been added

-- Hive truncate is through new exeutil operator
  -- older operator uses LOB interface to clear data.
     Maintained as Legacy operator, will be removed.
  -- new operator uses Hive to truncate tables

-- explain for truncate to show trunc query that will be sent

-- removed obsolete parallel label op
-- removed obsolete purgedata (fast delete) op


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

Branch: refs/heads/master
Commit: 2bba19ffaa8b6737e928ad98e4b0cf8cc6b24349
Parents: 9f3fb9f
Author: Anoop Sharma <anoop.sharma@esgyn.com>
Authored: Tue Jun 19 19:50:13 2018 +0000
Committer: Anoop Sharma <anoop.sharma@esgyn.com>
Committed: Tue Jun 19 19:50:13 2018 +0000

----------------------------------------------------------------------
 core/sql/arkcmp/CmpStatement.cpp         |    1 -
 core/sql/arkcmp/CmpStatement.h           |    5 -
 core/sql/comexe/ComTdb.cpp               |    6 -
 core/sql/comexe/ComTdb.h                 |    1 -
 core/sql/comexe/ComTdbExeUtil.cpp        |  149 +---
 core/sql/comexe/ComTdbExeUtil.h          |  156 +---
 core/sql/common/ComMisc.cpp              |   47 +
 core/sql/common/ComMisc.h                |   14 +
 core/sql/executor/ExComTdb.cpp           |    6 -
 core/sql/executor/ExExeUtil.h            |  198 ++---
 core/sql/executor/ExExeUtilMisc.cpp      | 1156 +++++--------------------
 core/sql/executor/hiveHook.cpp           |   47 +-
 core/sql/exp/ExpErrorEnums.h             |    2 -
 core/sql/generator/GenExplain.cpp        |   23 +
 core/sql/generator/GenPreCode.cpp        |   16 +-
 core/sql/generator/GenRelExeUtil.cpp     |  243 ++----
 core/sql/optimizer/BindRelExpr.cpp       |   14 +-
 core/sql/optimizer/ImplRule.h            |   64 --
 core/sql/optimizer/RelCache.cpp          |    4 -
 core/sql/optimizer/RelExeUtil.cpp        |  208 +++--
 core/sql/optimizer/RelExeUtil.h          |  179 ++--
 core/sql/optimizer/RelExpr.cpp           |    2 -
 core/sql/optimizer/RelFastTransport.cpp  |   75 +-
 core/sql/optimizer/RelUpdate.h           |   15 -
 core/sql/parser/sqlparser.y              |  153 +---
 core/sql/regress/hive/EXPECTED005        |  125 +--
 core/sql/regress/hive/EXPECTED008        |    5 +-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp |   24 +
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp  |  168 +---
 core/sql/sqlcomp/DefaultConstants.h      |    2 -
 core/sql/sqlcomp/nadefaults.cpp          |    2 -
 31 files changed, 970 insertions(+), 2140 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/arkcmp/CmpStatement.cpp
----------------------------------------------------------------------
diff --git a/core/sql/arkcmp/CmpStatement.cpp b/core/sql/arkcmp/CmpStatement.cpp
index f66baae..57253b9 100644
--- a/core/sql/arkcmp/CmpStatement.cpp
+++ b/core/sql/arkcmp/CmpStatement.cpp
@@ -151,7 +151,6 @@ CmpStatement::CmpStatement(CmpContext* context,
   recompiling_ = FALSE;
   isDDL_ = FALSE;
   isSMDRecompile_ = FALSE;
-  isParallelLabelOp_ = FALSE;
   displayGraph_ = FALSE;
   cses_ = NULL;
   detailsOnRefusedRequirements_ = NULL;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/arkcmp/CmpStatement.h
----------------------------------------------------------------------
diff --git a/core/sql/arkcmp/CmpStatement.h b/core/sql/arkcmp/CmpStatement.h
index 097d0cf..c5d8dad 100644
--- a/core/sql/arkcmp/CmpStatement.h
+++ b/core/sql/arkcmp/CmpStatement.h
@@ -160,9 +160,6 @@ public:
   //is this statement a DDL statement
   inline NABoolean isDDL(){return isDDL_;}
 
-  inline NABoolean isParallelLabelOp() { return isParallelLabelOp_; }
-  inline void setParallelLabelOp(NABoolean flag) { isParallelLabelOp_ = flag; }
-
   QueryAnalysis* getQueryAnalysis() { return queryAnalysis_; };
   QueryAnalysis* initQueryAnalysis();
 
@@ -292,8 +289,6 @@ private:
   //flag, indicates if this is a DDL statment
   NABoolean isDDL_;
 
-  NABoolean isParallelLabelOp_;
-
   // CompilationStats object that is recording the compilation stats for this statement
   CompilationStats* compStats_;
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/comexe/ComTdb.cpp
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdb.cpp b/core/sql/comexe/ComTdb.cpp
index 2578c46..4770f59 100644
--- a/core/sql/comexe/ComTdb.cpp
+++ b/core/sql/comexe/ComTdb.cpp
@@ -576,12 +576,6 @@ char *ComTdb::findVTblPtrCom(short classID)
       break;
     }
 
-    case ex_FAST_DELETE:
-    {
-      GetVTblPtr(vtblptr,ComTdbExeUtilFastDelete);
-      break;
-    }
-
     case ex_HIVE_TRUNCATE:
     {
       GetVTblPtr(vtblptr,ComTdbExeUtilHiveTruncate);

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/comexe/ComTdb.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdb.h b/core/sql/comexe/ComTdb.h
index 1b90b90..ea0a026 100644
--- a/core/sql/comexe/ComTdb.h
+++ b/core/sql/comexe/ComTdb.h
@@ -251,7 +251,6 @@ public:
     ex_CLEANUP_VOLATILE_TABLES = 109,
     ex_GET_VOLATILE_INFO = 110,
     ex_CREATE_TABLE_AS = 111,
-    ex_FAST_DELETE       = 112,
     ex_GET_STATISTICS    = 113,
     ex_PROBE_CACHE = 114,
     ex_LONG_RUNNING = 116,

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/comexe/ComTdbExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbExeUtil.cpp b/core/sql/comexe/ComTdbExeUtil.cpp
index c7c5a8c..df34a5d 100644
--- a/core/sql/comexe/ComTdbExeUtil.cpp
+++ b/core/sql/comexe/ComTdbExeUtil.cpp
@@ -1139,141 +1139,6 @@ void ComTdbExeUtilCreateTableAs::displayContents(Space * space,ULng32 flag)
     }
 }
 
-
-
-
-///////////////////////////////////////////////////////////////////////////
-//
-// Methods for class ComTdbExeUtilFastDelete
-//
-///////////////////////////////////////////////////////////////////////////
-ComTdbExeUtilFastDelete::ComTdbExeUtilFastDelete(
-     char * tableName,
-     ULng32 tableNameLen,
-     char * primaryPartnLoc,
-     Queue * indexList,
-     char * stmt,
-     ULng32 stmtLen,
-     Lng32 numEsps,
-     Int64 objectUID,
-     Lng32 numLOBs,
-     char * lobNumArray,
-     ex_cri_desc * work_cri_desc,
-     const unsigned short work_atp_index,
-     ex_cri_desc * given_cri_desc,
-     ex_cri_desc * returned_cri_desc,
-     queue_index down,
-     queue_index up,
-     Lng32 num_buffers,
-     ULng32 buffer_size)
-     : ComTdbExeUtil(ComTdbExeUtil::FAST_DELETE_,
-		     NULL, 0, (Int16)SQLCHARSETCODE_UNKNOWN,
-		     tableName, tableNameLen,
-		     NULL, 0,
-		     NULL, 0,
-		     NULL,
-		     work_cri_desc, work_atp_index,
-		     given_cri_desc, returned_cri_desc,
-		     down, up, 
-		     num_buffers, buffer_size),
-       flags_(0),
-       indexList_(indexList),
-       purgedataStmt_(stmt),
-       purgedataStmtLen_(stmtLen),
-       primaryPartnLoc_(primaryPartnLoc),
-       numEsps_(numEsps),
-       objectUID_(objectUID),
-       numLOBs_(numLOBs),
-       lobNumArray_(lobNumArray)
-{
-  setNodeType(ComTdb::ex_FAST_DELETE);
-}
-
-Long ComTdbExeUtilFastDelete::pack(void * space)
-{
-  indexList_.pack(space);
-
-  if (purgedataStmt_) 
-    purgedataStmt_.pack(space);
-
-  if (primaryPartnLoc_)
-    primaryPartnLoc_.pack(space);
-
-  if (lobNumArray_) 
-    lobNumArray_.pack(space);
-
-  return ComTdbExeUtil::pack(space);
-}
-
-Lng32 ComTdbExeUtilFastDelete::unpack(void * base, void * reallocator)
-{
-  if(indexList_.unpack(base, reallocator)) return -1;
-
-  if (purgedataStmt_.unpack(base)) 
-    return -1;
-
-  if (primaryPartnLoc_.unpack(base))
-    return -1;
-
-  if(lobNumArray_.unpack(base)) 
-    return -1;
-
-  return ComTdbExeUtil::unpack(base, reallocator);
-}
-
-short ComTdbExeUtilFastDelete::getLOBnum(short i)
-{
-  if ((i > numLOBs_) || (i <= 0))
-    return -1;
-
-  short lobNum = *((short*)&getLOBnumArray()[2*(i-1)]);
-
-  return lobNum;
-}
-
-void ComTdbExeUtilFastDelete::displayContents(Space * space,
-					      ULng32 flag)
-{
-  ComTdb::displayContents(space,flag & 0xFFFFFFFE);
-  
-  if(flag & 0x00000008)
-    {
-      char buf[500];
-      str_sprintf(buf, "\nFor ComTdbExeUtilFastDelete :");
-      space->allocateAndCopyToAlignedSpace(buf, str_len(buf), sizeof(short));
-      
-      if (getTableName() != NULL)
-	{
-	  str_sprintf(buf,"Tablename = %s ",getTableName());
-	  space->allocateAndCopyToAlignedSpace(buf, str_len(buf), 
-					       sizeof(short));
-	}
-
-      if (purgedataStmt_)
-	{
-	  str_sprintf(buf,"purgedataStmt_ = %s ", purgedataStmt());
-	  space->allocateAndCopyToAlignedSpace(buf, str_len(buf), 
-					       sizeof(short));
-	}
-
-      if (numLOBs_ > 0)
-	{
-	  str_sprintf(buf, "numLOBs_ = %d ", numLOBs_);
-	  space->allocateAndCopyToAlignedSpace(buf, str_len(buf), 
-					       sizeof(short));
-	}
- 
-    }
-
-  
-  if (flag & 0x00000001)
-    {
-      displayExpression(space,flag);
-      displayChildren(space,flag);
-    }
-
-}
-
 ///////////////////////////////////////////////////////////////////////////
 //
 // Methods for class ComTdbExeUtilHiveTruncate
@@ -1288,6 +1153,7 @@ ComTdbExeUtilHiveTruncate::ComTdbExeUtilHiveTruncate(
      char * hostName,
      Lng32 portNum,
      Int64 modTS,
+     char * hiveTruncQuery,
      ex_cri_desc * given_cri_desc,
      ex_cri_desc * returned_cri_desc,
      queue_index down,
@@ -1310,7 +1176,8 @@ ComTdbExeUtilHiveTruncate::ComTdbExeUtilHiveTruncate(
        partnLocation_(partnLocation),
        hdfsHost_(hostName),
        hdfsPort_(portNum),
-       modTS_(modTS)
+       modTS_(modTS),
+       hiveTruncQuery_(hiveTruncQuery)
 {
   setNodeType(ComTdb::ex_HIVE_TRUNCATE);
 }
@@ -1329,6 +1196,9 @@ Long ComTdbExeUtilHiveTruncate::pack(void * space)
   if (hiveTableName_)
     hiveTableName_.pack(space);
 
+  if (hiveTruncQuery_)
+    hiveTruncQuery_.pack(space);
+
   return ComTdbExeUtil::pack(space);
 }
 
@@ -1346,6 +1216,9 @@ Lng32 ComTdbExeUtilHiveTruncate::unpack(void * base, void * reallocator)
   if (hiveTableName_.unpack(base))
     return -1;
 
+  if (hiveTruncQuery_.unpack(base))
+    return -1;
+
   return ComTdbExeUtil::unpack(base, reallocator);
 }
 
@@ -1388,6 +1261,10 @@ void ComTdbExeUtilHiveTruncate::displayContents(Space * space,
 					       sizeof(short));
 	}
  
+      if (getHiveTruncQuery() != NULL)
+        {
+          
+        }
     }
   
   if (flag & 0x00000001)

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/comexe/ComTdbExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/comexe/ComTdbExeUtil.h b/core/sql/comexe/ComTdbExeUtil.h
index 40742ba..39cd249 100644
--- a/core/sql/comexe/ComTdbExeUtil.h
+++ b/core/sql/comexe/ComTdbExeUtil.h
@@ -65,7 +65,6 @@ public:
     CLEANUP_VOLATILE_SCHEMA_ = 5,
     GET_VOLATILE_INFO        = 6,
     CREATE_TABLE_AS_         = 7,
-    FAST_DELETE_             = 8,
     GET_MAINTAIN_INFO_       = 9,
     GET_STATISTICS_          = 10,
     USER_LOAD_               = 11,
@@ -1507,139 +1506,17 @@ private:
   char fillersComTdbExeUtilCreateTableAs_[92];       // 44-135
 };
 
-class ComTdbExeUtilFastDelete : public ComTdbExeUtil
-{
-public:
-  ComTdbExeUtilFastDelete()
-  : ComTdbExeUtil()
-  {}
-
-  ComTdbExeUtilFastDelete(char * tableName,
-			  ULng32 tableNameLen,
-			  char * primaryPartnLoc,
-			  Queue * indexList,
-			  char * stmt,
-			  ULng32 stmtLen,
-			  Lng32 numEsps,
-			  Int64 objectUID,
-			  Lng32 numLOBs,
-			  char * lobNumArray,
-			  ex_cri_desc * work_cri_desc,
-			  const unsigned short work_atp_index,
-			  ex_cri_desc * given_cri_desc,
-			  ex_cri_desc * returned_cri_desc,
-			  queue_index down,
-			  queue_index up,
-			  Lng32 num_buffers,
-			  ULng32 buffer_size
-			  );
-
-  Long pack(void *);
-  Lng32 unpack(void *, void * reallocator);
-
-
-  // ---------------------------------------------------------------------
-  // Redefine virtual functions required for Versioning.
-  //----------------------------------------------------------------------
-  virtual short getClassSize() {return (short)sizeof(ComTdbExeUtilFastDelete);}
-
-  virtual const char *getNodeName() const
-  {
-    return "FAST_DELETE";
-  };
-
-  Queue* getIndexList()       { return indexList_; }
-
-  char * purgedataStmt()      { return purgedataStmt_; }
-
-  char * getPrimaryPartnLoc()  { return primaryPartnLoc_; }
-
-  Lng32 getNumEsps() { return numEsps_;}
-
-  char * getLOBnumArray() { return lobNumArray_; }
-
-  short getLOBnum(short i);
-
-  UInt16 numLOBs() { return numLOBs_; }
-
-  Int64 getObjectUID() { return objectUID_; }
-
-  // ---------------------------------------------------------------------
-  // Used by the internal SHOWPLAN command to get attributes of a TDB.
-  // ---------------------------------------------------------------------
-  void displayContents(Space *space, ULng32 flag);
-
-  void setDoPurgedataCat(NABoolean v)
-  {(v ? flags_ |= DO_PURGEDATA_CAT : flags_ &= ~DO_PURGEDATA_CAT); };
-  NABoolean doPurgedataCat() { return (flags_ & DO_PURGEDATA_CAT) != 0; };
-
-  void setReturnPurgedataWarn(NABoolean v)
-  {(v ? flags_ |= RETURN_PURGEDATA_WARN : flags_ &= ~RETURN_PURGEDATA_WARN); };
-  NABoolean returnPurgedataWarn() { return (flags_ & RETURN_PURGEDATA_WARN) != 0; };
-
-  void setIsMV(NABoolean v)
-  {(v ? flags_ |= IS_MV: flags_ &= ~IS_MV); };
-  NABoolean isMV() { return (flags_ & IS_MV) != 0; };
-
-  void setDoParallelDelete(NABoolean v)
-  {(v ? flags_ |= DO_PARALLEL_DELETE: flags_ &= ~DO_PARALLEL_DELETE); };
-  NABoolean doParallelDelete() { return (flags_ & DO_PARALLEL_DELETE) != 0; };
-
-  void setDoParallelDeleteIfXn(NABoolean v)
-  {(v ? flags_ |= DO_PARALLEL_DELETE_IF_XN: flags_ &= ~DO_PARALLEL_DELETE_IF_XN); };
-  NABoolean doParallelDeleteIfXn() { return (flags_ & DO_PARALLEL_DELETE_IF_XN) != 0; };
-
-  void setOfflineTable(NABoolean v)
-  {(v ? flags_ |= OFFLINE_TABLE : flags_ &= ~OFFLINE_TABLE); };
-  NABoolean offlineTable() { return (flags_ & OFFLINE_TABLE) != 0; };
-
-  void setDoLabelPurgedata(NABoolean v)
-  {(v ? flags_ |= DO_LABEL_PURGEDATA: flags_ &= ~DO_LABEL_PURGEDATA); };
-  NABoolean doLabelPurgedata() { return (flags_ & DO_LABEL_PURGEDATA) != 0; };
-
-private:
-  enum
-  {
-    DO_PURGEDATA_CAT         = 0x0001,
-    RETURN_PURGEDATA_WARN    = 0x0002,
-    IS_MV                    = 0x0004,
-    DO_PARALLEL_DELETE       = 0x0008,
-    DO_PARALLEL_DELETE_IF_XN = 0x0010,
-    OFFLINE_TABLE            = 0x0020,
-    DO_LABEL_PURGEDATA       = 0x0040
-   };
-
-  // list of indexes on the table.
-  QueuePtr indexList_;                               // 00-07
-
-  NABasicPtr purgedataStmt_;                         // 08-15
-
-  NABasicPtr primaryPartnLoc_;                       // 16-23
-
-  UInt32 purgedataStmtLen_;                          // 24-27
-
-  UInt32 flags_;                                     // 28-31
-
-  UInt32 numEsps_;                                   // 32-35
-
-  // next 3 fields are used if table contains LOBs
-  UInt16 numLOBs_;                                   // 36-37
-  char   filler1_[2];                                // 38-39
-  
-  // array of shorts. numLOBs entries. 
-  // Each entry is the lobNum.
-  NABasicPtr lobNumArray_;                           // 40-47
-
-  Int64 objectUID_;                                  // 48-55
-};
-
 class ComTdbExeUtilHiveTruncate : public ComTdbExeUtil
 {
 public:
   // flags
   enum
   {
-    TRUNC_DROP_TABLE_ON_DEALLOC = 0x0001
+    TRUNC_DROP_TABLE_ON_DEALLOC = 0x0001,
+    IS_LEGACY                   = 0x0002,
+    IS_EXTERNAL                 = 0x0004,
+    IF_EXISTS                   = 0x0008,
+    TABLE_NOT_EXISTS            = 0x0010
   };
 
   ComTdbExeUtilHiveTruncate()
@@ -1654,6 +1531,7 @@ public:
                             char * hostName,
                             Lng32 portNum,
                             Int64 modTS,
+                            char * hiveTruncQuery,
                             ex_cri_desc * given_cri_desc,
                             ex_cri_desc * returned_cri_desc,
                             queue_index down,
@@ -1705,10 +1583,31 @@ public:
     return hiveTableName_;
   }
 
+  char * getHiveTruncQuery() const
+  {
+    return hiveTruncQuery_;
+  }
+
   void setDropOnDealloc(NABoolean v)
   {(v ? flags_ |= TRUNC_DROP_TABLE_ON_DEALLOC : flags_ &= ~TRUNC_DROP_TABLE_ON_DEALLOC); }
   NABoolean getDropOnDealloc() { return (flags_ & TRUNC_DROP_TABLE_ON_DEALLOC) != 0; }
 
+  void setIsLegacy(NABoolean v)
+  {(v ? flags_ |= IS_LEGACY : flags_ &= ~IS_LEGACY); }
+  NABoolean getIsLegacy() { return (flags_ & IS_LEGACY) != 0; }
+
+  void setIsExternal(NABoolean v)
+  {(v ? flags_ |= IS_EXTERNAL : flags_ &= ~IS_EXTERNAL); }
+  NABoolean getIsExternal() { return (flags_ & IS_EXTERNAL) != 0; }
+
+  void setIfExists(NABoolean v)
+  {(v ? flags_ |= IF_EXISTS : flags_ &= ~IF_EXISTS); }
+  NABoolean getIfExists() { return (flags_ & IF_EXISTS) != 0; }
+
+  void setTableNotExists(NABoolean v)
+  {(v ? flags_ |= TABLE_NOT_EXISTS : flags_ &= ~TABLE_NOT_EXISTS); }
+  NABoolean getTableNotExists() { return (flags_ & TABLE_NOT_EXISTS) != 0; }
+
   // ---------------------------------------------------------------------
   // Used by the internal SHOWPLAN command to get attributes of a TDB.
   // ---------------------------------------------------------------------
@@ -1722,6 +1621,7 @@ private:
   Int64 modTS_;                                  // 32-39
   Int32 hdfsPort_;                               // 40-43
   UInt32 flags_;                                 // 44-47
+  NABasicPtr hiveTruncQuery_;                    // 48-55
 };
 
 class ComTdbExeUtilHiveQuery : public ComTdbExeUtil

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/common/ComMisc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/ComMisc.cpp b/core/sql/common/ComMisc.cpp
index b4a0cea..387b309 100644
--- a/core/sql/common/ComMisc.cpp
+++ b/core/sql/common/ComMisc.cpp
@@ -296,6 +296,53 @@ NAString ComConvertTrafNameToNativeName(
   return convertedName;
 }
 
+// Hive names specified in the query may have any of the following
+// forms after they are fully qualified:
+//  hive.hive.t, hive.`default`.t, hive.hivesch.t, hive.hivesch
+// These names are valid in traf environment only and are used to determine
+// if hive ddl is being processed.
+//
+// Return equivalent native hive names of the format:
+//   `default`.t, `default`.t, hivesch.t, hivesch
+// Return NULL string in case of an error.
+NAString ComConvertTrafHiveNameToNativeHiveName(
+     const NAString &catalogName,
+     const NAString &schemaName,
+     const NAString &objectName)
+{
+  NAString newHiveName;
+  if (catalogName.compareTo(HIVE_SYSTEM_CATALOG, NAString::ignoreCase) != 0)
+    {
+      // Invalid hive name in traf environment.
+      return newHiveName;
+    }
+
+  if (schemaName.compareTo(HIVE_DEFAULT_SCHEMA_EXE, NAString::ignoreCase) == 0) // matches  'default'
+    {
+      newHiveName += NAString("`") + schemaName + "`";
+      if (NOT objectName.isNull())
+        newHiveName += ".";
+    }
+  else if (schemaName.compareTo(HIVE_SYSTEM_SCHEMA, NAString::ignoreCase) == 0) // matches  'hive'
+    {
+      // set fully qualified hive default schema name `default`
+      newHiveName += NAString("`default`");
+      if (NOT objectName.isNull())
+        newHiveName += ".";
+    }
+  else // user schema name
+    {
+      newHiveName += schemaName;
+      if (NOT objectName.isNull())
+        newHiveName += ".";
+    }
+
+  if (NOT objectName.isNull())
+    newHiveName += objectName;
+
+  return newHiveName;
+}
+
 NABoolean ComTrafReservedColName(
      const NAString &colName)
 {

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/common/ComMisc.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComMisc.h b/core/sql/common/ComMisc.h
index bbe418d..1581489 100644
--- a/core/sql/common/ComMisc.h
+++ b/core/sql/common/ComMisc.h
@@ -90,6 +90,20 @@ NAString ComConvertTrafNameToNativeName(
                                          const NAString &schemaName,
                                          const NAString &objectName);
 
+// Hive names specified in the query may have any of the following
+// forms after they are fully qualified:
+//  hive.hive.t, hive.`default`.t, hive.hivesch.t, hive.hivesch
+// These names are valid in traf environment only and are used to determine
+// if hive ddl is being processed.
+//
+// Return equivalent native hive names of the format:
+//   `default`.t, `default`.t, hivesch.t, hivesch
+// Return NULL string in case of an error.
+NAString ComConvertTrafHiveNameToNativeHiveName(
+     const NAString &catalogName,
+     const NAString &schemaName,
+     const NAString &objectName);
+
 // returns TRUE if specified name is a reserved name.
 // Currently, reserved names for traf internal usage are:
 //   SYSKEY

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/executor/ExComTdb.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExComTdb.cpp b/core/sql/executor/ExComTdb.cpp
index 68b4cf7..005cdf1 100644
--- a/core/sql/executor/ExComTdb.cpp
+++ b/core/sql/executor/ExComTdb.cpp
@@ -330,12 +330,6 @@ char *ComTdb::findVTblPtrExe(short classID)
       break;
     }
 
-    case ex_FAST_DELETE:
-    {
-      GetVTblPtr(vtblptr,ExExeUtilFastDeleteTdb);
-      break;
-    }
-
     case ex_HIVE_TRUNCATE:
     {
       GetVTblPtr(vtblptr,ExExeUtilHiveTruncateTdb);

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/executor/ExExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h
index 595a0a6..227e103 100644
--- a/core/sql/executor/ExExeUtil.h
+++ b/core/sql/executor/ExExeUtil.h
@@ -86,7 +86,6 @@ class HdfsClient;
 class ExExeUtilTdb;
 class ExExeUtilDisplayExplainTdb;
 class ExExeUtilDisplayExplainComplexTdb;
-class ExExeUtilFastDeleteTdb;
 class ExExeUtilHiveTruncateTdb;
 class ExExeUtilHiveQueryTdb;
 class ExExeUtilSuspendTdb;
@@ -436,7 +435,6 @@ class ExExeUtilPrivateState : public ex_tcb_private_state
   friend class ExExeUtilTcb;
   friend class ExExeUtilCleanupVolatileTablesTcb;
   friend class ExExeUtilCreateTableAsTcb;
-  friend class ExExeUtilFastDeleteTcb;
   friend class ExExeUtilHiveTruncateTcb;
   friend class ExExeUtilHiveQueryTcb;
   friend class ExExeUtilAQRTcb;
@@ -1359,141 +1357,6 @@ class ExExeUtilLoadVolatileTablePrivateState : public ex_tcb_private_state
  protected:
 };
 
-// -----------------------------------------------------------------------
-// ExExeUtilFastDeleteTdb
-// -----------------------------------------------------------------------
-class ExExeUtilFastDeleteTdb : public ComTdbExeUtilFastDelete
-{
- public:
-
-  // ---------------------------------------------------------------------
-  // Constructor is only called to instantiate an object used for
-  // retrieval of the virtual table function pointer of the class while
-  // unpacking. An empty constructor is enough.
-  // ---------------------------------------------------------------------
-  ExExeUtilFastDeleteTdb()
-    {}
-
-  virtual ~ExExeUtilFastDeleteTdb()
-    {}
-
-  // ---------------------------------------------------------------------
-  // Build a TCB for this TDB. Redefined in the Executor project.
-  // ---------------------------------------------------------------------
-  virtual ex_tcb *build(ex_globals *globals);
-
- private:
-  // ---------------------------------------------------------------------
-  // !!!!!!! IMPORTANT -- NO DATA MEMBERS ALLOWED IN EXECUTOR TDB !!!!!!!!
-  // *********************************************************************
-  // The Executor TDB's are only used for the sole purpose of providing a
-  // way to supplement the Compiler TDB's (in comexe) with methods whose
-  // implementation depends on Executor objects. This is done so as to
-  // decouple the Compiler from linking in Executor objects unnecessarily.
-  //
-  // When a Compiler generated TDB arrives at the Executor, the same data
-  // image is "cast" as an Executor TDB after unpacking. Therefore, it is
-  // a requirement that a Compiler TDB has the same object layout as its
-  // corresponding Executor TDB. As a result of this, all Executor TDB's
-  // must have absolutely NO data members, but only member functions. So,
-  // if you reach here with an intention to add data members to a TDB, ask
-  // yourself two questions:
-  //
-  // 1. Are those data members Compiler-generated?
-  //    If yes, put them in the ComTdbDLL instead.
-  //    If no, they should probably belong to someplace else (like TCB).
-  //
-  // 2. Are the classes those data members belong defined in the executor
-  //    project?
-  //    If your answer to both questions is yes, you might need to move
-  //    the classes to the comexe project.
-  // ---------------------------------------------------------------------
-};
-
-///////////////////////////////////////////////////////////////
-// ExExeUtilFastDeleteTcb
-///////////////////////////////////////////////////////////////
-class ExExeUtilFastDeleteTcb : public ExExeUtilTcb
-{
- public:
-  // Constructor
-  ExExeUtilFastDeleteTcb(const ComTdbExeUtilFastDelete & exe_util_tdb,
-                         ex_globals * glob = 0);
-
-  ~ExExeUtilFastDeleteTcb();
-
-  virtual short work();
-
-  virtual ex_tcb_private_state * allocatePstates(
-                                                            Lng32 &numElems,      // inout, desired/actual elements
-                                                            Lng32 &pstateLength); // out, length of one element
-
- private:
-  enum Step
-    {
-      INITIAL_,
-
-      ADD_DDL_LOCK_,
-      MAKE_OBJECT_OFFLINE_,
-      SET_CORRUPT_BIT_,
-
-      FASTDEL_TABLE_,
-      FASTDEL_INDEX_,
-
-      RESET_CORRUPT_BIT_,
-      MAKE_OBJECT_ONLINE_,
-      DROP_DDL_LOCK_,
-
-      BEGIN_WORK_,
-      COMMIT_WORK_,
-
-      PURGEDATA_CAT_,
-
-      KILL_MXCMP_AND_ERROR_,
-      ROLLBACK_WORK_AND_ERROR_,
-      ROLLBACK_WORK_AND_NO_PD_ERROR_,
-      ERROR_,
-
-      DONE_
-    };
-
-  ExExeUtilFastDeleteTdb & fdTdb() const
-    {return (ExExeUtilFastDeleteTdb &) tdb;};
-
-  short doPurgedataCat(char * objectName);
-  short doFastDelete(char * objectName,
-                     NABoolean isIndex,
-                     NABoolean fastDelUsingResetEOF);
-  short doLabelPurgedata(char * objectName,
-                         NABoolean isIndex);
-  
-  short injectError(const char * val);
-
-  
-  short purgedataLOBs();
-  
-
-  Step step_;
-
-  NABoolean fastDelUsingResetEOF_;
-
-  NABoolean xnWasStarted_;
-
-  NABoolean parallelDeleteDone_;
-
-  char failReason_[2000];
-};
-
-class ExExeUtilFastDeletePrivateState : public ex_tcb_private_state
-{
-  friend class ExExeUtilFastDeleteTcb;
-
- public:
-  ExExeUtilFastDeletePrivateState();
-  ~ExExeUtilFastDeletePrivateState();        // destructor
- protected:
-};
-
 //////////////////////////////////////////////////////////////////////////
 // -----------------------------------------------------------------------
 // ExExeUtilGetStatisticsTdb
@@ -3468,23 +3331,23 @@ class ExExeUtilHiveTruncateTdb : public ComTdbExeUtilHiveTruncate
 };
 
 ///////////////////////////////////////////////////////////////
-// ExExeUtilHiveTruncateTcb
+// ExExeUtilHiveTruncateLegacyTcb
 ///////////////////////////////////////////////////////////////
-class ExExeUtilHiveTruncateTcb : public ExExeUtilTcb
+class ExExeUtilHiveTruncateLegacyTcb : public ExExeUtilTcb
 {
  public:
   // Constructor
-  ExExeUtilHiveTruncateTcb(const ComTdbExeUtilHiveTruncate & exe_util_tdb,
+  ExExeUtilHiveTruncateLegacyTcb(const ComTdbExeUtilHiveTruncate & exe_util_tdb,
                            ex_globals * glob = 0);
 
-  ~ExExeUtilHiveTruncateTcb();
+  ~ExExeUtilHiveTruncateLegacyTcb();
 
   virtual void freeResources();
   virtual short work();
 
   virtual ex_tcb_private_state * allocatePstates(
-                                                            Lng32 &numElems,      // inout, desired/actual elements
-                                                            Lng32 &pstateLength); // out, length of one element
+       Lng32 &numElems,      // inout, desired/actual elements
+       Lng32 &pstateLength); // out, length of one element
   virtual Int32 fixup();
  private:
   enum Step
@@ -3507,6 +3370,52 @@ class ExExeUtilHiveTruncateTcb : public ExExeUtilTcb
   ExLobGlobals * lobGlob_;
 };
 
+class ExExeUtilHiveTruncateLegacyPrivateState : public ex_tcb_private_state
+{
+  friend class ExExeUtilHiveTruncateLegacyTcb;
+
+ public:
+  ExExeUtilHiveTruncateLegacyPrivateState();
+  ~ExExeUtilHiveTruncateLegacyPrivateState();        // destructor
+ protected:
+};
+
+///////////////////////////////////////////////////////////////
+// ExExeUtilHiveTruncateTcb
+///////////////////////////////////////////////////////////////
+class ExExeUtilHiveTruncateTcb : public ExExeUtilTcb
+{
+ public:
+  // Constructor
+  ExExeUtilHiveTruncateTcb(const ComTdbExeUtilHiveTruncate & exe_util_tdb,
+                                ex_globals * glob = 0);
+
+  ~ExExeUtilHiveTruncateTcb();
+
+  virtual ex_tcb_private_state * allocatePstates(
+       Lng32 &numElems,      // inout, desired/actual elements
+       Lng32 &pstateLength); // out, length of one element
+  virtual void freeResources();
+  virtual short work();
+
+ private:
+  enum Step
+    {
+      INITIAL_,
+      ALTER_TO_MANAGED_,
+      TRUNCATE_TABLE_,
+      ALTER_TO_EXTERNAL_,
+      ALTER_TO_EXTERNAL_AND_ERROR_,
+      ERROR_,
+      DONE_
+    };
+
+  ExExeUtilHiveTruncateTdb & htTdb() const
+    {return (ExExeUtilHiveTruncateTdb &) tdb;};
+
+  Step step_;
+};
+
 class ExExeUtilHiveTruncatePrivateState : public ex_tcb_private_state
 {
   friend class ExExeUtilHiveTruncateTcb;
@@ -3517,6 +3426,9 @@ class ExExeUtilHiveTruncatePrivateState : public ex_tcb_private_state
  protected:
 };
 
+//////////////////////////////////////////////////////////////
+// ExExeUtilHiveQueryTdb
+//////////////////////////////////////////////////////////////
 class ExExeUtilHiveQueryTdb : public ComTdbExeUtilHiveQuery
 {
  public:

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/executor/ExExeUtilMisc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilMisc.cpp b/core/sql/executor/ExExeUtilMisc.cpp
index dd4cd35..fd1477c 100644
--- a/core/sql/executor/ExExeUtilMisc.cpp
+++ b/core/sql/executor/ExExeUtilMisc.cpp
@@ -58,948 +58,7 @@
 //////////////////////////////////////////////////////////
 // classes defined in this file:
 //
-// class ExExeUtilFastDelete
-//
-//////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-ex_tcb * ExExeUtilFastDeleteTdb::build(ex_globals * glob)
-{
-  ExExeUtilTcb * exe_util_tcb;
-
-  exe_util_tcb = new(glob->getSpace()) ExExeUtilFastDeleteTcb(*this, glob);
-  exe_util_tcb->registerSubtasks();
-
-  return (exe_util_tcb);
-}
-
-////////////////////////////////////////////////////////////////
-// Constructor for class ExExeUtilFastDeleteTcb
-///////////////////////////////////////////////////////////////
-ExExeUtilFastDeleteTcb::ExExeUtilFastDeleteTcb(
-     const ComTdbExeUtilFastDelete & exe_util_tdb,
-     ex_globals * glob)
-     : ExExeUtilTcb( exe_util_tdb, NULL, glob),
-       fastDelUsingResetEOF_(FALSE),
-       xnWasStarted_(FALSE)
-{
-  // Allocate the private state in each entry of the down queue
-  qparent_.down->allocatePstate(this);
-
-  step_ = INITIAL_;
-}
-
-ExExeUtilFastDeleteTcb::~ExExeUtilFastDeleteTcb()
-{
-}
-
-short ExExeUtilFastDeleteTcb::doPurgedataCat(char * stmt)
-{
-  Lng32 cliRC = 0;
-
-  ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();
-
-  cliRC = holdAndSetCQD("EXE_PARALLEL_PURGEDATA", "OFF");
-  if (cliRC < 0)
-    {
-      cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-      return -1;
-    }
-
-  cliRC = cliInterface()->executeImmediate(stmt);
-  //  NADELETEBASIC(stmt, getHeap());
-
-  if (cliRC < 0)
-    {
-      cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-      restoreCQD("EXE_PARALLEL_PURGEDATA");
-      return -1;
-    }
-  
-  restoreCQD("EXE_PARALLEL_PURGEDATA");
-
-  return 0;
-}
-
-short ExExeUtilFastDeleteTcb::doLabelPurgedata(char * objectName,
-					       NABoolean isIndex)
-{
-  Lng32 cliRC;
-  short retcode = 0;
-
-  // Get the globals stucture of the master executor.
-  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
-  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();
-
-  ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();
-
-  SQL_EXEC_ClearDiagnostics(NULL);
-
-  char * stmt = NULL;
-
-  // set sqlparserflags to allow special label_purgedata syntax
-  masterGlob->getStatement()->getContext()->setSqlParserFlags(0x1); // ALLOW_SPECIALTABLETYPE
-
-  stmt = new(getHeap()) char[4000];
-
-  if (isIndex)
-    str_sprintf(stmt, "label_purgedata index_table %s parallel execution on",
-		objectName);
-  else
-    str_sprintf(stmt, "label_purgedata table %s parallel execution on",
-		objectName);
-    
-  cliRC = cliInterface()->executeImmediate(stmt);
-  NADELETEBASIC(stmt, getHeap());
-
-  masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x1);
-
-  if (cliRC < 0)
-    {
-      cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-      retcode = -1;
-      goto cleanUpAndReturn;
-    }
-  
-cleanUpAndReturn:
-
-  if (retcode == 0)
-    {
-      if (NOT isIndex)
-	// Inject error to cause fastdelete of table to fail.
-	retcode = injectError("13");
-      else
-	// Inject error to cause fastdelete of index to fail.
-	retcode = injectError("14");
-    }
-
-  if (retcode < 0)
-    {
-      strcpy(failReason_, "Error during fast delete using reset EOF operation.");
-    }
-
-  return retcode;
-}
-
-short ExExeUtilFastDeleteTcb::doFastDelete(char * objectName,
-					   NABoolean isIndex,
-					   NABoolean fastDelUsingResetEOF)
-{
-  Lng32 cliRC;
-  short retcode = 0;
-  char * stmt = NULL;
-  Lng32 pneBufLen = 0;
-
-  // Get the globals stucture of the master executor.
-  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
-  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();
-
-  ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();
-
-  SQL_EXEC_ClearDiagnostics(NULL);
-
-  // turn ON parallelism to force execution using ESPs.
-  // But first, hold and save the current value for attempt_esp_parallelism.
-  retcode = holdAndSetCQD("ATTEMPT_ESP_PARALLELISM", "ON");
-  if (retcode < 0)
-    {
-      goto cleanUpAndReturn_restore_CQS;
-    }
-
-
-  // Issue a control query shape to use ESPs.
-  // 'Hold' any previously issued CQS.
-  cliRC = 
-    cliInterface()->
-    executeImmediate("control query shape hold;");
-  if (cliRC < 0)
-    {
-      cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-      retcode = -1;
-      goto cleanUpAndReturn;
-    }
-
-  cliRC = 
-    cliInterface()->executeImmediate("control query shape esp_exchange(cut);");
-  if (cliRC < 0)
-    {
-      cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-      retcode = -1;
-      goto cleanUpAndReturn;
-    }
-  
-  if (fdTdb().isMV())
-    {
-      cliRC = 
-	cliInterface()->
-	executeImmediate("control query default mv_internal_ignore_uninitialized 'ON';");
-      if (cliRC < 0)
-	{
-          cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-	  retcode = -1;
-	  goto cleanUpAndReturn;
-	}
-    }
-
-  stmt = new(getHeap()) char[strlen("delete ")
-			    + (fastDelUsingResetEOF ? strlen("using purgedata ")
-			       : strlen("no purgedata "))
-			    + strlen("from table ( ") 
-			    + (isIndex ? strlen("index_table ") 
-			       : strlen("table "))
-			    + strlen(objectName) + 
-			    + strlen (" ) ") 
-			    + 200];
-  strcpy(stmt, "delete ");
-  if (fastDelUsingResetEOF)
-    strcat(stmt, "using purgedata ");
-  else
-    strcat(stmt, "no purgedata ");
-  strcat(stmt, "from table ( ");
-  if (isIndex)
-    strcat(stmt, "index_table ");
-  else
-    strcat(stmt, "table ");
-  
-  strcat(stmt, objectName);
-  strcat(stmt, " ) ;");
-
-  // set sqlparserflags to allow special INDEX_TABLE name
-  if (isIndex)
-    masterGlob->getStatement()->getContext()->setSqlParserFlags(0x1); // ALLOW_SPECIALTABLETYPE
-  
-  cliRC = cliInterface()->executeImmediate(stmt,NULL,NULL,TRUE,NULL,TRUE);
-
-  if (isIndex)
-   masterGlob->getStatement()->getContext()->resetSqlParserFlags(0x1); // ALLOW_SPECIALTABLETYPE
-
-  if (cliRC < 0)
-    {
-      cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-      retcode = -1;
-      goto cleanUpAndReturn;
-    }
-  
-cleanUpAndReturn:
-
-  // restore original value for attempt_esp_parallelism
-  cliRC = restoreCQD("attempt_esp_parallelism");
-
-
-cleanUpAndReturn_restore_CQS:
-
-  // restore original CQS
-  cliRC = 
-    cliInterface()->
-    executeImmediate("control query shape restore;");
-
-  if (fdTdb().isMV())
-    {
-      cliRC = 
-	cliInterface()->
-	executeImmediate("control query default mv_internal_ignore_uninitialized 'OFF';");
-    }
-
-  if (retcode == 0)
-    {
-      if (NOT isIndex)
-	// Inject error to cause fastdelete of table to fail.
-	retcode = injectError("13");
-      else
-	// Inject error to cause fastdelete of index to fail.
-	retcode = injectError("14");
-    }
-
-  if (retcode < 0)
-    {
-      if (fastDelUsingResetEOF)
-	strcpy(failReason_, "Error during fast delete using reset EOF operation.");
-      else
-	strcpy(failReason_, "Error during fast delete operation.");
-    }
-
-  return retcode;
-}
-
-short ExExeUtilFastDeleteTcb::injectError(const char * val)
-{
-  // Get the globals stucture of the master executor.
-  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
-  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();
-
-  char * e1 = masterGlob->getCliGlobals()->getEnv("SQLMX_TEST_POINT");
-  char * e2 = masterGlob->getCliGlobals()->getEnv("SQLMX_PPD_ERR_TEST_POINT");
-  if (((e1) && (strcmp(e1, val) == 0)) ||
-      ((e2) && (strcmp(e2, val) == 0)))
-    {
-      Lng32 errNumParam = ((Lng32)str_atoi(val, strlen(val)));
-      ExRaiseSqlError(getHeap(), &diagsArea_, -EXE_ERROR_INJECTED,
-          &errNumParam, NULL, NULL,   
-	  (e1 ? "SQLMX_TEST_POINT" : "SQLMX_PPD_ERR_TEST_POINT"));
-      return -EXE_ERROR_INJECTED;
-    }
-  return 0;
-}
-
-
-short ExExeUtilFastDeleteTcb::purgedataLOBs()
-{
-  // purgedata from lobs for this table
-  if (fdTdb().numLOBs() > 0)
-    {
-      for (Lng32 i = 1; i <= fdTdb().numLOBs(); i++)
-	{
-	  Lng32 rc = ExpLOBoper::purgedataLOB
-	    (NULL, NULL, fdTdb().getObjectUID(), fdTdb().getLOBnum(i));
-	}
-    }
-
-  return 0;
-}
-
-
-//////////////////////////////////////////////////////
-// work() for ExExePurgedataUtilTcb
-//////////////////////////////////////////////////////
-short ExExeUtilFastDeleteTcb::work()
-{
-  short rc = 0;
-  Lng32 cliRC = 0;
-
-  // if no parent request, return
-  if (qparent_.down->isEmpty())
-    return WORK_OK;
-  
-  // if no room in up queue, won't be able to return data/status.
-  // Come back later.
-  if (qparent_.up->isFull())
-    return WORK_OK;
-  
-  ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();
-  ExExeUtilPrivateState & pstate =
-    *((ExExeUtilPrivateState*) pentry_down->pstate);
-
-  // Get the globals stucture of the master executor.
-  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
-  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();
-  ExTransaction *ta = masterGlob->getStatement()->getContext()->getTransaction();
-
-  char buf[4000];
-
-  while (1)
-    {
-      switch (step_)
-	{
-	case INITIAL_:
-	  {
-	    fastDelUsingResetEOF_ = FALSE;
-	    xnWasStarted_ = FALSE;
-	    parallelDeleteDone_ = FALSE;
-	    strcpy(failReason_, " ");
-
-	    if (fdTdb().doPurgedataCat())
-	      step_ = PURGEDATA_CAT_;
-	    else if (fdTdb().doParallelDelete())
-	      {
-		if (NOT ta->xnInProgress())
-		  {
-		    cliRC = cliInterface()->beginWork();
-		    if (cliRC < 0)
-		      {
-                        cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-			step_ = ERROR_;
-			break;
-		      }
-		    
-		    xnWasStarted_ = TRUE;
-		  }
-
-		step_ = FASTDEL_TABLE_;
-
-		parallelDeleteDone_ = TRUE;
-	      }
-	    else if (NOT ta->xnInProgress())
-	      {
-		fastDelUsingResetEOF_ = TRUE;
-		step_ = ADD_DDL_LOCK_;
-	      }
-	    else
-	      {
-		// User transaction is in progress.
-		// We need to do fast delete without purgedata mode unless
-		// it has been turned off.
-		if (fdTdb().doParallelDeleteIfXn())
-		  {
-		    parallelDeleteDone_ = TRUE;
-		    step_ = FASTDEL_TABLE_;
-		  }
-		else
-		  step_ = PURGEDATA_CAT_;
-	      }
-
-	    if (step_ != PURGEDATA_CAT_)
-	      {
-		if (cliRC < 0)
-		  {
-                    cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		    step_ = ERROR_;
-		    break;
-		  }
-	      }
-	  }
-	break;
-
-	case ADD_DDL_LOCK_:
-	  {
-	    cliRC = cliInterface()->beginWork();
-	    if (cliRC < 0)
-	      {
-                cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		step_ = ERROR_;
-		break;
-	      }
-
-	    xnWasStarted_ = TRUE;
-
-	    // first drop this ddl lock, if it exists. Ignore errors.
-	    rc = alterDDLLock(FALSE, fdTdb().getTableName(), failReason_,
-			      fdTdb().isMV(), COM_UTIL_PURGEDATA);
-	    if (rc < 0)
-	      {
-		SQL_EXEC_ClearDiagnostics(NULL);
-		
-		strcpy(failReason_, " ");
-
-		rc = 0;
-
-		// if this table was offline, and there was no ddl lock,
-		// let catman purgedata handle it.
-		// In this case, don't want to change the table back to
-		// online which is what will happen if exe purgedata is
-		// used.
-
-		if (fdTdb().offlineTable())
-		  {
-		    // Abort transaction which was started.
-		    // Ignore errors, and clear diags area.
-		    if ((xnWasStarted_) &&
-			(ta->xnInProgress()))
-		      {
-			cliRC = cliInterface()->rollbackWork();
-			
-			SQL_EXEC_ClearDiagnostics(NULL);
-			
-			xnWasStarted_ = FALSE;
-		      }
-		    
-		    step_ = PURGEDATA_CAT_;
-		    break;
-		  }
-	      }
-
-	    // now add a ddl lock.
-	    rc = alterDDLLock(TRUE, fdTdb().getTableName(), failReason_,
-			      fdTdb().isMV(), COM_UTIL_PURGEDATA);
-	    if (rc == 0)
-	      rc = injectError("10");
-	    if (rc < 0)
-	      {
-                cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		// could not acquire a ddl lock.
-		// try to purgedata using catman sequential purgedata.
-
-		// Abort transaction which was started.
-		// Ignore errors, and clear diags area.
-		if ((xnWasStarted_) &&
-		    (ta->xnInProgress()))
-		  {
-		    cliRC = cliInterface()->rollbackWork();
-		    
-		    SQL_EXEC_ClearDiagnostics(NULL);
-		    
-		    xnWasStarted_ = FALSE;
-		  }
-
-		// see if catman seq purgedata can fix this.
-		step_ = PURGEDATA_CAT_;
-		break;
-	      }
-
-	    step_ = MAKE_OBJECT_OFFLINE_;
-	  }
-	break;
-
-	case MAKE_OBJECT_OFFLINE_:
-	  {
-	    // make object offline
-	    rc = alterObjectState(FALSE, fdTdb().getTableName(), 
-				  failReason_, TRUE);
-	    NABoolean rollbackNoPDErr = FALSE;
-	    if (rc == 0)
-	      {
-		rc = injectError("11");
-		if (rc == 0)
-		  {
-		    rc = injectError("18");
-		    if (rc < 0)
-		      rollbackNoPDErr = TRUE;
-		  }
-	      }
-	    if (rc < 0)
-	      {
-                cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		// security validation failed
-		if ((getDiagsArea()->contains(-1017)) ||
-		    (rollbackNoPDErr))
-		  step_ = ROLLBACK_WORK_AND_NO_PD_ERROR_;
-		else
-		  step_ = ROLLBACK_WORK_AND_ERROR_;
-		break;
-	      }
-
-	    step_ = SET_CORRUPT_BIT_;
-	  }
-	break;
-
-	case SET_CORRUPT_BIT_:
-	  {
-	    // set the corrupt bit in the label of table and all indices
-	    rc = alterCorruptBit(1, fdTdb().getTableName(), failReason_,
-				 fdTdb().getIndexList());
-	    if (rc == 0)
-	      rc = injectError("12");
-	    if (rc < 0)
-	      {
-                cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		step_ = ROLLBACK_WORK_AND_ERROR_;
-		break;
-	      }
-
-	    if ((xnWasStarted_) &&
-		(ta->xnInProgress()))
-	      {
-		cliRC = cliInterface()->commitWork();
-		
-		xnWasStarted_ = FALSE;
-		
-		if (cliRC < 0)
-		  {
-		    strcpy(failReason_, "Error during commit work.");
-
-                    cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		    step_ = ROLLBACK_WORK_AND_ERROR_;
-		    break;
-		  }
-	      }
-
-	    // inject error to test RECOVER.
-	    // DDL lock has been acquired and object has been made offline
-	    // but operation has not yet begun.
-	    if (injectError("1") || injectError("2"))
-	      {
-		// kill mxcmp
-		strcpy(buf, "SELECT TESTEXIT;");
-		cliRC = cliInterface()->executeImmediate(buf);
-		if (cliRC < 0)
-                  cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		  
-		strcpy(failReason_, " ");
-
-		step_ = ROLLBACK_WORK_AND_ERROR_;
-		break;
-	      }
-
-	    // now start parallel purgedata
-	    step_ = BEGIN_WORK_;
-	  }
-	break;
-
-	case BEGIN_WORK_:
-	  {
-	    cliRC = cliInterface()->beginWork();
-	    if (cliRC < 0)
-	      {
-                cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		step_ = ERROR_;
-		break;
-	      }
-
-	    xnWasStarted_ = TRUE;
-	    step_ = FASTDEL_TABLE_;
-	  }
-	break;
-
-	case FASTDEL_TABLE_:
-	  {
-	    if ((fdTdb().doLabelPurgedata()) &&
-		(fastDelUsingResetEOF_))
-	      rc = doLabelPurgedata(fdTdb().getTableName(), 
-				    FALSE);
-	    else
-	      rc = doFastDelete(fdTdb().getTableName(), 
-				FALSE, fastDelUsingResetEOF_);
-
-	    if (rc)
-	      {
-		if (fastDelUsingResetEOF_)
-		  step_ = KILL_MXCMP_AND_ERROR_;
-		else
-		  step_ = ROLLBACK_WORK_AND_ERROR_;
-		break;
-	      }
-	    
-	    if (fdTdb().getIndexList())
-	      {
-		fdTdb().getIndexList()->position();
-		step_ = FASTDEL_INDEX_;
-	      }
-	    else 
-	      step_ = COMMIT_WORK_;
-	  }
-	break;
-
-	case FASTDEL_INDEX_:
-	  {
-	    if (fdTdb().getIndexList()->atEnd())
-	      {
-		step_ = COMMIT_WORK_;
-		break;
-	      }
-
-	    char * indexName = (char*)fdTdb().getIndexList()->getNext();
-	    if ((fdTdb().doLabelPurgedata()) &&
-		(fastDelUsingResetEOF_))
-	      rc = doLabelPurgedata(indexName, 
-				    TRUE);
-	    else
-	      rc = doFastDelete(indexName, TRUE,
-				fastDelUsingResetEOF_);
-	    if (rc)
-	      {
-		if (fastDelUsingResetEOF_)
-		  step_ = KILL_MXCMP_AND_ERROR_;
-		else
-		  step_ = ROLLBACK_WORK_AND_ERROR_;
-		break;
-	      }
-	  }
-	break;
-
-	case KILL_MXCMP_AND_ERROR_:
-	  {
-	    // Abort transaction which was started.
-	    // Ignore errors, and clear diags area.
-	    if ((xnWasStarted_) &&
-		(ta->xnInProgress()))
-	      {
-		cliRC = cliInterface()->rollbackWork();
-		
-		SQL_EXEC_ClearDiagnostics(NULL);
-
-		xnWasStarted_ = FALSE;
-	      }
-
-	    // kill mxcmp so a subsequent recover operation
-	    // can succeed. Ignore errors.
-	    strcpy(buf, "SELECT TESTEXIT;");
-	    cliRC = cliInterface()->executeImmediate(buf);
-	    SQL_EXEC_ClearDiagnostics(NULL);
-
-	    step_ = ROLLBACK_WORK_AND_ERROR_;
-	  }
-	break;
-
-	case ROLLBACK_WORK_AND_ERROR_:
-	case ROLLBACK_WORK_AND_NO_PD_ERROR_:
-	  {
-	    // We come here only if fastDeleteUsingResetEOF failed.
-	    // Abort transaction which was started.
-	    // Ignore errors, and clear diags area.
-	    if ((xnWasStarted_) &&
-		(ta->xnInProgress()))
-	      {
-		cliRC = cliInterface()->rollbackWork();
-		
-		SQL_EXEC_ClearDiagnostics(NULL);
-
-		xnWasStarted_ = FALSE;
-	      }
-
-	    if (step_ == ROLLBACK_WORK_AND_ERROR_)
-	      {
-		ComDiagsArea * diagsArea = getDiagsArea();
-		// convert all errors into warnings
-		NegateAllErrors(diagsArea);
-                ExRaiseSqlError(getHeap(), &diagsArea_, -EXE_PARALLEL_PURGEDATA_FAILED,
-                    NULL, NULL, NULL,
-		    failReason_);
-	      }
-
-	    step_ = ERROR_;
-	  }
-	break;
-
-	case COMMIT_WORK_:
-	  {
-	    if ((xnWasStarted_) &&
-		(ta->xnInProgress()))
-	      {
-		cliRC = cliInterface()->commitWork();
-
-		xnWasStarted_ = FALSE;
-	      }
-
-	    if (injectError("3"))
-	      {
-		// kill mxcmp
-		strcpy(buf, "SELECT TESTEXIT;");
-		cliInterface()->executeImmediate(buf);
-		if (cliRC < 0)
-                  cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		
-		step_ = ERROR_;
-		break;
-	      }
-
-	    if (parallelDeleteDone_) //fdTdb().doParallelDelete())
-	      {
-		// raise a warning that parallel purgedata was performed.
-		if (fdTdb().returnPurgedataWarn())
-		  {
-                    ExRaiseSqlError(getHeap(), &diagsArea_, EXE_PURGEDATA_CAT,
-                        NULL, NULL, NULL,
-			"Parallel", "");
-		  }
-		step_ = DONE_;
-	      }
-	    else
-	      step_ = RESET_CORRUPT_BIT_;
-	  }
-	break;
-
-	case RESET_CORRUPT_BIT_:
-	  {
-	    cliRC = cliInterface()->beginWork();
-	    if (cliRC < 0)
-	      {
-                cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		step_ = ERROR_;
-		break;
-	      }
-
-	    xnWasStarted_ = TRUE;
-
-	    // reset the corrupt bit in the label of table and all indices.
-	    rc = alterCorruptBit(0, fdTdb().getTableName(), failReason_,
-				 fdTdb().getIndexList());
-	    if (rc == 0)
-	      rc = injectError("15");
-
-	    if (rc < 0)
-	      {
-                cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		step_ = KILL_MXCMP_AND_ERROR_;
-		break;
-	      }
-
-	    step_ = MAKE_OBJECT_ONLINE_;
-	  }
-	break;
-
-	case MAKE_OBJECT_ONLINE_:
-	  {
-	    rc = alterObjectState(TRUE, fdTdb().getTableName(), 
-				  failReason_, TRUE);
-	    if (rc == 0)
-	      rc = injectError("16");
-	    if (rc < 0)
-	      {
-                cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		step_ = KILL_MXCMP_AND_ERROR_;
-		break;
-	      }
-	    
-	    step_ = DROP_DDL_LOCK_;
-	  }
-	break;
-
-	case DROP_DDL_LOCK_:
-	  {
-	    if (fastDelUsingResetEOF_)
-	      {
-		rc = alterDDLLock(FALSE, fdTdb().getTableName(), failReason_,
-				  fdTdb().isMV(), COM_UTIL_PURGEDATA);
-		if (rc == 0)
-		  rc = injectError("17");
-		if (rc < 0)
-		  {
-                    cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		    step_ = KILL_MXCMP_AND_ERROR_;
-		    break;
-		  }
-	      }
-
-	    cliRC = cliInterface()->commitWork();
-	    if (cliRC < 0)
-	      {
-                cliInterface()->allocAndRetrieveSQLDiagnostics(diagsArea_);
-		step_ = ERROR_;
-		break;
-	      }
-	    
-	    step_ = DONE_;
-
-	    // raise a warning that parallel purgedata was performed.
-	    if (fdTdb().returnPurgedataWarn())
-	      {
-                ExRaiseSqlError(getHeap(), &diagsArea_, EXE_PURGEDATA_CAT,
-                    NULL, NULL, NULL,
-		    "Parallel", "");
-	      }
-	  }
-	break;
-
-	case PURGEDATA_CAT_:
-	  {
-	    if ((getDiagsArea()) &&
-		(getDiagsArea()->getNumber(DgSqlCode::ERROR_) > 0))
-	      {
-		// convert all errors into warnings
-		NegateAllErrors(getDiagsArea());
-	      }
-
-	    // raise a warning that regular purgedata is being performed,
-	    // either because the query/object didn't meet the criteria
-	    // for parallel purgedata, or because parallel purgedata failed.
-	    if (fdTdb().returnPurgedataWarn())
-	      {
-		if (fdTdb().doPurgedataCat())
-                  ExRaiseSqlError(getHeap(), &diagsArea_, EXE_PURGEDATA_CAT,
-                     NULL, NULL, NULL,
-                     "Regular", "Reason: Query or the object did not meet the criteria for parallel purgedata.");
-		else
-                  ExRaiseSqlError(getHeap(), &diagsArea_, EXE_PURGEDATA_CAT,
-                     NULL, NULL, NULL,
-                     "Regular", "Reason: Parallel purgedata failed.");
-	      }
-
-	    rc = doPurgedataCat(fdTdb().purgedataStmt());
-	    if (rc)
-	      step_ = ERROR_;
-	    else
-	      step_ = DONE_;
-	  }
-	break;
-
-	case ERROR_:
-	  {
-	    if (qparent_.up->isFull())
-	      return WORK_OK;
-
-	    // Return EOF.
-	    ex_queue_entry * up_entry = qparent_.up->getTailEntry();
-	    
-	    up_entry->upState.parentIndex = 
-	      pentry_down->downState.parentIndex;
-	    
-	    up_entry->upState.setMatchNo(0);
-	    up_entry->upState.status = ex_queue::Q_SQLERROR;
-
-	    ComDiagsArea *diagsArea = up_entry->getDiagsArea();
-	    
-	    if (diagsArea == NULL)
-	      diagsArea = 
-		ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap());
-            else
-              diagsArea->incrRefCount (); // setDiagsArea call below will decr ref count
-
-	    if (getDiagsArea())
-	      diagsArea->mergeAfter(*getDiagsArea());
-	    
-	    up_entry->setDiagsArea (diagsArea);
-
-	    getDiagsArea()->clear();
-
-	    // insert into parent
-	    qparent_.up->insert();
-	    
-	    step_ = DONE_;
-	  }
-	break;
-
-	case DONE_:
-	  {
-	    if (qparent_.up->isFull())
-	      return WORK_OK;
-
-
-	    // restore cqd and ignore errors
-	    SQL_EXEC_ClearDiagnostics(NULL);
-	    
-	    // Return EOF.
-	    ex_queue_entry * up_entry = qparent_.up->getTailEntry();
-	    
-	    up_entry->upState.parentIndex = 
-	      pentry_down->downState.parentIndex;
-	    
-	    up_entry->upState.setMatchNo(0);
-	    up_entry->upState.status = ex_queue::Q_NO_DATA;
-
-	    if (getDiagsArea()->getNumber(DgSqlCode::WARNING_) > 0) // must be a warning
-	      {
-		ComDiagsArea *diagsArea = up_entry->getDiagsArea();
-		
-		if (diagsArea == NULL)
-		  diagsArea = 
-		    ComDiagsArea::allocate(this->getGlobals()->getDefaultHeap());
-                else
-                  diagsArea->incrRefCount (); // setDiagsArea call below will decr ref count
-		
-		if (getDiagsArea())
-		  diagsArea->mergeAfter(*getDiagsArea());
-		
-		up_entry->setDiagsArea (diagsArea);
-	      }
-
-	    // insert into parent
-	    qparent_.up->insert();
-	    
-	    pstate.matches_ = 0;
-	    step_ = INITIAL_;
-	    qparent_.down->removeHead();
-	    
-	    return WORK_OK;
-	  }
-	break;
-
-	} // switch
-    } // while
-
-}
-
-////////////////////////////////////////////////////////////////////////
-// Redefine virtual method allocatePstates, to be used by dynamic queue
-// resizing, as well as the initial queue construction.
-////////////////////////////////////////////////////////////////////////
-ex_tcb_private_state * ExExeUtilFastDeleteTcb::allocatePstates(
-     Lng32 &numElems,      // inout, desired/actual elements
-     Lng32 &pstateLength)  // out, length of one element
-{
-  PstateAllocator<ExExeUtilFastDeletePrivateState> pa;
-
-  return pa.allocatePstates(this, numElems, pstateLength);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// Constructor and destructor for ExeUtil_private_state
-/////////////////////////////////////////////////////////////////////////////
-ExExeUtilFastDeletePrivateState::ExExeUtilFastDeletePrivateState()
-{
-}
-
-ExExeUtilFastDeletePrivateState::~ExExeUtilFastDeletePrivateState()
-{
-};
+//////////////////////////////////////////////////////////
 
 ///////////////////////////////////////////////////////////////////
 ex_tcb * ExExeUtilLongRunningTdb::build(ex_globals * glob)
@@ -2211,7 +1270,11 @@ ex_tcb * ExExeUtilHiveTruncateTdb::build(ex_globals * glob)
 {
   ExExeUtilTcb * exe_util_tcb;
 
-  exe_util_tcb = new(glob->getSpace()) ExExeUtilHiveTruncateTcb(*this, glob);
+  if (getIsLegacy())
+    exe_util_tcb = new(glob->getSpace()) ExExeUtilHiveTruncateLegacyTcb(*this, glob);
+  else
+    exe_util_tcb = new(glob->getSpace()) ExExeUtilHiveTruncateTcb(*this, glob);
+    
   exe_util_tcb->registerSubtasks();
 
   return (exe_util_tcb);
@@ -2219,9 +1282,9 @@ ex_tcb * ExExeUtilHiveTruncateTdb::build(ex_globals * glob)
 
 
 ////////////////////////////////////////////////////////////////
-// Constructor for class ExExeUtilHiveTruncateTcb
+// Constructor for class ExExeUtilHiveTruncateLegacyTcb
 ///////////////////////////////////////////////////////////////
-ExExeUtilHiveTruncateTcb::ExExeUtilHiveTruncateTcb(
+ExExeUtilHiveTruncateLegacyTcb::ExExeUtilHiveTruncateLegacyTcb(
      const ComTdbExeUtilHiveTruncate & exe_util_tdb,
      ex_globals * glob)
      : ExExeUtilTcb( exe_util_tdb, NULL, glob)
@@ -2234,12 +1297,12 @@ ExExeUtilHiveTruncateTcb::ExExeUtilHiveTruncateTcb(
   step_ = INITIAL_;
 }
 
-ExExeUtilHiveTruncateTcb::~ExExeUtilHiveTruncateTcb()
+ExExeUtilHiveTruncateLegacyTcb::~ExExeUtilHiveTruncateLegacyTcb()
 {
   freeResources();
 }
 
-void ExExeUtilHiveTruncateTcb::freeResources()
+void ExExeUtilHiveTruncateLegacyTcb::freeResources()
 {
   if (htTdb().getDropOnDealloc())
   {
@@ -2255,7 +1318,7 @@ void ExExeUtilHiveTruncateTcb::freeResources()
   }
 }
 
-Int32 ExExeUtilHiveTruncateTcb::fixup()
+Int32 ExExeUtilHiveTruncateLegacyTcb::fixup()
 {
   lobGlob_ = NULL;
 
@@ -2268,9 +1331,9 @@ Int32 ExExeUtilHiveTruncateTcb::fixup()
   return 0;
 }
 //////////////////////////////////////////////////////
-// work() for ExExeUtilHiveTruncateTsb
+// work() for ExExeUtilHiveTruncateLegacyTcb
 //////////////////////////////////////////////////////
-short ExExeUtilHiveTruncateTcb::work()
+short ExExeUtilHiveTruncateLegacyTcb::work()
 {
   short rc = 0;
   Lng32 cliRC = 0;
@@ -2434,6 +1497,196 @@ short ExExeUtilHiveTruncateTcb::work()
 }
 
 
+ex_tcb_private_state * ExExeUtilHiveTruncateLegacyTcb::allocatePstates(
+     Lng32 &numElems,      // inout, desired/actual elements
+     Lng32 &pstateLength)  // out, length of one element
+{
+  PstateAllocator<ExExeUtilHiveTruncateLegacyPrivateState> pa;
+
+  return pa.allocatePstates(this, numElems, pstateLength);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Constructor and destructor for ExeUtil_private_state
+/////////////////////////////////////////////////////////////////////////////
+ExExeUtilHiveTruncateLegacyPrivateState::ExExeUtilHiveTruncateLegacyPrivateState()
+{
+}
+
+ExExeUtilHiveTruncateLegacyPrivateState::~ExExeUtilHiveTruncateLegacyPrivateState()
+{
+};
+
+////////////////////////////////////////////////////////////////
+// Constructor for class ExExeUtilHiveTruncateTcb
+///////////////////////////////////////////////////////////////
+ExExeUtilHiveTruncateTcb::ExExeUtilHiveTruncateTcb(
+     const ComTdbExeUtilHiveTruncate & exe_util_tdb,
+     ex_globals * glob)
+     : ExExeUtilTcb( exe_util_tdb, NULL, glob)
+{
+  // Allocate the private state in each entry of the down queue
+  qparent_.down->allocatePstate(this);
+
+  step_ = INITIAL_;
+}
+
+ExExeUtilHiveTruncateTcb::~ExExeUtilHiveTruncateTcb()
+{
+  freeResources();
+}
+
+void ExExeUtilHiveTruncateTcb::freeResources()
+{
+  if (htTdb().getDropOnDealloc())
+  {
+    NAString hiveDropDDL("drop table ");
+    hiveDropDDL += htTdb().getHiveTableName();
+
+    // TODO: is it ok to ignore the error 
+    HiveClient_JNI::executeHiveSQL(hiveDropDDL);
+  }
+}
+
+//////////////////////////////////////////////////////
+// work() for ExExeUtilHiveTruncateTcb
+//////////////////////////////////////////////////////
+short ExExeUtilHiveTruncateTcb::work()
+{
+  short rc = 0;
+  Lng32 cliRC = 0;
+
+  // if no parent request, return
+  if (qparent_.down->isEmpty())
+    return WORK_OK;
+
+  // if no room in up queue, won't be able to return data/status.
+  // Come back later.
+  if (qparent_.up->isFull())
+    return WORK_OK;
+
+  ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();
+  ExExeUtilPrivateState & pstate = *((ExExeUtilPrivateState*) pentry_down->pstate);
+
+  while (1)
+    {
+      switch (step_)
+        {
+        case INITIAL_:
+          {
+            // if 'if exists' clause was specified and table does not exist
+            // during compile phase, return.
+            // If table was missing during compile and was created before
+            // execute, then QI/AQR/Timestamp check will recompile.
+            if (htTdb().getIfExists() && htTdb().getTableNotExists())
+              {
+                step_ = DONE_;
+                break;
+              }
+
+            if (htTdb().getIsExternal())
+              step_ = ALTER_TO_MANAGED_;
+            else
+              step_ = TRUNCATE_TABLE_;
+          }
+          break;
+          
+        case ALTER_TO_MANAGED_:
+          {
+            // A Hive table can be an External or Managed table.
+            // Currently, an External Hive table cannot be truncated.
+            // Maybe some future Hive version will allow that.
+            // Temporarily change the table attribute to be Managed,
+            // truncate the table and then change it back to be External.
+            NAString alterStmt("alter table ");
+            alterStmt += htTdb().getHiveTableName(); 
+            alterStmt += " set tblproperties ('EXTERNAL'='False')";
+            if (HiveClient_JNI::executeHiveSQL(alterStmt.data()) != HVC_OK)
+              {
+                // alter failed
+                ExRaiseSqlError(getHeap(), &diagsArea_, -1214,
+                                NULL, NULL, NULL,
+                                getSqlJniErrorStr(), htTdb().getHiveTruncQuery()); 
+                step_ = ERROR_;
+                break;
+              }
+            
+            step_ = TRUNCATE_TABLE_;
+          }
+          break;
+
+        case TRUNCATE_TABLE_:
+          {
+            if (HiveClient_JNI::executeHiveSQL(htTdb().getHiveTruncQuery()) != HVC_OK)
+              {
+                ExRaiseSqlError(getHeap(), &diagsArea_, -1214,
+                                NULL, NULL, NULL,
+                                getSqlJniErrorStr(), htTdb().getHiveTruncQuery());
+
+                if (htTdb().getIsExternal())
+                  {
+                    step_ = ALTER_TO_EXTERNAL_AND_ERROR_;
+                    break;
+                  }
+                
+                step_ = ERROR_;
+                break;
+              }
+ 
+            if (htTdb().getIsExternal())
+              step_ = ALTER_TO_EXTERNAL_;
+            else
+              step_= DONE_;
+          }
+          break;
+          
+         case ALTER_TO_EXTERNAL_:
+         case ALTER_TO_EXTERNAL_AND_ERROR_:
+          {
+            // table was altered to Managed. Alter it back to External.
+            NAString alterStmt("alter table ");
+            alterStmt += htTdb().getHiveTableName(); 
+            alterStmt += " set tblproperties ('EXTERNAL'='TRUE')";
+             if (HiveClient_JNI::executeHiveSQL(alterStmt.data()) != HVC_OK)
+              {
+                // alter failed
+                ExRaiseSqlError(getHeap(), &diagsArea_, -1214,
+                                NULL, NULL, NULL,
+                                getSqlJniErrorStr(), alterStmt.data());
+                step_ = ERROR_;
+                break;
+              }                    
+
+            if (step_ == ALTER_TO_EXTERNAL_AND_ERROR_)
+              step_ = ERROR_;
+            else
+              step_ = DONE_;
+          }
+          break;
+
+        case ERROR_:
+          {
+            if (handleError())
+              return WORK_OK;
+            step_ = DONE_;
+          }
+          break;
+          
+        case DONE_:
+          {
+            if (handleDone())
+              return WORK_OK;
+            step_ = INITIAL_;
+            
+            return WORK_OK;
+          }
+          break;
+          
+        } // switch
+    } // while
+  
+}
+
 ex_tcb_private_state * ExExeUtilHiveTruncateTcb::allocatePstates(
      Lng32 &numElems,      // inout, desired/actual elements
      Lng32 &pstateLength)  // out, length of one element
@@ -2454,6 +1707,9 @@ ExExeUtilHiveTruncatePrivateState::~ExExeUtilHiveTruncatePrivateState()
 {
 };
 
+///////////////////////////////////////////////////////////////////////
+// ExExeUtilHiveQueryTdb
+///////////////////////////////////////////////////////////////////////
 ex_tcb * ExExeUtilHiveQueryTdb::build(ex_globals * glob)
 {
   ExExeUtilTcb * exe_util_tcb;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/executor/hiveHook.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/hiveHook.cpp b/core/sql/executor/hiveHook.cpp
index aac76a9..bc3ef1b 100644
--- a/core/sql/executor/hiveHook.cpp
+++ b/core/sql/executor/hiveHook.cpp
@@ -495,47 +495,44 @@ NABoolean populateSerDeParams(HiveMetaData *md, Int32 serdeID,
   fieldTerminator  = '\001';  // this the Hive default ^A or ascii code 1
   recordTerminator = '\n';    // this is the Hive default
 
-  std::size_t foundB ;
   if (!findAToken(md, tblStr, pos, "serdeInfo:",
                   "populateSerDeParams::serdeInfo:###"))
     return FALSE;
 
-  std::size_t foundE = pos ;
+  std::size_t foundB = pos;
+  std::size_t foundE = pos;
+
   if (!findAToken(md, tblStr, foundE, "}),",
                   "populateSerDeParams::serDeInfo:)},###"))
     return FALSE;
   
+  NAText serdeStr = tblStr->substr(foundB, foundE-foundB);
+
   const char * nullStr = "serialization.null.format=";
-  const char * fieldStr = "field.delim" ;
-  const char * lineStr = "line.delim" ;
+  const char * fieldStr = "field.delim=" ;
+  const char * lineStr = "line.delim=" ;
 
   nullFormatSpec = FALSE;
-  foundB = tblStr->find(nullStr,pos);
-  if ((foundB != std::string::npos) && (foundB < foundE))
+  foundB = serdeStr.find(nullStr);
+  if (foundB != std::string::npos)
     {
       nullFormatSpec = TRUE;
       std::size_t foundNB = foundB + strlen(nullStr);
-      std::size_t foundNE = std::string::npos;
-      std::size_t foundNE1 = tblStr->find("}), ", foundNB);
-      std::size_t foundNE2 = tblStr->find(", ", foundNB);
-      if (foundNE1 == std::string::npos)
-        foundNE = foundNE2;
-      else if (foundNE2 == std::string::npos)
-        foundNE = foundNE1;
-      else
-        foundNE = MINOF(foundNE1, foundNE2);
-
-      if (foundNE != std::string::npos)
-        nullFormat = NAString(tblStr->substr(foundNB, (foundNE-foundNB)));
+      std::size_t foundNE = serdeStr.find(", ", foundNB);
+      if (foundNE == std::string::npos)
+        {
+          foundNE = serdeStr.length();
+        }
+      nullFormat = NAString(serdeStr.substr(foundNB, (foundNE-foundNB)));
     }
 
-  foundB = tblStr->find(fieldStr,pos);
-  if ((foundB != std::string::npos) && (foundB < foundE))
-    fieldTerminator = tblStr->at(foundB+strlen(fieldStr)+1);
-  
-  foundB = tblStr->find("line.delim=",pos);
-  if ((foundB != std::string::npos) && (foundB < foundE))
-    recordTerminator = tblStr->at(foundB+strlen(lineStr)+1);
+  std::size_t foundDelim = serdeStr.find(fieldStr);
+  if ((foundDelim != std::string::npos))
+    fieldTerminator = serdeStr.at(foundDelim+strlen(fieldStr));
+
+  foundDelim = serdeStr.find(lineStr);
+  if ((foundDelim != std::string::npos))
+    recordTerminator = serdeStr.at(foundDelim+strlen(lineStr));
   
   pos = foundE;
   

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/exp/ExpErrorEnums.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpErrorEnums.h b/core/sql/exp/ExpErrorEnums.h
index 2068c75..5a12b1d 100644
--- a/core/sql/exp/ExpErrorEnums.h
+++ b/core/sql/exp/ExpErrorEnums.h
@@ -62,8 +62,6 @@ enum ExeErrorCode
   EXE_EXPLAIN_BAD_DATA			= 8019,
 
   EXE_INITIALIZE_MAINTAIN               = 8020,
-  EXE_PURGEDATA_CAT                     = 8021,
-  EXE_PARALLEL_PURGEDATA_FAILED         = 8022,
 
   EXE_QUERY_LIMITS_CPU                  = 8023,
   EXE_QUERY_LIMITS_CPU_DEBUG            = 8024,

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/generator/GenExplain.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenExplain.cpp b/core/sql/generator/GenExplain.cpp
index 11a5a55..951cfee 100644
--- a/core/sql/generator/GenExplain.cpp
+++ b/core/sql/generator/GenExplain.cpp
@@ -1153,6 +1153,29 @@ DDLExpr::addSpecificExplainInfo(ExplainTupleMaster *explainTuple,
   return(explainTuple);
 }
 
+ExplainTuple *
+ExeUtilHiveTruncate::addSpecificExplainInfo(ExplainTupleMaster *explainTuple, 
+                                            ComTdb * tdb, 
+                                            Generator *generator)
+{
+  char buf[200];
+  NAString buffer;
+
+  ComTdbExeUtilHiveTruncate *ctdb = (ComTdbExeUtilHiveTruncate*)tdb;
+  if (ctdb->getTableName() != NULL)
+    buffer += NAString("table_name: ") + ctdb->getTableName() + " ";
+  else
+    buffer += "table_name: unknown ";
+  //  buffer += NAString("object_type: ") + hddl->getTypeStr() + " ";
+  if (NOT getHiveTruncQuery().isNull())
+    buffer += NAString("hive_trunc_query: ") + getHiveTruncQuery() + " ";
+  else
+    buffer += "hive_trunc_query: unknown ";
+
+  explainTuple->setDescription(buffer);
+  
+  return(explainTuple);
+}
 
 ExplainTuple*
 GroupByAgg::addSpecificExplainInfo(ExplainTupleMaster *explainTuple,

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/generator/GenPreCode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenPreCode.cpp b/core/sql/generator/GenPreCode.cpp
index 77902f9..b37274a 100644
--- a/core/sql/generator/GenPreCode.cpp
+++ b/core/sql/generator/GenPreCode.cpp
@@ -5742,19 +5742,9 @@ RelExpr * HbaseInsert::preCodeGen(Generator * generator,
   return this;
 }
 
-RelExpr * ExeUtilFastDelete::preCodeGen(Generator * generator,
-					const ValueIdSet & externalInputs,
-					ValueIdSet &pulledNewInputs)
-{
-  if (nodeIsPreCodeGenned())
-    return this;
-
-  return ExeUtilExpr::preCodeGen(generator,externalInputs,pulledNewInputs);
-}
-
-RelExpr * ExeUtilHiveTruncate::preCodeGen(Generator * generator,
-                                          const ValueIdSet & externalInputs,
-                                          ValueIdSet &pulledNewInputs)
+RelExpr * ExeUtilHiveTruncateLegacy::preCodeGen(Generator * generator,
+                                                const ValueIdSet & externalInputs,
+                                                ValueIdSet &pulledNewInputs)
 {
   if (nodeIsPreCodeGenned())
     return this;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/generator/GenRelExeUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenRelExeUtil.cpp b/core/sql/generator/GenRelExeUtil.cpp
index 161d82e..4842e96 100644
--- a/core/sql/generator/GenRelExeUtil.cpp
+++ b/core/sql/generator/GenRelExeUtil.cpp
@@ -3121,41 +3121,14 @@ short ExeUtilMaintainObject::codeGen(Generator * generator)
 
 /////////////////////////////////////////////////////////
 //
-// ExeUtilFastDelete::codeGen()
+// ExeUtilHiveTruncateLegacy::codeGen()
 //
 /////////////////////////////////////////////////////////
-short ExeUtilFastDelete::codeGen(Generator * generator)
+short ExeUtilHiveTruncateLegacy::codeGen(Generator * generator)
 {
   ExpGenerator * expGen = generator->getExpGenerator();
   Space * space = generator->getSpace();
 
-  char * stmtText = getStmtText();
-
-  // remove trailing blanks and append a semicolon, if one is not present.
-  char * stmt = NULL;
-  CollIndex i = 0;
-  if (stmtText)
-    {
-      i = strlen(stmtText);
-      while ((i > 0) && (getStmtText()[i-1] == ' '))
-	i--;
-      
-      if (stmtText[i-1] != ';')
-	{
-	  // add a semicolon to the end of str (required by the parser)
-	  stmt = space->allocateAlignedSpace(i+1+1);
-	  strncpy(stmt, stmtText, i);
-	  stmt[i]   = ';' ;
-	  stmt[i+1] = '\0';
-	}
-      else
-	{
-	  stmt = space->allocateAlignedSpace(i+1);
-	  strncpy(stmt, stmtText, i);
-	  stmt[i] = '\0';
-	}
-    }
-
   // allocate a map table for the retrieved columns
   generator->appendAtEnd();
 
@@ -3176,97 +3149,82 @@ short ExeUtilFastDelete::codeGen(Generator * generator)
       return -1;
     }
 
-  char * tablename = NULL;
-  if ((getUtilTableDesc()) && 
-      (getUtilTableDesc()->getNATable()) &&
-      (getUtilTableDesc()->getNATable()->isVolatileTable()))
-    {
-      tablename = space->AllocateAndCopyToAlignedSpace
-	(getTableName().getQualifiedNameObj().getObjectName(), 0);
-    }
-  else
-    {
-      tablename = space->AllocateAndCopyToAlignedSpace
-	(generator->genGetNameAsAnsiNAString(getTableName()), 0);
-    }
-
-  char * primaryPartnLoc = NULL;
-  if ((getUtilTableDesc()) && 
-      (getUtilTableDesc()->getNATable()) &&
-      (getUtilTableDesc()->getNATable()->isAnMV()))
+  char * partn_loc = NULL;
+  if (pl_)
     {
-      primaryPartnLoc = space->AllocateAndCopyToAlignedSpace
-      (getUtilTableDesc()->getClusteringIndex()->getNAFileSet()->
-       getFileSetName().getQualifiedNameAsString(), 0);
-    }
+      NAString partnLoc = getHiveTableLocation();
+      partnLoc += "/";
 
-  Queue * deleteIndexList    = NULL;
-  if (getUtilTableDesc())
-    {
-      const LIST(IndexDesc *) indexList = 
-	getUtilTableDesc()->getIndexes();
-      if (indexList.entries() > 0)
-	deleteIndexList = new(space) Queue(space);
-      for (i=0; i<indexList.entries(); i++) 
+      for (Lng32 i = 0; i < pl_->entries(); i++)
 	{
-	  IndexDesc *index = indexList[i];
-	  
-	  // The base table itself is an index (the clustering index);
-	  // obviously IM need not deal with it.
-	  if (index->isClusteringIndex())
-	    continue;
-	  
-	  char * indexName = 
-	    space->AllocateAndCopyToAlignedSpace
-	    (index->getExtIndexName(), 0);
-	  
-	  deleteIndexList->insert(indexName);
+	  const NAString *cs = (*pl_)[i];
+
+          partnLoc += *cs;
+          partnLoc += "/";
+          
 	}
+  
+      partn_loc = 
+        space->allocateAndCopyToAlignedSpace
+        (partnLoc.data(), partnLoc.length(), 0);
     }
 
-  Lng32 numEsps = -1;
-
-  ComTdbExeUtilFastDelete * exe_util_tdb = new(space) 
-    ComTdbExeUtilFastDelete(tablename, strlen(tablename),
-			    primaryPartnLoc,
-			    deleteIndexList,
-			    stmt,
-			    (stmt ? strlen(stmt) : 0),
-			    numEsps,
-			    (getUtilTableDesc() ? getUtilTableDesc()->getNATable()->
-			     objectUid().get_value() : 0),
-			    numLOBs_,
-			    NULL,
-			    0, 0, // no work cri desc
-			    (ex_cri_desc *)(generator->getCriDesc(Generator::DOWN)),
-			    (ex_cri_desc *)(generator->getCriDesc(Generator::DOWN)),
-			    (queue_index)getDefault(GEN_DDL_SIZE_DOWN),
-			    (queue_index)getDefault(GEN_DDL_SIZE_UP),
-			    getDefault(GEN_DDL_NUM_BUFFERS),
-			    getDefault(GEN_DDL_BUFFER_SIZE));
+  char * tablename = NULL;
+  tablename = space->AllocateAndCopyToAlignedSpace
+    (generator->genGetNameAsAnsiNAString(getTableName()), 0);
 
-  if (doPurgedataCat_)
-    exe_util_tdb->setDoPurgedataCat(TRUE);
+  NAString hiveTableNameStr;
+  char * hiveTableName = NULL;
 
-  if (doParallelDelete_)
-    exe_util_tdb->setDoParallelDelete(TRUE);
+  if (!getTableName().isInHiveDefaultSchema())
+    {
+      hiveTableNameStr =
+        getTableName().getQualifiedNameObj().getSchemaName();
+      hiveTableNameStr += ".";
+    }
 
-  if (doParallelDeleteIfXn_)
-    exe_util_tdb->setDoParallelDeleteIfXn(TRUE);
+  hiveTableNameStr +=
+    getTableName().getQualifiedNameObj().getObjectName();
+  hiveTableName = space->AllocateAndCopyToAlignedSpace(
+       hiveTableNameStr, 0);
 
-  if (offlineTable_)
-    exe_util_tdb->setOfflineTable(TRUE);
+  char * hiveTableLocation = NULL;
+  char * hiveHdfsHost = NULL;
+  Int32 hiveHdfsPort = getHiveHdfsPort();
+  
+  hiveTableLocation =
+    space->AllocateAndCopyToAlignedSpace (getHiveTableLocation(), 0);
+  hiveHdfsHost =
+    space->AllocateAndCopyToAlignedSpace (getHiveHostName(), 0);
+  if (getSuppressModCheck())
+    hiveModTS_ = 0;
 
-  if (doLabelPurgedata_)
-    exe_util_tdb->setDoLabelPurgedata(TRUE);
+  NABoolean doSimCheck = FALSE;
+  if ((CmpCommon::getDefault(HIVE_DATA_MOD_CHECK) == DF_ON) &&
+      (CmpCommon::getDefault(TRAF_SIMILARITY_CHECK) == DF_LEAF))
+    doSimCheck = TRUE;
 
-  if ((getUtilTableDesc()) && 
-      (getUtilTableDesc()->getNATable()) &&
-      (getUtilTableDesc()->getNATable()->isAnMV()))
-    exe_util_tdb->setIsMV(TRUE);
+  ComTdbExeUtilHiveTruncate * exe_util_tdb = new(space) 
+    ComTdbExeUtilHiveTruncate(tablename, strlen(tablename),
+                              hiveTableName,
+                              hiveTableLocation, partn_loc,
+                              hiveHdfsHost, hiveHdfsPort,
+                              (doSimCheck ? hiveModTS_ : -1),
+                              NULL,
+                              (ex_cri_desc *)(generator->getCriDesc(Generator::DOWN)),
+                              (ex_cri_desc *)(generator->getCriDesc(Generator::DOWN)),
+                              (queue_index)getDefault(GEN_DDL_SIZE_DOWN),
+                              (queue_index)getDefault(GEN_DDL_SIZE_UP),
+                              getDefault(GEN_DDL_NUM_BUFFERS),
+                              getDefault(GEN_DDL_BUFFER_SIZE));
 
   generator->initTdbFields(exe_util_tdb);
-  
+
+  if (getDropTableOnDealloc())
+    exe_util_tdb->setDropOnDealloc(TRUE);
+
+  exe_util_tdb->setIsLegacy(TRUE);
+
   if(!generator->explainDisabled()) {
     generator->setExplainTuple(
        addExplainInfo(exe_util_tdb, 0, 0, generator));
@@ -3277,11 +3235,7 @@ short ExeUtilFastDelete::codeGen(Generator * generator)
 			Generator::UP);
   generator->setGenObj(this, exe_util_tdb);
 
-  // Set the transaction flag.
-  //  if (xnNeeded())
-  // {
   generator->setTransactionFlag(0); // transaction is not needed.
-  //}
   
   return 0;
 }
@@ -3316,67 +3270,23 @@ short ExeUtilHiveTruncate::codeGen(Generator * generator)
       return -1;
     }
 
-  char * partn_loc = NULL;
-  if (pl_)
-    {
-      NAString partnLoc = getHiveTableLocation();
-      partnLoc += "/";
-
-      for (Lng32 i = 0; i < pl_->entries(); i++)
-	{
-	  const NAString *cs = (*pl_)[i];
-
-          partnLoc += *cs;
-          partnLoc += "/";
-          
-	}
-  
-      partn_loc = 
-        space->allocateAndCopyToAlignedSpace
-        (partnLoc.data(), partnLoc.length(), 0);
-    }
-
   char * tablename = NULL;
   tablename = space->AllocateAndCopyToAlignedSpace
     (generator->genGetNameAsAnsiNAString(getTableName()), 0);
 
-  NAString hiveTableNameStr;
   char * hiveTableName = NULL;
+  hiveTableName = space->AllocateAndCopyToAlignedSpace(getHiveTableName(), 0);
 
-  if (!getTableName().isInHiveDefaultSchema())
-    {
-      hiveTableNameStr =
-        getTableName().getQualifiedNameObj().getSchemaName();
-      hiveTableNameStr += ".";
-    }
-
-  hiveTableNameStr +=
-    getTableName().getQualifiedNameObj().getObjectName();
-  hiveTableName = space->AllocateAndCopyToAlignedSpace(
-       hiveTableNameStr, 0);
-
-  char * hiveTableLocation = NULL;
-  char * hiveHdfsHost = NULL;
-  Int32 hiveHdfsPort = getHiveHdfsPort();
-  
-  hiveTableLocation =
-    space->AllocateAndCopyToAlignedSpace (getHiveTableLocation(), 0);
-  hiveHdfsHost =
-    space->AllocateAndCopyToAlignedSpace (getHiveHostName(), 0);
-  if (getSuppressModCheck())
-    hiveModTS_ = 0;
-
-  NABoolean doSimCheck = FALSE;
-  if ((CmpCommon::getDefault(HIVE_DATA_MOD_CHECK) == DF_ON) &&
-      (CmpCommon::getDefault(TRAF_SIMILARITY_CHECK) == DF_LEAF))
-    doSimCheck = TRUE;
+  char * hiveTruncQuery = NULL;
+  hiveTruncQuery = space->AllocateAndCopyToAlignedSpace(getHiveTruncQuery(), 0);
 
   ComTdbExeUtilHiveTruncate * exe_util_tdb = new(space) 
     ComTdbExeUtilHiveTruncate(tablename, strlen(tablename),
                               hiveTableName,
-                              hiveTableLocation, partn_loc,
-                              hiveHdfsHost, hiveHdfsPort,
-                              (doSimCheck ? hiveModTS_ : -1),
+                              NULL, NULL,
+                              NULL, -1,
+                              -1,
+                              hiveTruncQuery,
                               (ex_cri_desc *)(generator->getCriDesc(Generator::DOWN)),
                               (ex_cri_desc *)(generator->getCriDesc(Generator::DOWN)),
                               (queue_index)getDefault(GEN_DDL_SIZE_DOWN),
@@ -3388,7 +3298,16 @@ short ExeUtilHiveTruncate::codeGen(Generator * generator)
 
   if (getDropTableOnDealloc())
     exe_util_tdb->setDropOnDealloc(TRUE);
-  
+
+  if (getHiveExternalTable())
+    exe_util_tdb->setIsExternal(TRUE);
+
+  if (getIfExist())
+    exe_util_tdb->setIfExists(TRUE);
+
+  if (NOT getTableNotExist())
+    exe_util_tdb->setTableNotExists(TRUE);
+
   if(!generator->explainDisabled()) {
     generator->setExplainTuple(
        addExplainInfo(exe_util_tdb, 0, 0, generator));

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp
index 58d2a4e..6d890f9 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -7756,8 +7756,6 @@ OptSqlTableOpenInfo *setupStoi(OptSqlTableOpenInfo *&optStoi_,
         stoi_->setDeleteAccess();
         if (((GenericUpdate*)re)->isMerge())
           stoi_->setInsertAccess();
-        if (((Delete*)re)->isFastDelete())
-          stoi_->setSelectAccess();
       }
       break;
     case REL_SCAN:
@@ -12034,7 +12032,7 @@ RelExpr *Delete::bindNode(BindWA *bindWA)
 
   // Triggers --
   
-  if ((NOT isFastDelete()) && (NOT noIMneeded()))
+  if (NOT noIMneeded())
     boundExpr = handleInlining(bindWA, boundExpr);
   else if (hbaseOper() && (getGroupAttr()->isEmbeddedUpdateOrDelete()))
   {
@@ -12936,16 +12934,10 @@ RelExpr * GenericUpdate::bindNode(BindWA *bindWA)
 
     // If this is not an INTERNAL REFRESH command, make sure the MV is
     // initialized and available.
-    // If this is FastDelete using parallel purgedata, do not enforce
-    // that MV is initialized.
     if (!bindWA->isBindingMvRefresh())
     {
-      if (NOT ((getOperatorType() == REL_UNARY_DELETE) &&
-               (((Delete*)this)->isFastDelete())))
-        {
-          if (naTable->verifyMvIsInitializedAndAvailable(bindWA))
-            return NULL;
-        }
+      if (naTable->verifyMvIsInitializedAndAvailable(bindWA))
+        return NULL;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/optimizer/ImplRule.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ImplRule.h b/core/sql/optimizer/ImplRule.h
index e2b8ffa..5cc8442 100644
--- a/core/sql/optimizer/ImplRule.h
+++ b/core/sql/optimizer/ImplRule.h
@@ -747,70 +747,6 @@ public:
                                   RuleSubstituteMemory *&memory);
 };
 
-class PhysicalParallelLabelCreateRule : public Rule
-{
-public:
-   PhysicalParallelLabelCreateRule(const char *name,
-                                   RelExpr *pattern,
-                                   RelExpr *substitute) : 
-                Rule(name,pattern,substitute) {}
-   PhysicalParallelLabelCreateRule(const PhysicalParallelLabelCreateRule &);
-   virtual ~PhysicalParallelLabelCreateRule();
-   virtual NABoolean topMatch(RelExpr * relExpr,
-                              Context *context);
-   virtual RelExpr * nextSubstitute(RelExpr * before,
-                                    Context * context,
-                                    RuleSubstituteMemory * & memory);
-};
-
-class PhysicalParallelLabelDropRule: public Rule
-{
-public:
-   PhysicalParallelLabelDropRule(const char *name,
-                                 RelExpr *pattern,
-                                 RelExpr *substitute) : 
-                Rule(name,pattern,substitute) {}
-   PhysicalParallelLabelDropRule(const PhysicalParallelLabelDropRule&);
-   virtual ~PhysicalParallelLabelDropRule();
-   virtual NABoolean topMatch(RelExpr * relExpr,
-                              Context *context);
-   virtual RelExpr * nextSubstitute(RelExpr * before,
-                                    Context * context,
-                                    RuleSubstituteMemory * & memory);
-};
-
-class PhysicalParallelLabelAlterRule : public Rule
-{
-public:
-   PhysicalParallelLabelAlterRule(const char *name,
-                                   RelExpr *pattern,
-                                   RelExpr *substitute) : 
-                Rule(name,pattern,substitute) {}
-   PhysicalParallelLabelAlterRule(const PhysicalParallelLabelAlterRule &);
-   virtual ~PhysicalParallelLabelAlterRule();
-   virtual NABoolean topMatch(RelExpr * relExpr,
-                              Context *context);
-   virtual RelExpr * nextSubstitute(RelExpr * before,
-                                    Context * context,
-                                    RuleSubstituteMemory * & memory);
-};
-
-class PhysicalParallelLabelPurgedataRule : public Rule
-{
-public:
-   PhysicalParallelLabelPurgedataRule(const char *name,
-                                   RelExpr *pattern,
-                                   RelExpr *substitute) : 
-                Rule(name,pattern,substitute) {}
-   PhysicalParallelLabelPurgedataRule(const PhysicalParallelLabelPurgedataRule &);
-   virtual ~PhysicalParallelLabelPurgedataRule();
-   virtual NABoolean topMatch(RelExpr * relExpr,
-                              Context *context);
-   virtual RelExpr * nextSubstitute(RelExpr * before,
-                                    Context * context,
-                                    RuleSubstituteMemory * & memory);
-};
-
 class PhysicalIsolatedScalarUDFRule : public Rule
 {
 public:

http://git-wip-us.apache.org/repos/asf/trafodion/blob/2bba19ff/core/sql/optimizer/RelCache.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelCache.cpp b/core/sql/optimizer/RelCache.cpp
index b3ee6da..4fb9a0d 100644
--- a/core/sql/optimizer/RelCache.cpp
+++ b/core/sql/optimizer/RelCache.cpp
@@ -527,10 +527,6 @@ RelExpr* Insert::normalizeForCache(CacheWA& cwa, BindWA& bindWA)
 // is this entire expression cacheable after this phase?
 NABoolean Delete::isCacheableExpr(CacheWA& cwa)
 {
-  // fastdelete (purgedata) is not a cacheable expression.
-  if (isFastDelete())
-    return FALSE; 
-
   return GenericUpdate::isCacheableExpr(cwa);
 }
 


Mime
View raw message