Github user kunal642 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1856#discussion_r174064693
  
    --- Diff: 
integration/spark-common-test/src/test/scala/org/apache/carbondata/integration/spark/testsuite/timeseries/TestTimeseriesDataLoad.scala
 ---
    @@ -330,16 +366,232 @@ class TestTimeseriesDataLoad extends QueryTest with 
BeforeAndAfterAll {
             """.stripMargin)
     
         checkAnswer(sql("select * from maintable_agg0_second"),
    -      Seq(Row(Timestamp.valueOf("2016-02-23 01:01:30.0"), 10),
    -        Row(Timestamp.valueOf("2016-02-23 01:01:40.0"), 20),
    -        Row(Timestamp.valueOf("2016-02-23 01:01:50.0"), 30),
    -        Row(Timestamp.valueOf("2016-02-23 01:02:30.0"), 40),
    -        Row(Timestamp.valueOf("2016-02-23 01:02:40.0"), 50),
    -        Row(Timestamp.valueOf("2016-02-23 01:02:50.0"), 50)))
    +      Seq(Row(Timestamp.valueOf("2016-02-23 09:01:30.0"), 10),
    +        Row(Timestamp.valueOf("2016-02-23 09:01:40.0"), 20),
    +        Row(Timestamp.valueOf("2016-02-23 09:01:50.0"), 30),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:30.0"), 40),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:40.0"), 50),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:50.0"), 50)))
    +  }
    +
    +  test("test timeseries table selection 14: load data into mainTable after 
create timeseries datamap ON TABLE and SELECT sub table") {
    +    sql("DROP TABLE IF EXISTS main_table")
    +    sql(
    +      """
    +        | CREATE TABLE main_table(
    +        |   mytime timestamp,
    +        |   name string,
    +        |   age int)
    +        | STORED BY 'org.apache.carbondata.format'
    +      """.stripMargin)
    +    sql(s"LOAD DATA LOCAL INPATH '$resourcesPath/timeseriestest.csv' INTO 
TABLE main_table")
    +    sql(
    +      s"""
    +         | CREATE DATAMAP agg0_second ON TABLE main_table
    +         | USING '$timeSeries'
    +         | DMPROPERTIES (
    +         |   'event_time'='mytime',
    +         |   'SECOND_GRANULARITY'='1')
    +         | AS SELECT mytime, SUM(age)
    +         | FROM main_table
    +         | GROUP BY mytime""".stripMargin)
    +
    +
    +    sql(s"LOAD DATA LOCAL INPATH '$resourcesPath/timeseriestest.csv' INTO 
TABLE main_table")
    +
    +    checkAnswer(sql("SELECT * FROM main_table_agg0_second"),
    +      Seq(Row(Timestamp.valueOf("2016-02-23 09:01:30.0"), 10),
    +        Row(Timestamp.valueOf("2016-02-23 09:01:40.0"), 20),
    +        Row(Timestamp.valueOf("2016-02-23 09:01:50.0"), 30),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:30.0"), 40),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:40.0"), 50),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:50.0"), 50),
    +        Row(Timestamp.valueOf("2016-02-23 09:01:30.0"), 10),
    +        Row(Timestamp.valueOf("2016-02-23 09:01:40.0"), 20),
    +        Row(Timestamp.valueOf("2016-02-23 09:01:50.0"), 30),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:30.0"), 40),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:40.0"), 50),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:50.0"), 50)))
    +  }
    +
    +  test("test timeseries table selection 15: load data into main_table 
after create timeseries datamap ON TABLE 1") {
    +    sql("DROP TABLE IF EXISTS main_table")
    +    sql(
    +      """
    +        | CREATE TABLE main_table(
    +        |   mytime timestamp,
    +        |   name string,
    +        |   age int)
    +        | STORED BY 'org.apache.carbondata.format'
    +      """.stripMargin)
    +    sql(s"LOAD DATA INPATH '$resourcesPath/timeseriestest.csv' INTO TABLE 
main_table")
    +
    +    sql(
    +      s"""
    +        | CREATE DATAMAP agg0_minute ON TABLE main_table
    +        | USING '$timeSeries'
    +        | DMPROPERTIES (
    +        |   'event_time'='mytime',
    +        |   'MINUTE_GRANULARITY'='1')
    +        | AS SELECT mytime, SUM(age)
    +        | FROM main_table
    +        | GROUP BY mytime""".stripMargin)
    +
    +    sql(s"LOAD DATA INPATH '$resourcesPath/timeseriestest.csv' INTO TABLE 
main_table")
    +    val df = sql(
    +      """
    +        | SELECT
    +        |   timeseries(mytime,'minute') AS minuteLevel,
    +        |   SUM(age) AS SUM
    +        | FROM main_table
    +        | WHERE timeseries(mytime,'minute')>='2016-02-23 09:01:00'
    +        | GROUP BY
    +        |   timeseries(mytime,'minute')
    +        | ORDER BY
    +        |   timeseries(mytime,'minute')
    +      """.stripMargin)
    +
    +    checkAnswer(df,
    +      Seq(Row(Timestamp.valueOf("2016-02-23 09:01:00"), 120),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:00"), 280)))
    +  }
    +
    +  test("test timeseries table selection 16: load data into main_table 
after create timeseries datamap ON TABLE 2") {
    +    sql("DROP TABLE IF EXISTS main_table")
    +    sql(
    +      """
    +        | CREATE TABLE main_table(
    +        |   mytime timestamp,
    +        |   name string,
    +        |   age int)
    +        | STORED BY 'org.apache.carbondata.format'
    +      """.stripMargin)
    +
    +    sql(s"LOAD DATA INPATH '$resourcesPath/timeseriestest.csv' INTO TABLE 
main_table")
    +    sql(s"LOAD DATA INPATH '$resourcesPath/timeseriestest.csv' INTO TABLE 
main_table")
    +    sql(
    +      s"""
    +        | CREATE DATAMAP agg0_minute ON TABLE main_table
    +        | USING '$timeSeries'
    +        | DMPROPERTIES (
    +        |   'event_time'='mytime',
    +        |   'MINUTE_GRANULARITY'='1')
    +        | AS SELECT mytime, SUM(age)
    +        | FROM main_table
    +        | GROUP BY mytime""".stripMargin)
    +
    +
    +    val df = sql(
    +      """
    +        | SELECT
    +        |   timeseries(mytime,'minute') AS minuteLevel,
    +        |   SUM(age) AS SUM
    +        | FROM main_table
    +        | WHERE timeseries(mytime,'minute')>='2016-02-23 09:01:00'
    +        | GROUP BY
    +        |   timeseries(mytime,'minute')
    +        | ORDER BY
    +        |   timeseries(mytime,'minute')
    +      """.stripMargin)
    +
    +    checkAnswer(df,
    +      Seq(Row(Timestamp.valueOf("2016-02-23 09:01:00"), 120),
    +        Row(Timestamp.valueOf("2016-02-23 09:02:00"), 280)))
    +  }
    +
    +  test("test timeseries table selection 17: load data into main_table 
after create timeseries datamap ON TABLE 3") {
    --- End diff --
    
    duplicate


---

Reply via email to