[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/3b9efed6 Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/3b9efed6 Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/3b9efed6 Branch: refs/heads/external-format Commit: 3b9efed6282e504cb5c872caf9b70f4f08c0f93b Parents: 91837a6 Author: Indhumathi27 <indhumathi...@gmail.com> Authored: Fri Jul 27 23:39:50 2018 +0530 Committer: ravipesala <ravi.pes...@gmail.com> Committed: Sun Jul 29 21:33:04 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/3b9efed6/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/3b9efed6/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 } }