morningman commented on code in PR #57972:
URL: https://github.com/apache/doris/pull/57972#discussion_r2552550111
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/iceberg/IcebergMetadataOps.java:
##########
@@ -767,6 +773,133 @@ public ExecutionAuthenticator getExecutionAuthenticator()
{
return executionAuthenticator;
}
+ private Term getTransform(String transformName, String columnName, Integer
transformArg) throws UserException {
+ if (columnName == null) {
+ throw new UserException("Column name is required for partition
transform");
+ }
+ if (transformName == null) {
+ // identity transform
+ return Expressions.ref(columnName);
+ }
+ switch (transformName.toLowerCase()) {
+ case "bucket":
+ if (transformArg == null) {
+ throw new UserException("Bucket transform requires a
bucket count argument");
+ }
+ return Expressions.bucket(columnName, transformArg);
+ case "truncate":
+ if (transformArg == null) {
+ throw new UserException("Truncate transform requires a
width argument");
+ }
+ return Expressions.truncate(columnName, transformArg);
+ case "year":
+ return Expressions.year(columnName);
+ case "month":
+ return Expressions.month(columnName);
+ case "day":
+ return Expressions.day(columnName);
+ case "hour":
+ return Expressions.hour(columnName);
+ default:
+ throw new UserException("Unsupported partition transform: " +
transformName);
+ }
+ }
+
+ /**
+ * Add partition field to Iceberg table for partition evolution
+ */
+ public void addPartitionField(ExternalTable dorisTable,
AddPartitionFieldClause clause) throws UserException {
+ Table icebergTable = IcebergUtils.getIcebergTable(dorisTable);
+ UpdatePartitionSpec updateSpec = icebergTable.updateSpec();
+
+ String transformName = clause.getTransformName();
+ Integer transformArg = clause.getTransformArg();
+ String columnName = clause.getColumnName();
+ String partitionFieldName = clause.getPartitionFieldName();
+ Term transform = getTransform(transformName, columnName, transformArg);
+
+ if (partitionFieldName != null) {
+ updateSpec.addField(partitionFieldName, transform);
+ } else {
+ updateSpec.addField(transform);
+ }
+
+ try {
+ executionAuthenticator.execute(() -> updateSpec.commit());
+ } catch (Exception e) {
+ throw new UserException("Failed to add partition field to table: "
+ icebergTable.name()
+ + ", error message is: " + e.getMessage(), e);
Review Comment:
Use `util.getRootCause(e)`
Same suggestion for others
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/hive/IcebergDlaTable.java:
##########
@@ -122,20 +121,15 @@ boolean isPartitionColumnAllowNull() {
@Override
protected boolean isValidRelatedTable() {
- if (isValidRelatedTableCached) {
Review Comment:
Why remove this?
##########
fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java:
##########
@@ -181,6 +186,16 @@ private boolean
processAlterOlapTableInternal(List<AlterClause> alterClauses, Ol
AlterOperations currentAlterOps = new AlterOperations();
currentAlterOps.checkConflict(alterClauses);
+ // Check for unsupported operations on internal tables
+ for (AlterClause clause : alterClauses) {
+ if (clause instanceof AddPartitionFieldClause) {
+ throw new UserException("ADD PARTITION KEY is only supported
for Iceberg tables");
+ }
+ if (clause instanceof DropPartitionFieldClause) {
Review Comment:
missing `ReplacePartitionFieldClause`?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]