You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ch...@apache.org on 2016/08/10 02:01:32 UTC

[1/2] incubator-carbondata git commit: Fixed right/left join query with filters are not working

Repository: incubator-carbondata
Updated Branches:
  refs/heads/master 2f56377cd -> 9d09cfcc9


Fixed right/left join query with filters are not working


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

Branch: refs/heads/master
Commit: 605e8d840ae8c1e8d7a0ca3cd9273de018550110
Parents: 2f56377
Author: ravipesala <ra...@gmail.com>
Authored: Tue Aug 9 23:57:50 2016 +0530
Committer: ravipesala <ra...@gmail.com>
Committed: Tue Aug 9 23:59:17 2016 +0530

----------------------------------------------------------------------
 .../spark/sql/optimizer/CarbonOptimizer.scala   | 12 +++++-
 .../AllDataTypesTestCaseAggregate.scala         | 45 ++++++++++++++++++++
 2 files changed, 55 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/605e8d84/integration/spark/src/main/scala/org/apache/spark/sql/optimizer/CarbonOptimizer.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/main/scala/org/apache/spark/sql/optimizer/CarbonOptimizer.scala b/integration/spark/src/main/scala/org/apache/spark/sql/optimizer/CarbonOptimizer.scala
index 00cae26..00febad 100644
--- a/integration/spark/src/main/scala/org/apache/spark/sql/optimizer/CarbonOptimizer.scala
+++ b/integration/spark/src/main/scala/org/apache/spark/sql/optimizer/CarbonOptimizer.scala
@@ -217,8 +217,16 @@ class ResolveCarbonFunctions(relations: Seq[CarbonDecoderRelation])
           }
         case filter: Filter if !filter.child.isInstanceOf[CarbonDictionaryTempDecoder] =>
           val attrsOnConds = new util.HashSet[AttributeReferenceWrapper]
-          CarbonFilters
-            .selectFilters(splitConjunctivePredicates(filter.condition), attrsOnConds, aliasMap)
+          // In case the child is join then we cannot push down the filters so decode them earlier
+          if (filter.child.isInstanceOf[Join]) {
+            filter.condition.collect {
+              case attr: AttributeReference =>
+                attrsOnConds.add(AttributeReferenceWrapper(aliasMap.getOrElse(attr, attr)))
+            }
+          } else {
+            CarbonFilters
+              .selectFilters(splitConjunctivePredicates(filter.condition), attrsOnConds, aliasMap)
+          }
 
           var child = filter.child
           if (attrsOnConds.size() > 0 && !child.isInstanceOf[Filter]) {

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/605e8d84/integration/spark/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCaseAggregate.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCaseAggregate.scala b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCaseAggregate.scala
index 7d73234..4fdd9ca 100644
--- a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCaseAggregate.scala
+++ b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/allqueries/AllDataTypesTestCaseAggregate.scala
@@ -1114,4 +1114,49 @@ class AllDataTypesTestCaseAggregate extends QueryTest with BeforeAndAfterAll {
       sql("select b.IMEI from Carbon_automation_hive a join Carbon_automation_hive b on a.imei=b.imei"))
   })
 
