Skip to content

feat(glue): add optimistic locking and skip-archive support to Glue catalog - #537

Merged
zeroshade merged 5 commits into
apache:mainfrom
xixipi-lining:feat-glue
Aug 27, 2025
Merged

zeroshade merged 5 commits into
apache:mainfrom
xixipi-lining:feat-glue

Conversation

@xixipi-lining

Copy link
Copy Markdown
Contributor

Add optimistic locking and skip-archive support to Glue catalog

Summary

This PR implements optimistic locking for table commits in the Glue catalog to prevent concurrent modification conflicts, and adds support for skipping table version archiving to improve performance for high-frequency workloads.

Changes

  • Optimistic Locking: Use Glue table VersionId to implement optimistic locking in CommitTable method
  • Skip Archive: Add glue.skip-archive configuration option (default: true) to skip archiving old table versions, consistent with Java and Python implementations
  • Code Refactoring: Extract convertGlueToIceberg method for better code reusability
  • Enhanced Testing: Add comprehensive integration tests for optimistic locking scenarios

Key Features

  • ✅ Prevents concurrent table modification conflicts
  • ✅ Improves performance for streaming workloads by skipping unnecessary archiving
  • ✅ Maintains backward compatibility with Java and Python Iceberg implementations
  • ✅ Handles both table creation and update scenarios

Testing

  • All existing unit tests pass
  • Added new integration test TestCommitTableOptimisticLockingIntegration to verify concurrent commit behavior
  • Enhanced test data with complete database name fields

@xixipi-lining xixipi-lining changed the title feat(glue): add optimistic locking and skip-archive support to lue catalog feat(glue): add optimistic locking and skip-archive support to Glue catalog Aug 19, 2025
@xixipi-lining
xixipi-lining marked this pull request as draft August 19, 2025 16:34
@xixipi-lining
xixipi-lining marked this pull request as ready for review August 21, 2025 07:21
Comment thread catalog/glue/glue.go Resolved
Comment thread catalog/glue/glue.go
Comment on lines -349 to -353
OpenTableFormatInput: &types.OpenTableFormatInput{
IcebergInput: &types.IcebergInput{
MetadataOperation: types.MetadataOperationCreate,
},
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't needed anymore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, neither Java nor Python uses this parameter, so I think keeping it consistent across languages makes sense. The AWS Glue CreateTable API does have this field, but it’s optional, and our current CreateTable method doesn’t include it either. Having it only in RegisterTable seems a bit odd.

Comment thread catalog/glue/glue.go Resolved
Comment thread table/metadata.go Resolved
### Changes
- Updated parameter keys in Glue table definitions to use consistent naming conventions (`tableParamTableType` and `tableParamMetadataLocation`).
- Refactored related test cases to align with the new parameter keys.
- Enhanced the `CreateTable`, `RegisterTable`, and `CommitTable` functions to utilize the new parameter structure for improved clarity and maintainability.
@zeroshade
zeroshade merged commit 1aa2a52 into apache:main Aug 27, 2025
@xixipi-lining
xixipi-lining deleted the feat-glue branch August 28, 2025 05:37
prafulla-kiran added a commit to prafulla-kiran/iceberg-go that referenced this pull request Jun 25, 2026
PR apache#480 made the Glue table_type check case-insensitive in getTable
and filterTableListByType so iceberg-go would accept the lowercase
"iceberg" value produced by PyIceberg and the AWS Glue Iceberg REST
endpoint (issue apache#479).

PR apache#537 (optimistic locking) later introduced a third call site,
convertGlueToIceberg, with a strict != comparison against "ICEBERG".
LoadTable -> getTable now passes case-insensitively but the subsequent
convertGlueToIceberg rejects the same table, reproducing the symptom
from apache#479 ("table X.Y is not an iceberg table" on a valid table).

This brings convertGlueToIceberg in line with the other two sites and
matches the case-insensitive behaviour in PyIceberg and the Java
implementation. Adds TestGlueConvertGlueToIcebergCaseInsensitive
mirroring the existing TestGlueGetTableCaseInsensitive.
prafulla-kiran added a commit to prafulla-kiran/iceberg-go that referenced this pull request Jun 25, 2026
PR apache#480 made the Glue table_type check case-insensitive in getTable
and filterTableListByType so iceberg-go would accept the lowercase
"iceberg" value produced by PyIceberg and the AWS Glue Iceberg REST
endpoint (issue apache#479).

PR apache#537 (optimistic locking) later introduced a third call site,
convertGlueToIceberg, with a strict != comparison against "ICEBERG".
LoadTable -> getTable now passes case-insensitively but the subsequent
convertGlueToIceberg rejects the same table, reproducing the symptom
from apache#479 ("table X.Y is not an iceberg table" on a valid table).

This brings convertGlueToIceberg in line with the other two sites and
matches the case-insensitive behaviour in PyIceberg and the Java
implementation. Adds TestGlueConvertGlueToIcebergCaseInsensitive
mirroring the existing TestGlueGetTableCaseInsensitive.
laskoviymishka pushed a commit that referenced this pull request Jun 26, 2026
#1269)

Fixes #1267 (related: #479, regressed by #537).

### Summary

`convertGlueToIceberg` is the only remaining case-sensitive `table_type`
check in `catalog/glue/glue.go` — the other two sites (`getTable`,
`filterTableListByType`) already use `strings.EqualFold` since #480.
This brings the third site in line so `LoadTable` accepts Glue tables
written by PyIceberg or via the AWS Glue Iceberg REST endpoint (both
emit lowercase `iceberg`), matching the case-insensitive semantics of
the PyIceberg and Java Glue implementations.

### Why

`LoadTable` → `getTable` now passes case-insensitively but the
subsequent `convertGlueToIceberg` rejects the same table, reproducing
the symptom from #479 (`table X.Y is not an iceberg table` on a valid
Iceberg table). Originally flagged by @tommika in a comment on #479.

### Change

- One-line fix at `catalog/glue/glue.go:703`: `!=` →
`!strings.EqualFold(...)`.
- New unit test `TestGlueConvertGlueToIcebergCaseInsensitive` mirroring
the existing `TestGlueGetTableCaseInsensitive`, covering `ICEBERG`,
`iceberg`, `IcEbErG`, and a non-Iceberg negative case. Verified by
reverting the fix and confirming the new test fails.

### Test plan

- [x] `go test ./catalog/glue/` passes
- [x] `golangci-lint run ./catalog/glue/...` clean
- [x] New test fails without the fix, passes with it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants