trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [1/5] incubator-trafodion git commit: fix JIRA-1556
Date Fri, 30 Oct 2015 15:50:49 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 955a0c018 -> 2fffe3441


fix JIRA-1556


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

Branch: refs/heads/master
Commit: 298ddd42b938c687585b820135bdaf6ee0144244
Parents: 9937f92
Author: Qifan Chen <qfc@dev02.trafodion.org>
Authored: Thu Oct 29 14:50:58 2015 +0000
Committer: Qifan Chen <qfc@dev02.trafodion.org>
Committed: Thu Oct 29 14:50:58 2015 +0000

----------------------------------------------------------------------
 core/sql/optimizer/NAColumn.cpp         |  24 ++++
 core/sql/optimizer/NAColumn.h           |   3 +
 core/sql/optimizer/NAFileSet.cpp        |  14 ++
 core/sql/optimizer/NAFileSet.h          |   2 +
 core/sql/optimizer/OptPhysRelExpr.cpp   |  16 +--
 core/sql/regress/core/EXPECTED162       |   2 -
 core/sql/regress/hive/EXPECTED018       | 170 +++++++++++-----------
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp |   7 -
 core/sql/sqlcomp/nadefaults.cpp         |   6 +-
 core/sql/ustat/hs_cli.cpp               | 204 +++++++++++++++++----------
 10 files changed, 267 insertions(+), 181 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/298ddd42/core/sql/optimizer/NAColumn.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAColumn.cpp b/core/sql/optimizer/NAColumn.cpp
index 8814db8..98e678f 100644
--- a/core/sql/optimizer/NAColumn.cpp
+++ b/core/sql/optimizer/NAColumn.cpp
@@ -838,3 +838,27 @@ Int32 NAColumnArray::getColumnPosition(NAColumn& nc) const
   return -1;
 }
 
+NAString NAColumnArray::getColumnNamesAsString(char separator) const
+{
+   return getColumnNamesAsString(separator, entries());
+}
+
+NAString NAColumnArray::getColumnNamesAsString(char separator, UInt32 ct) const
+{
+  NAString nmList;
+
+  if ( ct == 0 )
+    return NAString();
+
+  if ( ct > entries() )
+    ct = entries();
+
+  for (CollIndex i = 0; i < ct-1; i++)
+  {
+     nmList += at(i)->getColName();
+     nmList += separator;
+  }
+     
+  nmList += at(ct-1)->getColName();
+  return nmList;
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/298ddd42/core/sql/optimizer/NAColumn.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAColumn.h b/core/sql/optimizer/NAColumn.h
index 46ab004..32a479d 100644
--- a/core/sql/optimizer/NAColumn.h
+++ b/core/sql/optimizer/NAColumn.h
@@ -633,6 +633,9 @@ public:
   // are deleted during alter table drop column.
   Lng32 getMaxTrafHbaseColQualifier() const;
 
+  NAString getColumnNamesAsString(char separator) const;
+  NAString getColumnNamesAsString(char separator, UInt32 ct) const;
+
 private:
 
   ARRAY(NABoolean) ascending_; // ignore for non-key or hash key columns

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/298ddd42/core/sql/optimizer/NAFileSet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAFileSet.cpp b/core/sql/optimizer/NAFileSet.cpp
index f54fc77..83d34a8 100644
--- a/core/sql/optimizer/NAFileSet.cpp
+++ b/core/sql/optimizer/NAFileSet.cpp
@@ -373,3 +373,17 @@ const QualifiedName& NAFileSet::getRandomPartition() const
     new (STMTHEAP) QualifiedName(nme->getPartitionName(), 3, STMTHEAP, NULL);
   return *partQName;
 }
