You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2015/09/22 01:12:16 UTC

[01/14] incubator-trafodion git commit: jira-1443 final.

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master a982a5c4a -> e1093020f


jira-1443 final.


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

Branch: refs/heads/master
Commit: 3d212c68f2a4bca5388178068117da5f89119b80
Parents: 0434c60
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Thu Sep 17 03:54:24 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Thu Sep 17 03:54:24 2015 +0000

----------------------------------------------------------------------
 .../sql/scripts/install_hadoop_regr_test_env    |  15 ++-
 core/sql/common/ComSmallDefs.h                  |   5 +-
 core/sql/optimizer/BindRelExpr.cpp              |   3 +-
 core/sql/optimizer/BindWA.cpp                   |   4 +-
 core/sql/optimizer/BindWA.h                     |   4 +-
 core/sql/optimizer/NATable.cpp                  |  97 ++++++++--------
 core/sql/optimizer/NATable.h                    |  22 +++-
 core/sql/optimizer/ObjectNames.cpp              |  12 ++
 core/sql/optimizer/ObjectNames.h                |   3 +
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp         |   8 --
 core/sql/ustat/hs_cli.cpp                       |  12 ++
 core/sql/ustat/hs_globals.cpp                   |  24 +++-
 core/sql/ustat/hs_globals.h                     |  15 ++-
 core/sql/ustat/hs_la.cpp                        | 112 ++++++++++++++++++-
 core/sql/ustat/hs_la.h                          |  13 ++-
 core/sql/ustat/hs_parser.cpp                    |  82 +++++++-------
 core/sql/ustat/hs_util.cpp                      |   3 +
 17 files changed, 319 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sqf/sql/scripts/install_hadoop_regr_test_env
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/install_hadoop_regr_test_env b/core/sqf/sql/scripts/install_hadoop_regr_test_env
index 292d2bd..ee1bac9 100755
--- a/core/sqf/sql/scripts/install_hadoop_regr_test_env
+++ b/core/sqf/sql/scripts/install_hadoop_regr_test_env
@@ -199,7 +199,6 @@ fi
   ./dsdgen -force $FORCE -dir $MY_TPCDS_DATA_DIR -scale $SCALE -table store       >>${MY_LOG_FILE} 2>&1
   ./dsdgen -force $FORCE -dir $MY_TPCDS_DATA_DIR -scale $SCALE -table promotion   >>${MY_LOG_FILE} 2>&1
 
-  echo "Copying generated data to HDFS..."
   $MY_HDFS_CMD dfs -mkdir /hive/tpcds                        >>${MY_LOG_FILE} 2>&1
   $MY_HDFS_CMD dfs -mkdir /hive/tpcds/date_dim               >>${MY_LOG_FILE} 2>&1
   $MY_HDFS_CMD dfs -mkdir /hive/tpcds/time_dim               >>${MY_LOG_FILE} 2>&1
@@ -214,6 +213,20 @@ fi
 
   cd $MY_TPCDS_DATA_DIR
 
+  which iconv >>${MY_LOG_FILE} 2>&1
+  if (( $? != 0 ))
+  then
+    echo "iconv utility not available. The data will be in ISO-8859-1 format."
+  else
+    echo "Converting the data into UTF-8 format ..."
+    for t in date_dim time_dim item customer customer_demographics household_demographics customer_address store promotion store_sales
+      do
+        iconv -f ISO-8859-1 -t UTF-8 -o ${t}.utf8.dat ${t}.dat >>${MY_LOG_FILE} 2>&1
+        mv ${t}.utf8.dat ${t}.dat
+      done
+  fi
+
+  echo "Copying generated data to HDFS..."
   for t in date_dim time_dim item customer customer_demographics household_demographics customer_address store promotion store_sales
     do
       $MY_HDFS_CMD dfs -put ${t}.dat /hive/tpcds/${t}        >>${MY_LOG_FILE} 2>&1

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 028ca1b..6e893c5 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -116,7 +116,7 @@ typedef NABoolean               ComBoolean;
 #define HIVE_SYSTEM_CATALOG          "HIVE"
 #define HIVE_SYSTEM_SCHEMA           "HIVE"
 #define HIVE_STATS_CATALOG           "TRAFODION"
-#define HIVE_STATS_SCHEMA            "HIVESTATS"
+#define HIVE_STATS_SCHEMA            "\"_HIVESTATS_\""
 #define HIVE_EXT_SCHEMA_PREFIX       "_HV_"
 
 #define HBASE_SYSTEM_CATALOG          "HBASE"
@@ -127,6 +127,9 @@ typedef NABoolean               ComBoolean;
 #define HBASE_HISTINT_PK               "SB_HISTOGRAM_INTERVALS_PK"
 #define HBASE_EXT_SCHEMA_PREFIX       "_HB_"
 
+#define HBASE_STATS_CATALOG          "TRAFODION"
+#define HBASE_STATS_SCHEMA           "\"_HBASESTATS_\""
+
 #define TRAFODION_SYSCAT_LIT              "TRAFODION"
 #define SEABASE_SYSTEM_SCHEMA           "SEABASE"
 #define SEABASE_OLD_PRIVMGR_SCHEMA         "PRIVMGR_MD"

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp
index 2d400bb..74fa8f3 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -1573,7 +1573,8 @@ NATable *BindWA::getNATable(CorrName& corrName,
   // native HIVE or HBASE objects unless the allowExternalTables flag is set.  
   // allowExternalTables is set for drop table and SHOWDDL statements.  
   // TDB - may want to merge the Trafodion version with the native version.
-  if ((table) && (table->isExternalTable() && (! bindWA->allowExternalTables())))
+  if ((table) && (table->isExternalTable() && (! bindWA->allowExternalTables()) &&
+                  !table->isHistogramTable()))
     {
       *CmpCommon::diags() << DgSqlCode(-4258)
                           << DgTableName(table->getTableName().getQualifiedNameAsAnsiString());

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/optimizer/BindWA.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindWA.cpp b/core/sql/optimizer/BindWA.cpp
index ce83134..b80edff 100644
--- a/core/sql/optimizer/BindWA.cpp
+++ b/core/sql/optimizer/BindWA.cpp
@@ -114,7 +114,7 @@ void BindScope::mergeOuterRefs(const ValueIdSet& other)
 // ***********************************************************************
 // BindWA()
 // ***********************************************************************
-BindWA::BindWA(SchemaDB *schemaDB, CmpContext* cmpContext, NABoolean inDDL)
+BindWA::BindWA(SchemaDB *schemaDB, CmpContext* cmpContext, NABoolean inDDL, NABoolean allowExtTables)
      : schemaDB_(schemaDB)
      , currentCmpContext_(cmpContext)
      , inputVars_(cmpContext ? cmpContext->statementHeap() : NULL)
@@ -131,7 +131,7 @@ BindWA::BindWA(SchemaDB *schemaDB, CmpContext* cmpContext, NABoolean inDDL)
   //     , inRIMaint_(FALSE)
      , inViewWithCheckOption_(NULL)
      , viewCount_(0)
-     , allowExternalTables_(FALSE)
+     , allowExternalTables_(allowExtTables)
      , errFlag_(FALSE)
      , uniqueNum_(0)
      , uniqueIudNum_(0) //++Triggers,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/optimizer/BindWA.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindWA.h b/core/sql/optimizer/BindWA.h
index 11b1fdd..92406c5 100644
--- a/core/sql/optimizer/BindWA.h
+++ b/core/sql/optimizer/BindWA.h
@@ -1178,7 +1178,8 @@ public:
   // --------------------------------------------------------------------
   BindWA(SchemaDB *schemaDB,
   	 CmpContext *currentCmpContext = NULL,
-	 NABoolean inDDL = FALSE);
+	 NABoolean inDDL = FALSE,
+	 NABoolean allowExternalTables = FALSE);
 
   // copy ctor
   BindWA (const BindWA & orig, CollHeap * h=0) ; // not written
@@ -1797,7 +1798,6 @@ private:
   // --------------------------------------------------------------------
   NABoolean inDDL_;
 
-
   //---------------------------------------------------------------------
   // does the query tree contain any update nodes?
   //---------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index 5a68aa8..dbf8aed 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -4890,6 +4890,34 @@ Int64 lookupObjectUid( const QualifiedName& qualName
   return objectUID;
 }
 
+NABoolean NATable::fetchObjectUIDForNativeTable(const CorrName& corrName)
+{
+   NAString adjustedName = ComConvertNativeNameToTrafName
+         (corrName.getQualifiedNameObj().getCatalogName(),
+          corrName.getQualifiedNameObj().getUnqualifiedSchemaNameAsAnsiString(),
+          corrName.getQualifiedNameObj().getUnqualifiedObjectNameAsAnsiString());
+   QualifiedName extObjName (adjustedName, 3, STMTHEAP);
+
+   Lng32 diagsMark = CmpCommon::diags()->mark();
+   objectUID_ = ::lookupObjectUid(extObjName, COM_BASE_TABLE_OBJECT);
+
+   // If the objectUID is not found, then the table is not externally defined
+   // in Trafodion, set the objectUID to 0
+   // If an unexpected error occurs, then return with the error
+   if (objectUID_ <= 0)
+     {
+       if (CmpCommon::diags()->contains(-1389))
+         {
+           CmpCommon::diags()->rewind(diagsMark);
+           objectUID_ = 0;
+         }
+       else
+         return FALSE;
+     }
+
+   return TRUE;
+}
+
 // -----------------------------------------------------------------------
 // NATable::NATable() constructor
 // -----------------------------------------------------------------------
@@ -5110,6 +5138,12 @@ NATable::NATable(BindWA *bindWA,
     setIsExternalTable(TRUE);
   }
  
+  if (qualifiedName_.getQualifiedNameObj().isHistograms() || 
+      qualifiedName_.getQualifiedNameObj().isHistogramIntervals())
+  {
+    setIsHistogramTable(TRUE);
+  }
+ 
   insertMode_ = table_desc->body.table_desc.insertMode;
 
   setRecordLength(table_desc->body.table_desc.record_length);
