You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by xubo245 <gi...@git.apache.org> on 2018/02/07 04:20:10 UTC

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

GitHub user xubo245 opened a pull request:

    https://github.com/apache/carbondata/pull/1939

    [CARBONDATA-2139] Optimize CTAS documentation and test case

    Optimize CTAS:
    
    - optimize documentation
    - add test case
    - drop table after finishing run test acse, remove the file of table from disk
    
    Be sure to do all of the following checklist to help us incorporate 
    your contribution quickly and easily:
    
     - [ ] Any interfaces changed?
     
     - [ ] Any backward compatibility impacted?
     
     - [ ] Document update required?
    
     - [ ] Testing done
            Please provide details on 
            - Whether new unit test cases have been added or why no new tests are required?
            - How it is tested? Please attach test report.
            - Is it a performance related change? Please attach the performance test report.
            - Any additional information to help reviewers in testing this change.
           
     - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA. 
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/xubo245/carbondata CARBONDATA-3129_CTASOptimize

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/carbondata/pull/1939.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1939
    
----
commit 28f61381a0a5bc030838fbed9a1a04348a73f546
Author: xubo245 <60...@...>
Date:   2018-02-07T04:16:41Z

    [CARBONDATA-2139] Optimize CTAS documentation and test case

----


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/3396/



