[CARBONDATA-2794]Distinct count fails on ArrayOfStruct This PR fixes Code Generator Error thrown when Select filter contains more than one count of distinct of ArrayofStruct with group by Clause
This closes #2573 Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/9f105058 Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/9f105058 Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/9f105058 Branch: refs/heads/branch-1.4 Commit: 9f1050581fe976412f5253d7805b4b4622d5b865 Parents: 80d1310 Author: Indhumathi27 <[email protected]> Authored: Fri Jul 27 23:39:50 2018 +0530 Committer: ravipesala <[email protected]> Committed: Tue Jul 31 00:11:26 2018 +0530 ---------------------------------------------------------------------- .../spark/testsuite/complexType/TestComplexDataType.scala | 10 ++++++++++ .../apache/spark/sql/optimizer/CarbonLateDecodeRule.scala | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/carbondata/blob/9f105058/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/complexType/TestComplexDataType.scala ---------------------------------------------------------------------- diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/complexType/TestComplexDataType.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/complexType/TestComplexDataType.scala index e2884d8..2b3cfc0 100644 --- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/complexType/TestComplexDataType.scala +++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/complexType/TestComplexDataType.scala @@ -675,6 +675,16 @@ class TestComplexDataType extends QueryTest with BeforeAndAfterAll { CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT) } + test("test arrayofstruct with count(distinct)") { + sql("DROP TABLE IF EXISTS test") + sql("create table test(cus_id string,array_of_struct array<struct<id:int,country:string," + + "state:string,city:string>>) stored by 'carbondata'") + sql("insert into test values('cus_01','123:abc:mno:xyz$1234:abc1:mno1:xyz1')") + checkAnswer(sql("select array_of_struct.state[0],count(distinct array_of_struct.id[0]) as count_country," + + "count(distinct array_of_struct.state[0]) as count_city from test group by array_of_struct" + + ".state[0]"), Seq(Row("mno", 1, 1))) + } + test("test struct complex type with filter") { sql("DROP TABLE IF EXISTS test") sql("create table test(id int,a struct<b:int,c:int>) stored by 'carbondata'") http://git-wip-us.apache.org/repos/asf/carbondata/blob/9f105058/integration/spark2/src/main/scala/org/apache/spark/sql/optimizer/CarbonLateDecodeRule.scala ---------------------------------------------------------------------- diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/optimizer/CarbonLateDecodeRule.scala b/integration/spark2/src/main/scala/org/apache/spark/sql/optimizer/CarbonLateDecodeRule.scala index 9738ab0..ccdf034 100644 --- a/integration/spark2/src/main/scala/org/apache/spark/sql/optimizer/CarbonLateDecodeRule.scala +++ b/integration/spark2/src/main/scala/org/apache/spark/sql/optimizer/CarbonLateDecodeRule.scala @@ -743,7 +743,7 @@ class CarbonLateDecodeRule extends Rule[LogicalPlan] with PredicateHelper { attrName.contains(n) }) case ar : ArrayType => - attrName.contains(a.name + "[") + attrName.contains(a.name + "[") || attrName.contains(a.name + ".") case _ => false } }
