[GitHub] [carbondata] ravipesala commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] ravipesala commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment

GitBox
ravipesala commented on a change in pull request #3426: [CARBONDATA-3560] Fixed issues for Add Segment
URL: https://github.com/apache/carbondata/pull/3426#discussion_r342446221
 
 

 ##########
 File path: integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/management/CarbonAddLoadCommand.scala
 ##########
 @@ -92,6 +92,23 @@ case class CarbonAddLoadCommand(
     val segmentPath = options.getOrElse(
       "path", throw new UnsupportedOperationException("PATH is manadatory"))
 
+    val allSegments = SegmentStatusManager.readLoadMetadata(carbonTable.getMetadataPath)
+
+    // If a path is already added then we should block the adding of the same path again.
+    allSegments.exists { a =>
+      a.getPath != null && a.getPath.equalsIgnoreCase(segmentPath)
+      throw new AnalysisException(s"Cannot add the segment. This path is already in use by " +
+                                  s"another segment.")
+    }
+
+    val format = options.getOrElse("format", "carbondata")
+    val isCarbonFormat = format.equalsIgnoreCase("carbondata") || format.equalsIgnoreCase("carbon")
+
+    // If in the given location no carbon files are found then we can throw an exception
+    if (isCarbonFormat && SegmentFileStore.getListOfCarbonIndexFiles(segmentPath).isEmpty) {
 
 Review comment:
   @manishnalla1994  the condition earlier is not for validation, it is just to update the metadata. How is the behavior of SparkFiileFormat infer schema if there are no carbondata or carbonindex files? I feel it is better to correct in the down layer than adding validations on top layer.

----------------------------------------------------------------
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