jerryshao commented on code in PR #5078:
URL: https://github.com/apache/gravitino/pull/5078#discussion_r1794604283
##########
core/src/main/java/org/apache/gravitino/storage/relational/service/TableMetaService.java:
##########
@@ -117,16 +108,34 @@ public void insertTable(TableEntity tableEntity, boolean
overwrite) throws IOExc
TablePO.Builder builder = TablePO.builder();
fillTablePOBuilderParentEntityId(builder, tableEntity.namespace());
- SessionUtils.doWithCommit(
- TableMetaMapper.class,
- mapper -> {
- TablePO po =
POConverters.initializeTablePOWithVersion(tableEntity, builder);
+ AtomicReference<TablePO> tablePORef = new AtomicReference<>();
+ SessionUtils.doMultipleWithCommit(
+ () ->
+ SessionUtils.doWithoutCommit(
+ TableMetaMapper.class,
+ mapper -> {
+ TablePO po =
POConverters.initializeTablePOWithVersion(tableEntity, builder);
+ tablePORef.set(po);
+ if (overwrite) {
+ mapper.insertTableMetaOnDuplicateKeyUpdate(po);
+ } else {
+ mapper.insertTableMeta(po);
+ }
+ }),
+ () -> {
+ // We need to delete the columns first if we want to overwrite the
table.
if (overwrite) {
- mapper.insertTableMetaOnDuplicateKeyUpdate(po);
- } else {
- mapper.insertTableMeta(po);
+ TableColumnMetaService.getInstance()
Review Comment:
> we don't need to drop all columns and create them if no changes have been
made to them such as table renaming, or altering table comments
If we don't want to update the columns, we have to fetch the old columns
then do the comparison. The current `overwrite` doesn't fetch the old data, so
we have to fetch again, the overhead is the same.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]