---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by manishgupta88 <gi...@git.apache.org>.
Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1939#discussion_r168123320
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableAsSelect.scala ---
    @@ -170,10 +175,277 @@ class TestCreateTableAsSelect extends QueryTest with BeforeAndAfterAll {
         }
       }
     
    +  test("test create table as select with where clause in select from parquet table that does not return data") {
    +    sql("DROP TABLE IF EXISTS ctas_select_where_parquet")
    +    sql(
    +      """
    +        | CREATE TABLE ctas_select_where_parquet
    +        | STORED BY 'carbondata'
    +        | as select * FROM parquet_ctas_test
    +        | where key=300""".stripMargin)
    +    checkAnswer(sql("SELECT * FROM ctas_select_where_parquet"),
    +      sql("SELECT * FROM parquet_ctas_test where key=300"))
    +  }
    +
    +  test("test create table as select with where clause in select from hive/orc table that does not return data") {
    +    sql("DROP TABLE IF EXISTS ctas_select_where_orc")
    +    sql(
    +      """
    +        | CREATE TABLE ctas_select_where_orc
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM orc_ctas_test
    +        | where key=300""".stripMargin)
    +    checkAnswer(sql("SELECT * FROM ctas_select_where_orc"),
    +      sql("SELECT * FROM orc_ctas_test where key=300"))
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause") {
    +    sql("drop table if exists ctas_same_table_name")
    +    sql("CREATE TABLE ctas_same_table_name(key INT, value STRING) STORED BY 'carbondata'")
    +    checkExistence(sql("SHOW TABLES"), true, "ctas_same_table_name")
    +    sql(
    +      """
    +        | CREATE TABLE IF NOT EXISTS ctas_same_table_name
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM ctas_same_table_name
    +      """.stripMargin)
    +    intercept[Exception] {
    +      sql(
    +        """
    +          | CREATE TABLE ctas_same_table_name
    +          | STORED BY 'carbondata'
    +          | AS SELECT * FROM ctas_same_table_name
    +        """.stripMargin)
    +    }
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause and source table not exists") {
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    checkExistence(sql("SHOW TABLES"), false, "ctas_same_table_name")
    +    intercept[Exception] {
    +      sql(
    +        """
    +          | CREATE TABLE IF NOT EXISTS ctas_same_table_name
    +          | STORED BY 'carbondata'
    +          | AS SELECT * FROM ctas_same_table_name
    +        """.stripMargin)
    +    }
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause and source table exists") {
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    sql("DROP TABLE IF EXISTS ctas_if_table_name")
    +    sql("CREATE TABLE ctas_same_table_name(key INT, value STRING) STORED BY 'carbondata'")
    +    sql(
    +      """
    +        | CREATE TABLE IF NOT EXISTS ctas_if_table_name
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM ctas_same_table_name
    +      """.stripMargin)
    +    checkExistence(sql("show tables"), true, "ctas_if_table_name")
    +  }
    +
    +  test("add example for documentation") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED AS parquet
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age) FROM source_table group by city
    +      """.stripMargin)
    +    // results:
    +    //    sql("SELECT * FROM target_table").show
    +    //    +--------+--------+
    +    //    |    city|avg(age)|
    +    //    +--------+--------+
    +    //    |shenzhen|    29.0|
    +    //    +--------+--------+
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 29)))
    +  }
    +
    +  test("test create table as select with sum,count,min,max") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        | STORED BY 'carbondata'
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,sum(age),count(age),min(age),max(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 58, 2, 27, 31)))
    +  }
    +
    +  test("test create table as select with insert data into source_table after CTAS") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,sum(age),count(age),min(age),max(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 58, 2, 27, 31)))
    +  }
    +
    +  test("test create table as select with auto merge") {
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.ENABLE_AUTO_LOAD_MERGE, "true")
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE source_table"), true, "Compacted")
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE target_table"), false, "Compacted")
    +
    +    sql("INSERT INTO target_table SELECT 'shenzhen',8")
    +    sql("INSERT INTO target_table SELECT 'shenzhen',9")
    +    sql("INSERT INTO target_table SELECT 'shenzhen',3")
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE target_table"), true, "Compacted")
    +    checkAnswer(sql("SELECT * FROM target_table"),
    +      Seq(Row("shenzhen", 29), Row("shenzhen", 8), Row("shenzhen", 9), Row("shenzhen", 3)))
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.ENABLE_AUTO_LOAD_MERGE,
    +        CarbonCommonConstants.DEFAULT_ENABLE_AUTO_LOAD_MERGE)
    +  }
    +
    +  test("test create table as select with filter, <, and, >=") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql("INSERT INTO source_table SELECT 3,'jack','shenzhen',5")
    +    sql("INSERT INTO source_table SELECT 4,'alice','shenzhen',35")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table where age > 20 and age <= 31 GROUP BY city
    +      """.stripMargin)
    +
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 29)))
    +  }
    +
    +  test("test create table as select with filter, >=, or, =") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql("INSERT INTO source_table SELECT 3,'jack','shenzhen',5")
    +    sql("INSERT INTO source_table SELECT 4,'alice','shenzhen',35")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table where age >= 20 or age = 5 group by city
    +      """.stripMargin)
    +
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 24.5)))
    +  }
    +
       override def afterAll {
         sql("DROP TABLE IF EXISTS carbon_ctas_test")
         sql("DROP TABLE IF EXISTS parquet_ctas_test")
         sql("DROP TABLE IF EXISTS orc_ctas_test")
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    sql("DROP TABLE IF EXISTS ctas_select_carbon")
    +    sql("DROP TABLE IF EXISTS ctas_select_direct_data")
    +    sql("DROP TABLE IF EXISTS ctas_select_parquet")
    +    sql("DROP TABLE IF EXISTS ctas_select_orc")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_carbon")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_parquet")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_orc")
    +    sql("DROP TABLE IF EXISTS ctas_tblproperties_test")
    +    sql("DROP TABLE IF EXISTS ctas_if_table_name")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    sql("DROP TABLE IF EXISTS target_table")
    --- End diff --
    
    @xubo245 ...I agree with your point that we should ensure feature stability. But as explained in my suggestion above CTAS internally uses Create table flow and Insert Into flow and we have enough test cases to ensure the stability of create table and insert into feature and hence we dont require to add new test cases currently for CTAS feature.
    As far as coverage is concerned, existing test cases are sufficient to cover CTAS feature functionality completely. If something is not getting covered, then we need to write UT not FT.
    
    You can identify other features were FT is not sufficient to cover all scenarios and add the required test cases.


---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by manishgupta88 <gi...@git.apache.org>.
Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1939#discussion_r168386909
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableAsSelect.scala ---
    @@ -170,10 +175,277 @@ class TestCreateTableAsSelect extends QueryTest with BeforeAndAfterAll {
         }
       }
     
    +  test("test create table as select with where clause in select from parquet table that does not return data") {
    +    sql("DROP TABLE IF EXISTS ctas_select_where_parquet")
    +    sql(
    +      """
    +        | CREATE TABLE ctas_select_where_parquet
    +        | STORED BY 'carbondata'
    +        | as select * FROM parquet_ctas_test
    +        | where key=300""".stripMargin)
    +    checkAnswer(sql("SELECT * FROM ctas_select_where_parquet"),
    +      sql("SELECT * FROM parquet_ctas_test where key=300"))
    +  }
    +
    +  test("test create table as select with where clause in select from hive/orc table that does not return data") {
    +    sql("DROP TABLE IF EXISTS ctas_select_where_orc")
    +    sql(
    +      """
    +        | CREATE TABLE ctas_select_where_orc
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM orc_ctas_test
    +        | where key=300""".stripMargin)
    +    checkAnswer(sql("SELECT * FROM ctas_select_where_orc"),
    +      sql("SELECT * FROM orc_ctas_test where key=300"))
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause") {
    +    sql("drop table if exists ctas_same_table_name")
    +    sql("CREATE TABLE ctas_same_table_name(key INT, value STRING) STORED BY 'carbondata'")
    +    checkExistence(sql("SHOW TABLES"), true, "ctas_same_table_name")
    +    sql(
    +      """
    +        | CREATE TABLE IF NOT EXISTS ctas_same_table_name
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM ctas_same_table_name
    +      """.stripMargin)
    +    intercept[Exception] {
    +      sql(
    +        """
    +          | CREATE TABLE ctas_same_table_name
    +          | STORED BY 'carbondata'
    +          | AS SELECT * FROM ctas_same_table_name
    +        """.stripMargin)
    +    }
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause and source table not exists") {
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    checkExistence(sql("SHOW TABLES"), false, "ctas_same_table_name")
    +    intercept[Exception] {
    +      sql(
    +        """
    +          | CREATE TABLE IF NOT EXISTS ctas_same_table_name
    +          | STORED BY 'carbondata'
    +          | AS SELECT * FROM ctas_same_table_name
    +        """.stripMargin)
    +    }
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause and source table exists") {
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    sql("DROP TABLE IF EXISTS ctas_if_table_name")
    +    sql("CREATE TABLE ctas_same_table_name(key INT, value STRING) STORED BY 'carbondata'")
    +    sql(
    +      """
    +        | CREATE TABLE IF NOT EXISTS ctas_if_table_name
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM ctas_same_table_name
    +      """.stripMargin)
    +    checkExistence(sql("show tables"), true, "ctas_if_table_name")
    +  }
    +
    +  test("add example for documentation") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED AS parquet
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age) FROM source_table group by city
    +      """.stripMargin)
    +    // results:
    +    //    sql("SELECT * FROM target_table").show
    +    //    +--------+--------+
    +    //    |    city|avg(age)|
    +    //    +--------+--------+
    +    //    |shenzhen|    29.0|
    +    //    +--------+--------+
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 29)))
    +  }
    +
    +  test("test create table as select with sum,count,min,max") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        | STORED BY 'carbondata'
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,sum(age),count(age),min(age),max(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 58, 2, 27, 31)))
    +  }
    +
    +  test("test create table as select with insert data into source_table after CTAS") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,sum(age),count(age),min(age),max(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 58, 2, 27, 31)))
    +  }
    +
    +  test("test create table as select with auto merge") {
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.ENABLE_AUTO_LOAD_MERGE, "true")
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE source_table"), true, "Compacted")
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE target_table"), false, "Compacted")
    +
    +    sql("INSERT INTO target_table SELECT 'shenzhen',8")
    +    sql("INSERT INTO target_table SELECT 'shenzhen',9")
    +    sql("INSERT INTO target_table SELECT 'shenzhen',3")
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE target_table"), true, "Compacted")
    +    checkAnswer(sql("SELECT * FROM target_table"),
    +      Seq(Row("shenzhen", 29), Row("shenzhen", 8), Row("shenzhen", 9), Row("shenzhen", 3)))
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.ENABLE_AUTO_LOAD_MERGE,
    +        CarbonCommonConstants.DEFAULT_ENABLE_AUTO_LOAD_MERGE)
    +  }
    +
    +  test("test create table as select with filter, <, and, >=") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql("INSERT INTO source_table SELECT 3,'jack','shenzhen',5")
    +    sql("INSERT INTO source_table SELECT 4,'alice','shenzhen',35")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table where age > 20 and age <= 31 GROUP BY city
    +      """.stripMargin)
    +
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 29)))
    +  }
    +
    +  test("test create table as select with filter, >=, or, =") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql("INSERT INTO source_table SELECT 3,'jack','shenzhen',5")
    +    sql("INSERT INTO source_table SELECT 4,'alice','shenzhen',35")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table where age >= 20 or age = 5 group by city
    +      """.stripMargin)
    +
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 24.5)))
    +  }
    +
       override def afterAll {
         sql("DROP TABLE IF EXISTS carbon_ctas_test")
         sql("DROP TABLE IF EXISTS parquet_ctas_test")
         sql("DROP TABLE IF EXISTS orc_ctas_test")
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    sql("DROP TABLE IF EXISTS ctas_select_carbon")
    +    sql("DROP TABLE IF EXISTS ctas_select_direct_data")
    +    sql("DROP TABLE IF EXISTS ctas_select_parquet")
    +    sql("DROP TABLE IF EXISTS ctas_select_orc")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_carbon")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_parquet")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_orc")
    +    sql("DROP TABLE IF EXISTS ctas_tblproperties_test")
    +    sql("DROP TABLE IF EXISTS ctas_if_table_name")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    sql("DROP TABLE IF EXISTS target_table")
    --- End diff --
    
    @chenliang613....your understanding is correct. As per the hierarchy below
    CTAS  --> CREATE TABLE AND INSERT INTO (CTAS uses create table and insert into flow)
    INSERT INTO --> SELECT AND DATA LOAD FLOW (Insert into uses select and data load flow)
    
    I believe For Create table, Insert into, Select and Data load we have sufficient number of test cases as FT (which verify end to end functionality).  So new test cases should be added only for inter feature impact testing if required, not for direct feature testing.


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by jackylk <gi...@git.apache.org>.
Github user jackylk commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    LGTM


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/2316/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/4060/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    SDV Build Fail , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/3393/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/2813/



