jerryshao commented on code in PR #5127:
URL: https://github.com/apache/gravitino/pull/5127#discussion_r1803021307
##########
core/src/main/java/org/apache/gravitino/catalog/TableOperationDispatcher.java:
##########
@@ -492,4 +526,153 @@ private Table internalCreateTable(
getHiddenPropertyNames(
catalogIdent, HasPropertyMetadata::tablePropertiesMetadata,
table.properties()));
}
+
+ private List<ColumnEntity> toColumnEntities(Column[] columns, AuditInfo
audit) {
+ return columns == null
+ ? Collections.emptyList()
+ : Arrays.stream(columns)
+ .map(c -> ColumnEntity.toColumnEntity(c, idGenerator.nextId(),
audit))
+ .collect(Collectors.toList());
+ }
+
+ private boolean isSameColumn(Column left, ColumnEntity right) {
+ return Objects.equal(left.name(), right.name())
+ && Objects.equal(left.dataType(), right.dataType())
+ && Objects.equal(left.comment(), right.comment())
+ && left.nullable() == right.nullable()
+ && left.autoIncrement() == right.autoIncrement()
+ && Objects.equal(left.defaultValue(), right.defaultValue());
+ }
+
+ private Pair<Boolean, List<ColumnEntity>> updateColumnsIfNecessary(
+ Table tableFromCatalog, TableEntity tableFromGravitino) {
+ if (tableFromCatalog == null || tableFromGravitino == null) {
+ LOG.warn(
+ "Cannot update columns for table when altering because table or
table entity is "
+ + "null");
+ return Pair.of(false, Collections.emptyList());
+ }
+
+ Map<String, Column> columnsFromCatalogTable =
+ tableFromCatalog.columns() == null
+ ? Collections.emptyMap()
+ : Arrays.stream(tableFromCatalog.columns())
+ .collect(Collectors.toMap(Column::name, Function.identity()));
+ Map<String, ColumnEntity> columnsFromTableEntity =
+ tableFromGravitino.columns() == null
+ ? Collections.emptyMap()
+ : tableFromGravitino.columns().stream()
+ .collect(Collectors.toMap(ColumnEntity::name,
Function.identity()));
+
+ // Check if columns need to be updated in Gravitino store
Review Comment:
We don't maintain the order of columns in entity store, we only store them.
The columns return to user are all from catalog, if the order is guaranteed by
catalog, then it is fine.
--
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]