ShreelekhyaG commented on a change in pull request #4180:
URL: https://github.com/apache/carbondata/pull/4180#discussion_r695071362
##########
File path:
index/secondary-index/src/test/scala/org/apache/carbondata/spark/testsuite/secondaryindex/TestSIWithComplexArrayType.scala
##########
@@ -87,6 +86,70 @@ class TestSIWithComplexArrayType extends QueryTest with
BeforeAndAfterEach {
checkAnswer(result2, df2)
}
+ test("Test restructured array<int> and existing string column as index
columns on SI with compaction") {
+ sql("drop table if exists complextable")
+ sql("create table complextable (id string, name string, country
array<string>) stored as carbondata")
+ sql("insert into complextable select 3,'f',array('china')")
+ sql("drop index if exists index_11 on complextable")
+ sql("ALTER TABLE complextable ADD COLUMNS(arr2 array<int>)")
+ sql("insert into complextable select 4,'g',array('India'),array(1)")
+ // change datatype
+ sql("alter table complextable change arr2 arr2 array<long>")
+ sql("insert into complextable select
3,'f',array('china'),array(26557544541,2)")
+ sql("insert into complextable select
4,'g',array('India'),array(26557544541,46557544541,3)")
+ checkAnswer(sql("select * from complextable where array_contains(arr2,3)"),
+ Seq(Row("4", "g", make(Array("India")), make(Array(26557544541L,
46557544541L, 3)))))
+ val result1 = sql("select * from complextable where
array_contains(arr2,46557544541) and name='g'")
+ val result2 = sql("select * from complextable where arr2[0]=26557544541
and name='f'")
+ sql("create index index_11 on table complextable(arr2, name) as
'carbondata'")
+ sql("alter table complextable compact 'minor'")
+ val df1 = sql(" select * from complextable where
array_contains(arr2,46557544541) and name='g'")
+ val df2 = sql(" select * from complextable where arr2[0]=26557544541 and
name='f'")
+ if (!isFilterPushedDownToSI(df1.queryExecution.sparkPlan)) {
+ assert(false)
+ } else {
+ assert(true)
+ }
+ if (!isFilterPushedDownToSI(df2.queryExecution.sparkPlan)) {
+ assert(false)
+ } else {
+ assert(true)
+ }
+ val doNotHitSIDf = sql(
+ " select * from complextable where array_contains(arr2,26557544541) and
array_contains" +
+ "(arr2,46557544541)")
+ if (isFilterPushedDownToSI(doNotHitSIDf.queryExecution.sparkPlan)) {
+ assert(false)
+ } else {
+ assert(true)
+ }
+ checkAnswer(result1, df1)
+ checkAnswer(result2, df2)
+ }
+
+ test("Test restructured array<timestamp> as index column on SI with
compaction") {
+ sql("drop table if exists complextable")
+ sql("create table complextable (name string, time date) stored as
carbondata")
+ sql("insert into complextable select 'b', '2017-02-01'")
+ sql("ALTER TABLE complextable ADD COLUMNS(projectdate array<timestamp>)")
+ sql("insert into complextable select 'b', '2017-02-01',array('2017-02-01
00:01:00','2018-02-01 02:00:00')")
+ sql("drop index if exists index_1 on complextable")
+ sql("insert into complextable select 'b', '2017-02-01',array('2017-02-01
00:01:00','2018-02-01 02:00:00')")
+ sql("insert into complextable select 'b', '2017-02-01',array('2017-02-01
00:01:00','2018-02-01 02:00:00')")
Review comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]