---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by manishgupta88 <gi...@git.apache.org>.
Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1939#discussion_r168085211
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableAsSelect.scala ---
    @@ -53,6 +55,9 @@ class TestCreateTableAsSelect extends QueryTest with BeforeAndAfterAll {
         sql("DROP TABLE IF EXISTS parquet_ctas_test")
         sql("DROP TABLE IF EXISTS orc_ctas_test")
         createTablesAndInsertData
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.COMPACTION_SEGMENT_LEVEL_THRESHOLD,
    +        CarbonCommonConstants.DEFAULT_SEGMENT_LEVEL_THRESHOLD)
    --- End diff --
    
    I could not find any test case for compaction. Please remove this property as it is required only for compaction case


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    retest this please


---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1939#discussion_r168132152
  
    --- Diff: .gitignore ---
    @@ -15,4 +15,5 @@ target/
     .project
     .classpath
     metastore_db/
    -derby.log
    \ No newline at end of file
    +derby.log
    +integration/spark-common-test/src/test/resources/Data
    --- End diff --
    
    I removed this line


---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by manishgupta88 <gi...@git.apache.org>.
Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1939#discussion_r168085120
  
    --- Diff: .gitignore ---
    @@ -15,4 +15,5 @@ target/
     .project
     .classpath
     metastore_db/
    -derby.log
    \ No newline at end of file
    +derby.log
    +integration/spark-common-test/src/test/resources/Data
    --- End diff --
    
    Remove this file..it is not required to be committed


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/3392/



