You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2014/08/18 11:53:01 UTC
git commit: TAJO-1009: A binary eval for column references of the
same tables should not be recognized as a join condition.
Repository: tajo
Updated Branches:
refs/heads/master 057bc6d36 -> 96b6c2aad
TAJO-1009: A binary eval for column references of the same tables should not be recognized as a join condition.
Closes #121
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/96b6c2aa
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/96b6c2aa
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/96b6c2aa
Branch: refs/heads/master
Commit: 96b6c2aad76837c42d894b4aa217c6641e72ec86
Parents: 057bc6d
Author: Hyunsik Choi <hy...@apache.org>
Authored: Mon Aug 18 18:52:41 2014 +0900
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Mon Aug 18 18:52:41 2014 +0900
----------------------------------------------------------------------
CHANGES | 3 +++
.../apache/tajo/engine/eval/EvalTreeUtil.java | 23 +++++++++++++++++++-
.../tajo/engine/eval/TestEvalTreeUtil.java | 7 ++++++
3 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tajo/blob/96b6c2aa/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d09d4cf..17d87ce 100644
--- a/CHANGES
+++ b/CHANGES
@@ -112,6 +112,9 @@ Release 0.9.0 - unreleased
BUG FIXES
+ TAJO-1009: A binary eval for column references of the same tables
+ should not be recognized as a join condition. (hyunsik)
+
TAJO-985: Client API should be non-blocking. (jinho)
TAJO-1006: Fix wrong storage unit for kilo bytes and others. (hyunsik)
http://git-wip-us.apache.org/repos/asf/tajo/blob/96b6c2aa/tajo-core/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java b/tajo-core/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java
index 3921a7d..e6c27e1 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java
@@ -20,6 +20,7 @@ package org.apache.tajo.engine.eval;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+import org.apache.tajo.catalog.CatalogUtil;
import org.apache.tajo.catalog.Column;
import org.apache.tajo.catalog.Schema;
import org.apache.tajo.common.TajoDataTypes.DataType;
@@ -233,12 +234,23 @@ public class EvalTreeUtil {
/**
* If a given expression is join condition, it returns TRUE. Otherwise, it returns FALSE.
*
+ * If three conditions are satisfied, we can recognize the expression as a equi join condition.
+ * <ol>
+ * <li>An expression is an equal comparison expression.</li>
+ * <li>Both terms in an expression are column references.</li>
+ * <li>Both column references point come from different tables</li>
+ * </ol>
+ *
+ * For theta join condition, we will use "an expression is a predicate including column references which come
+ * from different two tables" instead of the first rule.
+ *
* @param expr EvalNode to be evaluated
* @param includeThetaJoin If true, it will return equi as well as non-equi join conditions.
* Otherwise, it only returns equi-join conditions.
* @return True if it is join condition.
*/
public static boolean isJoinQual(EvalNode expr, boolean includeThetaJoin) {
+
if (expr instanceof BinaryEval) {
boolean joinComparator;
if (includeThetaJoin) {
@@ -250,7 +262,16 @@ public class EvalTreeUtil {
BinaryEval binaryEval = (BinaryEval) expr;
boolean isBothTermFields = isSingleColumn(binaryEval.getLeftExpr()) && isSingleColumn(binaryEval.getRightExpr());
- return joinComparator && isBothTermFields;
+
+ String leftQualifier =
+ EvalTreeUtil.findUniqueColumns(binaryEval.getLeftExpr()).iterator().next().getQualifiedName();
+ String rightQualifier =
+ EvalTreeUtil.findUniqueColumns(binaryEval.getRightExpr()).iterator().next().getQualifiedName();
+
+ boolean isDifferentTables =
+ !(CatalogUtil.extractQualifier(leftQualifier).equals(CatalogUtil.extractQualifier(rightQualifier)));
+
+ return joinComparator && isBothTermFields && isDifferentTables;
} else {
return false;
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/96b6c2aa/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java b/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
index 2a37c9b..9000c18 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
@@ -58,6 +58,7 @@ import java.util.Set;
import static org.apache.tajo.TajoConstants.DEFAULT_TABLESPACE_NAME;
import static org.apache.tajo.common.TajoDataTypes.Type.INT4;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class TestEvalTreeUtil {
@@ -365,4 +366,10 @@ public class TestEvalTreeUtil {
assertTrue(result.contains(eval.getName()));
}
}
+
+ @Test
+ public final void testIsJoinQual() throws PlanningException {
+ EvalNode evalNode = getRootSelection("select score from people where people.score > people.age");
+ assertFalse(EvalTreeUtil.isJoinQual(evalNode, true));
+ }
}
\ No newline at end of file