akashrn5 commented on a change in pull request #3440: [CARBONDATA-3574] Block IUD for Add Segment and Delete segment by id issue fix
URL: https://github.com/apache/carbondata/pull/3440#discussion_r346192965 ########## File path: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/addsegment/AddSegmentTestCase.scala ########## @@ -314,6 +315,104 @@ class AddSegmentTestCase extends QueryTest with BeforeAndAfterAll { FileFactory.deleteAllFilesOfDir(new File(newPath)) } + test("Test update/delete blocking on mixed format segments") { + sql("drop table if exists addsegment1") + sql("drop table if exists addsegment2") + sql( + """ + | CREATE TABLE addsegment1 (empname String, designation String, doj Timestamp, + | workgroupcategory int, workgroupcategoryname String, deptno int, deptname String, + | projectcode int, projectjoindate Timestamp, projectenddate Date,attendance int, + | utilization int,salary int, empno int) + | STORED BY 'org.apache.carbondata.format' + """.stripMargin) + + sql( + s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE addsegment1 OPTIONS + |('DELIMITER'= ',', 'QUOTECHAR'= '"')""".stripMargin) + + sql( + """ + | CREATE TABLE addsegment2 (empname String, designation String, doj Timestamp, + | workgroupcategory int, workgroupcategoryname String, deptno int, deptname String, + | projectcode int, projectjoindate Timestamp, projectenddate Date,attendance int, + | utilization int,salary int, empno int) using parquet + """.stripMargin) + + sql(s"""insert into addsegment2 select * from addsegment1""") + + sql("select * from addsegment2").show() + val table = SparkSQLUtil.sessionState(sqlContext.sparkSession).catalog + .getTableMetadata(TableIdentifier("addsegment2")) + val path = table.location + val newPath = storeLocation + "/" + "addsegtest" + FileFactory.deleteAllFilesOfDir(new File(newPath)) + copy(path.toString, newPath) + + sql(s"alter table addsegment1 add segment options('path'='$newPath', 'format'='parquet')") + val exception1 = intercept[MalformedCarbonCommandException](sql( + """update addsegment1 d set (d.empname) = ('ravi') where d.empname = 'arvind'""").show()) + assertResult("Unsupported update operation for table containing mixed format segments")( + exception1.getMessage()) + val exception2 = intercept[MalformedCarbonCommandException](sql( + "delete from addsegment1 where deptno = 10")) + assertResult("Unsupported delete operation for table containing mixed format segments")( + exception2.getMessage()) + FileFactory.deleteAllFilesOfDir(new File(newPath)) + } + + test("Test delete by id for added segment") { + sql("drop table if exists addsegment1") + sql("drop table if exists addsegment2") + sql( + """ + | CREATE TABLE addsegment1 (empname String, designation String, doj Timestamp, + | workgroupcategory int, workgroupcategoryname String, deptno int, deptname String, + | projectcode int, projectjoindate Timestamp, projectenddate Date,attendance int, + | utilization int,salary int, empno int) + | STORED BY 'org.apache.carbondata.format' + """.stripMargin) + + sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE addsegment1 OPTIONS('DELIMITER'= ',', 'QUOTECHAR'= '"')""") + + sql( + """ + | CREATE TABLE addsegment2 (empname String, designation String, doj Timestamp, + | workgroupcategory int, workgroupcategoryname String, deptno int, deptname String, + | projectcode int, projectjoindate Timestamp, projectenddate Date,attendance int, + | utilization int,salary int, empno int) using parquet + """.stripMargin) + + sql(s"""insert into addsegment2 select * from addsegment1""") + + sql("select * from addsegment2").show() + val table = SparkSQLUtil.sessionState(sqlContext.sparkSession).catalog + .getTableMetadata(TableIdentifier("addsegment2")) + val path = table.location + val newPath = storeLocation + "/" + "addsegtest" + FileFactory.deleteAllFilesOfDir(new File(newPath)) + copy(path.toString, newPath) + checkAnswer(sql("select count(*) from addsegment1"), Seq(Row(10))) + + sql(s"alter table addsegment1 add segment options('path'='$newPath', 'format'='parquet')").show() + sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE addsegment1 OPTIONS('DELIMITER'= ',', 'QUOTECHAR'= '"')""") + sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE addsegment1 OPTIONS('DELIMITER'= ',', 'QUOTECHAR'= '"')""") + + checkAnswer(sql("select count(*) from addsegment1"), Seq(Row(40))) + sql("show segments for table addsegment1").show(100, false) + sql("delete from table addsegment1 where segment.id in(3)") + checkAnswer(sql("select count(*) from addsegment1"), Seq(Row(30))) + sql("show segments for table addsegment1").show(100, false) + sql("delete from table addsegment1 where segment.id in(2)") + checkAnswer(sql("select count(*) from addsegment1"), Seq(Row(20))) + sql("show segments for table addsegment1").show(100, false) + sql("delete from table addsegment1 where segment.id in(0,1)") + checkAnswer(sql("select count(*) from addsegment1"), Seq(Row(0))) + sql("show segments for table addsegment1").show(100, false) Review comment: remove show segments ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [hidden email] With regards, Apache Git Services |
Free forum by Nabble | Edit this page |