opencoder5241 opened a new issue, #14311:
URL: https://github.com/apache/gravitino/issues/14311

   ### Version
   
   main branch — update construction inspected at `eb11e9e1c`, using Iceberg 
1.11.0.
   
   ### Describe what's wrong
   
   Replacing an Iceberg view with a previously used definition can fail.
   
   Gravitino generates an `AddViewVersion` update followed by 
`SetCurrentViewVersion(-1)`. Iceberg may reuse an equivalent historical version 
instead of adding a new one. In that case, the subsequent update cannot resolve 
the last-added version.
   
   The operation should complete successfully.
   
   ### Error message and/or stacktrace
   
   ```text
   org.apache.iceberg.exceptions.ValidationException:
   Cannot set last version id: no current version id has been set
   
   at org.apache.iceberg.view.ViewMetadata$Builder.setCurrentVersionId
   at org.apache.iceberg.MetadataUpdate$SetCurrentViewVersion.applyTo
   at org.apache.iceberg.rest.CatalogHandlers.commit
   ```
   
   ### How to reproduce
   
   Use the Gravitino View API with an Iceberg catalog supporting views:
   
   1. Create a view with definition A: column `id`, SQL `SELECT id FROM source 
WHERE age > 10`.
   2. Replace it with definition B: columns `id, name`, SQL `SELECT id, name 
FROM source WHERE age > 20`.
   3. Replace it with definition A again.
   4. Replace it with definition B again.
   
   The fourth operation fails. Use `integer` for `id`, `string` for `name`, and 
the `spark` dialect for both definitions.
   
   ### Additional context
   
   Iceberg's `sameViewVersion()` compares `summary`, `representations`, 
`defaultCatalog`, `defaultNamespace`, and `schemaId`. It does not compare 
`versionId` or `timestampMillis`.
   
   A proposed minimal fix is to include the existing creation timestamp in the 
version summary, preserving Gravitino's current replacement flow.
   
   I would like to contribute a fix and regression tests.
   


-- 
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]

Reply via email to