zheliu2 opened a new pull request, #15565: URL: https://github.com/apache/iceberg/pull/15565
## Root Cause When concurrently re-applying the same changes to a View, the addSchemaInternal method in ViewMetadata.Builder detects that the schema already exists and returns early without setting lastAddedSchemaId. Subsequently, addVersionInternal tries to resolve LAST_ADDED (-1) as the schema ID, but lastAddedSchemaId is still null, causing a ValidationException: Cannot set last added schema: no schema has been added. ## Fix When addSchemaInternal finds a duplicate schema (one that already exists with the same fields), it now sets lastAddedSchemaId to the existing schema's ID before returning. This ensures that subsequent calls to addVersionInternal can correctly resolve LAST_ADDED to the existing schema. ## Testing Added two tests in TestViewMetadata: - concurrentReApplyOfSameViewChanges - reproduces the exact scenario from the issue where buildFrom(existing).setCurrentVersion(sameVersion, sameSchema) fails - concurrentReApplyWithNewVersionButSameSchema - verifies that a new version with different SQL but the same schema works correctly Fixes #15008 -- 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]