---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by manishgupta88 <gi...@git.apache.org>.
Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1939#discussion_r168085698
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableAsSelect.scala ---
    @@ -170,10 +175,277 @@ class TestCreateTableAsSelect extends QueryTest with BeforeAndAfterAll {
         }
       }
     
    +  test("test create table as select with where clause in select from parquet table that does not return data") {
    +    sql("DROP TABLE IF EXISTS ctas_select_where_parquet")
    +    sql(
    +      """
    +        | CREATE TABLE ctas_select_where_parquet
    +        | STORED BY 'carbondata'
    +        | as select * FROM parquet_ctas_test
    +        | where key=300""".stripMargin)
    +    checkAnswer(sql("SELECT * FROM ctas_select_where_parquet"),
    +      sql("SELECT * FROM parquet_ctas_test where key=300"))
    +  }
    +
    +  test("test create table as select with where clause in select from hive/orc table that does not return data") {
    +    sql("DROP TABLE IF EXISTS ctas_select_where_orc")
    +    sql(
    +      """
    +        | CREATE TABLE ctas_select_where_orc
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM orc_ctas_test
    +        | where key=300""".stripMargin)
    +    checkAnswer(sql("SELECT * FROM ctas_select_where_orc"),
    +      sql("SELECT * FROM orc_ctas_test where key=300"))
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause") {
    +    sql("drop table if exists ctas_same_table_name")
    +    sql("CREATE TABLE ctas_same_table_name(key INT, value STRING) STORED BY 'carbondata'")
    +    checkExistence(sql("SHOW TABLES"), true, "ctas_same_table_name")
    +    sql(
    +      """
    +        | CREATE TABLE IF NOT EXISTS ctas_same_table_name
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM ctas_same_table_name
    +      """.stripMargin)
    +    intercept[Exception] {
    +      sql(
    +        """
    +          | CREATE TABLE ctas_same_table_name
    +          | STORED BY 'carbondata'
    +          | AS SELECT * FROM ctas_same_table_name
    +        """.stripMargin)
    +    }
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause and source table not exists") {
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    checkExistence(sql("SHOW TABLES"), false, "ctas_same_table_name")
    +    intercept[Exception] {
    +      sql(
    +        """
    +          | CREATE TABLE IF NOT EXISTS ctas_same_table_name
    +          | STORED BY 'carbondata'
    +          | AS SELECT * FROM ctas_same_table_name
    +        """.stripMargin)
    +    }
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause and source table exists") {
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    sql("DROP TABLE IF EXISTS ctas_if_table_name")
    +    sql("CREATE TABLE ctas_same_table_name(key INT, value STRING) STORED BY 'carbondata'")
    +    sql(
    +      """
    +        | CREATE TABLE IF NOT EXISTS ctas_if_table_name
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM ctas_same_table_name
    +      """.stripMargin)
    +    checkExistence(sql("show tables"), true, "ctas_if_table_name")
    +  }
    +
    +  test("add example for documentation") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED AS parquet
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age) FROM source_table group by city
    +      """.stripMargin)
    +    // results:
    +    //    sql("SELECT * FROM target_table").show
    +    //    +--------+--------+
    +    //    |    city|avg(age)|
    +    //    +--------+--------+
    +    //    |shenzhen|    29.0|
    +    //    +--------+--------+
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 29)))
    +  }
    +
    +  test("test create table as select with sum,count,min,max") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        | STORED BY 'carbondata'
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,sum(age),count(age),min(age),max(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 58, 2, 27, 31)))
    +  }
    +
    +  test("test create table as select with insert data into source_table after CTAS") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,sum(age),count(age),min(age),max(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 58, 2, 27, 31)))
    +  }
    +
    +  test("test create table as select with auto merge") {
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.ENABLE_AUTO_LOAD_MERGE, "true")
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE source_table"), true, "Compacted")
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE target_table"), false, "Compacted")
    +
    +    sql("INSERT INTO target_table SELECT 'shenzhen',8")
    +    sql("INSERT INTO target_table SELECT 'shenzhen',9")
    +    sql("INSERT INTO target_table SELECT 'shenzhen',3")
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE target_table"), true, "Compacted")
    +    checkAnswer(sql("SELECT * FROM target_table"),
    +      Seq(Row("shenzhen", 29), Row("shenzhen", 8), Row("shenzhen", 9), Row("shenzhen", 3)))
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.ENABLE_AUTO_LOAD_MERGE,
    +        CarbonCommonConstants.DEFAULT_ENABLE_AUTO_LOAD_MERGE)
    +  }
    +
    +  test("test create table as select with filter, <, and, >=") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql("INSERT INTO source_table SELECT 3,'jack','shenzhen',5")
    +    sql("INSERT INTO source_table SELECT 4,'alice','shenzhen',35")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table where age > 20 and age <= 31 GROUP BY city
    +      """.stripMargin)
    +
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 29)))
    +  }
    +
    +  test("test create table as select with filter, >=, or, =") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql("INSERT INTO source_table SELECT 3,'jack','shenzhen',5")
    +    sql("INSERT INTO source_table SELECT 4,'alice','shenzhen',35")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table where age >= 20 or age = 5 group by city
    +      """.stripMargin)
    +
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 24.5)))
    +  }
    +
       override def afterAll {
         sql("DROP TABLE IF EXISTS carbon_ctas_test")
         sql("DROP TABLE IF EXISTS parquet_ctas_test")
         sql("DROP TABLE IF EXISTS orc_ctas_test")
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    sql("DROP TABLE IF EXISTS ctas_select_carbon")
    +    sql("DROP TABLE IF EXISTS ctas_select_direct_data")
    +    sql("DROP TABLE IF EXISTS ctas_select_parquet")
    +    sql("DROP TABLE IF EXISTS ctas_select_orc")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_carbon")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_parquet")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_orc")
    +    sql("DROP TABLE IF EXISTS ctas_tblproperties_test")
    +    sql("DROP TABLE IF EXISTS ctas_if_table_name")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    sql("DROP TABLE IF EXISTS target_table")
    --- End diff --
    
    @xubo245....According to me CTAS is a very small feature in terms of lines of code and internally it uses create table and insert into flow. So I think adding too many test cases for this feature  is not a good idea and it can unnecessary increase the UT test cases running time.
    I believe existing test cases are sufficient to validate the basic functionality of CTAS feature. If there are any problems with the existing test cases you can make modifications and correct them but **I suggest not to add any new test cases until and unless there is some specific scenario or bug in the feature**


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/2308/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/3745/



---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1939#discussion_r168109343
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableAsSelect.scala ---
    @@ -53,6 +55,9 @@ class TestCreateTableAsSelect extends QueryTest with BeforeAndAfterAll {
         sql("DROP TABLE IF EXISTS parquet_ctas_test")
         sql("DROP TABLE IF EXISTS orc_ctas_test")
         createTablesAndInsertData
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.COMPACTION_SEGMENT_LEVEL_THRESHOLD,
    +        CarbonCommonConstants.DEFAULT_SEGMENT_LEVEL_THRESHOLD)
    --- End diff --
    
    Please check this test case:  test("test create table as select with auto merge") 


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/3549/



---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1939#discussion_r168108321
  
    --- Diff: .gitignore ---
    @@ -15,4 +15,5 @@ target/
     .project
     .classpath
     metastore_db/
    -derby.log
    \ No newline at end of file
    +derby.log
    +integration/spark-common-test/src/test/resources/Data
    --- End diff --
    
    Are there any bad effect for carbon? Please tell me if have
    
    When I run SDV in local machine, I need copy DATA directory to carbondata project, and except DATA directory when I git add and commit. So I add this line to .gitignore. I suggest add this line if not bad effect for carbondata project.  
    
    Or there are any better method to solve this problem, please tell me too.


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Failed  with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/3553/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    SDV Build Fail , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/3754/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/2505/



---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1939#discussion_r168121198
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableAsSelect.scala ---
    @@ -170,10 +175,277 @@ class TestCreateTableAsSelect extends QueryTest with BeforeAndAfterAll {
         }
       }
     
    +  test("test create table as select with where clause in select from parquet table that does not return data") {
    +    sql("DROP TABLE IF EXISTS ctas_select_where_parquet")
    +    sql(
    +      """
    +        | CREATE TABLE ctas_select_where_parquet
    +        | STORED BY 'carbondata'
    +        | as select * FROM parquet_ctas_test
    +        | where key=300""".stripMargin)
    +    checkAnswer(sql("SELECT * FROM ctas_select_where_parquet"),
    +      sql("SELECT * FROM parquet_ctas_test where key=300"))
    +  }
    +
    +  test("test create table as select with where clause in select from hive/orc table that does not return data") {
    +    sql("DROP TABLE IF EXISTS ctas_select_where_orc")
    +    sql(
    +      """
    +        | CREATE TABLE ctas_select_where_orc
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM orc_ctas_test
    +        | where key=300""".stripMargin)
    +    checkAnswer(sql("SELECT * FROM ctas_select_where_orc"),
    +      sql("SELECT * FROM orc_ctas_test where key=300"))
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause") {
    +    sql("drop table if exists ctas_same_table_name")
    +    sql("CREATE TABLE ctas_same_table_name(key INT, value STRING) STORED BY 'carbondata'")
    +    checkExistence(sql("SHOW TABLES"), true, "ctas_same_table_name")
    +    sql(
    +      """
    +        | CREATE TABLE IF NOT EXISTS ctas_same_table_name
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM ctas_same_table_name
    +      """.stripMargin)
    +    intercept[Exception] {
    +      sql(
    +        """
    +          | CREATE TABLE ctas_same_table_name
    +          | STORED BY 'carbondata'
    +          | AS SELECT * FROM ctas_same_table_name
    +        """.stripMargin)
    +    }
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause and source table not exists") {
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    checkExistence(sql("SHOW TABLES"), false, "ctas_same_table_name")
    +    intercept[Exception] {
    +      sql(
    +        """
    +          | CREATE TABLE IF NOT EXISTS ctas_same_table_name
    +          | STORED BY 'carbondata'
    +          | AS SELECT * FROM ctas_same_table_name
    +        """.stripMargin)
    +    }
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause and source table exists") {
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    sql("DROP TABLE IF EXISTS ctas_if_table_name")
    +    sql("CREATE TABLE ctas_same_table_name(key INT, value STRING) STORED BY 'carbondata'")
    +    sql(
    +      """
    +        | CREATE TABLE IF NOT EXISTS ctas_if_table_name
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM ctas_same_table_name
    +      """.stripMargin)
    +    checkExistence(sql("show tables"), true, "ctas_if_table_name")
    +  }
    +
    +  test("add example for documentation") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED AS parquet
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age) FROM source_table group by city
    +      """.stripMargin)
    +    // results:
    +    //    sql("SELECT * FROM target_table").show
    +    //    +--------+--------+
    +    //    |    city|avg(age)|
    +    //    +--------+--------+
    +    //    |shenzhen|    29.0|
    +    //    +--------+--------+
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 29)))
    +  }
    +
    +  test("test create table as select with sum,count,min,max") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        | STORED BY 'carbondata'
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,sum(age),count(age),min(age),max(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 58, 2, 27, 31)))
    +  }
    +
    +  test("test create table as select with insert data into source_table after CTAS") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,sum(age),count(age),min(age),max(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 58, 2, 27, 31)))
    +  }
    +
    +  test("test create table as select with auto merge") {
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.ENABLE_AUTO_LOAD_MERGE, "true")
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE source_table"), true, "Compacted")
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE target_table"), false, "Compacted")
    +
    +    sql("INSERT INTO target_table SELECT 'shenzhen',8")
    +    sql("INSERT INTO target_table SELECT 'shenzhen',9")
    +    sql("INSERT INTO target_table SELECT 'shenzhen',3")
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE target_table"), true, "Compacted")
    +    checkAnswer(sql("SELECT * FROM target_table"),
    +      Seq(Row("shenzhen", 29), Row("shenzhen", 8), Row("shenzhen", 9), Row("shenzhen", 3)))
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.ENABLE_AUTO_LOAD_MERGE,
    +        CarbonCommonConstants.DEFAULT_ENABLE_AUTO_LOAD_MERGE)
    +  }
    +
    +  test("test create table as select with filter, <, and, >=") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql("INSERT INTO source_table SELECT 3,'jack','shenzhen',5")
    +    sql("INSERT INTO source_table SELECT 4,'alice','shenzhen',35")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table where age > 20 and age <= 31 GROUP BY city
    +      """.stripMargin)
    +
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 29)))
    +  }
    +
    +  test("test create table as select with filter, >=, or, =") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql("INSERT INTO source_table SELECT 3,'jack','shenzhen',5")
    +    sql("INSERT INTO source_table SELECT 4,'alice','shenzhen',35")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table where age >= 20 or age = 5 group by city
    +      """.stripMargin)
    +
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 24.5)))
    +  }
    +
       override def afterAll {
         sql("DROP TABLE IF EXISTS carbon_ctas_test")
         sql("DROP TABLE IF EXISTS parquet_ctas_test")
         sql("DROP TABLE IF EXISTS orc_ctas_test")
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    sql("DROP TABLE IF EXISTS ctas_select_carbon")
    +    sql("DROP TABLE IF EXISTS ctas_select_direct_data")
    +    sql("DROP TABLE IF EXISTS ctas_select_parquet")
    +    sql("DROP TABLE IF EXISTS ctas_select_orc")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_carbon")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_parquet")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_orc")
    +    sql("DROP TABLE IF EXISTS ctas_tblproperties_test")
    +    sql("DROP TABLE IF EXISTS ctas_if_table_name")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    sql("DROP TABLE IF EXISTS target_table")
    --- End diff --
    
    I think we should add test cases for checking CTAS basic function, like filter,sum and so on. When user use CTAS feature, they usually use filter and sum etc basic function.
    
    If no test cases to ensure the basic function, how to find the feature problem when other developer change the code logic in the future? we should ensure the function before user
    encounter a problem, not fix the problem after user encounter the problem.
    
    For UT test cases running time, I think we should consider other methods to decrease run time, such as increase the number of machine.  And we should more focus on ensure feature function,  such as increase the coverage of carbondata project, now the coverage only 71%