@@ -5128,29 +5162,10 @@ NATable::NATable(BindWA *bindWA,
   // been defined in Trafodion use this value, otherwise, set to 0
   if (isHbaseCell_ || isHbaseRow_)
     {
-      NAString adjustedName = ComConvertNativeNameToTrafName
-         (corrName.getQualifiedNameObj().getCatalogName(),
-          corrName.getQualifiedNameObj().getUnqualifiedSchemaNameAsAnsiString(),
-          corrName.getQualifiedNameObj().getUnqualifiedObjectNameAsAnsiString());
-      QualifiedName extObjName (adjustedName, 3, STMTHEAP);
-
-      Lng32 diagsMark = CmpCommon::diags()->mark();
-      objectUID_ = ::lookupObjectUid(extObjName, COM_BASE_TABLE_OBJECT);
+      if ( !fetchObjectUIDForNativeTable(corrName) )
+        return;
 
-      // If the objectUID is not found, then the table is not externally defined
-      // in Trafodion, set the objectUID to 0
-      // If an unexpected error occurs, then return with the error
-      if (objectUID_ <= 0)
-        {
-          if (CmpCommon::diags()->contains(-1389))
-            {
-              CmpCommon::diags()->rewind(diagsMark);
-              objectUID_ = 0;
-            }
-          else
-            return;
-        }
-      else
+      if (objectUID_ > 0 )
         setHasExternalTable(TRUE);
     }
 
@@ -5781,31 +5796,12 @@ NATable::NATable(BindWA *bindWA,
   // If the HIVE table has been registered in Trafodion, get the objectUID
   // from Trafodion, otherwise, set it to 0.
   // TBD - does getQualifiedNameObj handle delimited names correctly?
-  NAString adjustedName = ComConvertNativeNameToTrafName 
-                            ( corrName.getQualifiedNameObj().getCatalogName(),
-                              corrName.getQualifiedNameObj().getSchemaName(),
-                              corrName.getQualifiedNameObj().getObjectName()); 
-  QualifiedName extObjName (adjustedName, 3, STMTHEAP);
-
-  Lng32 diagsMark = CmpCommon::diags()->mark();
-  objectUID_ = ::lookupObjectUid(extObjName, COM_BASE_TABLE_OBJECT);
-
-  // If the objectUID is not found, then the table is not externally defined
-  // in Trafodion, set the objectUID to 0
-  // If an unexpected error occurs, then return with the error
-  if (objectUID_ <= 0)
-    {
-      if (CmpCommon::diags()->contains(-1389))
-        {
-          CmpCommon::diags()->rewind(diagsMark);
-          objectUID_ = 0;
-        }
-      else
-        return;
-    }
-  else
+  if ( !fetchObjectUIDForNativeTable(corrName) )
+     return;
+
+  if ( objectUID_ > 0 )
     setHasExternalTable(TRUE);
- 
+
   // for HIVE objects, the schema owner and table owner is HIVE_ROLE_ID
   if (CmpCommon::context()->isAuthorizationEnabled())
   {
@@ -6883,10 +6879,19 @@ void NATable::setupPrivInfo()
 // Query the metadata to find the object uid of the table. This is used when
 // the uid for a metadata table is requested, since 0 is usually stored for
 // these tables.
+// 
+// On return, the "Object Not Found" error (1389) is filtered out from 
+// CmpCommon::diags().
 Int64 NATable::lookupObjectUid()
 {
+    Lng32 diagsMark = CmpCommon::diags()->mark();
+
     QualifiedName qualName = getExtendedQualName().getQualifiedNameObj();
     objectUID_ = ::lookupObjectUid(qualName, objectType_);
+
+    if (CmpCommon::diags()->contains(-1389))
+      CmpCommon::diags()->rewind(diagsMark);
+
     return objectUID_.get_value();
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/optimizer/NATable.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.h b/core/sql/optimizer/NATable.h
index 6a22781..ec19d14 100644
--- a/core/sql/optimizer/NATable.h
+++ b/core/sql/optimizer/NATable.h
@@ -509,6 +509,7 @@ public:
 
   const ComUID &getCatalogUid() const           { return catalogUID_; }
   const ComUID &getSchemaUid() const            { return schemaUID_; }
+
   const ComUID &objectUid() const
   {
     if (objectUID_.get_value() == 0)
@@ -516,7 +517,17 @@ public:
     return objectUID_;
   }
 
-  Int64 lookupObjectUid();  // Used to look up uid on demand for metadata tables
+  // fetch the object UID that is associated with the external 
+  // table object (if any) for a native table.
+  // Set objectUID_ to 0 if no such external table exists;
+  // set objectUID_ to -1 if there is error during the fetch operation;
+  NABoolean fetchObjectUIDForNativeTable(const CorrName& corrName);
+
+
+  Int64 lookupObjectUid();  // Used to look up uid on demand for metadata tables.
+                            // On return, the "Object Not Found" error (-1389) 
+                            // is filtered out from CmpCommon::diags().
+
   bool isEnabledForDDLQI() const;
 
   const ComObjectType &getObjectType() const { return objectType_; }
@@ -710,6 +721,12 @@ public:
   NABoolean hasExternalTable() const
   {  return (flags_ & HAS_EXTERNAL_TABLE) != 0; }
 
+  void setIsHistogramTable( NABoolean value )
+  {  value ? flags_ |= IS_HISTOGRAM_TABLE : flags_ &= ~IS_HISTOGRAM_TABLE; }
+
+  NABoolean isHistogramTable() const
+  {  return (flags_ & IS_HISTOGRAM_TABLE) != 0; }
+
   const CheckConstraintList &getCheckConstraints() const
                                                 { return checkConstraints_; }
   const AbstractRIConstraintList &getUniqueConstraints() const
@@ -924,7 +941,8 @@ private:
     SERIALIZED_ENCODED_COLUMN = 0x00020000,
     SERIALIZED_COLUMN         = 0x00040000,
     IS_EXTERNAL_TABLE         = 0x00080000,
-    HAS_EXTERNAL_TABLE        = 0x00100000
+    HAS_EXTERNAL_TABLE        = 0x00100000,
+    IS_HISTOGRAM_TABLE        = 0x00200000
   };
     
   UInt32 flags_;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/optimizer/ObjectNames.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ObjectNames.cpp b/core/sql/optimizer/ObjectNames.cpp
index f2fe28b..75a9462 100644
--- a/core/sql/optimizer/ObjectNames.cpp
+++ b/core/sql/optimizer/ObjectNames.cpp
@@ -670,6 +670,7 @@ NABoolean QualifiedName::isSeabasePrivMgrMD() const
     (getCatalogName(), getSchemaName());
 }
 
+
 // -----------------------------------------------------------------------
 // Methods for class CorrName
 // -----------------------------------------------------------------------
@@ -1385,6 +1386,17 @@ void QualifiedName::print(FILE* ofd, const char* indent, const char* title) cons
 #endif
 }
 
+NABoolean QualifiedName::isHistograms() const
+{
+   return (getObjectName() == "SB_HISTOGRAMS");
+}
+
+NABoolean QualifiedName::isHistogramIntervals() const
+{
+   return (getObjectName() == "SB_HISTOGRAM_INTERVALS");
+}
+
+
 void ExtendedQualName::print(FILE* ofd, const char* indent, const char* title) const
 {
 #ifndef NDEBUG

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/optimizer/ObjectNames.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ObjectNames.h b/core/sql/optimizer/ObjectNames.h
index d7f15cf..981025f 100644
--- a/core/sql/optimizer/ObjectNames.h
+++ b/core/sql/optimizer/ObjectNames.h
@@ -322,6 +322,9 @@ public:
   NABoolean isSeabaseMD() const;
   NABoolean isSeabasePrivMgrMD() const;
 
+  NABoolean isHistograms() const;
+  NABoolean isHistogramIntervals() const;
+
   void setObjectName(const NAString &objName)   { objectName_ = objName; }
   void setObjectNameSpace(ComAnsiNameSpace objNameSpace)   { objectNameSpace_ = objNameSpace; }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 36663f5..e7f7b29 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -249,14 +249,6 @@ void CmpSeabaseDDL::createSeabaseTableLike(
   ComObjectName srcTableName(createTableNode->getLikeSourceTableName(), COM_TABLE_NAME);
   srcTableName.applyDefaults(currCatAnsiName, currSchAnsiName);
   
-  // If source table is external, return an error.  
-  // TBD - allow create table like a native (external) HIVE or HBASE table
-  if (ComIsTrafodionExternalSchemaName(srcTableName.getSchemaNamePart().getInternalName()))
-    {
-      *SqlParser_Diags << DgSqlCode(-CAT_UNSUPPORTED_COMMAND_ERROR);
-      return;
-    }
-  
   CorrName cn(srcTableName.getObjectNamePart().getInternalName(),
               STMTHEAP,
               srcTableName.getSchemaNamePart().getInternalName(),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/ustat/hs_cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_cli.cpp b/core/sql/ustat/hs_cli.cpp
index 9d1da06..94fce0f 100644
--- a/core/sql/ustat/hs_cli.cpp
+++ b/core/sql/ustat/hs_cli.cpp
@@ -540,6 +540,17 @@ Lng32 HSSample::create(NAString& tblName, NABoolean unpartitioned, NABoolean isP
 
     NAString tempTabName = tblName;
     NAString userTabName = objDef->getObjectFullName();
+
+    // If the table is a native one, convert the fully qualified user table name NT
+    // to a fully qualified external table name ET. The sample table will be coreated
+    // like ET.
+    if ( HSGlobalsClass::isNativeCat(objDef->getCatName(HSTableDef::EXTERNAL_FORMAT))) {
+      userTabName = ComConvertNativeNameToTrafName(
+                      objDef->getCatName(HSTableDef::EXTERNAL_FORMAT),
+                      objDef->getSchemaName(HSTableDef::EXTERNAL_FORMAT),
+                      objDef->getObjectName(HSTableDef::EXTERNAL_FORMAT));
+    }
+
     NAString userLocation;
     ComObjectName *sampleName;
     NAString tableOptions;
@@ -681,6 +692,7 @@ Lng32 HSSample::create(NAString& tblName, NABoolean unpartitioned, NABoolean isP
                             - UERR_UNABLE_TO_CREATE_OBJECT,
                             NULL,
                             tempTabName, objDef);
+
     HSHandleError(retcode);
 
     //***********************************************************

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index 6e0e9c0..d5dba38 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -2745,6 +2745,7 @@ THREAD_P NABoolean HSGlobalsClass::performISForMC_ = FALSE;
 HSGlobalsClass::HSGlobalsClass(ComDiagsArea &diags)
   : catSch(new(STMTHEAP) NAString(STMTHEAP)),
     isHbaseTable(FALSE),
+    isHiveTable(FALSE),
     user_table(new(STMTHEAP) NAString(STMTHEAP)),
     numPartitions(0),
     hstogram_table(new(STMTHEAP) NAString(STMTHEAP)),
@@ -2862,6 +2863,7 @@ Lng32 HSGlobalsClass::Initialize()
        defaultHiveCatName = new (GetCliGlobals()->exCollHeap()) NAString("");
     else
       (*defaultHiveCatName) = "";
+
     CmpCommon::getDefault(HIVE_CATALOG, (*defaultHiveCatName), FALSE);
     (*defaultHiveCatName).toUpper();
 
@@ -2869,7 +2871,8 @@ Lng32 HSGlobalsClass::Initialize()
        defaultHbaseCatName = new (GetCliGlobals()->exCollHeap()) NAString("");
     else
       (*defaultHbaseCatName) = "";
-    CmpCommon::getDefault(SEABASE_CATALOG, (*defaultHbaseCatName), FALSE);
+
+    CmpCommon::getDefault(HBASE_CATALOG, (*defaultHbaseCatName), FALSE);
     (*defaultHbaseCatName).toUpper();
 
                                               /*==============================*/
@@ -2887,6 +2890,22 @@ Lng32 HSGlobalsClass::Initialize()
         HSHandleError(retcode);
         TM->Commit(); // Must commit this transaction (even if schema didn't get created).
       }
+                                              /*=====================================*/
+                                              /*   CREATE HBASE STATS SCHEMA         */
+                                              /*   typically as trafodion.hbasestats */
+                                              /*=====================================*/
+    if (isNativeHbaseCat(objDef->getCatName()))
+      {
+        HSTranMan *TM = HSTranMan::Instance(); // Must have transaction around this.
+        TM->Begin("Create schema for native hbase stats.");
+        NAString ddl = "CREATE SCHEMA IF NOT EXISTS ";
+        ddl.append(HBASE_STATS_CATALOG).append('.').append(HBASE_STATS_SCHEMA);
+        retcode = HSFuncExecQuery(ddl, -UERR_INTERNAL_ERROR, NULL,
+                                  "Creating schema for native HBase statistics", NULL,
+                                  NULL);
+        HSHandleError(retcode);
+        TM->Commit(); // Must commit this transaction (even if schema didn't get created).
+      }
                                               /*==============================*/
                                               /*    CREATE HISTOGRM TABLES    */
                                               /*==============================*/
@@ -3938,7 +3957,7 @@ Lng32 HSSample::make(NABoolean rowCountIsEstimate, // input
     // On SQ, alter the sample table to audit afterwards. There are performance 
     // issues with non-audited tables on SQ. For Trafodion, however, this alter
     // is not supported, so skip it.
-     if (!hs_globals->isHbaseTable)
+     if (!hs_globals->isHbaseTable && !hs_globals->isHiveTable)
        {
          LM->StartTimer("Set audit attribute on sample table");
          SQL_EXEC_SetParserFlagsForExSqlComp_Internal(hsALLOW_SPECIALTABLETYPE);
@@ -15510,3 +15529,4 @@ Lng32 HSGlobalsClass::CollectStatisticsWithFastStats()
 
   return retcode;
 }
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/ustat/hs_globals.h
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.h b/core/sql/ustat/hs_globals.h
index a44899a..e55f27a 100644
--- a/core/sql/ustat/hs_globals.h
+++ b/core/sql/ustat/hs_globals.h
@@ -1374,11 +1374,21 @@ public:
     // See if catName is the name of an HBase catalog.
     static NABoolean isHbaseCat(const NAString& catName)
     {
+      return ((catName == TRAFODION_SYSCAT_LIT) || isNativeHbaseCat(catName));
+    }
+
+    static NABoolean isNativeHbaseCat(const NAString& catName)
+    {
       return (((defaultHbaseCatName != NULL) && (catName == (*defaultHbaseCatName))) ||
-              ((catName == TRAFODION_SYSCAT_LIT) ||
-	       (catName == HBASE_SYSTEM_CATALOG)));
+              (catName == HBASE_SYSTEM_CATALOG));
     }
 
+    static NABoolean isNativeCat(const NAString& catName)
+    {
+      return (isNativeHbaseCat(catName) || isHiveCat(catName));
+    }
+
+
     static NABoolean isHBaseMeta(const NAString& schName)
     { return (schName == "_MD_" || schName == "_PRIVMGR_MD_"); }
 
@@ -1560,6 +1570,7 @@ public:
     NAString      *catSch;                         /* catalog+schema name     */
     NAString      *user_table;                     /* object name             */
     NABoolean     isHbaseTable;                    /* ustat on HBase table    */
+    NABoolean     isHiveTable;                     /* ustat on Hive table     */
     ComAnsiNameSpace nameSpace;                    /* object namespace    ++MV*/
     Int64          numPartitions;                  /* # of partns in object   */
     NAString      *hstogram_table;                 /* HISTOGRM table          */

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/ustat/hs_la.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_la.cpp b/core/sql/ustat/hs_la.cpp
index 9ba464f..77a5ed1 100644
--- a/core/sql/ustat/hs_la.cpp
+++ b/core/sql/ustat/hs_la.cpp
@@ -121,7 +121,10 @@ NABoolean HSSqTableDef::objExists(labelDetail detail)
 
 void HSTableDef::setNATable()
   {
-    BindWA bindWA(ActiveSchemaDB(), CmpCommon::context());
+    //BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE, getIsNativeHbaseOrHive());
+    BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE, 
+                  HSGlobalsClass::isNativeCat(*catalog_));
+
     CorrName corrName(*object_, STMTHEAP, *schema_, *catalog_);
     if (isVolatile())
       corrName.setIsVolatile(TRUE);
@@ -848,6 +851,9 @@ NABoolean HSHiveTableDef::objExists(labelDetail unused)
   if (!naTbl_)
     return FALSE;
 
+  if (!setObjectUID())
+    return FALSE;
+
   tableStats_ = naTbl_->getClusteringIndex()->getHHDFSTableStats();
 
   *ansiName_ = *catalog_;
@@ -922,7 +928,6 @@ NABoolean HSHiveTableDef::objExists(labelDetail unused)
     return FALSE;
   }
 
-  objectUID_ = hiveTblDesc_->tblID_;
   objActualFormat_ = SQLMX;
 
   return TRUE;
@@ -994,13 +999,107 @@ Lng32 HSHiveTableDef::DescribeColumnNames()
 }
 
 //=====================================================
+//
+NAString HSHbaseTableDef::getHistLoc(formatType format) const
+{
+  return HBASE_STATS_CATALOG "." HBASE_STATS_SCHEMA;
+}
+
+static 
+Lng32 CreateExternalTable(const NAString& catName, const NAString& schName, const NAString& nativeTableName)
+{
+   HSLogMan *LM = HSLogMan::Instance();
+   if (LM->LogNeeded())
+      {
+        snprintf(LM->msg, sizeof(LM->msg), "Creating external table table for %s on demand.",
+                          nativeTableName.data());
+        LM->Log(LM->msg);
+      }
+
+   // do not have to worry about the catalog and schema for the new external table 
+   // here. These names will be determined by the processing logic. 
+   NAString ddl = "CREATE EXTERNAL TABLE ";
+   ddl.append(nativeTableName);
+   ddl.append(" FOR ");
+   ddl.append(catName);
+   ddl.append(".");
+   ddl.append(schName);
+   ddl.append(".");
+   ddl.append(nativeTableName);
+   ddl.append(" ATTRIBUTE ");
+
+   HSTranMan *TM = HSTranMan::Instance();
+   if (TM->InTransaction())
+      ddl.append(" AUDIT");
+   else
+      ddl.append("NO AUDIT");
+
+   Lng32 retcode = HSFuncExecDDL(ddl.data(), - UERR_INTERNAL_ERROR, NULL,
+                            "Create external table", NULL);
+
+   if (retcode < 0 && LM->LogNeeded())
+      {
+        snprintf(LM->msg, sizeof(LM->msg), "Creation of the external table failed.");
+        LM->Log(LM->msg);
+      }
+
+   return retcode;
+}
+
+NABoolean HSTableDef::setObjectUID()
+{
+  objectUID_ = naTbl_->objectUid().get_value();
+
+  if (objectUID_ <= 0 && HSGlobalsClass::isNativeCat(getCatName(EXTERNAL_FORMAT)) ) {
+
+    // If objectUID is not set, it means there is no corresponding
+    // external table created for it. Need to create one here.
+    NAString catName = getCatName(EXTERNAL_FORMAT);
+    NAString schName = getSchemaName(EXTERNAL_FORMAT);
+    NAString objName = getObjectName(EXTERNAL_FORMAT);
+    Lng32 retcode = CreateExternalTable(catName, schName, objName);
+
+    if (retcode != 0)
+      return FALSE;
+
+    setNATable();
+    if (!naTbl_)
+      return FALSE;
+
+    CorrName corrName(getObjectName(), STMTHEAP, getSchemaName(), getCatName());
+
+    if ( !naTbl_->fetchObjectUIDForNativeTable(corrName) )
+      return FALSE;
+
+    objectUID_ = naTbl_->objectUid().get_value();
+
+    HSLogMan *LM = HSLogMan::Instance();
+    if (LM->LogNeeded()) {
+       sprintf(LM->msg, "NATable::fetchObjectUIDForNativeTable() returns %ld\n", objectUID_);
+       LM->Log(LM->msg);
+    }
+  }
+
+  return (objectUID_ > 0);
+}
 
 NABoolean HSHbaseTableDef::objExists(labelDetail unused)
 {
+  HSLogMan *LM = HSLogMan::Instance();
+
+  if (LM->LogNeeded()) {
+     sprintf(LM->msg, "call HSHbaseTableDef::objExists\n");
+     LM->Log(LM->msg);
+  }
+
   setNATable();
   if (!naTbl_)
     return FALSE;
 
+  if (!setObjectUID())
+    return FALSE;
+
+
   *ansiName_ = getCatName(EXTERNAL_FORMAT);
   ansiName_->append(".");
   ansiName_->append(getSchemaName(EXTERNAL_FORMAT));
@@ -1018,7 +1117,14 @@ NABoolean HSHbaseTableDef::objExists(labelDetail unused)
   Lng32 retcode_ = getColumnNames();
   HSHandleError(retcode_);
 
-  objectUID_ = naTbl_->objectUid().get_value();
+  if (LM->LogNeeded()) {
+     sprintf(LM->msg, "objectUID_ set to %ld\n", objectUID_);
+     sprintf(LM->msg, "naTbl_->objectUid() is %ld\n", naTbl_->objectUid().get_value());
+     LM->Log(LM->msg);
+           
+  }
+
+
   objActualFormat_ = SQLMX;
 
   return TRUE;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/ustat/hs_la.h
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_la.h b/core/sql/ustat/hs_la.h
index 43c0aab..97db4ac 100644
--- a/core/sql/ustat/hs_la.h
+++ b/core/sql/ustat/hs_la.h
@@ -58,6 +58,7 @@ class HSTableDef : public NABasicObject
     HSTableDef(const ComObjectName &tableName,
                const hs_table_type tableType,
                const ComAnsiNameSpace nameSpace);
+
     ~HSTableDef();
     virtual NABoolean objExists(labelDetail detail = MIN_INFO) = 0;
     virtual NABoolean publicSchemaExists() = 0;
@@ -68,6 +69,7 @@ class HSTableDef : public NABasicObject
     NAString getObjectFullName() const;
     NATable* getNATable() const {return naTbl_;}
     void setNATable();
+
     virtual NAString getCatalogLoc(formatType format = INTERNAL_FORMAT) const = 0;
     NAString getPrimaryLoc(formatType format = INTERNAL_FORMAT) const;
     virtual NAString getHistLoc(formatType format = INTERNAL_FORMAT) const = 0;
@@ -113,6 +115,9 @@ class HSTableDef : public NABasicObject
     virtual tblOrigin getTblOrigin() const = 0;
 
   protected:
+    NABoolean setObjectUID();
+
+  protected:
     NAString           *tableName_;
     NAString           *ansiName_;
     NAString           *guardianName_;
@@ -350,12 +355,8 @@ class HSHbaseTableDef : public HSTableDef
         HS_ASSERT(FALSE);  // MP only
         return "";
       }
-    // Unlike Hive, for HBase we must put the hist and hist_ints tables in
-    // HBase, so we use same cat/sch as source table.
-    NAString getHistLoc(formatType format = INTERNAL_FORMAT) const
-      {
-        return getPrimaryLoc(format);  // inherited from HSTableDef
-      }
+    NAString getHistLoc(formatType format = INTERNAL_FORMAT) const;
+
     Lng32 getFileType()  const
       {
         return -1;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/ustat/hs_parser.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_parser.cpp b/core/sql/ustat/hs_parser.cpp
index f444245..82158dc 100644
--- a/core/sql/ustat/hs_parser.cpp
+++ b/core/sql/ustat/hs_parser.cpp
@@ -148,6 +148,7 @@ Lng32 AddTableName( const hs_table_type type
                  )
   {
     HSGlobalsClass *hs_globals = GetHSContext();
+    
     NAString catName, schName, objName;
     NAString extName;
     NAString defaultCat, defaultSch;
@@ -225,7 +226,7 @@ Lng32 AddTableName( const hs_table_type type
               catName = ActiveSchemaDB()->getDefaultSchema().getCatalogName();
           }
   
-        if (schema)
+        if (schema) 
           schName = schema;
         else
           {
@@ -299,6 +300,7 @@ Lng32 AddTableName( const hs_table_type type
                                                 volIntName,
                                                 hs_globals->tableType,
                                                 hs_globals->nameSpace);
+
       	if (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO))
           {
             // now look into the regular schema
@@ -340,45 +342,47 @@ Lng32 AddTableName( const hs_table_type type
 	  }
 	
 
-  hs_globals->objDef = HSTableDef::create(STMTHEAP,
+       hs_globals->objDef = HSTableDef::create(STMTHEAP,
                                           intName,
                                           hs_globals->tableType,
                                           hs_globals->nameSpace);
 
-  // try public schema if an object is not qualified and not found
-  if ((NOT schema) && 
-      (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO)))
-	  {
-      NAString pubSch = ActiveSchemaDB()->getDefaults().getValue(PUBLIC_SCHEMA_NAME);
-      ComSchemaName pubSchema(pubSch);
-      if (NOT pubSchema.getSchemaNamePart().isEmpty())
-      {
-        NAString pubSchName = pubSchema.getSchemaNamePart().getInternalName();
-        NAString pubCatName = (pubSchema.getCatalogNamePart().isEmpty() ? 
-          catName:pubSchema.getCatalogNamePart().getInternalName());
-      	ComObjectName pubIntName(pubCatName, pubSchName, objName,
-			                           COM_UNKNOWN_NAME, ComAnsiNamePart::INTERNAL_FORMAT);
-	      if (pubIntName.isValid())
-	      {
-          HSTableDef *pubObjDef = HSTableDef::create(STMTHEAP,
-                                                     pubIntName, 
-                                                     hs_globals->tableType,
-                                                     hs_globals->nameSpace);
-          if (pubObjDef->objExists(HSTableDef::MAX_INFO))
+       // try public schema if an object is not qualified and not found
+       if ((NOT schema) && 
+           (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO)))
+       {
+          NAString pubSch = ActiveSchemaDB()->getDefaults().getValue(PUBLIC_SCHEMA_NAME);
+          ComSchemaName pubSchema(pubSch);
+          if (NOT pubSchema.getSchemaNamePart().isEmpty())
           {
-            hs_globals->objDef = pubObjDef;
+            NAString pubSchName = pubSchema.getSchemaNamePart().getInternalName();
+            NAString pubCatName = (pubSchema.getCatalogNamePart().isEmpty() ? 
+              catName:pubSchema.getCatalogNamePart().getInternalName());
+      	    ComObjectName pubIntName(pubCatName, pubSchName, objName,
+                                     COM_UNKNOWN_NAME, ComAnsiNamePart::INTERNAL_FORMAT);
+	      
+            if (pubIntName.isValid())
+	     {
+                HSTableDef *pubObjDef = HSTableDef::create(STMTHEAP,
+                                                           pubIntName, 
+                                                           hs_globals->tableType,
+                                                           hs_globals->nameSpace);
+
+                if (pubObjDef->objExists(HSTableDef::MAX_INFO))
+                {
+                  hs_globals->objDef = pubObjDef;
+                }
+	     }
           }
-	      }
-      }
-	  }
+       }
 
-	if (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO))
-	  {
-	    HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, extName);
-	    retcode = -1;
-	    HSHandleError(retcode);
-	  }
+      if (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO))
+      {
+         HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, extName);
+         retcode = -1;
+         HSHandleError(retcode);
       }
