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

classic Classic list List threaded Threaded
38 messages Options
12
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
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 <601450868@...>
Date:   2018-02-07T04:16:41Z

    [CARBONDATA-2139] Optimize CTAS documentation and test case

----


---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user xubo245 commented on the issue:

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


---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user xubo245 commented on the issue:

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


---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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/



---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user xubo245 commented on the issue:

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


---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user xubo245 commented on the issue:

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


---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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


---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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


---
Reply | Threaded
Open this post in threaded view
|

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

qiuchenjian-2
In reply to this post by qiuchenjian-2
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**


---
12