---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by chenliang613 <gi...@git.apache.org>.
Github user chenliang613 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1939#discussion_r168372650
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableAsSelect.scala ---
    @@ -170,10 +175,277 @@ class TestCreateTableAsSelect extends QueryTest with BeforeAndAfterAll {
         }
       }
     
    +  test("test create table as select with where clause in select from parquet table that does not return data") {
    +    sql("DROP TABLE IF EXISTS ctas_select_where_parquet")
    +    sql(
    +      """
    +        | CREATE TABLE ctas_select_where_parquet
    +        | STORED BY 'carbondata'
    +        | as select * FROM parquet_ctas_test
    +        | where key=300""".stripMargin)
    +    checkAnswer(sql("SELECT * FROM ctas_select_where_parquet"),
    +      sql("SELECT * FROM parquet_ctas_test where key=300"))
    +  }
    +
    +  test("test create table as select with where clause in select from hive/orc table that does not return data") {
    +    sql("DROP TABLE IF EXISTS ctas_select_where_orc")
    +    sql(
    +      """
    +        | CREATE TABLE ctas_select_where_orc
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM orc_ctas_test
    +        | where key=300""".stripMargin)
    +    checkAnswer(sql("SELECT * FROM ctas_select_where_orc"),
    +      sql("SELECT * FROM orc_ctas_test where key=300"))
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause") {
    +    sql("drop table if exists ctas_same_table_name")
    +    sql("CREATE TABLE ctas_same_table_name(key INT, value STRING) STORED BY 'carbondata'")
    +    checkExistence(sql("SHOW TABLES"), true, "ctas_same_table_name")
    +    sql(
    +      """
    +        | CREATE TABLE IF NOT EXISTS ctas_same_table_name
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM ctas_same_table_name
    +      """.stripMargin)
    +    intercept[Exception] {
    +      sql(
    +        """
    +          | CREATE TABLE ctas_same_table_name
    +          | STORED BY 'carbondata'
    +          | AS SELECT * FROM ctas_same_table_name
    +        """.stripMargin)
    +    }
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause and source table not exists") {
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    checkExistence(sql("SHOW TABLES"), false, "ctas_same_table_name")
    +    intercept[Exception] {
    +      sql(
    +        """
    +          | CREATE TABLE IF NOT EXISTS ctas_same_table_name
    +          | STORED BY 'carbondata'
    +          | AS SELECT * FROM ctas_same_table_name
    +        """.stripMargin)
    +    }
    +  }
    +
    +  test("test create table as select with select from same carbon table name with if not exists clause and source table exists") {
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    sql("DROP TABLE IF EXISTS ctas_if_table_name")
    +    sql("CREATE TABLE ctas_same_table_name(key INT, value STRING) STORED BY 'carbondata'")
    +    sql(
    +      """
    +        | CREATE TABLE IF NOT EXISTS ctas_if_table_name
    +        | STORED BY 'carbondata'
    +        | AS SELECT * FROM ctas_same_table_name
    +      """.stripMargin)
    +    checkExistence(sql("show tables"), true, "ctas_if_table_name")
    +  }
    +
    +  test("add example for documentation") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED AS parquet
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age) FROM source_table group by city
    +      """.stripMargin)
    +    // results:
    +    //    sql("SELECT * FROM target_table").show
    +    //    +--------+--------+
    +    //    |    city|avg(age)|
    +    //    +--------+--------+
    +    //    |shenzhen|    29.0|
    +    //    +--------+--------+
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 29)))
    +  }
    +
    +  test("test create table as select with sum,count,min,max") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        | STORED BY 'carbondata'
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,sum(age),count(age),min(age),max(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 58, 2, 27, 31)))
    +  }
    +
    +  test("test create table as select with insert data into source_table after CTAS") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,sum(age),count(age),min(age),max(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 58, 2, 27, 31)))
    +  }
    +
    +  test("test create table as select with auto merge") {
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.ENABLE_AUTO_LOAD_MERGE, "true")
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table group by city
    +      """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE source_table"), true, "Compacted")
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE target_table"), false, "Compacted")
    +
    +    sql("INSERT INTO target_table SELECT 'shenzhen',8")
    +    sql("INSERT INTO target_table SELECT 'shenzhen',9")
    +    sql("INSERT INTO target_table SELECT 'shenzhen',3")
    +    checkExistence(sql("SHOW SEGMENTS FOR TABLE target_table"), true, "Compacted")
    +    checkAnswer(sql("SELECT * FROM target_table"),
    +      Seq(Row("shenzhen", 29), Row("shenzhen", 8), Row("shenzhen", 9), Row("shenzhen", 3)))
    +    CarbonProperties.getInstance().
    +      addProperty(CarbonCommonConstants.ENABLE_AUTO_LOAD_MERGE,
    +        CarbonCommonConstants.DEFAULT_ENABLE_AUTO_LOAD_MERGE)
    +  }
    +
    +  test("test create table as select with filter, <, and, >=") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql("INSERT INTO source_table SELECT 3,'jack','shenzhen',5")
    +    sql("INSERT INTO source_table SELECT 4,'alice','shenzhen',35")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table where age > 20 and age <= 31 GROUP BY city
    +      """.stripMargin)
    +
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 29)))
    +  }
    +
    +  test("test create table as select with filter, >=, or, =") {
    +    sql("DROP TABLE IF EXISTS target_table")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    // create carbon table and insert data
    +    sql(
    +      """
    +        | CREATE TABLE source_table(
    +        |     id INT,
    +        |     name STRING,
    +        |     city STRING,
    +        |     age INT)
    +        |     STORED BY 'carbondata'
    +        |     """.stripMargin)
    +    sql("INSERT INTO source_table SELECT 1,'bob','shenzhen',27")
    +    sql("INSERT INTO source_table SELECT 2,'david','shenzhen',31")
    +    sql("INSERT INTO source_table SELECT 3,'jack','shenzhen',5")
    +    sql("INSERT INTO source_table SELECT 4,'alice','shenzhen',35")
    +    sql(
    +      """
    +        | CREATE TABLE target_table
    +        | STORED BY 'carbondata'
    +        | AS
    +        |   SELECT city,avg(age)
    +        |   FROM source_table where age >= 20 or age = 5 group by city
    +      """.stripMargin)
    +
    +    checkAnswer(sql("SELECT * FROM target_table"), Seq(Row("shenzhen", 24.5)))
    +  }
    +
       override def afterAll {
         sql("DROP TABLE IF EXISTS carbon_ctas_test")
         sql("DROP TABLE IF EXISTS parquet_ctas_test")
         sql("DROP TABLE IF EXISTS orc_ctas_test")
    +    sql("DROP TABLE IF EXISTS ctas_same_table_name")
    +    sql("DROP TABLE IF EXISTS ctas_select_carbon")
    +    sql("DROP TABLE IF EXISTS ctas_select_direct_data")
    +    sql("DROP TABLE IF EXISTS ctas_select_parquet")
    +    sql("DROP TABLE IF EXISTS ctas_select_orc")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_carbon")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_parquet")
    +    sql("DROP TABLE IF EXISTS ctas_select_where_orc")
    +    sql("DROP TABLE IF EXISTS ctas_tblproperties_test")
    +    sql("DROP TABLE IF EXISTS ctas_if_table_name")
    +    sql("DROP TABLE IF EXISTS source_table")
    +    sql("DROP TABLE IF EXISTS target_table")
    --- End diff --
    
    @manishgupta88  so your point is that : CTAS feature is reusing "create table and insert into" flows, so you proposed to add test cases from "create table and insert into" perspective , not from CTAS perspective ?  If my understanding is right,  i agree with manish's point.


---

[GitHub] carbondata pull request #1939: [CARBONDATA-2139] Optimize CTAS documentation...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/carbondata/pull/1939


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    retest sdv please


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    @sraghunandan @chenliang613 @jackylk @ravipesala Please review it


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    @chenliang613 @jackylk @ravipesala @sraghunandan  Please review it


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/3768/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    SDV Build Fail , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/3390/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    SDV Build Fail , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/3387/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/3545/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    retest this please


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/2312/



---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    retest sdv please


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    retest sdv please


---

[GitHub] carbondata issue #1939: [CARBONDATA-2139] Optimize CTAS documentation and te...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/1939
  
    Build Failed with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/2314/



---