+    }
 
     //10-040123-2660 We only support tables. We do not allow views.
     // Tables can be metadata tables.
@@ -398,6 +402,7 @@ Lng32 AddTableName( const hs_table_type type
     *hs_globals->user_table = hs_globals->objDef->getObjectFullName();
     hs_globals->tableFormat = hs_globals->objDef->getObjectFormat();
     hs_globals->isHbaseTable = HSGlobalsClass::isHbaseCat(catName);
+    hs_globals->isHiveTable = HSGlobalsClass::isHiveCat(catName);
 
     if (hs_globals->tableFormat == SQLMX)
       {
@@ -428,21 +433,20 @@ Lng32 AddTableName( const hs_table_type type
             LM->Log(LM->msg);
          }
 
-        const char* period = strchr(hs_globals->catSch->data(), '.');
-        NAString catName(hs_globals->catSch->data(),
-                         period - hs_globals->catSch->data());
+        NAString catName(hs_globals->objDef->getCatName());
+
+        *hs_globals->hstogram_table = getHistogramsTableLocation(hs_globals->catSch->data(), FALSE);
+
+        *hs_globals->hsintval_table = getHistogramsTableLocation(hs_globals->catSch->data(), FALSE);
+
         NABoolean isHbaseOrHive = HSGlobalsClass::isHbaseCat(catName) ||
                                   HSGlobalsClass::isHiveCat(catName);
 
-        *hs_globals->hstogram_table = 
-            getHistogramsTableLocation(hs_globals->catSch->data(), FALSE);
         if (isHbaseOrHive)
           hs_globals->hstogram_table->append(".").append(HBASE_HIST_NAME);
         else
           hs_globals->hstogram_table->append(".HISTOGRAMS");
 
-        *hs_globals->hsintval_table = 
-            getHistogramsTableLocation(hs_globals->catSch->data(), FALSE);
         if (isHbaseOrHive)
           hs_globals->hsintval_table->append(".").append(HBASE_HISTINT_NAME);
         else

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3d212c68/core/sql/ustat/hs_util.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_util.cpp b/core/sql/ustat/hs_util.cpp
index 672b19c..f676bf5 100644
--- a/core/sql/ustat/hs_util.cpp
+++ b/core/sql/ustat/hs_util.cpp
@@ -1147,6 +1147,9 @@ NAString getHistogramsTableLocation(
     {
       NAString catName = regularLocation;
       catName.remove(catName.first('.'));
+      if ( HSGlobalsClass::isNativeHbaseCat(catName) )
+        histLoc = HBASE_STATS_CATALOG "." HBASE_STATS_SCHEMA;
+      else
       if (HSGlobalsClass::isHiveCat(catName))
         histLoc = HIVE_STATS_CATALOG "." HIVE_STATS_SCHEMA;
       else



[14/14] incubator-trafodion git commit: Merge [TRAFODION-1443] support stats for native HBase and Hive tables

Posted by db...@apache.org.
Merge [TRAFODION-1443] support stats for native HBase and Hive tables


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

Branch: refs/heads/master
Commit: e1093020f269a9f7404c286f573c4949e4645874
Parents: a982a5c 5698fe4
Author: Dave Birdsall <db...@apache.org>
Authored: Mon Sep 21 23:10:44 2015 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Mon Sep 21 23:10:44 2015 +0000

----------------------------------------------------------------------
 .../sql/scripts/install_hadoop_regr_test_env    |  15 +-
 core/sql/common/ComSmallDefs.h                  |   5 +-
 core/sql/optimizer/BindRelExpr.cpp              |   2 +-
 core/sql/optimizer/BindWA.cpp                   |   4 +-
 core/sql/optimizer/BindWA.h                     |   4 +-
 core/sql/optimizer/NATable.cpp                  | 139 +++++++------------
 core/sql/optimizer/NATable.h                    |  22 ++-
 core/sql/optimizer/ObjectNames.cpp              |  12 ++
 core/sql/optimizer/ObjectNames.h                |   3 +
 core/sql/regress/executor/EXPECTED002.SB        |  29 ++--
 core/sql/regress/executor/TEST002               |   3 +
 core/sql/regress/hive/EXPECTED001               | 133 +++++++++---------
 core/sql/regress/hive/EXPECTED003               |  24 ++--
 core/sql/regress/hive/EXPECTED004               |   4 +-
 core/sql/regress/hive/EXPECTED020               |  18 +--
 core/sql/regress/hive/EXPECTED021               |  27 ++++
 core/sql/regress/hive/FILTER021                 |  96 +++++++++++++
 core/sql/regress/hive/TEST001                   |   3 +-
 core/sql/regress/hive/TEST021                   |  48 +++++++
 core/sql/regress/seabase/EXPECTED028            |  84 +++++++++++
 core/sql/regress/seabase/FILTER028              |  96 +++++++++++++
 core/sql/regress/seabase/TEST028                |  31 +++++
 core/sql/regress/seabase/ddl.sb028              |  45 ++++++
 core/sql/regress/seabase/dml.sb028              |  33 +++++
 core/sql/regress/tools/runregr_seabase.ksh      |   5 +
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp         |   8 --
 core/sql/ustat/hs_cli.cpp                       |  12 ++
 core/sql/ustat/hs_globals.cpp                   |  35 ++++-
 core/sql/ustat/hs_globals.h                     |  16 ++-
 core/sql/ustat/hs_la.cpp                        | 124 ++++++++++++++++-
 core/sql/ustat/hs_la.h                          |  21 +--
 core/sql/ustat/hs_parser.cpp                    |  97 ++++++-------
 core/sql/ustat/hs_read.cpp                      |   3 +-
 core/sql/ustat/hs_util.cpp                      |   3 +
 core/sql/ustat/hs_yacc.y                        |   5 +-
 35 files changed, 929 insertions(+), 280 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e1093020/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e1093020/core/sql/ustat/hs_parser.cpp
----------------------------------------------------------------------


[10/14] incubator-trafodion git commit: update seabase/TEST028.

Posted by db...@apache.org.
update seabase/TEST028.


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

Branch: refs/heads/master
Commit: 3b293592ba101f0b9e87af978ded129c7a219311
Parents: 052b3bb
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Mon Sep 21 00:28:39 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Mon Sep 21 00:28:39 2015 +0000

----------------------------------------------------------------------
 core/sql/regress/seabase/EXPECTED028       | 32 ++++++-------------------
 core/sql/regress/seabase/TEST028           | 31 ++++--------------------
 core/sql/regress/tools/runregr_seabase.ksh |  4 ++--
 3 files changed, 13 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3b293592/core/sql/regress/seabase/EXPECTED028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED028 b/core/sql/regress/seabase/EXPECTED028
index c84e4f2..c57b16c 100644
--- a/core/sql/regress/seabase/EXPECTED028
+++ b/core/sql/regress/seabase/EXPECTED028
@@ -3,7 +3,7 @@
 
 --- SQL operation complete.
 >>
->>insert into hbase."_CELL_".t028tbl1 values 
+>>insert into hbase."_CELL_".t028tbl1 values
 +>('0', 'cf', '1a', -1, '2'),
 +>('1', 'cf', '1a', -1, '102'),
 +>('2', 'cf', '1a', -1, '202'),
@@ -16,6 +16,10 @@
 
 --- 9 row(s) inserted.
 >>
+>>exit;
+
+End of MXCI Session
+
 >>
 >>cqd  USTAT_INTERNAL_SORT 'off';
 
@@ -23,13 +27,12 @@
 >>update statistics for table hbase."_CELL_".t028tbl1 on every column;
 
 --- SQL operation complete.
->>
 >>showstats for table hbase."_CELL_".t028tbl1 on ROW_ID detail;
 
 Detailed Histogram data for Table HBASE."_CELL_".T028TBL1
-Table ID: 6047285781859643730
+Table ID: 378379789629904219
 
-Hist ID:    1955006841
+Hist ID:    2022909903
 Column(s):  ROW_ID
 Total Rows: 9
 Total UEC:  9
@@ -52,26 +55,6 @@ Number    Rowcount         UEC Boundary
 
 
 --- SQL operation complete.
->>showstats for table hbase."_CELL_".t028tbl1 on COL_FAMILY detail;
-
-Detailed Histogram data for Table HBASE."_CELL_".T028TBL1
-Table ID: 6047285781859643730
-
-Hist ID:    1955006834
-Column(s):  COL_FAMILY
-Total Rows: 9
-Total UEC:  1
-Low Value:  ('cf')
-High Value: ('cf')
-Intervals:  1
-
-Number    Rowcount         UEC Boundary
-====== =========== =========== ======================================
-     0           0           0 ('cf')
-     1           9           1 ('cf')
-
-
---- SQL operation complete.
 >>
 >>explain options 'f' select * from hbase."_CELL_".t028tbl1;
 
@@ -95,7 +78,6 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 >>drop hbase table t028tbl1;
 
 --- SQL operation complete.
->>
 >>exit;
 
 End of MXCI Session

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3b293592/core/sql/regress/seabase/TEST028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST028 b/core/sql/regress/seabase/TEST028
index edfd58b..d114e06 100644
--- a/core/sql/regress/seabase/TEST028
+++ b/core/sql/regress/seabase/TEST028
@@ -21,34 +21,11 @@
 --
 -- @@@ END COPYRIGHT @@@
 
+-- setup tables
+sh sqlci -i ddl.sb028;
 
-set schema hbase."_CELL_";
-drop hbase table t028tbl1;
-
-log LOG028 clear;
-
-create hbase table t028tbl1(column family 'cf');
-
-insert into hbase."_CELL_".t028tbl1 values 
-('0', 'cf', '1a', -1, '2'),
-('1', 'cf', '1a', -1, '102'),
-('2', 'cf', '1a', -1, '202'),
-('3', 'cf', '1a', -1, '302'),
-('4', 'cf', '1a', -1, '402'),
-('5', 'cf', '1a', -1, '502'),
-('6', 'cf', '1a', -1, '602'),
-('7', 'cf', '1a', -1, '702'),
-('8', 'cf', '1a', -1, '802');
-
-
-cqd  USTAT_INTERNAL_SORT 'off';
-update statistics for table hbase."_CELL_".t028tbl1 on every column;
-
-showstats for table hbase."_CELL_".t028tbl1 on ROW_ID detail;
-showstats for table hbase."_CELL_".t028tbl1 on COL_FAMILY detail;
-
-explain options 'f' select * from hbase."_CELL_".t028tbl1;
-explain options 'f' select * from hbase."_CELL_".t028tbl1 where col_family = 'cf1';
+-- do update stats 
+sh sqlci -i dml.sb028;
 
 drop hbase table t028tbl1;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3b293592/core/sql/regress/tools/runregr_seabase.ksh
----------------------------------------------------------------------
diff --git a/core/sql/regress/tools/runregr_seabase.ksh b/core/sql/regress/tools/runregr_seabase.ksh
index c3f2675..dc3d992 100755
--- a/core/sql/regress/tools/runregr_seabase.ksh
+++ b/core/sql/regress/tools/runregr_seabase.ksh
@@ -210,8 +210,8 @@ else
 fi
 
 echo "copying scripts to $REGRRUNDIR"
-cp $REGRTSTDIR/create_hbase_tables.sh $REGRRUNDIR 2>$NULL
-cp $REGRTSTDIR/drop_hbase_tables.sh $REGRRUNDIR 2>$NULL
+cp $REGRTSTDIR/ddl.sb028 $REGRRUNDIR 2>$NULL
+cp $REGRTSTDIR/dml.sb028 $REGRRUNDIR 2>$NULL
 cp $REGRTSTDIR/FILTER028 $REGRRUNDIR 2>$NULL
 
 skippedfiles=


[11/14] incubator-trafodion git commit: add ddl.sb028 and dml.sb028

Posted by db...@apache.org.
add ddl.sb028 and dml.sb028


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

Branch: refs/heads/master
Commit: 3b1cf85169569f0aa1f9962d3386deab5efc805d
Parents: 3b29359
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Mon Sep 21 00:30:10 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Mon Sep 21 00:30:10 2015 +0000

----------------------------------------------------------------------
 core/sql/regress/seabase/ddl.sb028 | 23 +++++++++++++++++++++++
 core/sql/regress/seabase/dml.sb028 | 11 +++++++++++
 2 files changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3b1cf851/core/sql/regress/seabase/ddl.sb028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/ddl.sb028 b/core/sql/regress/seabase/ddl.sb028
new file mode 100644
index 0000000..a58ab55
--- /dev/null
+++ b/core/sql/regress/seabase/ddl.sb028
@@ -0,0 +1,23 @@
+
+set schema hbase."_CELL_";
+drop hbase table t028tbl1;
+
+drop table trafodion."_HB__CELL__".T028TBL1;
+drop table TRAFODION."_HBASESTATS_".SB_HISTOGRAMS;
+drop table TRAFODION."_HBASESTATS_".SB_HISTOGRAM_INTERVALS;
+
+log LOG028 clear;
+
+create hbase table t028tbl1(column family 'cf');
+
+insert into hbase."_CELL_".t028tbl1 values
+('0', 'cf', '1a', -1, '2'),
+('1', 'cf', '1a', -1, '102'),
+('2', 'cf', '1a', -1, '202'),
+('3', 'cf', '1a', -1, '302'),
+('4', 'cf', '1a', -1, '402'),
+('5', 'cf', '1a', -1, '502'),
+('6', 'cf', '1a', -1, '602'),
+('7', 'cf', '1a', -1, '702'),
+('8', 'cf', '1a', -1, '802');
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3b1cf851/core/sql/regress/seabase/dml.sb028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/dml.sb028 b/core/sql/regress/seabase/dml.sb028
new file mode 100644
index 0000000..08d3b26
--- /dev/null
+++ b/core/sql/regress/seabase/dml.sb028
@@ -0,0 +1,11 @@
+
+log LOG028;
+
+cqd  USTAT_INTERNAL_SORT 'off';
+update statistics for table hbase."_CELL_".t028tbl1 on every column;
+showstats for table hbase."_CELL_".t028tbl1 on ROW_ID detail;
+
+explain options 'f' select * from hbase."_CELL_".t028tbl1;
+explain options 'f' select * from hbase."_CELL_".t028tbl1 where col_family = 'cf1';
+
+drop hbase table t028tbl1;


[07/14] incubator-trafodion git commit: JIRA1443: address seabase/TEST028 failure.

Posted by db...@apache.org.
JIRA1443: address seabase/TEST028 failure.


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

Branch: refs/heads/master
Commit: 92428d71d0111a493cf244b18976502630ce022e
Parents: e0598c5
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Sun Sep 20 13:22:07 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Sun Sep 20 13:22:07 2015 +0000

----------------------------------------------------------------------
 core/sql/ustat/hs_parser.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/92428d71/core/sql/ustat/hs_parser.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_parser.cpp b/core/sql/ustat/hs_parser.cpp
index 56988b3..fb547e5 100644
--- a/core/sql/ustat/hs_parser.cpp
+++ b/core/sql/ustat/hs_parser.cpp
@@ -165,6 +165,11 @@ Lng32 AddTableName( const hs_table_type type
     // the default attribute values set by SET MPLOC/CQD.
     ActiveSchemaDB()->getDefaults().getSqlParser_NADefaults();
 
+    NABoolean createExternalTable = TRUE;
+    if ( hs_globals->optFlags & SHOWSTATS_OPT ||
+        (hs_globals->optFlags & CLEAR_OPT) )
+      createExternalTable = FALSE;
+
     if (type == GUARDIAN_TABLE)
       {
         if (*table == '$')
@@ -301,7 +306,7 @@ Lng32 AddTableName( const hs_table_type type
                                                 hs_globals->tableType,
                                                 hs_globals->nameSpace);
 
-      	if (NOT hs_globals->objDef->objExists(TRUE))
+      	if (NOT hs_globals->objDef->objExists(createExternalTable))
           {
             // now look into the regular schema
             delete hs_globals->objDef;
@@ -349,7 +354,7 @@ Lng32 AddTableName( const hs_table_type type
 
        // try public schema if an object is not qualified and not found
        if ((NOT schema) && 
-           (NOT hs_globals->objDef->objExists(TRUE)))
+           (NOT hs_globals->objDef->objExists(createExternalTable)))
        {
           NAString pubSch = ActiveSchemaDB()->getDefaults().getValue(PUBLIC_SCHEMA_NAME);
           ComSchemaName pubSchema(pubSch);
@@ -368,7 +373,7 @@ Lng32 AddTableName( const hs_table_type type
                                                            hs_globals->tableType,
                                                            hs_globals->nameSpace);
 
-                if (pubObjDef->objExists(TRUE))
+                if (pubObjDef->objExists(createExternalTable))
                 {
                   hs_globals->objDef = pubObjDef;
                 }
@@ -376,7 +381,7 @@ Lng32 AddTableName( const hs_table_type type
           }
        }
 
-      if (NOT hs_globals->objDef->objExists(TRUE))
+      if (NOT hs_globals->objDef->objExists(createExternalTable))
       {
          HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, extName);
          retcode = -1;


[12/14] incubator-trafodion git commit: rework the fix to JIRA1443: add copyright notes and move isUpdatestatsStmt into HSGLOBALCLASS

Posted by db...@apache.org.
rework the fix to JIRA1443: add copyright notes and move isUpdatestatsStmt into HSGLOBALCLASS


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

Branch: refs/heads/master
Commit: a906cca5c43666ca67aa592f765781e329de8d86
Parents: 3b1cf85
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Mon Sep 21 17:59:50 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Mon Sep 21 17:59:50 2015 +0000

----------------------------------------------------------------------
 core/sql/regress/seabase/ddl.sb028 | 22 ++++++++++++++++++++++
 core/sql/regress/seabase/dml.sb028 | 22 ++++++++++++++++++++++
 core/sql/ustat/hs_globals.cpp      |  3 ++-
 core/sql/ustat/hs_globals.h        |  1 +
 core/sql/ustat/hs_parser.cpp       | 11 ++++-------
 core/sql/ustat/hs_yacc.y           |  6 ++----
 6 files changed, 53 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a906cca5/core/sql/regress/seabase/ddl.sb028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/ddl.sb028 b/core/sql/regress/seabase/ddl.sb028
index a58ab55..9d0f806 100644
--- a/core/sql/regress/seabase/ddl.sb028
+++ b/core/sql/regress/seabase/ddl.sb028
@@ -1,3 +1,25 @@
+-- tests for updating statistics for external native hbase tables.
+--
+-- @@@ START COPYRIGHT @@@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+-- @@@ END COPYRIGHT @@@
 
 set schema hbase."_CELL_";
 drop hbase table t028tbl1;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a906cca5/core/sql/regress/seabase/dml.sb028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/dml.sb028 b/core/sql/regress/seabase/dml.sb028
index 08d3b26..e700882 100644
--- a/core/sql/regress/seabase/dml.sb028
+++ b/core/sql/regress/seabase/dml.sb028
@@ -1,3 +1,25 @@
+-- tests for updating statistics for external native hbase tables.
+--
+-- @@@ START COPYRIGHT @@@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+-- @@@ END COPYRIGHT @@@
 
 log LOG028;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a906cca5/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index d5dba38..c64d26d 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -2785,7 +2785,8 @@ HSGlobalsClass::HSGlobalsClass(ComDiagsArea &diags)
     sample_I_generated(FALSE),
     jitLogThreshold(0),
     stmtStartTime(0),
-    jitLogOn(FALSE)
+    jitLogOn(FALSE),
+    isUpdatestatsStmt(FALSE)
   {
     // Must add the context first in the constructor.
     contID_ = AddHSContext(this);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a906cca5/core/sql/ustat/hs_globals.h
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.h b/core/sql/ustat/hs_globals.h
index e55f27a..e6a6592 100644
--- a/core/sql/ustat/hs_globals.h
+++ b/core/sql/ustat/hs_globals.h
@@ -1604,6 +1604,7 @@ public:
     NABoolean      sampleTableUsed;                /* sample table created    */
     NABoolean      samplingUsed;                   /* sample (w/wo sample tbl)*/
     NABoolean      unpartitionedSample;            /* sample tbl not partitned*/
+    NABoolean      isUpdatestatsStmt;              /* is update stats command */
     Lng32           groupCount;                     /* total #column groups    */
     Lng32           singleGroupCount;               /* #single-column groups   */
     HSColGroupStruct *singleGroup;                 /* single-column group list*/

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a906cca5/core/sql/ustat/hs_parser.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_parser.cpp b/core/sql/ustat/hs_parser.cpp
index 5738438..162a211 100644
--- a/core/sql/ustat/hs_parser.cpp
+++ b/core/sql/ustat/hs_parser.cpp
@@ -58,9 +58,6 @@ extern void destroy_scanner(void* &scanner);
 Lng32 AddSingleColumn(const Lng32 colNumber);
 
     
-NABoolean isUpdatestatsStmt = FALSE;
-
-
 // -----------------------------------------------------------------------
 // Invoke yyparse, set hsGlobal structure for each column group.
 // -----------------------------------------------------------------------
@@ -303,7 +300,7 @@ Lng32 AddTableName( const hs_table_type type
                                                 hs_globals->tableType,
                                                 hs_globals->nameSpace);
 
-      	if (NOT hs_globals->objDef->objExists(isUpdatestatsStmt))
+      	if (NOT hs_globals->objDef->objExists(hs_globals->isUpdatestatsStmt))
           {
             // now look into the regular schema
             delete hs_globals->objDef;
@@ -351,7 +348,7 @@ Lng32 AddTableName( const hs_table_type type
 
        // try public schema if an object is not qualified and not found
        if ((NOT schema) && 
-           (NOT hs_globals->objDef->objExists(isUpdatestatsStmt)))
+           (NOT hs_globals->objDef->objExists(hs_globals->isUpdatestatsStmt)))
        {
           NAString pubSch = ActiveSchemaDB()->getDefaults().getValue(PUBLIC_SCHEMA_NAME);
           ComSchemaName pubSchema(pubSch);
@@ -370,7 +367,7 @@ Lng32 AddTableName( const hs_table_type type
                                                            hs_globals->tableType,
                                                            hs_globals->nameSpace);
 
-                if (pubObjDef->objExists(isUpdatestatsStmt))
+                if (pubObjDef->objExists(hs_globals->isUpdatestatsStmt))
                 {
                   hs_globals->objDef = pubObjDef;
                 }
@@ -378,7 +375,7 @@ Lng32 AddTableName( const hs_table_type type
           }
        }
 
-      if (NOT hs_globals->objDef->objExists(isUpdatestatsStmt))
+      if (NOT hs_globals->objDef->objExists(hs_globals->isUpdatestatsStmt))
       {
          HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, extName);
          retcode = -1;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/a906cca5/core/sql/ustat/hs_yacc.y
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_yacc.y b/core/sql/ustat/hs_yacc.y
index 7acf82f..2a602c7 100644
--- a/core/sql/ustat/hs_yacc.y
+++ b/core/sql/ustat/hs_yacc.y
@@ -60,8 +60,6 @@ extern THREAD_P HSGlobalsClass *hs_globals_y;
 extern int yylex(YYSTYPE * lvalp, void* scanner);
 //extern int yylex();
 
-extern NABoolean isUpdatestatsStmt;
-
 #define scanner scanner
 
 %}
@@ -104,9 +102,9 @@ extern NABoolean isUpdatestatsStmt;
          same syntax it will fail to parse there and never get here.
 */
 
-statement   :  UPDATE STATISTICS { isUpdatestatsStmt = TRUE; } FOR table_kind table_identifier histogram_options
+statement   :  UPDATE STATISTICS { hs_globals_y->isUpdatestatsStmt = TRUE; } FOR table_kind table_identifier histogram_options
                    {
-                       isUpdatestatsStmt = FALSE;
+                      hs_globals_y->isUpdatestatsStmt = FALSE;
                    }
               | UPDATE STATISTICS LOG ON
                    {


[02/14] incubator-trafodion git commit: add a new regression test for upstats for native hbase tables

Posted by db...@apache.org.
add a new regression test for upstats for native hbase tables


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

Branch: refs/heads/master
Commit: 890c306d2aa99635581d4abe5215ccd08fade280
Parents: 3d212c6
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Thu Sep 17 14:49:24 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Thu Sep 17 14:49:24 2015 +0000

----------------------------------------------------------------------
 core/sql/regress/seabase/EXPECTED028            | 111 +++++++++++++++++++
 core/sql/regress/seabase/FILTER028              |  96 ++++++++++++++++
 core/sql/regress/seabase/TEST028                |  44 ++++++++
 core/sql/regress/seabase/create_hbase_tables.sh |  29 +++++
 core/sql/regress/seabase/drop_hbase_tables.sh   |   7 ++
 core/sql/regress/tools/runregr_seabase.ksh      |   5 +
 core/sql/ustat/hs_la.cpp                        |   9 +-
 core/sql/ustat/hs_parser.cpp                    |  10 +-
 core/sql/ustat/hs_read.cpp                      |   3 +-
 9 files changed, 306 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/890c306d/core/sql/regress/seabase/EXPECTED028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED028 b/core/sql/regress/seabase/EXPECTED028
new file mode 100644
index 0000000..f49c05a
--- /dev/null
+++ b/core/sql/regress/seabase/EXPECTED028
@@ -0,0 +1,111 @@
+>>
+>>log off;
+>>
+>>update statistics for table hbase."_CELL_"."test028tbl2" on every column;
+
+--- SQL operation complete.
+>>update statistics for table hbase."_CELL_"."test028tbl2" on every key;
+
+*** WARNING[9202] UPDATE STATISTICS has located previously generated histograms that are not being regenerated. This may affect the plans that will be generated. Missing columns lists are (COL_VALUE),(COL_TIMESTAMP),(COL_NAME),(COL_FAMILY).
+
+--- SQL operation completed with warnings.
+>>
+>>showstats for table hbase."_CELL_"."test028tbl2" on ROW_ID detail;
+
+Detailed Histogram data for Table HBASE."_CELL_"."test028tbl2"
+Table ID: 961595648449090953
+
+Hist ID:    1150301280
+Column(s):  ROW_ID
+Total Rows: 10
+Total UEC:  10
+Low Value:  ('100')
+High Value: ('9990')
+Intervals:  10
+
+Number    Rowcount         UEC Boundary
+====== =========== =========== ======================================
+     0           0           0 ('100')
+     1           1           1 ('100')
+     2           1           1 ('200')
+     3           1           1 ('300')
+     4           1           1 ('400')
+     5           1           1 ('500')
+     6           1           1 ('600')
+     7           1           1 ('700')
+     8           1           1 ('720')
+     9           1           1 ('999')
+    10           1           1 ('9990')
+
+
+--- SQL operation complete.
+>>showstats for table hbase."_CELL_"."test028tbl2" on COL_FAMILY detail;
+
+Detailed Histogram data for Table HBASE."_CELL_"."test028tbl2"
+Table ID: 961595648449090953
+
+Hist ID:    1150301276
+Column(s):  COL_FAMILY
+Total Rows: 10
+Total UEC:  1
+Low Value:  ('cf1')
+High Value: ('cf1')
+Intervals:  1
+
+Number    Rowcount         UEC Boundary
+====== =========== =========== ======================================
+     0           0           0 ('cf1')
+     1          10           1 ('cf1')
+
+
+--- SQL operation complete.
+>>showstats for table hbase."_CELL_"."test028tbl2" on COL_VALUE detail;
+
+Detailed Histogram data for Table HBASE."_CELL_"."test028tbl2"
+Table ID: 961595648449090953
+
+Hist ID:    1150301261
+Column(s):  COL_VALUE
+Total Rows: 10
+Total UEC:  10
+Low Value:  ('v100')
+High Value: ('v9990')
+Intervals:  10
+
+Number    Rowcount         UEC Boundary
+====== =========== =========== ======================================
+     0           0           0 ('v100')
+     1           1           1 ('v100')
+     2           1           1 ('v200')
+     3           1           1 ('v300')
+     4           1           1 ('v400')
+     5           1           1 ('v500')
+     6           1           1 ('v600')
+     7           1           1 ('v700')
+     8           1           1 ('v720')
+     9           1           1 ('v999')
+    10           1           1 ('v9990')
+
+
+--- SQL operation complete.
+>>
+>>explain options 'f' select * from hbase."_CELL_"."test028tbl2";
+
+LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
+---- ---- ---- --------------------  --------  --------------------  ---------
+
+1    .    2    root                                                  1.00E+001
+.    .    1    hbase_scan                      test028tbl2           1.00E+001
+
+--- SQL operation complete.
+>>explain options 'f' select * from hbase."_CELL_"."test028tbl2" where ROW_ID = '700';
+
+LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
+---- ---- ---- --------------------  --------  --------------------  ---------
+
+1    .    2    root                  o                               1.00E+000
+.    .    1    hbase_scan                      test028tbl2           1.00E+000
+
+--- SQL operation complete.
+>>
+>>log off;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/890c306d/core/sql/regress/seabase/FILTER028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/FILTER028 b/core/sql/regress/seabase/FILTER028
new file mode 100755
index 0000000..590eeb9
--- /dev/null
+++ b/core/sql/regress/seabase/FILTER028
@@ -0,0 +1,96 @@
+#! /bin/sh
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+
+# Like the pattern-masking of QACOMP, here we filter out such stuff as
+# timestamps and generated identifiers.  Called by the runregr script
+# before doing diff.
+
+fil=$1
+if [ "$fil" = "" ]; then
+  echo "Usage: $0 filename"
+  exit 1
+fi
+
+# Remove following types of lines:
+#   Lines started with "Start Time", "End Time", "Elapsed Time",
+#                      "Execution Time", "Table ID: ddddddddd", and
+#                      "Hist ID: ddddddddd"
+ON_A_VM=
+SYSVENDOR="$(cat /sys/class/dmi/id/sys_vendor)"
+if [[ ( "${SYSVENDOR/OpenStack/}" != "$SYSVENDOR" ) ||
+      ( "${SYSVENDOR/VMware/}"    != "$SYSVENDOR" ) ]]; then
+  # Running on an OpenStack or VMware virtual machine
+  ON_A_VM=yes
+fi
+if [[ "$SQ_BUILD_TYPE" = "release" ]]; then
+sed "
+/Start Time.*/d
+" $fil |
+sed "/End Time.*/d" |
+sed "/Elapsed Time.*/d" |
+sed "/Execution Time.*/d" |
+sed "/Table ID.*/d" |
+sed "/Hist ID.*/d" |
+awk '
+{
+# we are looking for a less than 1 ms compile time
+#   but we accept time up to 1.4 ms because of other loads
+#   and time up to 2.0 ms on a virtual machine
+#   when the test is being run
+# Acceptable compile time is no more than 00:00:01.001399
+#   or on a virtual machine, no more than 00:00:01.001999
+# Examples of patterns to classify:
+#  1.  "Compile Time 00:00:01.001047" --> FAILED (at least one second)
+#  2.  "Compile Time 00:00:00.001470" --> FAILED (more than 1ms)
+#  3.  "Compile Time 00:00:00.000870" --> SUCCESS(less than 1ms)
+#  4.  "Compile Time 00:00:00.001200" --> SUCCESS(less than 1ms)
+#  5.  "Compile Time 00:00:00.001821" --> SUCCESS(less than 1ms)  only on a VM
+   if ( $1 == "Compile"  && $2 == "Time" ) { \
+     split($3, a, "."); \
+     if ( !match(a[1], "00:00:00") ) \
+       print "FAIL (at least one second)", $0; \
+     else { \
+              split(a[2], b, ""); \
+              if ((b[1] == 0) && (b[2]==0) &&  \
+                  ((b[3] == 0) || ((b[3] == 1) && ((b[4] < 4) || (ENVIRON["ON_A_VM"] = "yes"))) )) \
+                  print "SUCCESS (less than 1ms)"; \
+              else \
+                  print "FAIL (at least 1ms)", $0; \
+     }; \
+   } else \
+     print; \
+}
+'
+fi
+
+if [[ "$SQ_BUILD_TYPE" = "debug" ]]; then
+sed "
+/Start Time.*/d
+" $fil |
+sed "/End Time.*/d" |
+sed "/Elapsed Time.*/d" |
+sed "/Execution Time.*/d" |
+sed "/Table ID.*/d" |
+sed "/Hist ID.*/d" |
+sed "/Compile Time.*/d"
+fi
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/890c306d/core/sql/regress/seabase/TEST028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST028 b/core/sql/regress/seabase/TEST028
new file mode 100644
index 0000000..64cbd38
--- /dev/null
+++ b/core/sql/regress/seabase/TEST028
@@ -0,0 +1,44 @@
+-- tests for updating statistics for external native hbase tables.
+--
+-- @@@ START COPYRIGHT @@@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+-- @@@ END COPYRIGHT @@@
+
+log LOG028 clear;
+
+log off;
+sh sh drop_hbase_tables.sh;
+sh sh create_hbase_tables.sh;
+
+log LOG028;
+
+update statistics for table hbase."_CELL_"."test028tbl2" on every column;
+update statistics for table hbase."_CELL_"."test028tbl2" on every key;
+
+showstats for table hbase."_CELL_"."test028tbl2" on ROW_ID detail;
+showstats for table hbase."_CELL_"."test028tbl2" on COL_FAMILY detail;
+showstats for table hbase."_CELL_"."test028tbl2" on COL_VALUE detail;
+
+explain options 'f' select * from hbase."_CELL_"."test028tbl2";
+explain options 'f' select * from hbase."_CELL_"."test028tbl2" where ROW_ID = '700';
+
+log off;
+sh sh drop_hbase_tables.sh;
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/890c306d/core/sql/regress/seabase/create_hbase_tables.sh
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/create_hbase_tables.sh b/core/sql/regress/seabase/create_hbase_tables.sh
new file mode 100644
index 0000000..cc44104
--- /dev/null
+++ b/core/sql/regress/seabase/create_hbase_tables.sh
@@ -0,0 +1,29 @@
+
+swhbase << EOF
+
+create 'test028tbl2', {NAME => 'cf1', VERSIONS => 1 }, {SPLITS => ['333','666','999']}
+
+tbl2=get_table 'test028tbl2'
+
+# region 0
+tbl2.put '100', 'cf1:#1', 'v100'
+tbl2.put '200', 'cf1:#1', 'v200'
+tbl2.put '300', 'cf1:#1', 'v300'
+
+# region 1
+tbl2.put '400', 'cf1:#1', 'v400'
+tbl2.put '500', 'cf1:#1', 'v500'
+tbl2.put '600', 'cf1:#1', 'v600'
+
+# region 2
+tbl2.put '700', 'cf1:#1', 'v700'
+tbl2.put '720', 'cf1:#1', 'v720'
+
+# region 3
+tbl2.put '999', 'cf1:#1', 'v999'
+tbl2.put '9990', 'cf1:#1', 'v9990'
+
+tbl2.scan
+
+
+EOF

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/890c306d/core/sql/regress/seabase/drop_hbase_tables.sh
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/drop_hbase_tables.sh b/core/sql/regress/seabase/drop_hbase_tables.sh
new file mode 100644
index 0000000..f9853e7
--- /dev/null
+++ b/core/sql/regress/seabase/drop_hbase_tables.sh
@@ -0,0 +1,7 @@
+
+swhbase << EOF
+
+disable 'test028tbl2'
+drop 'test028tbl2'
+
+EOF

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/890c306d/core/sql/regress/tools/runregr_seabase.ksh
----------------------------------------------------------------------
diff --git a/core/sql/regress/tools/runregr_seabase.ksh b/core/sql/regress/tools/runregr_seabase.ksh
index 184412f..c3f2675 100755
--- a/core/sql/regress/tools/runregr_seabase.ksh
+++ b/core/sql/regress/tools/runregr_seabase.ksh
@@ -209,6 +209,11 @@ else
   done
 fi
 
+echo "copying scripts to $REGRRUNDIR"
+cp $REGRTSTDIR/create_hbase_tables.sh $REGRRUNDIR 2>$NULL
+cp $REGRTSTDIR/drop_hbase_tables.sh $REGRRUNDIR 2>$NULL
+cp $REGRTSTDIR/FILTER028 $REGRRUNDIR 2>$NULL
+
 skippedfiles=
 
 ##############################################################

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/890c306d/core/sql/ustat/hs_la.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_la.cpp b/core/sql/ustat/hs_la.cpp
index 77a5ed1..a4c9e7a 100644
--- a/core/sql/ustat/hs_la.cpp
+++ b/core/sql/ustat/hs_la.cpp
@@ -1002,7 +1002,14 @@ Lng32 HSHiveTableDef::DescribeColumnNames()
 //
 NAString HSHbaseTableDef::getHistLoc(formatType format) const
 {
-  return HBASE_STATS_CATALOG "." HBASE_STATS_SCHEMA;
+  if ( HSGlobalsClass::isNativeHbaseCat(getCatName(format))) {
+    return HBASE_STATS_CATALOG "." HBASE_STATS_SCHEMA;
+  } else {  
+    NAString name(getCatName(format));
+    name.append(".");
+    name.append(getSchemaName(format));
+    return name;
+  }
 }
 
 static 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/890c306d/core/sql/ustat/hs_parser.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_parser.cpp b/core/sql/ustat/hs_parser.cpp
index 82158dc..00dfe8f 100644
--- a/core/sql/ustat/hs_parser.cpp
+++ b/core/sql/ustat/hs_parser.cpp
@@ -442,15 +442,13 @@ Lng32 AddTableName( const hs_table_type type
         NABoolean isHbaseOrHive = HSGlobalsClass::isHbaseCat(catName) ||
                                   HSGlobalsClass::isHiveCat(catName);
 
-        if (isHbaseOrHive)
+        if (isHbaseOrHive) {
           hs_globals->hstogram_table->append(".").append(HBASE_HIST_NAME);
-        else
-          hs_globals->hstogram_table->append(".HISTOGRAMS");
-
-        if (isHbaseOrHive)
           hs_globals->hsintval_table->append(".").append(HBASE_HISTINT_NAME);
-        else
+        } else {
+          hs_globals->hstogram_table->append(".HISTOGRAMS");
           hs_globals->hsintval_table->append(".HISTOGRAM_INTERVALS");
+        }
       }
     else
       {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/890c306d/core/sql/ustat/hs_read.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_read.cpp b/core/sql/ustat/hs_read.cpp
index 4970d64..9f72d8c 100644
--- a/core/sql/ustat/hs_read.cpp
+++ b/core/sql/ustat/hs_read.cpp
@@ -921,7 +921,8 @@ Lng32 FetchHistograms( const QualifiedName & qualifiedName
                 getHistogramsTableLocation
                 (tabDef->getHistLoc(HSTableDef::EXTERNAL_FORMAT),
                  tabDef->isInMemoryObjectDefn());
-              if (HSGlobalsClass::isHbaseCat(objectName->getCatalogNamePart().getInternalName()))
+              if (HSGlobalsClass::isHbaseCat(objectName->getCatalogNamePart().getInternalName()) ||
+                  HSGlobalsClass::isHiveCat(objectName->getCatalogNamePart().getInternalName()))
                 {
                   histogramTableName = histLoc + "." + HBASE_HIST_NAME;
                   histintsTableName  = histLoc + "." + HBASE_HISTINT_NAME;


[13/14] incubator-trafodion git commit: more rework

Posted by db...@apache.org.
more rework


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

Branch: refs/heads/master
Commit: 5698fe4d91e780446de88767b5991aa89792e163
Parents: a906cca
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Mon Sep 21 19:41:16 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Mon Sep 21 19:41:16 2015 +0000

----------------------------------------------------------------------
 core/sql/optimizer/BindRelExpr.cpp |   3 +-
 core/sql/optimizer/ObjectNames.cpp |   4 +-
 core/sql/regress/hive/EXPECTED021  | 113 ++------------------------------
 core/sql/ustat/hs_globals.cpp      |  12 ++--
 core/sql/ustat/hs_la.cpp           |   9 +--
 5 files changed, 17 insertions(+), 124 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5698fe4d/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp
index 74fa8f3..0e0ef71 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -1573,8 +1573,7 @@ NATable *BindWA::getNATable(CorrName& corrName,
   // native HIVE or HBASE objects unless the allowExternalTables flag is set.  
   // allowExternalTables is set for drop table and SHOWDDL statements.  
   // TDB - may want to merge the Trafodion version with the native version.
-  if ((table) && (table->isExternalTable() && (! bindWA->allowExternalTables()) &&
-                  !table->isHistogramTable()))
+  if ((table) && table->isExternalTable() && (! bindWA->allowExternalTables()))
     {
       *CmpCommon::diags() << DgSqlCode(-4258)
                           << DgTableName(table->getTableName().getQualifiedNameAsAnsiString());

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5698fe4d/core/sql/optimizer/ObjectNames.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ObjectNames.cpp b/core/sql/optimizer/ObjectNames.cpp
index 75a9462..7a8c314 100644
--- a/core/sql/optimizer/ObjectNames.cpp
+++ b/core/sql/optimizer/ObjectNames.cpp
@@ -1388,12 +1388,12 @@ void QualifiedName::print(FILE* ofd, const char* indent, const char* title) cons
 
 NABoolean QualifiedName::isHistograms() const
 {
-   return (getObjectName() == "SB_HISTOGRAMS");
+   return (getObjectName() == HBASE_HIST_NAME);
 }
 
 NABoolean QualifiedName::isHistogramIntervals() const
 {
-   return (getObjectName() == "SB_HISTOGRAM_INTERVALS");
+   return (getObjectName() == HBASE_HISTINT_NAME);
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5698fe4d/core/sql/regress/hive/EXPECTED021
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED021 b/core/sql/regress/hive/EXPECTED021
index 41b95e2..7dd7b03 100644
--- a/core/sql/regress/hive/EXPECTED021
+++ b/core/sql/regress/hive/EXPECTED021
@@ -12,118 +12,13 @@
 >>--------------------------------------------------------------------------
 >>-- test update stats on native hive tables
 >>
->>update statistics for table customer on every column sample random 2 percent;
+>>update statistics for table hive.hive.customer on every column sample random 1 percent;
 
 --- SQL operation complete.
 >>
->>showstats for table customer on "C_BIRTH_YEAR" detail;
-
-Detailed Histogram data for Table HIVE.HIVE.CUSTOMER
-Table ID: 8826569449427418914
-
-Hist ID:    1850933272
-Column(s):  C_BIRTH_YEAR
-Total Rows: 100000
-Total UEC:  70
-Low Value:  (1924)
-High Value: (1992)
-Intervals:  70
-
-Number    Rowcount         UEC Boundary
-====== =========== =========== ======================================
-     0           0           0 (1924)
-     1        1300           1 (1924)
-     2        1750           1 (1925)
-     3        1600           1 (1926)
-     4        1400           1 (1927)
-     5        1250           1 (1928)
-     6        1150           1 (1929)
-     7        1400           1 (1930)
-     8         800           1 (1931)
-     9        1700           1 (1932)
-    10        1300           1 (1933)
-    11        1500           1 (1934)
-    12        1550           1 (1935)
-    13        1400           1 (1936)
-    14        1700           1 (1937)
-    15        1300           1 (1938)
-    16        1800           1 (1939)
-    17        1450           1 (1940)
-    18        1450           1 (1941)
-    19        1700           1 (1942)
-    20        1750           1 (1943)
-    21        1450           1 (1944)
-    22        1150           1 (1945)
-    23        1000           1 (1946)
-    24        1250           1 (1947)
-    25        1600           1 (1948)
-    26        1550           1 (1949)
-    27        1650           1 (1950)
-    28        1550           1 (1951)
-    29        1050           1 (1952)
-    30        1500           1 (1953)
-    31        1200           1 (1954)
-    32        1700           1 (1955)
-    33        1450           1 (1956)
-    34        1600           1 (1957)
-    35        1550           1 (1958)
-    36        1100           1 (1959)
-    37        1500           1 (1960)
-    38        1750           1 (1961)
-    39         950           1 (1962)
-    40        1700           1 (1963)
-    41        1500           1 (1964)
-    42        1100           1 (1965)
-    43        1350           1 (1966)
-    44        1350           1 (1967)
-    45        1400           1 (1968)
-    46        1300           1 (1969)
-    47        1700           1 (1970)
-    48        2000           1 (1971)
-    49        1300           1 (1972)
-    50        1650           1 (1973)
-    51         850           1 (1974)
-    52        1050           1 (1975)
-    53        1300           1 (1976)
-    54        1000           1 (1977)
-    55        1350           1 (1978)
-    56        1700           1 (1979)
-    57        1100           1 (1980)
-    58        1650           1 (1981)
-    59        1700           1 (1982)
-    60        1150           1 (1983)
-    61        1100           1 (1984)
-    62        1850           1 (1985)
-    63         950           1 (1986)
-    64        1350           1 (1987)
-    65        1850           1 (1988)
-    66         950           1 (1989)
-    67        1400           1 (1990)
-    68        1250           1 (1991)
-    69        1100           1 (1992)
-    70        3200           1 (NULL)
-
-
---- SQL operation complete.
->>
->>explain options 'f' select * from customer ;
-
-LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
----- ---- ---- --------------------  --------  --------------------  ---------
-
-1    .    2    root                                                  1.00E+005
-.    .    1    hive_scan                       CUSTOMER              1.00E+005
-
---- SQL operation complete.
->>explain options 'f' select * from customer where "C_BIRTH_YEAR" = 1973;
-
-LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
----- ---- ---- --------------------  --------  --------------------  ---------
-
-1    .    2    root                                                  1.65E+003
-.    .    1    hive_scan                       CUSTOMER              1.65E+003
-
---- SQL operation complete.
+>>--showstats for table customer on "C_BIRTH_YEAR" detail;
+>>--explain options 'f' select * from customer ;
+>>--explain options 'f' select * from customer where "C_BIRTH_YEAR" = 1973;
 >>
 >>update statistics for table customer clear;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5698fe4d/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index c64d26d..0d2822e 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -2884,12 +2884,14 @@ Lng32 HSGlobalsClass::Initialize()
         HSTranMan *TM = HSTranMan::Instance(); // Must have transaction around this.
         TM->Begin("Create schema for hive stats.");
         NAString ddl = "CREATE SCHEMA IF NOT EXISTS ";
-        ddl.append(HIVE_STATS_CATALOG).append('.').append(HIVE_STATS_SCHEMA);
+        ddl.append(HIVE_STATS_CATALOG).append('.').append(HIVE_STATS_SCHEMA).
+            append(" AUTHORIZATION DB__ROOT");
         retcode = HSFuncExecQuery(ddl, -UERR_INTERNAL_ERROR, NULL,
                                   "Creating schema for Hive statistics", NULL,
                                   NULL);
         HSHandleError(retcode);
-        TM->Commit(); // Must commit this transaction (even if schema didn't get created).
+        TM->Commit(); // In case if there is an error, the commit will log the error (if
+                      // ULOG is enabled. Otherwise, the method will commit the tranaction.
       }
                                               /*=====================================*/
                                               /*   CREATE HBASE STATS SCHEMA         */
@@ -2900,12 +2902,14 @@ Lng32 HSGlobalsClass::Initialize()
         HSTranMan *TM = HSTranMan::Instance(); // Must have transaction around this.
         TM->Begin("Create schema for native hbase stats.");
         NAString ddl = "CREATE SCHEMA IF NOT EXISTS ";
-        ddl.append(HBASE_STATS_CATALOG).append('.').append(HBASE_STATS_SCHEMA);
+        ddl.append(HBASE_STATS_CATALOG).append('.').append(HBASE_STATS_SCHEMA).
+            append(" AUTHORIZATION DB__ROOT");
         retcode = HSFuncExecQuery(ddl, -UERR_INTERNAL_ERROR, NULL,
                                   "Creating schema for native HBase statistics", NULL,
                                   NULL);
         HSHandleError(retcode);
-        TM->Commit(); // Must commit this transaction (even if schema didn't get created).
+        TM->Commit(); // In case if there is an error, the commit will log the error (if
+                      // ULOG is enabled. Otherwise, the method will commit the tranaction.
       }
                                               /*==============================*/
                                               /*    CREATE HISTOGRM TABLES    */

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/5698fe4d/core/sql/ustat/hs_la.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_la.cpp b/core/sql/ustat/hs_la.cpp
index ac18500..68b32e9 100644
--- a/core/sql/ustat/hs_la.cpp
+++ b/core/sql/ustat/hs_la.cpp
@@ -1033,13 +1033,8 @@ Lng32 CreateExternalTable(const NAString& catName, const NAString& schName, cons
    ddl.append(schName);
    ddl.append(".");
    ddl.append(nativeTableName);
-   ddl.append(" ATTRIBUTE ");
-
-   HSTranMan *TM = HSTranMan::Instance();
-   if (TM->InTransaction())
-      ddl.append(" AUDIT");
-   else
-      ddl.append("NO AUDIT");
+   ddl.append(" ATTRIBUTE NO AUDIT"); // The external table will not be audited because it 
+                                      // does not store any data.
 
    Lng32 retcode = HSFuncExecDDL(ddl.data(), - UERR_INTERNAL_ERROR, NULL,
                             "Create external table", NULL);


[04/14] incubator-trafodion git commit: Avoid creating an external table when the access is not originated from update stats.

Posted by db...@apache.org.
Avoid creating an external table when the access is not originated from update stats.


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

Branch: refs/heads/master
Commit: d3e4151308c0c0460b835d0162e6a6e009d6cd82
Parents: 8886fa8
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Fri Sep 18 19:05:54 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Fri Sep 18 19:05:54 2015 +0000

----------------------------------------------------------------------
 core/sql/regress/executor/TEST002 |   3 +
 core/sql/regress/hive/EXPECTED001 | 141 ++++++++++++++++-----------------
 core/sql/regress/hive/TEST001     |   3 +-
 core/sql/regress/hive/TEST021     |   9 +--
 core/sql/ustat/hs_la.cpp          |  20 +++--
 core/sql/ustat/hs_la.h            |  10 +--
 core/sql/ustat/hs_parser.cpp      |   8 +-
 7 files changed, 97 insertions(+), 97 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d3e41513/core/sql/regress/executor/TEST002
----------------------------------------------------------------------
diff --git a/core/sql/regress/executor/TEST002 b/core/sql/regress/executor/TEST002
index 9d1c648..28fd2b0 100755
--- a/core/sql/regress/executor/TEST002
+++ b/core/sql/regress/executor/TEST002
@@ -661,7 +661,9 @@ left outer join (
   ) T) T) T) T) T) T
 on (t002t6.c = T.a)
 ;
+
 control query shape merge_join(cut,cut);
+cqd PCODE_OPT_LEVEL '0';
 select t002t6.c, character_length(T.b), T.a+10
 from t002t6
 left outer join (
@@ -674,6 +676,7 @@ left outer join (
   ) T) T) T) T) T) T
 on (t002t6.c = T.a)
 ;
+cqd PCODE_OPT_LEVEL reset;
 control query shape cut;
 
 -- Test Outer Join with many (all) rows are null instanitated.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d3e41513/core/sql/regress/hive/EXPECTED001
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED001 b/core/sql/regress/hive/EXPECTED001
index a85938a..7a6e9bd 100644
--- a/core/sql/regress/hive/EXPECTED001
+++ b/core/sql/regress/hive/EXPECTED001
@@ -85,8 +85,6 @@
 >>
 >>select c_customer_sk from customer where c_customer_sk < 100;
 
-*** WARNING[6008] Statistics for column (C_CUSTOMER_SK) from table HIVE.HIVE.CUSTOMER were not available. As a result, the access path chosen might not be the best possible.
-
 C_CUSTOMER_SK
 -------------
 
@@ -192,34 +190,88 @@ C_CUSTOMER_SK
 
 --- 99 row(s) selected.
 >>
->>select ca_gmt_offset from customer_address where ca_gmt_offset < -8;
-
-*** WARNING[6008] Statistics for column (CA_GMT_OFFSET) from table HIVE.HIVE.CUSTOMER_ADDRESS were not available. As a result, the access path chosen might not be the best possible.
+>>select ca_gmt_offset from customer_address where ca_gmt_offset < -8 
++>order by ca_gmt_offset;
 
 CA_GMT_OFFSET  
 ---------------
 
--9.0000000E+000
 -1.0000000E+001
--9.0000000E+000
 -1.0000000E+001
--9.0000000E+000
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
+-1.0000000E+001
 -1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -231,11 +283,8 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -246,16 +295,13 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -264,7 +310,6 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -275,21 +320,17 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -301,7 +342,6 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -314,7 +354,6 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -325,11 +364,9 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -365,57 +402,41 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
--1.0000000E+001
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -432,7 +453,6 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -443,11 +463,9 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -455,7 +473,6 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -464,10 +481,7 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
--1.0000000E+001
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -475,12 +489,10 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -502,16 +514,13 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -520,9 +529,7 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -532,9 +539,7 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -550,7 +555,6 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -560,7 +564,6 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -569,22 +572,18 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -592,15 +591,12 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -608,7 +604,6 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -618,7 +613,9 @@ CA_GMT_OFFSET
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
--1.0000000E+001
+-9.0000000E+000
+-9.0000000E+000
+-9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
 -9.0000000E+000
@@ -1048,8 +1045,6 @@ P_PROMO_SK   P_PROMO_ID            P_START_DATE_SK  P_END_DATE_SK  P_ITEM_SK
 >>
 >>select t_time from time_dim where t_time > 100 and t_time < 200 ;
 
-*** WARNING[6008] Statistics for column (T_TIME) from table HIVE.HIVE.TIME_DIM were not available. As a result, the access path chosen might not be the best possible.
-
 T_TIME     
 -----------
 
@@ -1177,8 +1172,6 @@ S_STORE_SK   S_STORE_ID            S_REC_START_DATE            S_REC_END_DATE
 >>
 >>select d_date from date_dim where d_date > cast('2099-01-01' as timestamp);
 
-*** WARNING[6008] Statistics for column (D_DATE) from table HIVE.HIVE.DATE_DIM were not available. As a result, the access path chosen might not be the best possible.
-
 D_DATE                    
 --------------------------
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d3e41513/core/sql/regress/hive/TEST001
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/TEST001 b/core/sql/regress/hive/TEST001
index 3f0a713..4af01ea 100644
--- a/core/sql/regress/hive/TEST001
+++ b/core/sql/regress/hive/TEST001
@@ -53,7 +53,8 @@ select count(*) from time_dim ;
 
 select c_customer_sk from customer where c_customer_sk < 100; 
 
-select ca_gmt_offset from customer_address where ca_gmt_offset < -8;
+select ca_gmt_offset from customer_address where ca_gmt_offset < -8 
+order by ca_gmt_offset;
 
 select [first 100] hd_buy_potential from household_demographics ;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d3e41513/core/sql/regress/hive/TEST021
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/TEST021 b/core/sql/regress/hive/TEST021
index 9c1b2ef..b7c7e14 100644
--- a/core/sql/regress/hive/TEST021
+++ b/core/sql/regress/hive/TEST021
@@ -38,12 +38,11 @@ cqd mode_seahive 'ON';
 --------------------------------------------------------------------------
 -- test update stats on native hive tables
 
-update statistics for table customer on every column sample random 2 percent;
+update statistics for table hive.hive.customer on every column sample random 1 percent;
 
-showstats for table customer on "C_BIRTH_YEAR" detail;
-
-explain options 'f' select * from customer ;
-explain options 'f' select * from customer where "C_BIRTH_YEAR" = 1973;
+--showstats for table customer on "C_BIRTH_YEAR" detail;
+--explain options 'f' select * from customer ;
+--explain options 'f' select * from customer where "C_BIRTH_YEAR" = 1973;
 
 update statistics for table customer clear;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d3e41513/core/sql/ustat/hs_la.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_la.cpp b/core/sql/ustat/hs_la.cpp
index a4c9e7a..ac18500 100644
--- a/core/sql/ustat/hs_la.cpp
+++ b/core/sql/ustat/hs_la.cpp
@@ -111,7 +111,7 @@ HSTableDef::~HSTableDef()
       }
   }
 
-NABoolean HSSqTableDef::objExists(labelDetail detail)
+NABoolean HSSqTableDef::objExists(NABoolean createExternalTable)
   {
     setNATable();
     if (!naTbl_)
@@ -845,13 +845,13 @@ Lng32 HSSqTableDef::collectFileStatistics() const
 
 //=====================================================
 
-NABoolean HSHiveTableDef::objExists(labelDetail unused)
+NABoolean HSHiveTableDef::objExists(NABoolean createExternalTable)
 {
   setNATable();
   if (!naTbl_)
     return FALSE;
 
-  if (!setObjectUID())
+  if (!setObjectUID(createExternalTable))
     return FALSE;
 
   tableStats_ = naTbl_->getClusteringIndex()->getHHDFSTableStats();
@@ -1053,11 +1053,12 @@ Lng32 CreateExternalTable(const NAString& catName, const NAString& schName, cons
    return retcode;
 }
 
-NABoolean HSTableDef::setObjectUID()
+NABoolean HSTableDef::setObjectUID(NABoolean createExternalTable)
 {
   objectUID_ = naTbl_->objectUid().get_value();
 
-  if (objectUID_ <= 0 && HSGlobalsClass::isNativeCat(getCatName(EXTERNAL_FORMAT)) ) {
+  if (createExternalTable && objectUID_ <= 0 && 
+      HSGlobalsClass::isNativeCat(getCatName(EXTERNAL_FORMAT)) ) {
 
     // If objectUID is not set, it means there is no corresponding
     // external table created for it. Need to create one here.
@@ -1087,10 +1088,13 @@ NABoolean HSTableDef::setObjectUID()
     }
   }
 
-  return (objectUID_ > 0);
+  if ( createExternalTable )
+    return (objectUID_ > 0);
+  else 
+    return TRUE;
 }
 
-NABoolean HSHbaseTableDef::objExists(labelDetail unused)
+NABoolean HSHbaseTableDef::objExists(NABoolean createExternalTable)
 {
   HSLogMan *LM = HSLogMan::Instance();
 
@@ -1103,7 +1107,7 @@ NABoolean HSHbaseTableDef::objExists(labelDetail unused)
   if (!naTbl_)
     return FALSE;
 
-  if (!setObjectUID())
+  if (!setObjectUID(createExternalTable))
     return FALSE;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d3e41513/core/sql/ustat/hs_la.h
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_la.h b/core/sql/ustat/hs_la.h
index 97db4ac..e9e7286 100644
--- a/core/sql/ustat/hs_la.h
+++ b/core/sql/ustat/hs_la.h
@@ -60,7 +60,7 @@ class HSTableDef : public NABasicObject
                const ComAnsiNameSpace nameSpace);
 
     ~HSTableDef();
-    virtual NABoolean objExists(labelDetail detail = MIN_INFO) = 0;
+    virtual NABoolean objExists(NABoolean createExternalTable = FALSE) = 0;
     virtual NABoolean publicSchemaExists() = 0;
     Lng32 getColNum(const char *colName, NABoolean errIfNotFound = TRUE) const;
     char* getColName(Lng32 colNum) const;
@@ -115,7 +115,7 @@ class HSTableDef : public NABasicObject
     virtual tblOrigin getTblOrigin() const = 0;
 
   protected:
-    NABoolean setObjectUID();
+    NABoolean setObjectUID(NABoolean createExternalObject);
 
   protected:
     NAString           *tableName_;
@@ -154,7 +154,7 @@ class HSSqTableDef : public HSTableDef
       {}
     ~HSSqTableDef()
       {}
-    NABoolean objExists(labelDetail detail = MIN_INFO);
+    NABoolean objExists(NABoolean createExternalTable = FALSE);
     NABoolean publicSchemaExists();
     NAString getNodeName() const;
     NAString getCatalogLoc(formatType format = INTERNAL_FORMAT) const;
@@ -229,7 +229,7 @@ class HSHiveTableDef : public HSTableDef
 
     ~HSHiveTableDef()
       {}
-    NABoolean objExists(labelDetail detail = MIN_INFO);
+    NABoolean objExists(NABoolean createExternalTable = FALSE);
     NABoolean publicSchemaExists()
       {
         return FALSE;
@@ -340,7 +340,7 @@ class HSHbaseTableDef : public HSTableDef
 
     ~HSHbaseTableDef()
       {}
-    NABoolean objExists(labelDetail detail = MIN_INFO);
+    NABoolean objExists(NABoolean createExternalTable = FALSE);
     NABoolean publicSchemaExists()
       {
         return FALSE;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d3e41513/core/sql/ustat/hs_parser.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_parser.cpp b/core/sql/ustat/hs_parser.cpp
index 00dfe8f..56988b3 100644
--- a/core/sql/ustat/hs_parser.cpp
+++ b/core/sql/ustat/hs_parser.cpp
@@ -301,7 +301,7 @@ Lng32 AddTableName( const hs_table_type type
                                                 hs_globals->tableType,
                                                 hs_globals->nameSpace);
 
-      	if (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO))
+      	if (NOT hs_globals->objDef->objExists(TRUE))
           {
             // now look into the regular schema
             delete hs_globals->objDef;
@@ -349,7 +349,7 @@ Lng32 AddTableName( const hs_table_type type
 
        // try public schema if an object is not qualified and not found
        if ((NOT schema) && 
-           (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO)))
+           (NOT hs_globals->objDef->objExists(TRUE)))
        {
           NAString pubSch = ActiveSchemaDB()->getDefaults().getValue(PUBLIC_SCHEMA_NAME);
           ComSchemaName pubSchema(pubSch);
@@ -368,7 +368,7 @@ Lng32 AddTableName( const hs_table_type type
                                                            hs_globals->tableType,
                                                            hs_globals->nameSpace);
 
-                if (pubObjDef->objExists(HSTableDef::MAX_INFO))
+                if (pubObjDef->objExists(TRUE))
                 {
                   hs_globals->objDef = pubObjDef;
                 }
@@ -376,7 +376,7 @@ Lng32 AddTableName( const hs_table_type type
           }
        }
 
-      if (NOT hs_globals->objDef->objExists(HSTableDef::MAX_INFO))
+      if (NOT hs_globals->objDef->objExists(TRUE))
       {
          HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, extName);
          retcode = -1;


[05/14] incubator-trafodion git commit: Update regression expected files, mostly for HIVE and for EXECUTOR/TEST002

Posted by db...@apache.org.
Update regression expected files, mostly for HIVE and for EXECUTOR/TEST002


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

Branch: refs/heads/master
Commit: 566ce15272c238621dc1d121f77137b8837e67e8
Parents: d3e4151
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Sat Sep 19 02:54:02 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Sat Sep 19 02:54:02 2015 +0000

----------------------------------------------------------------------
 core/sql/regress/executor/EXPECTED002.SB | 29 +++++++++++++++++----------
 core/sql/regress/hive/EXPECTED001        |  8 ++++++++
 core/sql/regress/hive/EXPECTED003        | 24 ++++++++++------------
 core/sql/regress/hive/EXPECTED004        |  4 ++--
 core/sql/regress/hive/EXPECTED020        | 18 ++++++++---------
 5 files changed, 48 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/566ce152/core/sql/regress/executor/EXPECTED002.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/executor/EXPECTED002.SB b/core/sql/regress/executor/EXPECTED002.SB
index 5d482d9..b0511c2 100644
--- a/core/sql/regress/executor/EXPECTED002.SB
+++ b/core/sql/regress/executor/EXPECTED002.SB
@@ -61,7 +61,7 @@ W       X
 >>				-- should work
 >>update t002v set w=0;
 
-*** ERROR[4028] Table or view SEABASE.SCH.T002V is not updatable.
+*** ERROR[4028] Table or view TRAFODION.SCH.T002V is not updatable.
 
 *** ERROR[8822] The statement was not prepared.
 
@@ -957,7 +957,7 @@ A            (EXPR)
 +> (select a,sum(a) from t002t1 group by a) y) z(a,b,c,d)
 +>		group by a;
 
-*** ERROR[4001] Column B is not found.  Tables in scope: X, Y.  Default schema: SEABASE.SCH.
+*** ERROR[4001] Column B is not found.  Tables in scope: X, Y.  Default schema: TRAFODION.SCH.
 
 *** ERROR[8822] The statement was not prepared.
 
@@ -1032,28 +1032,28 @@ A            (EXPR)
 >>
 >>select *, sum(a) from t002t1;
 
-*** ERROR[4012] Column reference SEABASE.SCH.T002T1.A must be a grouping column or be specified within an aggregate.  On this grouped table a star reference is not allowed.
+*** ERROR[4012] Column reference TRAFODION.SCH.T002T1.A must be a grouping column or be specified within an aggregate.  On this grouped table a star reference is not allowed.
 
 *** ERROR[8822] The statement was not prepared.
 
 >>			-- err 4012
 >>select sum(a), * from t002t1;
 
-*** ERROR[4012] Column reference SEABASE.SCH.T002T1.A must be a grouping column or be specified within an aggregate.  On this grouped table a star reference is not allowed.
+*** ERROR[4012] Column reference TRAFODION.SCH.T002T1.A must be a grouping column or be specified within an aggregate.  On this grouped table a star reference is not allowed.
 
 *** ERROR[8822] The statement was not prepared.
 
 >>			-- err 4012
 >>select *, sum(a) from t002t1 having 1=1;
 
-*** ERROR[4012] Column reference SEABASE.SCH.T002T1.A must be a grouping column or be specified within an aggregate.  On this grouped table a star reference is not allowed.
+*** ERROR[4012] Column reference TRAFODION.SCH.T002T1.A must be a grouping column or be specified within an aggregate.  On this grouped table a star reference is not allowed.
 
 *** ERROR[8822] The statement was not prepared.
 
 >>	-- err 4012
 >>select *, sum(a) from t002t1 group by b;
 
-*** ERROR[4012] Column reference SEABASE.SCH.T002T1.A must be a grouping column or be specified within an aggregate.  On this grouped table a star reference is not allowed.
+*** ERROR[4012] Column reference TRAFODION.SCH.T002T1.A must be a grouping column or be specified within an aggregate.  On this grouped table a star reference is not allowed.
 
 *** ERROR[8822] The statement was not prepared.
 
@@ -1102,7 +1102,7 @@ A            B          C            D     (EXPR)
 >>-- The select list contains a non-grouping non-aggregated column.
 >>SELECT A,MAX(A) FROM T002T1;
 
-*** ERROR[4021] The select list contains a nongrouping non-aggregated column, SEABASE.SCH.T002T1.A.
+*** ERROR[4021] The select list contains a nongrouping non-aggregated column, TRAFODION.SCH.T002T1.A.
 
 *** ERROR[8822] The statement was not prepared.
 
@@ -1129,7 +1129,7 @@ A            (EXPR)
 >>-- The select list contains a non-grouping non-aggregated column.
 >>SELECT A,COUNT(*) FROM T002T1;
 
-*** ERROR[4021] The select list contains a nongrouping non-aggregated column, SEABASE.SCH.T002T1.A.
+*** ERROR[4021] The select list contains a nongrouping non-aggregated column, TRAFODION.SCH.T002T1.A.
 
 *** ERROR[8822] The statement was not prepared.
 
@@ -1156,7 +1156,7 @@ A            (EXPR)
 >>-- The select list contains a non-grouping non-aggregated column.
 >>SELECT (SELECT A FROM T002T2 WHERE OUTT.A > A AND MAX(OUTT.B)>'C') FROM T002T1 OUTT;
 
-*** ERROR[4021] The select list contains a nongrouping non-aggregated column, SEABASE.SCH.T002T1.A.
+*** ERROR[4021] The select list contains a nongrouping non-aggregated column, TRAFODION.SCH.T002T1.A.
 
 *** ERROR[8822] The statement was not prepared.
 
@@ -1571,9 +1571,13 @@ C            (EXPR)      (EXPR)
          20       27648                    30
 
 --- 6 row(s) selected.
+>>
 >>control query shape merge_join(cut,cut);
 
 --- SQL operation complete.
+>>cqd PCODE_OPT_LEVEL '0';
+
+--- SQL operation complete.
 >>select t002t6.c, character_length(T.b), T.a+10
 +>from t002t6
 +>left outer join (
@@ -1598,6 +1602,9 @@ C            (EXPR)      (EXPR)
          20       27648                    30
 
 --- 6 row(s) selected.
+>>cqd PCODE_OPT_LEVEL reset;
+
+--- SQL operation complete.
 >>control query shape cut;
 
 --- SQL operation complete.
@@ -6709,7 +6716,7 @@ FOO
 +>  WHERE
 +>    (SELECT 27 FROM TbadCorr) = 27;
 
-*** ERROR[4082] Object SEABASE.SCH.TBADCORR does not exist or is inaccessible.
+*** ERROR[4082] Object TRAFODION.SCH.TBADCORR does not exist or is inaccessible.
 
 *** ERROR[8822] The statement was not prepared.
 
@@ -6862,7 +6869,7 @@ FOO
 +>  WHERE
 +>    (SELECT 27 FROM TbadCorr) = 27;
 
-*** ERROR[4082] Object SEABASE.SCH.TBADCORR does not exist or is inaccessible.
+*** ERROR[4082] Object TRAFODION.SCH.TBADCORR does not exist or is inaccessible.
 
 *** ERROR[8822] The statement was not prepared.
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/566ce152/core/sql/regress/hive/EXPECTED001
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED001 b/core/sql/regress/hive/EXPECTED001
index 7a6e9bd..b015023 100644
--- a/core/sql/regress/hive/EXPECTED001
+++ b/core/sql/regress/hive/EXPECTED001
@@ -85,6 +85,8 @@
 >>
 >>select c_customer_sk from customer where c_customer_sk < 100;
 
+*** WARNING[6008] Statistics for column (C_CUSTOMER_SK) from table HIVE.HIVE.CUSTOMER were not available. As a result, the access path chosen might not be the best possible.
+
 C_CUSTOMER_SK
 -------------
 
@@ -193,6 +195,8 @@ C_CUSTOMER_SK
 >>select ca_gmt_offset from customer_address where ca_gmt_offset < -8 
 +>order by ca_gmt_offset;
 
+*** WARNING[6008] Statistics for column (CA_GMT_OFFSET) from table HIVE.HIVE.CUSTOMER_ADDRESS were not available. As a result, the access path chosen might not be the best possible.
+
 CA_GMT_OFFSET  
 ---------------
 
@@ -1045,6 +1049,8 @@ P_PROMO_SK   P_PROMO_ID            P_START_DATE_SK  P_END_DATE_SK  P_ITEM_SK
 >>
 >>select t_time from time_dim where t_time > 100 and t_time < 200 ;
 
+*** WARNING[6008] Statistics for column (T_TIME) from table HIVE.HIVE.TIME_DIM were not available. As a result, the access path chosen might not be the best possible.
+
 T_TIME     
 -----------
 
@@ -1172,6 +1178,8 @@ S_STORE_SK   S_STORE_ID            S_REC_START_DATE            S_REC_END_DATE
 >>
 >>select d_date from date_dim where d_date > cast('2099-01-01' as timestamp);
 
+*** WARNING[6008] Statistics for column (D_DATE) from table HIVE.HIVE.DATE_DIM were not available. As a result, the access path chosen might not be the best possible.
+
 D_DATE                    
 --------------------------
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/566ce152/core/sql/regress/hive/EXPECTED003
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED003 b/core/sql/regress/hive/EXPECTED003
index cd31d30..8c8006a 100644
--- a/core/sql/regress/hive/EXPECTED003
+++ b/core/sql/regress/hive/EXPECTED003
@@ -523,12 +523,11 @@ T_TIME_SK    T_TIME_ID                  T_TIME       T_HOUR       T_MINUTE     T
 LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 ---- ---- ---- --------------------  --------  --------------------  ---------
 
-7    .    8    root                                                  4.00E+000
-6    .    7    esp_exchange                    1:2(hash2)            4.00E+000
-4    .    6    hive_insert                     INS_STORE_SALES_SUMM  4.00E+000
-3    .    4    hash_partial_groupby                                  4.00E+000
-2    .    3    esp_exchange                    2(hash2):2(hash2)     4.00E+000
-1    .    2    hash_partial_groupby                                  4.00E+000
+6    .    7    root                                                  2.92E+006
+5    .    6    esp_exchange                    1:2(hash2)            2.92E+006
+3    .    5    hive_insert                     INS_STORE_SALES_SUMM  2.92E+006
+2    .    3    hash_groupby                                          2.92E+006
+1    .    2    esp_exchange                    2(hash2):2(hash2)     2.92E+006
 .    .    1    hive_scan                       STORE_SALES           2.92E+006
 
 --- SQL operation complete.
@@ -596,13 +595,12 @@ test lp bug # 1355477
 LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 ---- ---- ---- --------------------  --------  --------------------  ---------
 
-9    .    10   root                                                  5.00E+000
-1    8    9    blocked_union                                         5.00E+000
-7    .    8    esp_exchange                    1:2(hash2)            4.00E+000
-5    .    7    hive_insert                     INS_STORE_SALES_SUMM  4.00E+000
-4    .    5    hash_partial_groupby                                  4.00E+000
-3    .    4    esp_exchange                    2(hash2):2(hash2)     4.00E+000
-2    .    3    hash_partial_groupby                                  4.00E+000
+8    .    9    root                                                  2.92E+006
+1    7    8    blocked_union                                         2.92E+006
+6    .    7    esp_exchange                    1:2(hash2)            2.92E+006
+4    .    6    hive_insert                     INS_STORE_SALES_SUMM  2.92E+006
+3    .    4    hash_groupby                                          2.92E+006
+2    .    3    esp_exchange                    2(hash2):2(hash2)     2.92E+006
 .    .    2    hive_scan                       STORE_SALES           2.92E+006
 .    .    1    hive_truncate                                         1.00E+000
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/566ce152/core/sql/regress/hive/EXPECTED004
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED004 b/core/sql/regress/hive/EXPECTED004
index 303aa6d..08ecaff 100644
--- a/core/sql/regress/hive/EXPECTED004
+++ b/core/sql/regress/hive/EXPECTED004
@@ -55,7 +55,7 @@ C_CUSTOMER_SK  C_CUSTOMER_ID              C_CURRENT_CDEMO_SK  C_CURRENT_HDEMO_SK
            25  AAAAAAAAJBAAAAAA                       476176                3278              25933                 2449246                2449216  Miss                       Nancy                      Mccormick                  N                                    6             10          1973  BAHAMAS                    ?                          Nancy.Mccormick@DA26I9ZAr  2452425                  
            26  AAAAAAAAKBAAAAAA                       230278                1242              28206                 2449816                2449786  Ms.                        Monique                    Baker                      N                                   14              6          1991  MOROCCO                    ?                          Monique.Baker@9uEucNczY.o  2452356                  
            27  AAAAAAAALBAAAAAA                       111621                 835              16096                 2450611                2450581  Dr.                        Shawn                      Prather                    N                                    7              3          1972  PUERTO RICO                ?                          Shawn.Prather@8BusRYegn6.  2452353                  
-           28  AAAAAAAAMBAAAAAA                       889961                 897              33480                 2452615                2452585  Miss                       Edith                      Hernandez                  Y                                   17              8          1959  C?TE D'IVOIRE              ?                          Edith.Hernandez@BNHL0k.co  2452631                  
+           28  AAAAAAAAMBAAAAAA                       889961                 897              33480                 2452615                2452585  Miss                       Edith                      Hernandez                  Y                                   17              8          1959  C�TE D'IVOIRE              ?                          Edith.Hernandez@BNHL0k.co  2452631                  
            29  AAAAAAAANBAAAAAA                      1634269                1204              44139                 2452216                2452186  Ms.                        Margaret                   Collins                    Y                                   25              8          1973  NETHERLANDS ANTILLES       ?                          Margaret.Collins@9obPr3UV  2452496                  
            30  AAAAAAAAOBAAAAAA                        84232                5869              45459                 2449916                2449886  Dr.                        Pamela                     Luna                       Y                                    4              7          1956  GUAM                       ?                          Pamela.Luna@QBGuhL36lnA.e  2452410                  
            31  AAAAAAAAPBAAAAAA                      1275120                5724               7128                 2452054                2452024  Dr.                        William                    Craig                      N                                   13              6          1964  SPAIN                      ?                          William.Craig@prVDE1E8AHc  2452336                  
@@ -107,7 +107,7 @@ C_CUSTOMER_SK  C_CUSTOMER_ID              C_CURRENT_CDEMO_SK  C_CURRENT_HDEMO_SK
            77  AAAAAAAANEAAAAAA                       915180                2167              37154                 2451632                2451602  Dr.                        Darrin                     Smith                      N                                   30              5          1931  UNITED STATES              ?                          Darrin.Smith@Mti.edu       2452355                  
            78  AAAAAAAAOEAAAAAA                      1092537                3677               7264                 2449388                2449358  Ms.                        Wanda                      Davis                      N                                   11              5          1940  NETHERLANDS ANTILLES       ?                          Wanda.Davis@I6s7DD86i6.ed  2452339                  
            79  AAAAAAAAPEAAAAAA                       389494                3493               9539                 2450863                2450833  Miss                       Sandi                      Tran                       Y                                   10              6          1937  FRENCH GUIANA              ?                          Sandi.Tran@myikqStif1Q.ed  2452644                  
-           80  AAAAAAAAAFAAAAAA                      1499808                3891              44727                 2450558                2450528  Mrs.                       Eleanor                    Evans                      N                                   21             12          1948  C?TE D'IVOIRE              ?                          Eleanor.Evans@zxvr5rl.org  2452413                  
+           80  AAAAAAAAAFAAAAAA                      1499808                3891              44727                 2450558                2450528  Mrs.                       Eleanor                    Evans                      N                                   21             12          1948  C�TE D'IVOIRE              ?                          Eleanor.Evans@zxvr5rl.org  2452413                  
            81  AAAAAAAABFAAAAAA                       728917                 388              48306                 2452562                2452532  Ms.                        Jessica                    Levesque                   Y                                   17              7          1940  ALBANIA                    ?                          Jessica.Levesque@06mGqI9m  2452414                  
            82  AAAAAAAACFAAAAAA                        75627                5081              30088                 2450357                2450327  Sir                        Max                        Mueller                    N                                   26              2          1947  IRAQ                       ?                          Max.Mueller@xqCZRBSrTGD6C  2452303                  
            83  AAAAAAAADFAAAAAA                       976724                5574              40824                 2451032                2451002  Miss                       Daisy                      Flynn                      N                                   24              1          1943  NEW ZEALAND                ?                          Daisy.Flynn@288e6Z0csxJ.c  2452338                  

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/566ce152/core/sql/regress/hive/EXPECTED020
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED020 b/core/sql/regress/hive/EXPECTED020
index c04bda7..bd1cdfe 100644
--- a/core/sql/regress/hive/EXPECTED020
+++ b/core/sql/regress/hive/EXPECTED020
@@ -20,7 +20,7 @@
 >>invoke hive.hive.store_orc;
 
 -- Definition of hive table STORE_ORC
--- Definition current  Sun Nov  9 22:00:42 2014
+-- Definition current  Fri Sep 18 21:54:29 2015
 
   (
     S_STORE_SK                       INT
@@ -139,10 +139,10 @@ S_STORE_SK   (EXPR)
 LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 ---- ---- ---- --------------------  --------  --------------------  ---------
 
-3    .    4    root                                                  4.09E+001
-2    1    3    hybrid_hash_join                                      4.09E+001
-.    .    2    hive_scan                       STORE_ORC             9.00E+000
-.    .    1    hive_scan                       STORE_ORC             9.00E+000
+3    .    4    root                                                  8.17E+004
+2    1    3    hybrid_hash_join                                      8.17E+004
+.    .    2    hive_scan                       STORE_ORC             4.08E+003
+.    .    1    hive_scan                       STORE_ORC             4.08E+003
 
 --- SQL operation complete.
 >>
@@ -177,10 +177,10 @@ Suite 100             College
 LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 ---- ---- ---- --------------------  --------  --------------------  ---------
 
-3    .    4    root                                                  5.00E+001
-2    1    3    hybrid_hash_join                                      5.00E+001
-.    .    2    hive_scan                       STORE                 1.10E+001
-.    .    1    hive_scan                       STORE_ORC             9.00E+000
+3    .    4    root                                                  4.08E+003
+1    2    3    nested_join                                           4.08E+003
+.    .    2    hive_scan                       STORE_ORC             4.08E+001
+.    .    1    hive_scan                       STORE                 1.00E+002
 
 --- SQL operation complete.
 >>


[06/14] incubator-trafodion git commit: update seabase/TEST028 to avoid use swhbase.

Posted by db...@apache.org.
update seabase/TEST028 to avoid use swhbase.


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

Branch: refs/heads/master
Commit: e0598c5328a826496f3f55bcd407634210eb46a2
Parents: 566ce15
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Sat Sep 19 20:25:36 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Sat Sep 19 20:25:36 2015 +0000

----------------------------------------------------------------------
 core/sql/regress/seabase/EXPECTED028            | 136 ++++++++-----------
 core/sql/regress/seabase/TEST028                |  36 +++--
 core/sql/regress/seabase/create_hbase_tables.sh |  29 ----
 core/sql/regress/seabase/drop_hbase_tables.sh   |   7 -
 4 files changed, 79 insertions(+), 129 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e0598c53/core/sql/regress/seabase/EXPECTED028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED028 b/core/sql/regress/seabase/EXPECTED028
index f49c05a..3de355b 100644
--- a/core/sql/regress/seabase/EXPECTED028
+++ b/core/sql/regress/seabase/EXPECTED028
@@ -1,111 +1,87 @@
 >>
->>log off;
->>
->>update statistics for table hbase."_CELL_"."test028tbl2" on every column;
+>>create hbase table t028tbl1(column family 'cf');
 
 --- SQL operation complete.
->>update statistics for table hbase."_CELL_"."test028tbl2" on every key;
-
-*** WARNING[9202] UPDATE STATISTICS has located previously generated histograms that are not being regenerated. This may affect the plans that will be generated. Missing columns lists are (COL_VALUE),(COL_TIMESTAMP),(COL_NAME),(COL_FAMILY).
-
---- SQL operation completed with warnings.
 >>
->>showstats for table hbase."_CELL_"."test028tbl2" on ROW_ID detail;
-
-Detailed Histogram data for Table HBASE."_CELL_"."test028tbl2"
-Table ID: 961595648449090953
-
-Hist ID:    1150301280
-Column(s):  ROW_ID
-Total Rows: 10
-Total UEC:  10
-Low Value:  ('100')
-High Value: ('9990')
-Intervals:  10
-
-Number    Rowcount         UEC Boundary
-====== =========== =========== ======================================
-     0           0           0 ('100')
-     1           1           1 ('100')
-     2           1           1 ('200')
-     3           1           1 ('300')
-     4           1           1 ('400')
-     5           1           1 ('500')
-     6           1           1 ('600')
-     7           1           1 ('700')
-     8           1           1 ('720')
-     9           1           1 ('999')
-    10           1           1 ('9990')
+>>insert into hbase."_CELL_".t028tbl1 values 
++>('0', 'cf', '1a', -1, '2'),
++>('1', 'cf', '1a', -1, '102'),
++>('2', 'cf', '1a', -1, '202'),
++>('3', 'cf', '1a', -1, '302'),
++>('4', 'cf', '1a', -1, '402'),
++>('5', 'cf', '1a', -1, '502'),
++>('6', 'cf', '1a', -1, '602'),
++>('7', 'cf', '1a', -1, '702'),
++>('8', 'cf', '1a', -1, '802');
+
+--- 9 row(s) inserted.
+>>
+>>
+>>cqd  USTAT_INTERNAL_SORT 'off';
 
+--- SQL operation complete.
+>>update statistics for table hbase."_CELL_".t028tbl1 on every column;
 
 --- SQL operation complete.
->>showstats for table hbase."_CELL_"."test028tbl2" on COL_FAMILY detail;
+>>
+>>showstats for table hbase."_CELL_".t028tbl1 on ROW_ID detail;
 
-Detailed Histogram data for Table HBASE."_CELL_"."test028tbl2"
-Table ID: 961595648449090953
+Detailed Histogram data for Table HBASE."_CELL_".T028TBL1
+Table ID: 7271138919030419384
 
-Hist ID:    1150301276
-Column(s):  COL_FAMILY
-Total Rows: 10
-Total UEC:  1
-Low Value:  ('cf1')
-High Value: ('cf1')
-Intervals:  1
+Hist ID:    519562736
+Column(s):  ROW_ID
+Total Rows: 9
+Total UEC:  9
+Low Value:  ('0')
+High Value: ('8')
+Intervals:  9
 
 Number    Rowcount         UEC Boundary
 ====== =========== =========== ======================================
-     0           0           0 ('cf1')
-     1          10           1 ('cf1')
+     0           0           0 ('0')
+     1           1           1 ('0')
+     2           1           1 ('1')
+     3           1           1 ('2')
+     4           1           1 ('3')
+     5           1           1 ('4')
+     6           1           1 ('5')
+     7           1           1 ('6')
+     8           1           1 ('7')
+     9           1           1 ('8')
 
 
 --- SQL operation complete.
->>showstats for table hbase."_CELL_"."test028tbl2" on COL_VALUE detail;
-
-Detailed Histogram data for Table HBASE."_CELL_"."test028tbl2"
-Table ID: 961595648449090953
-
-Hist ID:    1150301261
-Column(s):  COL_VALUE
-Total Rows: 10
-Total UEC:  10
-Low Value:  ('v100')
-High Value: ('v9990')
-Intervals:  10
-
-Number    Rowcount         UEC Boundary
-====== =========== =========== ======================================
-     0           0           0 ('v100')
-     1           1           1 ('v100')
-     2           1           1 ('v200')
-     3           1           1 ('v300')
-     4           1           1 ('v400')
-     5           1           1 ('v500')
-     6           1           1 ('v600')
-     7           1           1 ('v700')
-     8           1           1 ('v720')
-     9           1           1 ('v999')
-    10           1           1 ('v9990')
+>>showstats for table hbase."_CELL_".t028tbl1 on COL_FAMILAY detail;
 
+*** ERROR[9209] Column COL_FAMILAY does not exist in object HBASE."_CELL_".T028TBL1.
 
---- SQL operation complete.
+--- SQL operation failed with errors.
 >>
->>explain options 'f' select * from hbase."_CELL_"."test028tbl2";
+>>explain options 'f' select * from hbase."_CELL_".t028tbl1;
 
 LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 ---- ---- ---- --------------------  --------  --------------------  ---------
 
-1    .    2    root                                                  1.00E+001
-.    .    1    hbase_scan                      test028tbl2           1.00E+001
+1    .    2    root                                                  9.00E+000
+.    .    1    hbase_scan                      T028TBL1              9.00E+000
 
 --- SQL operation complete.
->>explain options 'f' select * from hbase."_CELL_"."test028tbl2" where ROW_ID = '700';
+>>explain options 'f' select * from hbase."_CELL_".t028tbl1 where col_family = 'cf1';
 
 LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
 ---- ---- ---- --------------------  --------  --------------------  ---------
 
-1    .    2    root                  o                               1.00E+000
-.    .    1    hbase_scan                      test028tbl2           1.00E+000
+1    .    2    root                                                  9.00E+000
+.    .    1    hbase_scan                      T028TBL1              9.00E+000
+
+--- SQL operation complete.
+>>
+>>drop hbase table t028tbl1;
 
 --- SQL operation complete.
 >>
->>log off;
+>>exit;
+
+End of MXCI Session
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e0598c53/core/sql/regress/seabase/TEST028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST028 b/core/sql/regress/seabase/TEST028
index 64cbd38..398d301 100644
--- a/core/sql/regress/seabase/TEST028
+++ b/core/sql/regress/seabase/TEST028
@@ -21,24 +21,34 @@
 --
 -- @@@ END COPYRIGHT @@@
 
+
+set schema hbase."_CELL_";
+drop hbase table t028tbl1;
+
 log LOG028 clear;
 
-log off;
-sh sh drop_hbase_tables.sh;
-sh sh create_hbase_tables.sh;
+create hbase table t028tbl1(column family 'cf');
+
+insert into hbase."_CELL_".t028tbl1 values 
+('0', 'cf', '1a', -1, '2'),
+('1', 'cf', '1a', -1, '102'),
+('2', 'cf', '1a', -1, '202'),
+('3', 'cf', '1a', -1, '302'),
+('4', 'cf', '1a', -1, '402'),
+('5', 'cf', '1a', -1, '502'),
+('6', 'cf', '1a', -1, '602'),
+('7', 'cf', '1a', -1, '702'),
+('8', 'cf', '1a', -1, '802');
 
-log LOG028;
 
-update statistics for table hbase."_CELL_"."test028tbl2" on every column;
-update statistics for table hbase."_CELL_"."test028tbl2" on every key;
+cqd  USTAT_INTERNAL_SORT 'off';
+update statistics for table hbase."_CELL_".t028tbl1 on every column;
 
-showstats for table hbase."_CELL_"."test028tbl2" on ROW_ID detail;
-showstats for table hbase."_CELL_"."test028tbl2" on COL_FAMILY detail;
-showstats for table hbase."_CELL_"."test028tbl2" on COL_VALUE detail;
+showstats for table hbase."_CELL_".t028tbl1 on ROW_ID detail;
+showstats for table hbase."_CELL_".t028tbl1 on COL_FAMILAY detail;
 
-explain options 'f' select * from hbase."_CELL_"."test028tbl2";
-explain options 'f' select * from hbase."_CELL_"."test028tbl2" where ROW_ID = '700';
+explain options 'f' select * from hbase."_CELL_".t028tbl1;
+explain options 'f' select * from hbase."_CELL_".t028tbl1 where col_family = 'cf1';
 
-log off;
-sh sh drop_hbase_tables.sh;
+drop hbase table t028tbl1;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e0598c53/core/sql/regress/seabase/create_hbase_tables.sh
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/create_hbase_tables.sh b/core/sql/regress/seabase/create_hbase_tables.sh
deleted file mode 100644
index cc44104..0000000
--- a/core/sql/regress/seabase/create_hbase_tables.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-
-swhbase << EOF
-
-create 'test028tbl2', {NAME => 'cf1', VERSIONS => 1 }, {SPLITS => ['333','666','999']}
-
-tbl2=get_table 'test028tbl2'
-
-# region 0
-tbl2.put '100', 'cf1:#1', 'v100'
-tbl2.put '200', 'cf1:#1', 'v200'
-tbl2.put '300', 'cf1:#1', 'v300'
-
-# region 1
-tbl2.put '400', 'cf1:#1', 'v400'
-tbl2.put '500', 'cf1:#1', 'v500'
-tbl2.put '600', 'cf1:#1', 'v600'
-
-# region 2
-tbl2.put '700', 'cf1:#1', 'v700'
-tbl2.put '720', 'cf1:#1', 'v720'
-
-# region 3
-tbl2.put '999', 'cf1:#1', 'v999'
-tbl2.put '9990', 'cf1:#1', 'v9990'
-
-tbl2.scan
-
-
-EOF

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e0598c53/core/sql/regress/seabase/drop_hbase_tables.sh
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/drop_hbase_tables.sh b/core/sql/regress/seabase/drop_hbase_tables.sh
deleted file mode 100644
index f9853e7..0000000
--- a/core/sql/regress/seabase/drop_hbase_tables.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-
-swhbase << EOF
-
-disable 'test028tbl2'
-drop 'test028tbl2'
-
-EOF


[03/14] incubator-trafodion git commit: fix hive stats not being used by the compiler

Posted by db...@apache.org.
fix hive stats not being used by the compiler


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

Branch: refs/heads/master
Commit: 8886fa81d810035a26535f945e9d889b718cd480
Parents: 890c306
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Thu Sep 17 16:54:28 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Thu Sep 17 16:54:28 2015 +0000

----------------------------------------------------------------------
 core/sql/optimizer/NATable.cpp    |  42 -----------
 core/sql/regress/hive/EXPECTED021 | 132 +++++++++++++++++++++++++++++++++
 core/sql/regress/hive/FILTER021   |  96 ++++++++++++++++++++++++
 core/sql/regress/hive/TEST021     |  49 ++++++++++++
 4 files changed, 277 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8886fa81/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index dbf8aed..8ebb37c 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -5939,48 +5939,6 @@ NABoolean NATable::insertMissingStatsWarning(CollIndexSet colsSet) const
 StatsList &
 NATable::getStatistics()
 {
-   // HIVE-TBD
-   if ( isHiveTable() ) {
-
-       NAMemory* heap = CmpCommon::statementHeap();
-
-       if ( colStats_ == NULL ) {
-	  colStats_ = new (heap) StatsList(CmpCommon::statementHeap());
-       }
-
-       return *colStats_;
-
-//       // side-affect NAColumn in colArray on needHistogram() and 
-//       // needFullHistogram()
-//       markColumnsForHistograms();
-//
-//       NAColumnArray& colArray = const_cast<NAColumnArray&>(getNAColumnArray());
-//
-//       for(UInt32 i=0;i<colArray.entries();i++)
-//       {
-//          //get a reference to the column
-//          NAColumn * column = colArray[i];
-//
-//          if ( column->needHistogram() ) {
-//
-//            ComUID id(ColStats::nextFakeHistogramID());
-//
-//            ColStatsSharedPtr colStatsPtr = new (heap)
-//                ColStats (id,
-//                          CostScalar(1000), /*CS uec*/
-//                          CostScalar(2200), /* rowcount in CS */
-//                          CostScalar(-1),  // baseRC
-//                          FALSE, // NABoolean unique 
-//                          0,     // Int32 avgVarcharSize = 0
-//                          heap   // NAMemory* heap=0
-//                         );
-//
-//             colStats_->insertAt(colStats_->entries(), colStatsPtr);
-//          }
-//       }
-//       return *colStats_;
-   }
-
     if (!statsFetched_)
     {
       // mark the kind of histograms needed for this table's columns

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8886fa81/core/sql/regress/hive/EXPECTED021
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED021 b/core/sql/regress/hive/EXPECTED021
new file mode 100644
index 0000000..41b95e2
--- /dev/null
+++ b/core/sql/regress/hive/EXPECTED021
@@ -0,0 +1,132 @@
+>>obey TEST021(setup);
+>>--------------------------------------------------------------------------
+>>
+>>set schema hive.hive;
+
+--- SQL operation complete.
+>>cqd mode_seahive 'ON';
+
+--- SQL operation complete.
+>>
+>>obey TEST021(tests);
+>>--------------------------------------------------------------------------
+>>-- test update stats on native hive tables
+>>
+>>update statistics for table customer on every column sample random 2 percent;
+
+--- SQL operation complete.
+>>
+>>showstats for table customer on "C_BIRTH_YEAR" detail;
+
+Detailed Histogram data for Table HIVE.HIVE.CUSTOMER
+Table ID: 8826569449427418914
+
+Hist ID:    1850933272
+Column(s):  C_BIRTH_YEAR
+Total Rows: 100000
+Total UEC:  70
+Low Value:  (1924)
+High Value: (1992)
+Intervals:  70
+
+Number    Rowcount         UEC Boundary
+====== =========== =========== ======================================
+     0           0           0 (1924)
+     1        1300           1 (1924)
+     2        1750           1 (1925)
+     3        1600           1 (1926)
+     4        1400           1 (1927)
+     5        1250           1 (1928)
+     6        1150           1 (1929)
+     7        1400           1 (1930)
+     8         800           1 (1931)
+     9        1700           1 (1932)
+    10        1300           1 (1933)
+    11        1500           1 (1934)
+    12        1550           1 (1935)
+    13        1400           1 (1936)
+    14        1700           1 (1937)
+    15        1300           1 (1938)
+    16        1800           1 (1939)
+    17        1450           1 (1940)
+    18        1450           1 (1941)
+    19        1700           1 (1942)
+    20        1750           1 (1943)
+    21        1450           1 (1944)
+    22        1150           1 (1945)
+    23        1000           1 (1946)
+    24        1250           1 (1947)
+    25        1600           1 (1948)
+    26        1550           1 (1949)
+    27        1650           1 (1950)
+    28        1550           1 (1951)
+    29        1050           1 (1952)
+    30        1500           1 (1953)
+    31        1200           1 (1954)
+    32        1700           1 (1955)
+    33        1450           1 (1956)
+    34        1600           1 (1957)
+    35        1550           1 (1958)
+    36        1100           1 (1959)
+    37        1500           1 (1960)
+    38        1750           1 (1961)
+    39         950           1 (1962)
+    40        1700           1 (1963)
+    41        1500           1 (1964)
+    42        1100           1 (1965)
+    43        1350           1 (1966)
+    44        1350           1 (1967)
+    45        1400           1 (1968)
+    46        1300           1 (1969)
+    47        1700           1 (1970)
+    48        2000           1 (1971)
+    49        1300           1 (1972)
+    50        1650           1 (1973)
+    51         850           1 (1974)
+    52        1050           1 (1975)
+    53        1300           1 (1976)
+    54        1000           1 (1977)
+    55        1350           1 (1978)
+    56        1700           1 (1979)
+    57        1100           1 (1980)
+    58        1650           1 (1981)
+    59        1700           1 (1982)
+    60        1150           1 (1983)
+    61        1100           1 (1984)
+    62        1850           1 (1985)
+    63         950           1 (1986)
+    64        1350           1 (1987)
+    65        1850           1 (1988)
+    66         950           1 (1989)
+    67        1400           1 (1990)
+    68        1250           1 (1991)
+    69        1100           1 (1992)
+    70        3200           1 (NULL)
+
+
+--- SQL operation complete.
+>>
+>>explain options 'f' select * from customer ;
+
+LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
+---- ---- ---- --------------------  --------  --------------------  ---------
+
+1    .    2    root                                                  1.00E+005
+.    .    1    hive_scan                       CUSTOMER              1.00E+005
+
+--- SQL operation complete.
+>>explain options 'f' select * from customer where "C_BIRTH_YEAR" = 1973;
+
+LC   RC   OP   OPERATOR              OPT       DESCRIPTION           CARD
+---- ---- ---- --------------------  --------  --------------------  ---------
+
+1    .    2    root                                                  1.65E+003
+.    .    1    hive_scan                       CUSTOMER              1.65E+003
+
+--- SQL operation complete.
+>>
+>>update statistics for table customer clear;
+
+--- SQL operation complete.
+>>
+>>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8886fa81/core/sql/regress/hive/FILTER021
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/FILTER021 b/core/sql/regress/hive/FILTER021
new file mode 100755
index 0000000..590eeb9
--- /dev/null
+++ b/core/sql/regress/hive/FILTER021
@@ -0,0 +1,96 @@
+#! /bin/sh
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+
+# Like the pattern-masking of QACOMP, here we filter out such stuff as
+# timestamps and generated identifiers.  Called by the runregr script
+# before doing diff.
+
+fil=$1
+if [ "$fil" = "" ]; then
+  echo "Usage: $0 filename"
+  exit 1
+fi
+
+# Remove following types of lines:
+#   Lines started with "Start Time", "End Time", "Elapsed Time",
+#                      "Execution Time", "Table ID: ddddddddd", and
+#                      "Hist ID: ddddddddd"
+ON_A_VM=
+SYSVENDOR="$(cat /sys/class/dmi/id/sys_vendor)"
+if [[ ( "${SYSVENDOR/OpenStack/}" != "$SYSVENDOR" ) ||
+      ( "${SYSVENDOR/VMware/}"    != "$SYSVENDOR" ) ]]; then
+  # Running on an OpenStack or VMware virtual machine
+  ON_A_VM=yes
+fi
+if [[ "$SQ_BUILD_TYPE" = "release" ]]; then
+sed "
+/Start Time.*/d
+" $fil |
+sed "/End Time.*/d" |
+sed "/Elapsed Time.*/d" |
+sed "/Execution Time.*/d" |
+sed "/Table ID.*/d" |
+sed "/Hist ID.*/d" |
+awk '
+{
+# we are looking for a less than 1 ms compile time
+#   but we accept time up to 1.4 ms because of other loads
+#   and time up to 2.0 ms on a virtual machine
+#   when the test is being run
+# Acceptable compile time is no more than 00:00:01.001399
+#   or on a virtual machine, no more than 00:00:01.001999
+# Examples of patterns to classify:
+#  1.  "Compile Time 00:00:01.001047" --> FAILED (at least one second)
+#  2.  "Compile Time 00:00:00.001470" --> FAILED (more than 1ms)
+#  3.  "Compile Time 00:00:00.000870" --> SUCCESS(less than 1ms)
+#  4.  "Compile Time 00:00:00.001200" --> SUCCESS(less than 1ms)
+#  5.  "Compile Time 00:00:00.001821" --> SUCCESS(less than 1ms)  only on a VM
+   if ( $1 == "Compile"  && $2 == "Time" ) { \
+     split($3, a, "."); \
+     if ( !match(a[1], "00:00:00") ) \
+       print "FAIL (at least one second)", $0; \
+     else { \
+              split(a[2], b, ""); \
+              if ((b[1] == 0) && (b[2]==0) &&  \
+                  ((b[3] == 0) || ((b[3] == 1) && ((b[4] < 4) || (ENVIRON["ON_A_VM"] = "yes"))) )) \
+                  print "SUCCESS (less than 1ms)"; \
+              else \
+                  print "FAIL (at least 1ms)", $0; \
+     }; \
+   } else \
+     print; \
+}
+'
+fi
+
+if [[ "$SQ_BUILD_TYPE" = "debug" ]]; then
+sed "
+/Start Time.*/d
+" $fil |
+sed "/End Time.*/d" |
+sed "/Elapsed Time.*/d" |
+sed "/Execution Time.*/d" |
+sed "/Table ID.*/d" |
+sed "/Hist ID.*/d" |
+sed "/Compile Time.*/d"
+fi
+

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/8886fa81/core/sql/regress/hive/TEST021
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/TEST021 b/core/sql/regress/hive/TEST021
new file mode 100644
index 0000000..9c1b2ef
--- /dev/null
+++ b/core/sql/regress/hive/TEST021
@@ -0,0 +1,49 @@
+-- Tests for update stats for native hive tables
+-- Added Sept 2015
+--
+-- @@@ START COPYRIGHT @@@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+-- @@@ END COPYRIGHT @@@
+
+log LOG021 clear;
+obey TEST021(setup);
+obey TEST021(tests);
+log;
+exit;
+
+?section setup
+--------------------------------------------------------------------------
+
+set schema hive.hive;
+cqd mode_seahive 'ON';
+
+?section tests
+--------------------------------------------------------------------------
+-- test update stats on native hive tables
+
+update statistics for table customer on every column sample random 2 percent;
+
+showstats for table customer on "C_BIRTH_YEAR" detail;
+
+explain options 'f' select * from customer ;
+explain options 'f' select * from customer where "C_BIRTH_YEAR" = 1973;
+
+update statistics for table customer clear;
+


[08/14] incubator-trafodion git commit: Generalize the fix to all update stats stmt.

Posted by db...@apache.org.
Generalize the fix to all update stats stmt.


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

Branch: refs/heads/master
Commit: 3a01e69ccaabee40070c44de6c48005ee76326ce
Parents: 92428d7
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Sun Sep 20 19:44:04 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Sun Sep 20 19:44:04 2015 +0000

----------------------------------------------------------------------
 core/sql/ustat/hs_parser.cpp | 15 ++++++---------
 core/sql/ustat/hs_yacc.y     |  7 ++++++-
 2 files changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3a01e69c/core/sql/ustat/hs_parser.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_parser.cpp b/core/sql/ustat/hs_parser.cpp
index fb547e5..5738438 100644
--- a/core/sql/ustat/hs_parser.cpp
+++ b/core/sql/ustat/hs_parser.cpp
@@ -57,6 +57,8 @@ extern void init_scanner (void* &);
 extern void destroy_scanner(void* &scanner);
 Lng32 AddSingleColumn(const Lng32 colNumber);
 
+    
+NABoolean isUpdatestatsStmt = FALSE;
 
 
 // -----------------------------------------------------------------------
@@ -165,11 +167,6 @@ Lng32 AddTableName( const hs_table_type type
     // the default attribute values set by SET MPLOC/CQD.
     ActiveSchemaDB()->getDefaults().getSqlParser_NADefaults();
 
-    NABoolean createExternalTable = TRUE;
-    if ( hs_globals->optFlags & SHOWSTATS_OPT ||
-        (hs_globals->optFlags & CLEAR_OPT) )
-      createExternalTable = FALSE;
-
     if (type == GUARDIAN_TABLE)
       {
         if (*table == '$')
@@ -306,7 +303,7 @@ Lng32 AddTableName( const hs_table_type type
                                                 hs_globals->tableType,
                                                 hs_globals->nameSpace);
 
-      	if (NOT hs_globals->objDef->objExists(createExternalTable))
+      	if (NOT hs_globals->objDef->objExists(isUpdatestatsStmt))
           {
             // now look into the regular schema
             delete hs_globals->objDef;
@@ -354,7 +351,7 @@ Lng32 AddTableName( const hs_table_type type
 
        // try public schema if an object is not qualified and not found
        if ((NOT schema) && 
-           (NOT hs_globals->objDef->objExists(createExternalTable)))
+           (NOT hs_globals->objDef->objExists(isUpdatestatsStmt)))
        {
           NAString pubSch = ActiveSchemaDB()->getDefaults().getValue(PUBLIC_SCHEMA_NAME);
           ComSchemaName pubSchema(pubSch);
@@ -373,7 +370,7 @@ Lng32 AddTableName( const hs_table_type type
                                                            hs_globals->tableType,
                                                            hs_globals->nameSpace);
 
-                if (pubObjDef->objExists(createExternalTable))
+                if (pubObjDef->objExists(isUpdatestatsStmt))
                 {
                   hs_globals->objDef = pubObjDef;
                 }
@@ -381,7 +378,7 @@ Lng32 AddTableName( const hs_table_type type
           }
        }
 
-      if (NOT hs_globals->objDef->objExists(createExternalTable))
+      if (NOT hs_globals->objDef->objExists(isUpdatestatsStmt))
       {
          HSFuncMergeDiags(-UERR_OBJECT_INACCESSIBLE, extName);
          retcode = -1;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3a01e69c/core/sql/ustat/hs_yacc.y
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_yacc.y b/core/sql/ustat/hs_yacc.y
index 438cabf..7acf82f 100644
--- a/core/sql/ustat/hs_yacc.y
+++ b/core/sql/ustat/hs_yacc.y
@@ -60,6 +60,8 @@ extern THREAD_P HSGlobalsClass *hs_globals_y;
 extern int yylex(YYSTYPE * lvalp, void* scanner);
 //extern int yylex();
 
+extern NABoolean isUpdatestatsStmt;
+
 #define scanner scanner
 
 %}
@@ -102,7 +104,10 @@ extern int yylex(YYSTYPE * lvalp, void* scanner);
          same syntax it will fail to parse there and never get here.
 */
 
-statement   :  UPDATE STATISTICS FOR table_kind table_identifier histogram_options
+statement   :  UPDATE STATISTICS { isUpdatestatsStmt = TRUE; } FOR table_kind table_identifier histogram_options
+                   {
+                       isUpdatestatsStmt = FALSE;
+                   }
               | UPDATE STATISTICS LOG ON
                    {
                      HSLogMan *LM = HSLogMan::Instance();


[09/14] incubator-trafodion git commit: update TEST028

Posted by db...@apache.org.
update TEST028


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

Branch: refs/heads/master
Commit: 052b3bb7ba9e6b205cdc12b969bc36148d881de4
Parents: 3a01e69
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Sun Sep 20 22:52:10 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Sun Sep 20 22:52:10 2015 +0000

----------------------------------------------------------------------
 core/sql/regress/seabase/EXPECTED028 | 25 ++++++++++++++++++++-----
 core/sql/regress/seabase/TEST028     |  2 +-
 2 files changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/052b3bb7/core/sql/regress/seabase/EXPECTED028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED028 b/core/sql/regress/seabase/EXPECTED028
index 3de355b..c84e4f2 100644
--- a/core/sql/regress/seabase/EXPECTED028
+++ b/core/sql/regress/seabase/EXPECTED028
@@ -27,9 +27,9 @@
 >>showstats for table hbase."_CELL_".t028tbl1 on ROW_ID detail;
 
 Detailed Histogram data for Table HBASE."_CELL_".T028TBL1
-Table ID: 7271138919030419384
+Table ID: 6047285781859643730
 
-Hist ID:    519562736
+Hist ID:    1955006841
 Column(s):  ROW_ID
 Total Rows: 9
 Total UEC:  9
@@ -52,11 +52,26 @@ Number    Rowcount         UEC Boundary
 
 
 --- SQL operation complete.
->>showstats for table hbase."_CELL_".t028tbl1 on COL_FAMILAY detail;
+>>showstats for table hbase."_CELL_".t028tbl1 on COL_FAMILY detail;
 
-*** ERROR[9209] Column COL_FAMILAY does not exist in object HBASE."_CELL_".T028TBL1.
+Detailed Histogram data for Table HBASE."_CELL_".T028TBL1
+Table ID: 6047285781859643730
+
+Hist ID:    1955006834
+Column(s):  COL_FAMILY
+Total Rows: 9
+Total UEC:  1
+Low Value:  ('cf')
+High Value: ('cf')
+Intervals:  1
+
+Number    Rowcount         UEC Boundary
+====== =========== =========== ======================================
+     0           0           0 ('cf')
+     1           9           1 ('cf')
 
---- SQL operation failed with errors.
+
+--- SQL operation complete.
 >>
 >>explain options 'f' select * from hbase."_CELL_".t028tbl1;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/052b3bb7/core/sql/regress/seabase/TEST028
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST028 b/core/sql/regress/seabase/TEST028
index 398d301..edfd58b 100644
--- a/core/sql/regress/seabase/TEST028
+++ b/core/sql/regress/seabase/TEST028
@@ -45,7 +45,7 @@ cqd  USTAT_INTERNAL_SORT 'off';
 update statistics for table hbase."_CELL_".t028tbl1 on every column;
 
 showstats for table hbase."_CELL_".t028tbl1 on ROW_ID detail;
-showstats for table hbase."_CELL_".t028tbl1 on COL_FAMILAY detail;
+showstats for table hbase."_CELL_".t028tbl1 on COL_FAMILY detail;
 
 explain options 'f' select * from hbase."_CELL_".t028tbl1;
 explain options 'f' select * from hbase."_CELL_".t028tbl1 where col_family = 'cf1';