New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CARBONDATA-1882] select with group by and insertoverwrite to another carbon table #1641
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
integration/spark-common-test/src/test/resources/overwriteTable1_noRecord.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
id,name,salary |
6 changes: 6 additions & 0 deletions
6
integration/spark-common-test/src/test/resources/overwriteTable1_someRecord.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
id,name,salary | ||
1,hello,2300 | ||
2,hi,2500 | ||
3,xyz,4000 | ||
4,xyz1,5000 | ||
5,xyz2,6000 |
1 change: 1 addition & 0 deletions
1
integration/spark-common-test/src/test/resources/overwriteTable2_noRecord.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
id,name,salary,age |
4 changes: 4 additions & 0 deletions
4
integration/spark-common-test/src/test/resources/overwriteTable2_someRecord.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
id,name,salary,age | ||
9,abc,48,20 | ||
10,abc1,90,21 | ||
11,abc2,99,22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,7 +375,17 @@ object CarbonDataRDDFactory { | |
} | ||
} | ||
} else { | ||
loadStatus = SegmentStatus.LOAD_FAILURE | ||
// if no value is there in data load, make load status Success | ||
// and data load flow executes | ||
if (dataFrame.isDefined && updateModel.isEmpty) { | ||
val rdd = dataFrame.get.rdd | ||
if (rdd.partitions == null || rdd.partitions.length == 0) { | ||
LOGGER.warn("DataLoading finished. No data was loaded.") | ||
loadStatus = SegmentStatus.SUCCESS | ||
} | ||
} else { | ||
loadStatus = SegmentStatus.LOAD_FAILURE | ||
} | ||
} | ||
|
||
if (loadStatus != SegmentStatus.LOAD_FAILURE && | ||
|
@@ -483,20 +493,21 @@ object CarbonDataRDDFactory { | |
s"${ carbonLoadModel.getDatabaseName }.${ carbonLoadModel.getTableName }") | ||
throw new Exception(status(0)._2._2.errorMsg) | ||
} | ||
// if segment is empty then fail the data load | ||
// as no record loaded in new segment, new segment should be deleted | ||
var newEntryLoadStatus = | ||
if (!carbonLoadModel.getCarbonDataLoadSchema.getCarbonTable.isChildDataMap && | ||
!CarbonLoaderUtil.isValidSegment(carbonLoadModel, carbonLoadModel.getSegmentId.toInt)) { | ||
// update the load entry in table status file for changing the status to marked for delete | ||
CommonUtil.updateTableStatusForFailure(carbonLoadModel) | ||
LOGGER.info("********starting clean up**********") | ||
CarbonLoaderUtil.deleteSegment(carbonLoadModel, carbonLoadModel.getSegmentId.toInt) | ||
LOGGER.info("********clean up done**********") | ||
|
||
LOGGER.audit(s"Data load is failed for " + | ||
s"${ carbonLoadModel.getDatabaseName }.${ carbonLoadModel.getTableName }" + | ||
" as there is no data to load") | ||
LOGGER.warn("Cannot write load metadata file as data load failed") | ||
throw new Exception("No Data to load") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. write comment 'as no records loaded in new segment, new segment should be deleted' |
||
SegmentStatus.MARKED_FOR_DELETE | ||
} else { | ||
loadStatus | ||
} | ||
|
||
writeDictionary(carbonLoadModel, result, writeAll = false) | ||
val loadTablePreStatusUpdateEvent: LoadTablePreStatusUpdateEvent = | ||
LoadTablePreStatusUpdateEvent( | ||
|
@@ -505,7 +516,13 @@ object CarbonDataRDDFactory { | |
carbonLoadModel) | ||
operationContext.setProperty("isOverwrite", overwriteTable) | ||
OperationListenerBus.getInstance().fireEvent(loadTablePreStatusUpdateEvent, operationContext) | ||
val done = updateTableStatus(status, carbonLoadModel, loadStatus, overwriteTable) | ||
val done = | ||
updateTableStatus( | ||
status, | ||
carbonLoadModel, | ||
loadStatus, | ||
newEntryLoadStatus, | ||
overwriteTable) | ||
if (!done) { | ||
CommonUtil.updateTableStatusForFailure(carbonLoadModel) | ||
LOGGER.info("********starting clean up**********") | ||
|
@@ -766,17 +783,18 @@ object CarbonDataRDDFactory { | |
status: Array[(String, (LoadMetadataDetails, ExecutionErrors))], | ||
carbonLoadModel: CarbonLoadModel, | ||
loadStatus: SegmentStatus, | ||
newEntryLoadStatus: SegmentStatus, | ||
overwriteTable: Boolean | ||
): Boolean = { | ||
val carbonTable = carbonLoadModel.getCarbonDataLoadSchema.getCarbonTable | ||
val metadataDetails = if (status != null && status(0) != null) { | ||
val metadataDetails = if (status != null && status.size > 0 && status(0) != null) { | ||
status(0)._2._1 | ||
} else { | ||
new LoadMetadataDetails | ||
} | ||
CarbonLoaderUtil.populateNewLoadMetaEntry( | ||
metadataDetails, | ||
loadStatus, | ||
newEntryLoadStatus, | ||
carbonLoadModel.getFactTimeStamp, | ||
true) | ||
CarbonUtil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only insert overwrite query is kept in all the testcases as we handled two different scenario 1) IN GROUP BY CASE
2) WITHOUT GROUP BY CASE if we refactor so one extra method need to be written where again same code will exists