+  test("Right join with filter issue1") {
+
+    checkAnswer(
+      sql("""SELECT Carbon_automation_test.AMSize AS AMSize, Carbon_automation_test.ActiveCountry AS
+       ActiveCountry, Carbon_automation_test.Activecity AS Activecity, SUM(Carbon_automation_test
+       .gamePointId) AS Sum_gamePointId FROM ( SELECT AMSize, ActiveCountry, Activecity,
+       gamePointId FROM (select * from Carbon_automation_test) SUB_QRY ) Carbon_automation_test RIGHT JOIN
+       ( SELECT AMSize, ActiveCountry, Activecity, gamePointId FROM (select * from
+       Carbon_automation_test) SUB_QRY ) Carbon_automation_test1 ON Carbon_automation_test.gamePointId =
+       Carbon_automation_test1.gamePointId WHERE Carbon_automation_test.AMSize IN ("6RAM size","8RAM size")
+        GROUP BY Carbon_automation_test.AMSize, Carbon_automation_test.ActiveCountry, Carbon_automation_test
+        .Activecity ORDER BY Carbon_automation_test.AMSize ASC, Carbon_automation_test.ActiveCountry ASC,
+        Carbon_automation_test.Activecity ASC"""),
+      sql("""SELECT Carbon_automation_test_hive.AMSize AS AMSize, Carbon_automation_test_hive.ActiveCountry AS
+       ActiveCountry, Carbon_automation_test_hive.Activecity AS Activecity, SUM(Carbon_automation_test_hive
+       .gamePointId) AS Sum_gamePointId FROM ( SELECT AMSize, ActiveCountry, Activecity,
+       gamePointId FROM (select * from Carbon_automation_test_hive) SUB_QRY ) Carbon_automation_test_hive RIGHT JOIN
+       ( SELECT AMSize, ActiveCountry, Activecity, gamePointId FROM (select * from
+       Carbon_automation_test_hive) SUB_QRY ) Carbon_automation_test_hive1 ON Carbon_automation_test_hive.gamePointId =
+       Carbon_automation_test_hive1.gamePointId WHERE Carbon_automation_test_hive.AMSize IN ("6RAM size","8RAM size")
+        GROUP BY Carbon_automation_test_hive.AMSize, Carbon_automation_test_hive.ActiveCountry, Carbon_automation_test_hive
+        .Activecity ORDER BY Carbon_automation_test_hive.AMSize ASC, Carbon_automation_test_hive.ActiveCountry ASC,
+        Carbon_automation_test_hive.Activecity ASC """))
+  }
+
+  test("Right join with filter issue2") {
+
+    checkAnswer(
+      sql("""SELECT Carbon_automation_test.AMSize AS AMSize, Carbon_automation_test.gamePointId AS
+       gamePointId, Carbon_automation_test.ActiveCountry AS ActiveCountry, Carbon_automation_test
+       .Activecity AS Activecity FROM ( SELECT AMSize,  ActiveCountry,  Activecity, gamePointId
+       FROM (select * from Carbon_automation_test) SUB_QRY ) Carbon_automation_test RIGHT JOIN ( SELECT
+       AMSize,  ActiveCountry,  Activecity,  gamePointId FROM (select * from Carbon_automation_test)
+       SUB_QRY ) Carbon_automation_test1 ON Carbon_automation_test.gamePointId = Carbon_automation_test1
+       .gamePointId WHERE Carbon_automation_test.AMSize > "5RAM size" """),
+      sql("""SELECT Carbon_automation_test_hive.AMSize AS AMSize, Carbon_automation_test_hive.gamePointId AS
+       gamePointId, Carbon_automation_test_hive.ActiveCountry AS ActiveCountry, Carbon_automation_test_hive
+       .Activecity AS Activecity FROM ( SELECT AMSize,  ActiveCountry,  Activecity, gamePointId
+       FROM (select * from Carbon_automation_test_hive) SUB_QRY ) Carbon_automation_test_hive RIGHT JOIN ( SELECT
+       AMSize,  ActiveCountry,  Activecity,  gamePointId FROM (select * from Carbon_automation_test_hive)
+       SUB_QRY ) Carbon_automation_test_hive1 ON Carbon_automation_test_hive.gamePointId = Carbon_automation_test_hive1
+       .gamePointId WHERE Carbon_automation_test_hive.AMSize > "5RAM size" """))
+
+  }
+
 }
\ No newline at end of file


[2/2] incubator-carbondata git commit: Fixed right/left join query with filters are not working This closes #69

Posted by ch...@apache.org.
Fixed right/left join query with filters are not working This closes #69


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

Branch: refs/heads/master
Commit: 9d09cfcc905c67a2782cf4266d858d428280e577
Parents: 2f56377 605e8d8
Author: chenliang613 <ch...@apache.org>
Authored: Wed Aug 10 10:01:11 2016 +0800
Committer: chenliang613 <ch...@apache.org>
Committed: Wed Aug 10 10:01:11 2016 +0800

----------------------------------------------------------------------
 .../spark/sql/optimizer/CarbonOptimizer.scala   | 12 +++++-
 .../AllDataTypesTestCaseAggregate.scala         | 45 ++++++++++++++++++++
 2 files changed, 55 insertions(+), 2 deletions(-)
----------------------------------------------------------------------