+
+NAString NAFileSet::getBestPartitioningKeyColumns(char separator) const
+{
+   const NAColumnArray & partKeyCols = getPartitioningKeyColumns();
+
+   if ( partKeyCols.entries() > 0 ) {
+      return partKeyCols.getColumnNamesAsString(separator);
+   } else {
+      const NAColumnArray& allCols = getAllColumns();
+      UInt32 ct = allCols.entries();
+      if ( ct > 2 ) ct=2;
+      return allCols.getColumnNamesAsString(separator, ct);
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/298ddd42/core/sql/optimizer/NAFileSet.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAFileSet.h b/core/sql/optimizer/NAFileSet.h
index 1c59db0..04b4c0e 100644
--- a/core/sql/optimizer/NAFileSet.h
+++ b/core/sql/optimizer/NAFileSet.h
@@ -239,6 +239,8 @@ public:
   const NAColumnArray & getPartitioningKeyColumns() const
                                        { return partitioningKeyColumns_; }
 
+  NAString getBestPartitioningKeyColumns(char separator) const;
+
   PartitioningFunction * getPartitioningFunction() const
                                                      { return partFunc_; }
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/298ddd42/core/sql/optimizer/OptPhysRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/OptPhysRelExpr.cpp b/core/sql/optimizer/OptPhysRelExpr.cpp
index fc256c6..4cf496b 100644
--- a/core/sql/optimizer/OptPhysRelExpr.cpp
+++ b/core/sql/optimizer/OptPhysRelExpr.cpp
@@ -3432,14 +3432,14 @@ NABoolean NestedJoin::genLeftChildPartReq(
           physicalPartFunc = new(CmpCommon::statementHeap())
               Hash2PartitioningFunction (partKey, partKey, childNumPartsRequirement);
         }
-    }
-    else
-      // HBase tables can be updated in any way, no restrictions on 
-      // parallelism
-      if (numOfESPsForced && physicalPartFunc)
-        childNumPartsRequirement = numOfESPsForced;
-      else
-        createPartReqForChild = FALSE;
+     }
+     else
+        // HBase tables can be updated in any way, no restrictions on 
+        // parallelism
+        if (numOfESPsForced && physicalPartFunc)
+          childNumPartsRequirement = numOfESPsForced;
+        else
+          createPartReqForChild = FALSE;
     }
     else if (physicalPartFunc == NULL)
     {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/298ddd42/core/sql/regress/core/EXPECTED162
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/EXPECTED162 b/core/sql/regress/core/EXPECTED162
index c715ed1..176f3b7 100644
--- a/core/sql/regress/core/EXPECTED162
+++ b/core/sql/regress/core/EXPECTED162
@@ -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
 -------------
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/298ddd42/core/sql/regress/hive/EXPECTED018
----------------------------------------------------------------------
diff --git a/core/sql/regress/hive/EXPECTED018 b/core/sql/regress/hive/EXPECTED018
index 08c8ce5..65ea210 100644
--- a/core/sql/regress/hive/EXPECTED018
+++ b/core/sql/regress/hive/EXPECTED018
@@ -140,9 +140,9 @@ Task:  CLEANUP         Status: Started    Object: TRAFODION.HBASE.CUSTOMER_ADDRE
 Task:  CLEANUP         Status: Ended      Object: TRAFODION.HBASE.CUSTOMER_ADDRESS
 Task:  PREPARATION     Status: Started    Object: TRAFODION.HBASE.CUSTOMER_ADDRESS
        Rows Processed: 50000 
-Task:  PREPARATION     Status: Ended      ET: 00:00:06.355
+Task:  PREPARATION     Status: Ended      ET: 00:00:09.002
 Task:  COMPLETION      Status: Started    Object: TRAFODION.HBASE.CUSTOMER_ADDRESS
-Task:  COMPLETION      Status: Ended      ET: 00:00:00.271
+Task:  COMPLETION      Status: Ended      ET: 00:00:00.276
 
 --- 50000 row(s) loaded.
 >>--
@@ -171,9 +171,9 @@ Task:  CLEANUP         Status: Started    Object: TRAFODION.HBASE.CUSTOMER_DEMOG
 Task:  CLEANUP         Status: Ended      Object: TRAFODION.HBASE.CUSTOMER_DEMOGRAPHICS
 Task:  PREPARATION     Status: Started    Object: TRAFODION.HBASE.CUSTOMER_DEMOGRAPHICS
        Rows Processed: 20000 
-Task:  PREPARATION     Status: Ended      ET: 00:00:15.680
+Task:  PREPARATION     Status: Ended      ET: 00:00:14.699
 Task:  COMPLETION      Status: Started    Object: TRAFODION.HBASE.CUSTOMER_DEMOGRAPHICS
-Task:  COMPLETION      Status: Ended      ET: 00:00:00.329
+Task:  COMPLETION      Status: Ended      ET: 00:00:00.331
 
 --- 20000 row(s) loaded.
 >>--
@@ -203,7 +203,7 @@ Task:  CLEANUP         Status: Started    Object: TRAFODION.HBASE.CUSTOMER_DEMOG
 Task:  CLEANUP         Status: Ended      Object: TRAFODION.HBASE.CUSTOMER_DEMOGRAPHICS_SALT
 Task:  PREPARATION     Status: Started    Object: TRAFODION.HBASE.CUSTOMER_DEMOGRAPHICS_SALT
        Rows Processed: 20000 
-Task:  PREPARATION     Status: Ended      ET: 00:00:08.693
+Task:  PREPARATION     Status: Ended      ET: 00:00:09.416
 Task:  COMPLETION      Status: Started    Object: TRAFODION.HBASE.CUSTOMER_DEMOGRAPHICS_SALT
 Task:  COMPLETION      Status: Ended      ET: 00:00:00.288
 
@@ -225,9 +225,9 @@ Task:  CLEANUP         Status: Started    Object: TRAFODION.HBASE.CUSTOMER_SALT
 Task:  CLEANUP         Status: Ended      Object: TRAFODION.HBASE.CUSTOMER_SALT
 Task:  PREPARATION     Status: Started    Object: TRAFODION.HBASE.CUSTOMER_SALT
        Rows Processed: 100000 
-Task:  PREPARATION     Status: Ended      ET: 00:00:18.490
+Task:  PREPARATION     Status: Ended      ET: 00:00:12.736
 Task:  COMPLETION      Status: Started    Object: TRAFODION.HBASE.CUSTOMER_SALT
-Task:  COMPLETION      Status: Ended      ET: 00:00:00.300
+Task:  COMPLETION      Status: Ended      ET: 00:00:00.309
 
 --- 100000 row(s) loaded.
 >>--
@@ -256,9 +256,9 @@ Task:  CLEANUP         Status: Started    Object: TRAFODION.HBASE.STORE_SALES_SA
 Task:  CLEANUP         Status: Ended      Object: TRAFODION.HBASE.STORE_SALES_SALT
 Task:  PREPARATION     Status: Started    Object: TRAFODION.HBASE.STORE_SALES_SALT
        Rows Processed: 160756 
-Task:  PREPARATION     Status: Ended      ET: 00:00:32.781
+Task:  PREPARATION     Status: Ended      ET: 00:00:23.570
 Task:  COMPLETION      Status: Started    Object: TRAFODION.HBASE.STORE_SALES_SALT
-Task:  COMPLETION      Status: Ended      ET: 00:00:00.284
+Task:  COMPLETION      Status: Ended      ET: 00:00:00.264
 
 --- 160756 row(s) loaded.
 >>--
@@ -304,10 +304,10 @@ aaa5                                                          ?
 +>   select * from nulls;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.013
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.042
 Task:  EXTRACT         Status: Started
        Rows Processed: 6 
-Task:  EXTRACT         Status: Ended      ET: 00:00:01.228
+Task:  EXTRACT         Status: Ended      ET: 00:00:00.692
 
 --- 6 row(s) unloaded.
 >>select * from hive.hive.nulls order by a,b;
@@ -352,9 +352,9 @@ Task:  EMPTY TARGET    Status: Started
 Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.002
 Task:  EXTRACT         Status: Started
        Rows Processed: 50000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:04.327
+Task:  EXTRACT         Status: Ended      ET: 00:00:03.020
 Task:  MERGE FILES     Status: Started
-Task:  MERGE FILES     Status: Ended      ET: 00:00:00.066
+Task:  MERGE FILES     Status: Ended      ET: 00:00:00.082
 
 --- 50000 row(s) unloaded.
 >>log;
@@ -387,12 +387,12 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION         
 CARD
 +><<+ cardinality 10e10 >>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.003
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.002
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:01.041
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.018
 Task:  MERGE FILES     Status: Started
-Task:  MERGE FILES     Status: Ended      ET: 00:00:00.056
+Task:  MERGE FILES     Status: Ended      ET: 00:00:00.436
 
 --- 20000 row(s) unloaded.
 >>log;
@@ -411,12 +411,12 @@ cat /tmp/merged_customer_demogs | wc -l
 +><<+ cardinality 10e10 >>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.014
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.006
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:01.164
+Task:  EXTRACT         Status: Ended      ET: 00:00:00.909
 Task:  MERGE FILES     Status: Started
-Task:  MERGE FILES     Status: Ended      ET: 00:00:00.097
+Task:  MERGE FILES     Status: Ended      ET: 00:00:00.025
 
 --- 20000 row(s) unloaded.
 >>log;
@@ -451,9 +451,9 @@ Task:  EMPTY TARGET    Status: Started
 Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.002
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:12.782
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.537
 Task:  MERGE FILES     Status: Started
-Task:  MERGE FILES     Status: Ended      ET: 00:00:00.082
+Task:  MERGE FILES     Status: Ended      ET: 00:00:00.045
 
 --- 20000 row(s) unloaded.
 >>
@@ -471,12 +471,12 @@ regrhadoop.ksh fs -du -s /bulkload/customer_demographics_salt/merged_customer_de
 +><<+ cardinality 10e10 >>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.013
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.005
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:01.108
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.076
 Task:  MERGE FILES     Status: Started
-Task:  MERGE FILES     Status: Ended      ET: 00:00:00.089
+Task:  MERGE FILES     Status: Ended      ET: 00:00:00.048
 
 --- 20000 row(s) unloaded.
 >>
@@ -509,10 +509,10 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION         
 CARD
 +><<+ cardinality 10e10 >>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.014
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.006
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:07.157
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.563
 
 --- 20000 row(s) unloaded.
 >>
@@ -532,12 +532,12 @@ regrhadoop.ksh fs -ls /bulkload/customer_demographics_salt/file* | 
grep file |
 +><<+ cardinality 10e10 >>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.035
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.009
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:07.111
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.368
 Task:  MERGE FILES     Status: Started
-Task:  MERGE FILES     Status: Ended      ET: 00:00:00.079
+Task:  MERGE FILES     Status: Ended      ET: 00:00:00.040
 
 --- 20000 row(s) unloaded.
 >>
@@ -670,12 +670,12 @@ CD_DEMO_SK   CD_GENDER
 +><<+ cardinality 10e10 >>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.013
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.009
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:03.632
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.352
 Task:  MERGE FILES     Status: Started
-Task:  MERGE FILES     Status: Ended      ET: 00:00:00.087
+Task:  MERGE FILES     Status: Ended      ET: 00:00:00.036
 
 --- 20000 row(s) unloaded.
 >>log;
@@ -710,12 +710,12 @@ regrhadoop.ksh fs -ls /bulkload/customer_demographics_salt/merged* |
grep merge
 +><<+ cardinality 10e10 >>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.009
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.006
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:02.152
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.356
 Task:  MERGE FILES     Status: Started
-Task:  MERGE FILES     Status: Ended      ET: 00:00:00.087
+Task:  MERGE FILES     Status: Ended      ET: 00:00:00.045
 
 --- 20000 row(s) unloaded.
 >>
@@ -765,10 +765,10 @@ CD_DEMO_SK   CD_GENDER
 +><<+ cardinality 10e10 >>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.014
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.006
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:03.550
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.288
 
 --- 20000 row(s) unloaded.
 >>
@@ -818,7 +818,7 @@ Task:  EMPTY TARGET    Status: Started
 Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.002
 Task:  EXTRACT         Status: Started
        Rows Processed: 50000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:01.724
+Task:  EXTRACT         Status: Ended      ET: 00:00:02.101
 
 --- 50000 row(s) unloaded.
 >>
@@ -868,10 +868,10 @@ CA_ADDRESS_SK  CA_ADDRESS_ID
 +>select * from trafodion.hbase.customer_address ;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.013
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.006
 Task:  EXTRACT         Status: Started
        Rows Processed: 50000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:01.694
+Task:  EXTRACT         Status: Ended      ET: 00:00:02.239
 
 --- 50000 row(s) unloaded.
 >>
@@ -930,10 +930,10 @@ CA_ADDRESS_SK  CA_ADDRESS_ID
 +>select * from trafodion.hbase.customer_salt;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.003
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.004
 Task:  EXTRACT         Status: Started
        Rows Processed: 100000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:05.411
+Task:  EXTRACT         Status: Ended      ET: 00:00:06.196
 
 --- 100000 row(s) unloaded.
 >>select count(*) from hive.hive.unload_customer;
@@ -983,10 +983,10 @@ C_CUSTOMER_SK  C_CUSTOMER_ID
 +>select * from trafodion.hbase.customer_demographics_salt;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.033
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.009
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:01.680
+Task:  EXTRACT         Status: Ended      ET: 00:00:00.915
 
 --- 20000 row(s) unloaded.
 >>
@@ -1036,12 +1036,12 @@ CD_DEMO_SK   CD_GENDER
 +>select * from trafodion.hbase.customer_address where ca_address_sk < 100;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.014
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.005
 Task:  EXTRACT         Status: Started
        Rows Processed: 99 
-Task:  EXTRACT         Status: Ended      ET: 00:00:00.229
+Task:  EXTRACT         Status: Ended      ET: 00:00:00.233
 Task:  MERGE FILES     Status: Started
-Task:  MERGE FILES     Status: Ended      ET: 00:00:00.601
+Task:  MERGE FILES     Status: Ended      ET: 00:00:00.025
 
 --- 99 row(s) unloaded.
 >>
@@ -1077,10 +1077,10 @@ regrhadoop.ksh fs -rm /user/hive/exttables/unload_customer_demographics/*
 +>select ss_sold_date_sk,ss_store_sk, sum (ss_quantity) from store_sales_salt group by
 ss_sold_date_sk ,ss_store_sk;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.003
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.004
 Task:  EXTRACT         Status: Started
        Rows Processed: 12349 
-Task:  EXTRACT         Status: Ended      ET: 00:00:09.045
+Task:  EXTRACT         Status: Ended      ET: 00:00:06.595
 
 --- 12349 row(s) unloaded.
 >>
@@ -1202,7 +1202,7 @@ Task:  EMPTY TARGET    Status: Started
 Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.002
 Task:  EXTRACT         Status: Started
        Rows Processed: 100000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:05.778
+Task:  EXTRACT         Status: Ended      ET: 00:00:08.539
 
 --- 100000 row(s) unloaded.
 >>
@@ -1250,10 +1250,10 @@ C_CUSTOMER_SK  C_CUSTOMER_ID
 +>select * from customer_address where ca_address_sk < 1000 union select * from customer_address
where ca_address_sk > 40000  and ca_address_sk < 41000;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.016
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.007
 Task:  EXTRACT         Status: Started
        Rows Processed: 1998 
-Task:  EXTRACT         Status: Ended      ET: 00:00:00.656
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.029
 
 --- 1998 row(s) unloaded.
 >>
@@ -1364,7 +1364,7 @@ ESP_EXCHANGE ==============================  SEQ_NO 3        ONLY CHILD
2
   use_snapshot_scan ...... TRUE
   full_table_name ........ TRAFODION.HBASE.CUSTOMER_DEMOGRAPHICS_SALT
   snapshot_name .......... TRAFODION.HBASE.CUSTOMER_DEMOGRAPHICS_SALT_SNAP111
-  snapshot_temp_location   /bulkload/20150521211646/
+  snapshot_temp_location   /bulkload/20151029081911/
 grep -i -e 'explain reg' -e snapshot -e full_table_name  -e esp_exchange  LOG018_REGULAR_SCAN_PLAN.TXT
| grep -v snapshot_scan_run_id
 >>--no snapshot
 >>explain reg;
@@ -1444,7 +1444,7 @@ grep -i -e 'explain snp' -e snapshot -e full_table_name -e esp_exchange
LOG018_S
   use_snapshot_scan ...... TRUE
   full_table_name ........ TRAFODION.HBASE.CUSTOMER_ADDRESS
   snapshot_name .......... TRAFODION.HBASE.CUSTOMER_ADDRESS_SNAP111
-  snapshot_temp_location   /bulkload/20150521211805/
+  snapshot_temp_location   /bulkload/20151029082021/
 grep -i -e 'explain reg' -e snapshot -e full_table_name  -e esp_exchange  LOG018_REGULAR_SCAN_PLAN.TXT
| grep -v snapshot_scan_run_id
 >>--no snapshot
 >>explain reg;
@@ -1526,11 +1526,11 @@ grep -i -e 'explain snp' -e snapshot -e full_table_name -e esp_exchange
LOG018_S
   use_snapshot_scan ...... TRUE
   full_table_name ........ TRAFODION.HBASE.CUSTOMER_SALT
   snapshot_name .......... TRAFODION.HBASE.CUSTOMER_SALT_SNAP111
-  snapshot_temp_location   /bulkload/20150521211936/
+  snapshot_temp_location   /bulkload/20151029082045/
   use_snapshot_scan ...... TRUE
   full_table_name ........ TRAFODION.HBASE.CUSTOMER_ADDRESS
   snapshot_name .......... TRAFODION.HBASE.CUSTOMER_ADDRESS_SNAP111
-  snapshot_temp_location   /bulkload/20150521211936/
+  snapshot_temp_location   /bulkload/20151029082045/
 grep -i -e 'explain reg' -e snapshot -e full_table_name  -e esp_exchange  LOG018_REGULAR_SCAN_PLAN.TXT
| grep -v snapshot_scan_run_id
 >>--no snapshot
 >>explain reg;
@@ -1636,13 +1636,13 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION       
   CARD
 +><<+ cardinality 10e10 >>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.016
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.005
 Task:  VERIFY SNAPSHO  Status: Started
        Snapshots verified: 1 
-Task:  VERIFY SNAPSHO  Status: Ended      ET: 00:00:00.304
+Task:  VERIFY SNAPSHO  Status: Ended      ET: 00:00:00.331
 Task:  EXTRACT         Status: Started
        Rows Processed: 50000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:18.460
+Task:  EXTRACT         Status: Ended      ET: 00:00:03.160
 
 --- 50000 row(s) unloaded.
 >>
@@ -1656,8 +1656,6 @@ Task:  EXTRACT         Status: Ended      ET: 00:00:18.460
 --- 1 row(s) selected.
 >>select [first 20] * from hive.hive.unload_customer_address  where ca_address_sk <
100 order by ca_address_sk;
 
-*** WARNING[6008] Statistics for column (CA_ADDRESS_SK) from table HIVE.HIVE.UNLOAD_CUSTOMER_ADDRESS
were not available. As a result, the access path chosen might not be the best possible.
-
 CA_ADDRESS_SK  CA_ADDRESS_ID                                                            
                            CA_STREET_NUMBER                                             
                                        CA_STREET_NAME                                   
                                                    CA_STREET_TYPE                       
                                                                CA_SUITE_NUMBER          
                                                                            CA_CITY      
                                                                                        CA_COUNTY
                                                                                         
  CA_STATE                                                                               
              CA_ZIP                                                                     
                          CA_COUNTRY                                                     

                                       CA_GMT_OFFSET    CA_LOCATION_TYPE
 -------------  ----------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------------
 ----------------------------------------------------------------
 ------------------------------------  ---------------  ----------------------------------------------------------------------------------------------------
 
@@ -1707,13 +1705,13 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION       
   CARD
 +>select * from trafodion.hbase.customer_demographics_salt <<+ cardinality 10e10
>>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.003
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.002
 Task:  VERIFY SNAPSHO  Status: Started
        Snapshots verified: 1 
-Task:  VERIFY SNAPSHO  Status: Ended      ET: 00:00:00.299
+Task:  VERIFY SNAPSHO  Status: Ended      ET: 00:00:00.323
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:01:03.769
+Task:  EXTRACT         Status: Ended      ET: 00:00:02.389
 
 --- 20000 row(s) unloaded.
 >>
@@ -1761,16 +1759,16 @@ CD_DEMO_SK   CD_GENDER
 +>select * from trafodion.hbase.customer_demographics_salt <<+ cardinality 10e10
>>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.029
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.007
 Task:  CREATE SNAPSHO  Status: Started
        Snapshots created: 1 
-Task:  CREATE SNAPSHO  Status: Ended      ET: 00:00:00.913
+Task:  CREATE SNAPSHO  Status: Ended      ET: 00:00:00.671
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:02.949
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.856
 Task:  DELETE SNAPSHO  Status: Started
        Snapshots deleted: 1 
-Task:  DELETE SNAPSHO  Status: Ended      ET: 00:00:00.014
+Task:  DELETE SNAPSHO  Status: Ended      ET: 00:00:00.016
 
 --- 20000 row(s) unloaded.
 >>
@@ -1818,16 +1816,16 @@ CD_DEMO_SK   CD_GENDER
 +>select * from trafodion.hbase.customer_demographics_salt <<+ cardinality 10e10
>>;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.028
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.011
 Task:  CREATE SNAPSHO  Status: Started
        Snapshots created: 1 
-Task:  CREATE SNAPSHO  Status: Ended      ET: 00:00:00.887
+Task:  CREATE SNAPSHO  Status: Ended      ET: 00:00:01.767
 Task:  EXTRACT         Status: Started
        Rows Processed: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:03.434
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.408
 Task:  DELETE SNAPSHO  Status: Started
        Snapshots deleted: 1 
-Task:  DELETE SNAPSHO  Status: Ended      ET: 00:00:00.008
+Task:  DELETE SNAPSHO  Status: Ended      ET: 00:00:00.006
 
 --- 20000 row(s) unloaded.
 >>
@@ -1876,16 +1874,16 @@ CD_DEMO_SK   CD_GENDER
 +>select * from customer_address where ca_address_sk < 1000 union select * from customer_address
where ca_address_sk > 40000  and ca_address_sk < 41000;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.023
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.004
 Task:  CREATE SNAPSHO  Status: Started
        Snapshots created: 1 
-Task:  CREATE SNAPSHO  Status: Ended      ET: 00:00:00.708
+Task:  CREATE SNAPSHO  Status: Ended      ET: 00:00:00.581
 Task:  EXTRACT         Status: Started
        Rows Processed: 1998 
-Task:  EXTRACT         Status: Ended      ET: 00:00:00.999
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.470
 Task:  DELETE SNAPSHO  Status: Started
        Snapshots deleted: 1 
-Task:  DELETE SNAPSHO  Status: Ended      ET: 00:00:00.010
+Task:  DELETE SNAPSHO  Status: Ended      ET: 00:00:00.005
 
 --- 1998 row(s) unloaded.
 >>
@@ -1960,16 +1958,16 @@ CA_ADDRESS_SK  CA_ADDRESS_ID
 +>select * from trafodion.hbase.customer_salt c join trafodion.hbase.customer_address
ca on c.c_current_addr_sk = ca.ca_address_sk ;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.014
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.005
 Task:  CREATE SNAPSHO  Status: Started
        Snapshots created: 2 
-Task:  CREATE SNAPSHO  Status: Ended      ET: 00:00:02.803
+Task:  CREATE SNAPSHO  Status: Ended      ET: 00:00:02.995
 Task:  EXTRACT         Status: Started
        Rows Processed: 100000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:07.221
+Task:  EXTRACT         Status: Ended      ET: 00:00:10.049
 Task:  DELETE SNAPSHO  Status: Started
        Snapshots deleted: 2 
-Task:  DELETE SNAPSHO  Status: Ended      ET: 00:00:00.017
+Task:  DELETE SNAPSHO  Status: Ended      ET: 00:00:00.009
 
 --- 100000 row(s) unloaded.
 >>
@@ -2030,16 +2028,16 @@ LC   RC   OP   OPERATOR              OPT       DESCRIPTION       
   CARD
 +>select c_first_name,c_last_name from trafodion.hbase.customer_salt;
 Task: UNLOAD           Status: Started
 Task:  EMPTY TARGET    Status: Started
-Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.004
+Task:  EMPTY TARGET    Status: Ended      ET: 00:00:00.008
 Task:  CREATE SNAPSHO  Status: Started
        Snapshots created: 1 
-Task:  CREATE SNAPSHO  Status: Ended      ET: 00:00:00.609
+Task:  CREATE SNAPSHO  Status: Ended      ET: 00:00:00.637
 Task:  EXTRACT         Status: Started
        Rows Processed: 100000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:02.499
+Task:  EXTRACT         Status: Ended      ET: 00:00:03.948
 Task:  DELETE SNAPSHO  Status: Started
        Snapshots deleted: 1 
-Task:  DELETE SNAPSHO  Status: Ended      ET: 00:00:00.010
+Task:  DELETE SNAPSHO  Status: Ended      ET: 00:00:00.007
 
 --- 100000 row(s) unloaded.
 >>
@@ -2112,7 +2110,7 @@ unload with delimiter 0 into '/bulkload/test' select * from CUSTOMER_ADDRESS;
 Task: UNLOAD           Status: Started
 Task:  EXTRACT         Status: Started
        Rows Processed: 50000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:01.783
+Task:  EXTRACT         Status: Ended      ET: 00:00:02.385
 
 --- 50000 row(s) unloaded.
 >>--unload  24 -- should give an error
@@ -2177,7 +2175,7 @@ regrhadoop.ksh fs -rm /user/hive/exttables/unload_customer_demographics/*
 Task: UNLOAD           Status: Started
 Task:  EXTRACT         Status: Started
        Rows Processed but NOT Written to Disk: 20000 
-Task:  EXTRACT         Status: Ended      ET: 00:00:00.480
+Task:  EXTRACT         Status: Ended      ET: 00:00:01.063
 
 --- 20000 row(s) unloaded.
 >>select count(*) from hive.hive.unload_customer_demographics;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/298ddd42/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 6fe3fbc..5789c13 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -318,13 +318,6 @@ void CmpSeabaseDDL::createSeabaseTableLike(
       return;
     }
 
-  if (createTableNode->getSaltOptions())
-    {
-      *CmpCommon::diags() << DgSqlCode(-3111)
-                          << DgString0("SALT");
-      return;
-    }
-
   ParDDLLikeOptsCreateTable &likeOptions = createTableNode->getLikeOptions();
   
   char * buf = NULL;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/298ddd42/core/sql/sqlcomp/nadefaults.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/nadefaults.cpp b/core/sql/sqlcomp/nadefaults.cpp
index 3f2f0b9..f2e9467 100644
--- a/core/sql/sqlcomp/nadefaults.cpp
+++ b/core/sql/sqlcomp/nadefaults.cpp
@@ -1876,7 +1876,10 @@ SDDkwd__(EXE_DIAGNOSTIC_EVENTS,		"OFF"),
   DDflt_0_1(HIST_DEFAULT_SEL_FOR_LIKE_WILDCARD,	"0.10"),
   DDflt_0_1(HIST_DEFAULT_SEL_FOR_PRED_EQUAL,	"0.01"),
   DDflt_0_1(HIST_DEFAULT_SEL_FOR_PRED_RANGE,	"0.3333"),
+
+  // control the amount of data in each partition of the persistent sample tble.
   DDflt1_(HIST_FETCHCOUNT_SCRATCH_VOL_THRESHOLD, "10240000"),
+
   DDkwd__(HIST_FREQ_VALS_NULL_FIX,              "ON"),
   DDkwd__(HIST_INCLUDE_SKEW_FOR_NON_INNER_JOIN,      "ON"),
   DDkwd__(HIST_INTERMEDIATE_REDUCTION,      "OFF"),
@@ -1932,7 +1935,8 @@ SDDkwd__(EXE_DIAGNOSTIC_EVENTS,		"OFF"),
  XDDflt1_(HIST_ROWCOUNT_REQUIRING_STATS,        "50000"),
   DDflt0_(HIST_SAME_TABLE_PRED_REDUCTION,       "0.0"),
   DDvol__(HIST_SCRATCH_VOL,                     ""),
-  DDflt1_(HIST_SCRATCH_VOL_THRESHOLD,           "104857600"),
+  // control the amount of data in each partition of the sample tble.
+  DDflt1_(HIST_SCRATCH_VOL_THRESHOLD,           "10240000"),
   DDflt_0_1(HIST_SKEW_COST_ADJUSTMENT,            "0.2"),
   DDkwd__(HIST_SKIP_MC_FOR_NONKEY_JOIN_COLUMNS,   "OFF"),
   DDui___(HIST_TUPLE_FREQVAL_LIST_THRESHOLD,     "40"),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/298ddd42/core/sql/ustat/hs_cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_cli.cpp b/core/sql/ustat/hs_cli.cpp
index 982b47d..4761796 100644
--- a/core/sql/ustat/hs_cli.cpp
+++ b/core/sql/ustat/hs_cli.cpp
@@ -544,7 +544,10 @@ Lng32 HSSample::create(NAString& tblName, NABoolean unpartitioned,
NABoolean isP
     // 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 created
     // like ET.
-    if ( HSGlobalsClass::isNativeCat(objDef->getCatName(HSTableDef::EXTERNAL_FORMAT)))
{
+    NABoolean isNativeTable =  
+      HSGlobalsClass::isNativeCat(objDef->getCatName(HSTableDef::EXTERNAL_FORMAT));
+
+    if ( isNativeTable ) {
       userTabName = ComConvertNativeNameToTrafName(
                       objDef->getCatName(HSTableDef::EXTERNAL_FORMAT),
                       objDef->getSchemaName(HSTableDef::EXTERNAL_FORMAT),
@@ -558,7 +561,11 @@ Lng32 HSSample::create(NAString& tblName, NABoolean unpartitioned,
NABoolean isP
 
     if (objDef->getObjectFormat() == SQLMX)
       {
-        tableOptions = " WITH PARTITIONS";
+        
+        // Do not emit the WITH PARTITIONS clause for native table. 
+        // Rather, the SALT USING clause will be used. 
+        if ( !isNativeTable ) 
+           tableOptions = " WITH PARTITIONS";
         // If a transaction is running, the table needs to be created as audited.
         // Otherwise, create table as non-audited.
         if (TM->InTransaction())
@@ -5130,9 +5137,9 @@ NAString HSSample::getTempTablePartitionInfo(NABoolean unpartitionedSample,
     // 4. The table is an hbase table.
     // In any of these case, the sample table will be single partitioned.
     if (objDef->getObjectFormat() == SQLMP
-             // Set by HSTableDef::getLabelInfo().
+        // Set by HSTableDef::getLabelInfo().
         || (usePOS == FALSE && userDefinedScratchVols == FALSE)
-        || (HSGlobalsClass::isHbaseCat(objDef->getCatName())))
+        || HSGlobalsClass::isTrafodionCatalog(objDef->getCatName()) )
      {
         numPartitionsNeeded = 1;
 
@@ -5144,93 +5151,136 @@ NAString HSSample::getTempTablePartitionInfo(NABoolean unpartitionedSample,
           }
       }
     else
-      {
-        numPartitionsNeeded = (Lng32) ceil((double)sampleRowCount
+     // if the table is a native HBase or Hive table
+     if ( HSGlobalsClass::isNativeCat(objDef->getCatName()) )
+     {
+
+           usePOS = FALSE;
+
+           numPartitionsNeeded = (Lng32) ceil((double)sampleRowCount
                                                      *
                                            objDef->getRecordLength()
                                                      /
                                            scratchVolThreshold
                                          );
 
+           NADefaults &defs = CmpCommon::context()->schemaDB_->getDefaults();
 
-        // For both IUS and RUS, make sure the number of partitions of the source table
-        // is a multiple of numPartitionsNeeded.
-        if ( CmpCommon::getDefault(USTAT_USE_GROUPING_FOR_SAMPLING) == DF_ON )
-        {
+           NABoolean fakeEnv= FALSE;
+           ComUInt32 numConfiguredESPs = defs.getTotalNumOfESPsInCluster(fakeEnv);
 
-          Lng32 tblPartns = objDef->getNumPartitions();
+           numPartitionsNeeded = MINOF(numConfiguredESPs, numPartitionsNeeded);
+           numPartitionsNeeded = MAXOF(1, numPartitionsNeeded);
 
-          if ( tblPartns < numPartitionsNeeded )
-            numPartitionsNeeded = tblPartns;
+           LM->Log("SYSKEY primary key.");
 
-          if ( numPartitionsNeeded > 0 )
-            while ( tblPartns % numPartitionsNeeded != 0 )
-              numPartitionsNeeded++;
+           snprintf(LM->msg, sizeof(LM->msg), "Partitions Needed: %d (TableType=%s,
~SampleSet=%d, RecLen=%d, threshold=%d)"
+                            , numPartitionsNeeded
+                            , "NATIVE"
+                            , (Lng32)sampleRowCount
+                            , (Lng32)objDef->getRecordLength()
+                            , scratchVolThreshold);
+  
+           LM->Log(LM->msg);
 
-          // Force to take the default code path of local node POS mode
-          // (which is identical to multi-node POS for SQ) to set the number of
-          // partitions for POS. That is, the # of partns of the sample table
-          // is specified via CQD POS_NUM_OF_PARTNS.
-          usePOSMultiNode = FALSE;
-          usePOSLocalNodeWithTableSize = FALSE;
+           if ( numPartitionsNeeded > 1 ) {
+               tableOptions +=" salt using ";
+               snprintf(tempStr, sizeof(tempStr), "%d", numPartitionsNeeded);
+               tableOptions += tempStr;
+               tableOptions +=" partitions on( ";
+               NAFileSet *naSet = objDef->getNATable()->getClusteringIndex();
+               tableOptions +=  naSet->getBestPartitioningKeyColumns(',');
+               tableOptions +=" ) ";
+           }
 
-        } else
-        {
+           return tableOptions;
 
-        // part of fix/workaround to bugzilla 2784: we need to guard against
-        // partitioning the sample table in a way that mxcmp is unable to
-        // generate a parallel plan for the sideinsert to populate it.
-        // For now, choosing numPartitionsNeeded to be even is safe.
-        if (((numPartitionsNeeded % 2) != 0) AND (numPartitionsNeeded > 1))
-          --numPartitionsNeeded;
-
-        // If POS is going to be uzed, there are 3 possibilities
-        // 1. estimated Number of partitions of sample table is less than
-        // number of partitions on local node, assuming each partition holds
-        // at most HIST_SCRATCH_VOL_THRESHOLD/HIST_FETCHCOUNT_SCRATCH_VOL_THRESHOLD
-        // (100MB/10MB is defaul) bytes of data.
-        // In this case we set POS to LOCAL_NODE and create exactly as many
-        // partitions as needed.
-        // 2. If case 1. is not true, (i.e. data in sample table will not fit on
-        // node, if we have HIST_SCRATCH_VOL_THRESHOLD/HIST_FETCHCOUNT_SCRATCH_VOL_THRESHOLD
-        // bytes of data in each partition and 1 partition per disk) we heuristically
-        // multiply HIST_SCRATCH_VOL_THRESHOLD/HIST_FETCHCOUNT_SCRATCH_VOL_THRESHOLD
-        // by 3 and see if the sample table will now fit in the local node. If it
-        // does we set POS to LOCAL_NODE and provide POS with the sample table size.
-        // POS will create one partition in each disk on the local node and automatically
-        // adjust the extent size based on the sample table size. If the number of partitions
-        // in the source table is less than or equal to the number of partitions in the local
-        // node we choose this option too as we do not want the sample table to have more
partitions
-        // than the base table.
-        // 3. If the sample table will not fit in the local node even when
-        // HIST_SCRATCH_VOL_THRESHOLD is multiplied by 3, then we set POS to MULTI_NODE and
-        // provide it with the sample table size. POS will create a sample table
-        // with one partition in each available disk in the multi-node with the appropriate
-        // extent size based on sample table size.
-
-        NAString *localNodeName = getLocalNodeName();
-        NodeToCpuVolMapDB *volumeCache = ActiveSchemaDB()->getNodeToCpuVolMapDB();
-        Lng32 numVolsInLocalNode = volumeCache->getTotalNumOfVols(localNodeName);
-        if ( (numVolsInLocalNode > 0) &&
-             (numPartitionsNeeded > numVolsInLocalNode))
-        {
-          if ((numPartitionsNeeded < 3*numVolsInLocalNode) ||
-              (objDef->getNumPartitions() <= numVolsInLocalNode))
-          {
-            usePOSLocalNodeWithTableSize = TRUE;
-            numPartitionsNeeded = numVolsInLocalNode;
-          }
-          else
-            usePOSMultiNode = TRUE ;
+        } else {
 
-            sampleTableSizeInMB = (Lng32) ceil((double)sampleRowCount
-                                                           *
-                                               objDef->getRecordLength()
-                                                           /
-                                                     MB_IN_BYTES);
-        }
-       } // end of not IUS
-      }
+           numPartitionsNeeded = (Lng32) ceil((double)sampleRowCount
+                                                     *
+                                           objDef->getRecordLength()
+                                                     /
+                                           scratchVolThreshold
+                                         );
+
+           // For both IUS and RUS, make sure the number of partitions of the source table
+           // is a multiple of numPartitionsNeeded.
+           if ( CmpCommon::getDefault(USTAT_USE_GROUPING_FOR_SAMPLING) == DF_ON )
+           {
+   
+             Lng32 tblPartns = objDef->getNumPartitions();
+   
+             if ( tblPartns < numPartitionsNeeded )
+               numPartitionsNeeded = tblPartns;
+   
+             if ( numPartitionsNeeded > 0 )
+               while ( tblPartns % numPartitionsNeeded != 0 )
+                 numPartitionsNeeded++;
+   
+             // Force to take the default code path of local node POS mode
+             // (which is identical to multi-node POS for SQ) to set the number of
+             // partitions for POS. That is, the # of partns of the sample table
+             // is specified via CQD POS_NUM_OF_PARTNS.
+             usePOSMultiNode = FALSE;
+             usePOSLocalNodeWithTableSize = FALSE;
+   
+           } else {
+   
+           // part of fix/workaround to bugzilla 2784: we need to guard against
+           // partitioning the sample table in a way that mxcmp is unable to
+           // generate a parallel plan for the sideinsert to populate it.
+           // For now, choosing numPartitionsNeeded to be even is safe.
+           if (((numPartitionsNeeded % 2) != 0) AND (numPartitionsNeeded > 1))
+             --numPartitionsNeeded;
+   
+           // If POS is going to be uzed, there are 3 possibilities
+           // 1. estimated Number of partitions of sample table is less than
+           // number of partitions on local node, assuming each partition holds
+           // at most HIST_SCRATCH_VOL_THRESHOLD/HIST_FETCHCOUNT_SCRATCH_VOL_THRESHOLD
+           // (100MB/10MB is defaul) bytes of data.
+           // In this case we set POS to LOCAL_NODE and create exactly as many
+           // partitions as needed.
+           // 2. If case 1. is not true, (i.e. data in sample table will not fit on
+           // node, if we have HIST_SCRATCH_VOL_THRESHOLD/HIST_FETCHCOUNT_SCRATCH_VOL_THRESHOLD
+           // bytes of data in each partition and 1 partition per disk) we heuristically
+           // multiply HIST_SCRATCH_VOL_THRESHOLD/HIST_FETCHCOUNT_SCRATCH_VOL_THRESHOLD
+           // by 3 and see if the sample table will now fit in the local node. If it
+           // does we set POS to LOCAL_NODE and provide POS with the sample table size.
+           // POS will create one partition in each disk on the local node and automatically
+           // adjust the extent size based on the sample table size. If the number of partitions
+           // in the source table is less than or equal to the number of partitions in the
local
+           // node we choose this option too as we do not want the sample table to have more
partitions
+           // than the base table.
+           // 3. If the sample table will not fit in the local node even when
+           // HIST_SCRATCH_VOL_THRESHOLD is multiplied by 3, then we set POS to MULTI_NODE
and
+           // provide it with the sample table size. POS will create a sample table
+           // with one partition in each available disk in the multi-node with the appropriate
+           // extent size based on sample table size.
+   
+           NAString *localNodeName = getLocalNodeName();
+           NodeToCpuVolMapDB *volumeCache = ActiveSchemaDB()->getNodeToCpuVolMapDB();
+           Lng32 numVolsInLocalNode = volumeCache->getTotalNumOfVols(localNodeName);
+           if ( (numVolsInLocalNode > 0) &&
+                (numPartitionsNeeded > numVolsInLocalNode))
+           {
+             if ((numPartitionsNeeded < 3*numVolsInLocalNode) ||
+                 (objDef->getNumPartitions() <= numVolsInLocalNode))
+             {
+               usePOSLocalNodeWithTableSize = TRUE;
+               numPartitionsNeeded = numVolsInLocalNode;
+             }
+             else
+               usePOSMultiNode = TRUE ;
+   
+               sampleTableSizeInMB = (Lng32) ceil((double)sampleRowCount
+                                                              *
+                                                  objDef->getRecordLength()
+                                                              /
+                                                        MB_IN_BYTES);
+           }
+          } // end of USTAT_USE_GROUPING_FOR_SAMPLING is OFF
+     } // end of non hive tables
                                    /*=========================================*/
                                    /*   FLOAT PRIMARY KEY - NO PARTITIONING   */
                                    /*=========================================*/



Mime
View raw message