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/03/27 23:04:34 UTC
[1/3] incubator-trafodion git commit: [TRAFODION-2552] Use column
stats when SUBSTR takes a column prefix
Repository: incubator-trafodion
Updated Branches:
refs/heads/master 0c6089d7a -> d878a12ea
[TRAFODION-2552] Use column stats when SUBSTR takes a column prefix
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/66d837f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/66d837f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/66d837f1
Branch: refs/heads/master
Commit: 66d837f106db3ab27ca77f7ee331390d858cf851
Parents: 0c6089d
Author: Dave Birdsall <db...@apache.org>
Authored: Thu Mar 23 23:15:27 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Thu Mar 23 23:15:27 2017 +0000
----------------------------------------------------------------------
core/sql/optimizer/ItemExpr.cpp | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/66d837f1/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index 7d0007d..6e2d40b 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -1019,7 +1019,22 @@ NABoolean ItemExpr::referencesAHostVar() const
// should use stats to compute selectivity or use default selectivity
// Return TRUE if the expression is a VEG reference, base column,
// index column, column with CAST / UPPER / LOWER / UCASE /
-// LCASE / UPSHIFT / TRIM
+// LCASE / UPSHIFT / TRIM / SUBSTR (sometimes)
+//
+// Note that in the case of functions such as CAST and UPPER,
+// the stats returned are those of the argument. For a right TRIM
+// where we are trimming blanks, this is correct but for the
+// others the resulting stats will be incorrect in some way.
+// For example, UPPER maps characters to upper case, so the UECs
+// of the result should often be lower than the original, and
+// certain intervals (namely those encompassing values that begin
+// with a lower case letter) should be empty. For another
+// example, CAST often is a 1-to-1 transformation so the UECs
+// are right, but the order might change (e.g. when casting
+// numerics to characters; 99 < 100, but '99' > '100'). Even
+// so, the statistics of the argument are still a better reflection
+// of the result of the function than the default distribution,
+// particularly from the standpoint of skew. So, we use them.
NABoolean ItemExpr::useStatsForPred()
{
OperatorTypeEnum myType = getOperatorType();
@@ -1038,6 +1053,21 @@ NABoolean ItemExpr::useStatsForPred()
myType == ITM_CONVERT)
return TRUE;
+ else if (myType == ITM_SUBSTR)
+ {
+ // if the substring is known to be a prefix of the string,
+ // then use the stats
+ ItemExpr * startPosition = child(1);
+ if (startPosition->getOperatorType() == ITM_CONSTANT)
+ {
+ NABoolean negate = FALSE;
+ ConstValue * c = startPosition->castToConstValue(negate);
+ if (c->canGetApproximateNumericValue() &&
+ (c->getExactNumericValue() == 1))
+ return TRUE;
+ }
+ return FALSE;
+ }
else
return FALSE;
}
[2/3] incubator-trafodion git commit: Fix cut-and-paste error
Posted by db...@apache.org.
Fix cut-and-paste error
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/47e31f59
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/47e31f59
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/47e31f59
Branch: refs/heads/master
Commit: 47e31f59fd79590a9d100857e1343e10be36f7b0
Parents: 66d837f
Author: Dave Birdsall <db...@apache.org>
Authored: Sat Mar 25 21:34:56 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Sat Mar 25 21:34:56 2017 +0000
----------------------------------------------------------------------
core/sql/optimizer/ItemExpr.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/47e31f59/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index 6e2d40b..b45faae 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -1062,7 +1062,7 @@ NABoolean ItemExpr::useStatsForPred()
{
NABoolean negate = FALSE;
ConstValue * c = startPosition->castToConstValue(negate);
- if (c->canGetApproximateNumericValue() &&
+ if (c->canGetExactNumericValue() &&
(c->getExactNumericValue() == 1))
return TRUE;
}
[3/3] incubator-trafodion git commit: Merge [TRAFODION-2552] PR 1023
Use column stats for SUBSTR when possible
Posted by db...@apache.org.
Merge [TRAFODION-2552] PR 1023 Use column stats for SUBSTR when possible
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/d878a12e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/d878a12e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/d878a12e
Branch: refs/heads/master
Commit: d878a12ea0ac3dac5f17ac7f2a51d31d684bc355
Parents: 0c6089d 47e31f5
Author: Dave Birdsall <db...@apache.org>
Authored: Mon Mar 27 23:03:44 2017 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Mon Mar 27 23:03:44 2017 +0000
----------------------------------------------------------------------
core/sql/optimizer/ItemExpr.cpp | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------