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_r346193191
##########
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")
Review comment:
please refactor code and put in single method or multiple methods for common
code
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services