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. --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/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") --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/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% --- |
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_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. --- |
In reply to this post by qiuchenjian-2
Github user xubo245 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/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 --- |
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/3745/ --- |
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/2505/ --- |
In reply to this post by qiuchenjian-2
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. --- |
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_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. --- |
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 --- |
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 --- |
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/2813/ --- |
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/4060/ --- |
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/3754/ --- |
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 --- |
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/3768/ --- |
In reply to this post by qiuchenjian-2
|
In reply to this post by qiuchenjian-2
|
Free forum by Nabble | Edit this page |