Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174123968 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesCreateTable.scala --- @@ -354,21 +390,137 @@ class TestTimeSeriesCreateTable extends QueryTest with BeforeAndAfterAll { checkExistence(sql("DESC FORMATTED mainTable_agg1"), true, "maintable_age_sum") } + test("test timeseries create table 32: should support if not exists, create when same table not exists") { + sql("DROP DATAMAP IF EXISTS agg1_year ON TABLE mainTable") + sql( + s""" + |CREATE DATAMAP if not exists agg1_year ON TABLE mainTable + |USING '$timeSeries' + |DMPROPERTIES ( + | 'event_time'='dataTime', + | 'YEAR_GRANULARITY'='1') + |AS SELECT dataTime, SUM(age) FROM mainTable + |GROUP BY dataTime + """.stripMargin) + checkExistence(sql("SHOW DATAMAP ON TABLE mainTable"), true, "agg1_year") + checkExistence(sql("DESC FORMATTED mainTable_agg1_year"), true, "maintable_age_sum") + } + test("test timeseries create table 20: don't support 'create datamap if exists'") { val e: Exception = intercept[AnalysisException] { sql( s"""CREATE DATAMAP IF EXISTS agg2 ON TABLE mainTable - | USING '$timeSeries' - | DMPROPERTIES ( - | 'EVENT_TIME'='dataTime', - | 'MONTH_GRANULARITY'='1') - | AS SELECT dataTime, SUM(age) FROM mainTable - | GROUP BY dataTime + | USING '$timeSeries' --- End diff -- ok --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174126731 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesCreateTable.scala --- @@ -354,21 +390,137 @@ class TestTimeSeriesCreateTable extends QueryTest with BeforeAndAfterAll { checkExistence(sql("DESC FORMATTED mainTable_agg1"), true, "maintable_age_sum") } + test("test timeseries create table 32: should support if not exists, create when same table not exists") { + sql("DROP DATAMAP IF EXISTS agg1_year ON TABLE mainTable") + sql( + s""" + |CREATE DATAMAP if not exists agg1_year ON TABLE mainTable + |USING '$timeSeries' + |DMPROPERTIES ( + | 'event_time'='dataTime', + | 'YEAR_GRANULARITY'='1') + |AS SELECT dataTime, SUM(age) FROM mainTable + |GROUP BY dataTime + """.stripMargin) + checkExistence(sql("SHOW DATAMAP ON TABLE mainTable"), true, "agg1_year") + checkExistence(sql("DESC FORMATTED mainTable_agg1_year"), true, "maintable_age_sum") + } + test("test timeseries create table 20: don't support 'create datamap if exists'") { val e: Exception = intercept[AnalysisException] { sql( s"""CREATE DATAMAP IF EXISTS agg2 ON TABLE mainTable - | USING '$timeSeries' - | DMPROPERTIES ( - | 'EVENT_TIME'='dataTime', - | 'MONTH_GRANULARITY'='1') - | AS SELECT dataTime, SUM(age) FROM mainTable - | GROUP BY dataTime + | USING '$timeSeries' + | DMPROPERTIES ( + | 'EVENT_TIME'='dataTime', + | 'MONTH_GRANULARITY'='1') + | AS SELECT dataTime, SUM(age) FROM mainTable + | GROUP BY dataTime """.stripMargin) } assert(e.getMessage.contains("identifier matching regex")) } + test("test timeseries create table 26: test different data type") { + sql("drop table if exists dataTable") + sql( + s""" + | CREATE TABLE dataTable( + | shortField SHORT, + | booleanField BOOLEAN, + | intField INT, + | bigintField LONG, + | doubleField DOUBLE, + | stringField STRING, + | decimalField DECIMAL(18,2), + | charField CHAR(5), + | floatField FLOAT, + | dataTime timestamp + | ) + | STORED BY 'carbondata' + """.stripMargin) + + + sql( + s"""CREATE DATAMAP agg0_hour ON TABLE dataTable + | USING '$timeSeries' + | DMPROPERTIES ( + | 'event_time'='dataTime', + | 'HOUR_GRANULARITY'='1') + | AS SELECT + | dataTime, + | SUM(intField), + | shortField, + | booleanField, + | intField, + | bigintField, + | doubleField, + | stringField, + | decimalField, + | charField, + | floatField + | FROM dataTable + | GROUP BY + | dataTime, + | shortField, + | booleanField, + | intField, + | bigintField, + | doubleField, + | stringField, + | decimalField, + | charField, + | floatField + """.stripMargin) + checkExistence(sql("SHOW DATAMAP ON TABLE dataTable"), true, "datatable_agg0_hour") + sql("DROP TABLE IF EXISTS dataTable") + } + + test("test timeseries create table 27: test data map name") { --- End diff -- test case 32 and test 27 is different, test case 32 is check carbon should support if CREATE DATAMAP not exists --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174127189 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesDropSuite.scala --- @@ -16,15 +16,28 @@ */ package org.apache.carbondata.integration.spark.testsuite.timeseries +import org.apache.spark.sql.AnalysisException import org.apache.spark.sql.test.util.QueryTest import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} -import org.apache.carbondata.common.exceptions.sql.MalformedCarbonCommandException +import org.apache.carbondata.common.exceptions.sql.{MalformedCarbonCommandException, NoSuchDataMapException} +import org.apache.carbondata.core.constants.CarbonCommonConstants +import org.apache.carbondata.core.util.CarbonProperties +import org.apache.carbondata.spark.exception.ProcessMetaDataException class TestTimeSeriesDropSuite extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + val timeSeries = "timeseries" + var timestampFormat: String = _ --- End diff -- @sraghunandan suggested should not change the CarbonCommonConstants values after running the test case, because other place maybe need this constants value. --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174127244 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesMatchStrategySuite.scala --- @@ -0,0 +1,401 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.carbondata.integration.spark.testsuite.timeseries + +import java.sql.Timestamp + +import org.apache.spark.sql.{CarbonDatasourceHadoopRelation, Row} +import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan +import org.apache.spark.sql.execution.datasources.LogicalRelation +import org.apache.spark.sql.hive.CarbonRelation +import org.apache.spark.sql.test.util.QueryTest +import org.apache.spark.util.SparkUtil4Test +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.core.constants.CarbonCommonConstants +import org.apache.carbondata.core.util.CarbonProperties + +class TestTimeSeriesMatchStrategySuite extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { + + var timestampFormat: String = _ --- End diff -- @sraghunandan suggested should not change the CarbonCommonConstants values after running the test case, because other place maybe need this constants value. --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174128505 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesUnsupportedSuite.scala --- @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.carbondata.integration.spark.testsuite.timeseries + +import java.sql.Timestamp + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.core.constants.CarbonCommonConstants +import org.apache.carbondata.core.util.CarbonProperties + +class TestTimeSeriesUnsupportedSuite extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { --- End diff -- Can you tell me where is the test case of inser/load/Update/delete/alter into timeseries aggregate table? --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174128639 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeseriesTableSelection.scala --- @@ -99,124 +113,763 @@ class TestTimeseriesTableSelection extends QueryTest with BeforeAndAfterAll { sql(s"LOAD DATA LOCAL INPATH '$resourcesPath/timeseriestest.csv' into table mainTable") } - test("test PreAggregate table selection 1") { - val df = sql("select mytime from mainTable group by mytime") + test("test timeseries table selection 1") { + val df = sql("SELECT mytime FROM mainTable GROUP BY mytime") preAggTableValidator(df.queryExecution.analyzed, "maintable") } - test("test PreAggregate table selection 2") { - val df = sql("select timeseries(mytime,'hour') from mainTable group by timeseries(mytime,'hour')") + test("test timeseries table selection 2") { + val df = sql("SELECT TIMESERIES(mytime,'hour') FROM mainTable GROUP BY TIMESERIES(mytime,'hour')") preAggTableValidator(df.queryExecution.analyzed, "maintable_agg0_hour") } - test("test PreAggregate table selection 3") { - val df = sql("select timeseries(mytime,'milli') from mainTable group by timeseries(mytime,'milli')") - preAggTableValidator(df.queryExecution.analyzed, "maintable") + test("test timeseries table selection 3: No enum constant MILLI") { + val e = intercept[Exception] { + val df = sql( + """ + | SELECT TIMESERIES(mytime,'milli') + | FROM mainTable + | GROUP BY TIMESERIES(mytime,'milli') + """.stripMargin) + preAggTableValidator(df.queryExecution.analyzed, "maintable") + df.show() + } + assert(e.getMessage.contains( + "No enum constant org.apache.carbondata.core.preagg.TimeSeriesFunctionEnum.MILLI")) } - test("test PreAggregate table selection 4") { - val df = sql("select timeseries(mytime,'year') from mainTable group by timeseries(mytime,'year')") + test("test timeseries table selection 4") { + val df = sql("SELECT TIMESERIES(mytime,'year') FROM mainTable GROUP BY TIMESERIES(mytime,'year')") --- End diff -- The operation should be upper case and table name should be down case according to SQL syntax, Hive syntax also like this. --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174129743 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeseriesTableSelection.scala --- @@ -99,124 +113,763 @@ class TestTimeseriesTableSelection extends QueryTest with BeforeAndAfterAll { sql(s"LOAD DATA LOCAL INPATH '$resourcesPath/timeseriestest.csv' into table mainTable") } - test("test PreAggregate table selection 1") { - val df = sql("select mytime from mainTable group by mytime") + test("test timeseries table selection 1") { + val df = sql("SELECT mytime FROM mainTable GROUP BY mytime") preAggTableValidator(df.queryExecution.analyzed, "maintable") } - test("test PreAggregate table selection 2") { - val df = sql("select timeseries(mytime,'hour') from mainTable group by timeseries(mytime,'hour')") + test("test timeseries table selection 2") { + val df = sql("SELECT TIMESERIES(mytime,'hour') FROM mainTable GROUP BY TIMESERIES(mytime,'hour')") preAggTableValidator(df.queryExecution.analyzed, "maintable_agg0_hour") } - test("test PreAggregate table selection 3") { - val df = sql("select timeseries(mytime,'milli') from mainTable group by timeseries(mytime,'milli')") - preAggTableValidator(df.queryExecution.analyzed, "maintable") + test("test timeseries table selection 3: No enum constant MILLI") { + val e = intercept[Exception] { + val df = sql( + """ + | SELECT TIMESERIES(mytime,'milli') + | FROM mainTable + | GROUP BY TIMESERIES(mytime,'milli') + """.stripMargin) + preAggTableValidator(df.queryExecution.analyzed, "maintable") + df.show() + } + assert(e.getMessage.contains( + "No enum constant org.apache.carbondata.core.preagg.TimeSeriesFunctionEnum.MILLI")) } - test("test PreAggregate table selection 4") { - val df = sql("select timeseries(mytime,'year') from mainTable group by timeseries(mytime,'year')") + test("test timeseries table selection 4") { + val df = sql("SELECT TIMESERIES(mytime,'year') FROM mainTable GROUP BY TIMESERIES(mytime,'year')") preAggTableValidator(df.queryExecution.analyzed,"maintable_agg0_year") } - test("test PreAggregate table selection 5") { - val df = sql("select timeseries(mytime,'day') from mainTable group by timeseries(mytime,'day')") + test("test timeseries table selection 5") { + val df = sql("SELECT TIMESERIES(mytime,'day') FROM mainTable GROUP BY TIMESERIES(mytime,'day')") preAggTableValidator(df.queryExecution.analyzed,"maintable_agg0_day") } - test("test PreAggregate table selection 6") { - val df = sql("select timeseries(mytime,'month') from mainTable group by timeseries(mytime,'month')") + test("test timeseries table selection 6") { + val df = sql("SELECT TIMESERIES(mytime,'month') FROM mainTable GROUP BY TIMESERIES(mytime,'month')") preAggTableValidator(df.queryExecution.analyzed,"maintable_agg0_month") } - test("test PreAggregate table selection 7") { - val df = sql("select timeseries(mytime,'minute') from mainTable group by timeseries(mytime,'minute')") + test("test timeseries table selection 7") { + val df = sql("SELECT TIMESERIES(mytime,'minute') FROM mainTable GROUP BY TIMESERIES(mytime,'minute')") preAggTableValidator(df.queryExecution.analyzed,"maintable_agg0_minute") } - test("test PreAggregate table selection 8") { - val df = sql("select timeseries(mytime,'second') from mainTable group by timeseries(mytime,'second')") + test("test timeseries table selection 8") { + val df = sql("SELECT TIMESERIES(mytime,'second') FROM mainTable GROUP BY TIMESERIES(mytime,'second')") preAggTableValidator(df.queryExecution.analyzed,"maintable_agg0_second") } - test("test PreAggregate table selection 9") { - val df = sql("select timeseries(mytime,'hour') from mainTable where timeseries(mytime,'hour')='x' group by timeseries(mytime,'hour')") - preAggTableValidator(df.queryExecution.analyzed,"maintable_agg0_hour") + test("test timeseries table selection 9") { + val df = sql( + """ + | SELECT TIMESERIES(mytime,'hour') + | FROM mainTable + | WHERE TIMESERIES(mytime,'hour')='x' + | GROUP BY TIMESERIES(mytime,'hour') + """.stripMargin) + preAggTableValidator(df.queryExecution.analyzed, "maintable_agg0_hour") } - test("test PreAggregate table selection 10") { - val df = sql("select timeseries(mytime,'hour') from mainTable where timeseries(mytime,'hour')='x' group by timeseries(mytime,'hour') order by timeseries(mytime,'hour')") - preAggTableValidator(df.queryExecution.analyzed,"maintable_agg0_hour") + test("test timeseries table selection 10") { + val df = sql( + """ + | SELECT TIMESERIES(mytime,'hour') + | FROM mainTable + | WHERE TIMESERIES(mytime,'hour')='x' + | GROUP BY TIMESERIES(mytime,'hour') + | ORDER BY TIMESERIES(mytime,'hour') + """.stripMargin) + preAggTableValidator(df.queryExecution.analyzed, "maintable_agg0_hour") + } + + test("test timeseries table selection 11") { + val df = sql( + """ + | SELECT TIMESERIES(mytime,'hour'),SUM(age) + | FROM mainTable + | WHERE TIMESERIES(mytime,'hour')='x' + | GROUP BY TIMESERIES(mytime,'hour') + | ORDER BY TIMESERIES(mytime,'hour') + """.stripMargin) + preAggTableValidator(df.queryExecution.analyzed, "maintable_agg0_hour") } - test("test PreAggregate table selection 11") { - val df = sql("select timeseries(mytime,'hour'),sum(age) from mainTable where timeseries(mytime,'hour')='x' group by timeseries(mytime,'hour') order by timeseries(mytime,'hour')") - preAggTableValidator(df.queryExecution.analyzed,"maintable_agg0_hour") + test("test timeseries table selection 12") { + val df = sql( + """ + | SELECT TIMESERIES(mytime,'hour') AS hourlevel,SUM(age) AS SUM + | FROM mainTable + | WHERE TIMESERIES(mytime,'hour')='x' + | GROUP BY TIMESERIES(mytime,'hour') + | ORDER BY TIMESERIES(mytime,'hour') + """.stripMargin) + preAggTableValidator(df.queryExecution.analyzed, "maintable_agg0_hour") } - test("test PreAggregate table selection 12") { - val df = sql("select timeseries(mytime,'hour')as hourlevel,sum(age) as sum from mainTable where timeseries(mytime,'hour')='x' group by timeseries(mytime,'hour') order by timeseries(mytime,'hour')") - preAggTableValidator(df.queryExecution.analyzed,"maintable_agg0_hour") + test("test timeseries table selection 13") { + val df = sql( + """ + | SELECT TIMESERIES(mytime,'hour')as hourlevel,SUM(age) AS SUM + | FROM mainTable + | WHERE TIMESERIES(mytime,'hour')='x' AND name='vishal' + | GROUP BY TIMESERIES(mytime,'hour') + | ORDER BY TIMESERIES(mytime,'hour') + """.stripMargin) + preAggTableValidator(df.queryExecution.analyzed, "maintable") } - test("test PreAggregate table selection 13") { - val df = sql("select timeseries(mytime,'hour')as hourlevel,sum(age) as sum from mainTable where timeseries(mytime,'hour')='x' and name='vishal' group by timeseries(mytime,'hour') order by timeseries(mytime,'hour')") - preAggTableValidator(df.queryExecution.analyzed,"maintable") + test("test timeseries table selection 14: TIMESERIES(mytime,'hour') match") { + val df = sql( + """ + | SELECT TIMESERIES(mytime,'hour') + | FROM mainTable + | WHERE TIMESERIES(mytime,'hour')='2016-02-23 09:00:00' + | GROUP BY TIMESERIES(mytime,'hour') + """.stripMargin) + preAggTableValidator(df.queryExecution.analyzed, "maintable_agg0_hour") + checkAnswer(df, Row(Timestamp.valueOf("2016-02-23 09:00:00.0"))) } - test("test timeseries table selection 14: Granularity only support 1 and throw Exception") { - val e = intercept[MalformedCarbonCommandException] { - sql( - s""" - | CREATE DATAMAP agg3_second ON TABLE mainTable - | USING '$timeSeries' - | DMPROPERTIES ( - | 'EVENT_TIME'='dataTime', - | 'HOUR_GRANULARITY'='2') - | AS SELECT dataTime, SUM(age) FROM mainTable - | GROUP BY dataTime - """.stripMargin) - } - assert(e.getMessage.contains("Granularity only support 1")) - } - - test("test timeseries table selection 15: Granularity only support 1 and throw Exception") { - val e = intercept[MalformedCarbonCommandException] { - sql( - s""" - | CREATE DATAMAP agg3_second ON TABLE mainTable - | USING '$timeSeries' - | DMPROPERTIES ( - | 'EVENT_TIME'='dataTime', - | 'HOUR_GRANULARITY'='1.5') - | AS SELECT dataTime, SUM(age) FROM mainTable - | GROUP BY dataTime - """.stripMargin) - } - assert(e.getMessage.contains("Granularity only support 1")) - } - - test("test timeseries table selection 16: Granularity only support 1 and throw Exception") { - val e = intercept[MalformedCarbonCommandException] { - sql( - s""" - | CREATE DATAMAP agg3_second ON TABLE mainTable - | USING '$timeSeries' - | DMPROPERTIES ( - | 'EVENT_TIME'='dataTime', - | 'HOUR_GRANULARITY'='-1') - | AS SELECT dataTime, SUM(age) FROM mainTable - | GROUP BY dataTime - """.stripMargin) - } - assert(e.getMessage.contains("Granularity only support 1")) + test("test timeseries table selection 15: TIMESERIES(mytime,'hour') not match") { + val df = sql( + """ + | SELECT TIMESERIES(mytime,'hour') + | FROM mainTable + | WHERE TIMESERIES(mytime,'hour')='2016-02-23 09:01:00' + | GROUP BY TIMESERIES(mytime,'hour') + """.stripMargin) + preAggTableValidator(df.queryExecution.analyzed, "maintable_agg0_hour") + checkExistence(df, false, "2016-02-23 09:00:00", "2016-02-23 09:01:00") + } + + test("test timeseries table selection 16: TIMESERIES(mytime,'minute') match") { + checkExistence(sql("SELECT * FROM mainTable"), true, + "2016-02-23 09:01:30", "2016-02-23 09:02:40") + checkExistence(sql("SELECT * FROM mainTable"), false, + "2016-02-23 09:02:00", "2016-02-23 09:01:00") + val df = sql( + """ + |SELECT TIMESERIES(mytime,'minute') + |FROM mainTable + |GROUP BY TIMESERIES(mytime,'minute') + """.stripMargin) + preAggTableValidator(df.queryExecution.analyzed, "maintable_agg0_minute") + checkExistence(df, true, "2016-02-23 09:02:00", "2016-02-23 09:01:00") + checkAnswer(df, + Seq(Row(Timestamp.valueOf("2016-02-23 09:02:00.0")), + Row(Timestamp.valueOf("2016-02-23 09:01:00.0")))) + + val df2 = sql( + """ + | SELECT + | TIMESERIES(mytime,'minute')as minutelevel, + | SUM(age) AS SUM + | FROM mainTable + | WHERE TIMESERIES(mytime,'minute')='2016-02-23 09:01:00' + | GROUP BY TIMESERIES(mytime,'minute') + | ORDER BY TIMESERIES(mytime,'minute') + """.stripMargin) + preAggTableValidator(df2.queryExecution.analyzed, "maintable_agg0_minute") + checkAnswer(df2, Seq(Row(Timestamp.valueOf("2016-02-23 09:01:00"), 60))) + } + + test("test timeseries table selection 17: TIMESERIES(mytime,'minute') not match pre agg") { + val df = sql( + """ + | SELECT + | TIMESERIES(mytime,'minute')as minutelevel, + | SUM(age) AS SUM + | FROM mainTable + | WHERE TIMESERIES(mytime,'minute')='2016-02-23 09:01:00' AND name='vishal' + | GROUP BY TIMESERIES(mytime,'minute') + | ORDER BY TIMESERIES(mytime,'minute') + """.stripMargin) + checkAnswer(df, Seq(Row(Timestamp.valueOf("2016-02-23 09:01:00"), 10))) + preAggTableValidator(df.queryExecution.analyzed, "maintable") + } + + test("test timeseries table selection 18: select with many GROUP BY AND one filter") { + val df = sql( + """ + | SELECT + | TIMESERIES(mytime,'year') AS yearLevel, + | TIMESERIES(mytime,'month') AS monthLevel, + | TIMESERIES(mytime,'day') AS dayLevel, + | TIMESERIES(mytime,'hour') AS hourLevel, + | TIMESERIES(mytime,'minute') AS minuteLevel, + | TIMESERIES(mytime,'second') AS secondLevel, + | SUM(age) AS SUM + | FROM mainTable + | WHERE TIMESERIES(mytime,'minute')='2016-02-23 09:01:00' + | GROUP BY + | TIMESERIES(mytime,'year'), + | TIMESERIES(mytime,'month'), + | TIMESERIES(mytime,'day'), + | TIMESERIES(mytime,'hour'), + | TIMESERIES(mytime,'minute'), + | TIMESERIES(mytime,'second') + | ORDER BY + | TIMESERIES(mytime,'year'), + | TIMESERIES(mytime,'month'), + | TIMESERIES(mytime,'day'), + | TIMESERIES(mytime,'hour'), + | TIMESERIES(mytime,'minute'), + | TIMESERIES(mytime,'second') + """.stripMargin) + + checkExistence(df, true, + "2016-01-01 00:00:00", + "2016-02-01 00:00:00", + "2016-02-23 09:00:00", + "2016-02-23 09:01:00", + "2016-02-23 09:01:50", + "30" + ) + } + + test("test timeseries table selection 19: select with many GROUP BY AND many filter") { + val df = sql( + """ + | SELECT + | TIMESERIES(mytime,'year') AS yearLevel, + | TIMESERIES(mytime,'month') AS monthLevel, + | TIMESERIES(mytime,'day') AS dayLevel, + | TIMESERIES(mytime,'hour') AS hourLevel, + | TIMESERIES(mytime,'minute') AS minuteLevel, + | TIMESERIES(mytime,'second') AS secondLevel, + | SUM(age) AS SUM + | FROM mainTable + | WHERE + | TIMESERIES(mytime,'second')='2016-02-23 09:01:50' and + | TIMESERIES(mytime,'minute')='2016-02-23 09:01:00' and + | TIMESERIES(mytime,'hour')='2016-02-23 09:00:00' and + | TIMESERIES(mytime,'month')='2016-02-01 00:00:00' and + | TIMESERIES(mytime,'year')='2016-01-01 00:00:00' + | GROUP BY + | TIMESERIES(mytime,'year'), + | TIMESERIES(mytime,'month'), + | TIMESERIES(mytime,'day'), + | TIMESERIES(mytime,'hour'), + | TIMESERIES(mytime,'minute'), + | TIMESERIES(mytime,'second') + | ORDER BY + | TIMESERIES(mytime,'year'), + | TIMESERIES(mytime,'month'), + | TIMESERIES(mytime,'day'), + | TIMESERIES(mytime,'hour'), + | TIMESERIES(mytime,'minute'), + | TIMESERIES(mytime,'second') + """.stripMargin) + + checkExistence(df, true, + "2016-01-01 00:00:00", + "2016-02-01 00:00:00", + "2016-02-23 09:00:00", + "2016-02-23 09:01:00", + "2016-02-23 09:01:50", + "30" + ) + } + + test("test timeseries table selection 20: filter < AND >") { --- End diff -- different purpose, but I can remove this. --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174130738 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/sortcolumns/TestSortColumns.scala --- @@ -33,16 +33,15 @@ class TestSortColumns extends QueryTest with BeforeAndAfterAll { CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, "dd-MM-yyyy") SparkUtil4Test.createTaskMockUp(sqlContext) - dropTable CarbonProperties.getInstance() .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, "dd-MM-yyyy") + dropTestTables --- End diff -- I add common method QueryTest for all test case in org.apache.spark.sql.test.util.QueryTest, so subclass should change the method name --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on the issue:
https://github.com/apache/carbondata/pull/1856 @kunal642 Done, please check again. Please tell me if there are any problem. Can you help me to merge it if it's no problem? I spend much time to rebase before. --- |
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:
https://github.com/apache/carbondata/pull/1856 Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/3001/ --- |
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:
https://github.com/apache/carbondata/pull/1856 Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/4245/ --- |
In reply to this post by qiuchenjian-2
Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174404853 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesCreateTable.scala --- @@ -354,21 +390,137 @@ class TestTimeSeriesCreateTable extends QueryTest with BeforeAndAfterAll { checkExistence(sql("DESC FORMATTED mainTable_agg1"), true, "maintable_age_sum") } + test("test timeseries create table 32: should support if not exists, create when same table not exists") { + sql("DROP DATAMAP IF EXISTS agg1_year ON TABLE mainTable") + sql( + s""" + |CREATE DATAMAP if not exists agg1_year ON TABLE mainTable + |USING '$timeSeries' + |DMPROPERTIES ( + | 'event_time'='dataTime', + | 'YEAR_GRANULARITY'='1') + |AS SELECT dataTime, SUM(age) FROM mainTable + |GROUP BY dataTime + """.stripMargin) + checkExistence(sql("SHOW DATAMAP ON TABLE mainTable"), true, "agg1_year") + checkExistence(sql("DESC FORMATTED mainTable_agg1_year"), true, "maintable_age_sum") + } + test("test timeseries create table 20: don't support 'create datamap if exists'") { val e: Exception = intercept[AnalysisException] { sql( s"""CREATE DATAMAP IF EXISTS agg2 ON TABLE mainTable - | USING '$timeSeries' - | DMPROPERTIES ( - | 'EVENT_TIME'='dataTime', - | 'MONTH_GRANULARITY'='1') - | AS SELECT dataTime, SUM(age) FROM mainTable - | GROUP BY dataTime + | USING '$timeSeries' + | DMPROPERTIES ( + | 'EVENT_TIME'='dataTime', + | 'MONTH_GRANULARITY'='1') + | AS SELECT dataTime, SUM(age) FROM mainTable + | GROUP BY dataTime """.stripMargin) } assert(e.getMessage.contains("identifier matching regex")) } + test("test timeseries create table 26: test different data type") { + sql("drop table if exists dataTable") + sql( + s""" + | CREATE TABLE dataTable( + | shortField SHORT, + | booleanField BOOLEAN, + | intField INT, + | bigintField LONG, + | doubleField DOUBLE, + | stringField STRING, + | decimalField DECIMAL(18,2), + | charField CHAR(5), + | floatField FLOAT, + | dataTime timestamp + | ) + | STORED BY 'carbondata' + """.stripMargin) + + + sql( + s"""CREATE DATAMAP agg0_hour ON TABLE dataTable + | USING '$timeSeries' + | DMPROPERTIES ( + | 'event_time'='dataTime', + | 'HOUR_GRANULARITY'='1') + | AS SELECT + | dataTime, + | SUM(intField), + | shortField, + | booleanField, + | intField, + | bigintField, + | doubleField, + | stringField, + | decimalField, + | charField, + | floatField + | FROM dataTable + | GROUP BY + | dataTime, + | shortField, + | booleanField, + | intField, + | bigintField, + | doubleField, + | stringField, + | decimalField, + | charField, + | floatField + """.stripMargin) + checkExistence(sql("SHOW DATAMAP ON TABLE dataTable"), true, "datatable_agg0_hour") + sql("DROP TABLE IF EXISTS dataTable") + } + + test("test timeseries create table 27: test data map name") { --- End diff -- but it has covered this scenario also right?? --- |
In reply to this post by qiuchenjian-2
Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174406193 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesUnsupportedSuite.scala --- @@ -0,0 +1,265 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.carbondata.integration.spark.testsuite.timeseries + +import java.sql.Timestamp + +import org.apache.spark.sql.Row +import org.apache.spark.sql.test.util.QueryTest +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} + +import org.apache.carbondata.core.constants.CarbonCommonConstants +import org.apache.carbondata.core.util.CarbonProperties + +class TestTimeSeriesUnsupportedSuite extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach { --- End diff -- you can find these in preaggregate test cases. No need check the same for timeseries because the base code is the same --- |
In reply to this post by qiuchenjian-2
Github user kunal642 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1856#discussion_r174406656 --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeSeriesCreateTable.scala --- @@ -17,18 +17,28 @@ package org.apache.carbondata.integration.spark.testsuite.timeseries import org.apache.spark.sql.AnalysisException +import org.apache.spark.sql.catalyst.analysis.TableAlreadyExistsException import org.apache.spark.sql.test.util.QueryTest -import org.scalatest.BeforeAndAfterAll +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} import org.apache.carbondata.common.exceptions.sql.{MalformedCarbonCommandException, MalformedDataMapCommandException} +import org.apache.carbondata.core.constants.CarbonCommonConstants import org.apache.carbondata.core.metadata.schema.datamap.DataMapProvider.TIMESERIES +import org.apache.carbondata.core.util.CarbonProperties -class TestTimeSeriesCreateTable extends QueryTest with BeforeAndAfterAll { +class TestTimeSeriesCreateTable extends QueryTest with BeforeAndAfterAll with BeforeAndAfterEach{ val timeSeries = TIMESERIES.toString + var timestampFormat: String = _ --- End diff -- ok --- |
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:
https://github.com/apache/carbondata/pull/1856 Build Failed with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/3047/ --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on the issue:
https://github.com/apache/carbondata/pull/1856 retest this please --- |
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:
https://github.com/apache/carbondata/pull/1856 Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/4291/ --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on the issue:
https://github.com/apache/carbondata/pull/1856 SDV Build Fail , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/3886/ --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on the issue:
https://github.com/apache/carbondata/pull/1856 retest sdv please --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on the issue:
https://github.com/apache/carbondata/pull/1856 SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/3887/ --- |
Free forum by Nabble | Edit this page |