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 2017/04/05 23:19:49 UTC
[1/2] incubator-trafodion git commit: [TRAFODION-2575] Truncate long
strings when computing USTAT aggregates
Repository: incubator-trafodion
Updated Branches:
refs/heads/master 8de588865 -> 48c7c608c
[TRAFODION-2575] Truncate long strings when computing USTAT aggregates
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/ca7c9c58
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/ca7c9c58
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/ca7c9c58
Branch: refs/heads/master
Commit: ca7c9c589eb01497ed7b24a83da812a75361999f
Parents: a955827
Author: Dave Birdsall <db...@apache.org>
Authored: Tue Apr 4 21:14:47 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Tue Apr 4 21:14:47 2017 +0000
----------------------------------------------------------------------
core/sql/ustat/hs_globals.cpp | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ca7c9c58/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index 243e3d0..d459dff 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -5780,6 +5780,13 @@ Lng32 HSGlobalsClass::CollectStatistics()
//We must use TRANSLATE to convert non-unicode character strings
//to unicode
NABoolean isVarChar = group->computeAvgVarCharSize();
+ // For long character strings, we'll truncate (trading off some
+ // UEC accuracy for performance and also avoiding engine bugs
+ // pertaining to very long varchars).
+ HSColumnStruct &col = group->colSet[0];
+ bool isOverSized = DFS2REC::isAnyCharacter(col.datatype) &&
+ (col.length > maxCharColumnLengthInBytes);
+
if (isVarChar)
*group->clistr = "SELECT FMTVAL, SUMVAL, AVGVAL FROM (SELECT ";
else
@@ -5794,8 +5801,7 @@ Lng32 HSGlobalsClass::CollectStatistics()
}
else
group->clistr->append(", COUNT(*) FROM ");
- group->clistr->append(hssample_table->data());
-
+
Int64 hintRowCount = 0;
if (sampleTableUsed)
@@ -5809,7 +5815,31 @@ Lng32 HSGlobalsClass::CollectStatistics()
char cardHint[50];
sprintf(cardHint, " <<+ cardinality %e >> ", (double)hintRowCount);
- group->clistr->append(cardHint);
+
+ if (isOverSized)
+ {
+ // Stick in a nested select that truncates the string.
+ // We have to do it here so the truncated string is
+ // the grouping column below.
+ char temp[20]; // long enough for 32-bit integer
+ sprintf(temp,"%d",maxCharColumnLengthInBytes);
+
+ group->clistr->append("(SELECT SUBSTR(");
+ group->clistr->append(columnName.data());
+ group->clistr->append(" FOR ");
+ group->clistr->append(temp);
+ group->clistr->append(") AS ");
+ group->clistr->append(columnName.data());
+ group->clistr->append(" FROM ");
+ group->clistr->append(hssample_table->data());
+ group->clistr->append(cardHint);
+ group->clistr->append(") AS T1");
+ }
+ else
+ {
+ group->clistr->append(hssample_table->data());
+ group->clistr->append(cardHint);
+ }
group->clistr->append(" GROUP BY ");
group->clistr->append(columnName.data());
[2/2] incubator-trafodion git commit: Merge [TRAFODION-2575] PR 1044
Truncate long strings when doing USTAT aggs
Posted by db...@apache.org.
Merge [TRAFODION-2575] PR 1044 Truncate long strings when doing USTAT aggs
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/48c7c608
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/48c7c608
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/48c7c608
Branch: refs/heads/master
Commit: 48c7c608c0b4c219c33a425675e5315e50c8deb7
Parents: 8de5888 ca7c9c5
Author: Dave Birdsall <db...@apache.org>
Authored: Wed Apr 5 23:19:00 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Wed Apr 5 23:19:00 2017 +0000
----------------------------------------------------------------------
core/sql/ustat/hs_globals.cpp | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------