Skip to content

[Server] Store view definitions, column type texts and function definitions as text - #1928

Merged
yili-db merged 8 commits into
unitycatalog:mainfrom
s-maling-celonis:fix/lob-columns-to-text
Dec 2, 2026
Merged

yili-db merged 8 commits into
unitycatalog:mainfrom
s-maling-celonis:fix/lob-columns-to-text

Conversation

@s-maling-celonis

@s-maling-celonis s-maling-celonis commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

Description of changes

On PostgreSQL, Hibernate stores a @Lob String as an oid large object, and pgjdbc reads each value with separate lo_open/loread/lo_close round trips. listTables reads type_text for every column of a page, so on a schema with a few thousand columns one page spent about 37 s in these reads.

This PR drops @Lob from ColumnInfoDAO.typeText, TableInfoDAO.viewDefinition and FunctionInfoDAO.routineDefinition, so they map like type_json:

Database Column type
PostgreSQL oid → text
MySQL mediumtext, unchanged
H2 clob, unchanged

uc_credentials.credential is not part of this PR anymore: main already stores it as text (step V4).

Converting existing databases: #2394

#2394 by @shba24 adds schema steps V17 to V19, which convert the existing PostgreSQL columns during bin/start-uc-server --upgrade-schema, plus the tests and the upgrade notes in docs/server/upgrades.md. The startup conversion this PR originally had is gone; schema changes now ship as Flyway steps.

Merge order: this PR first, then #2394 right after. In between, main's PostgreSQL schema checks fail, because the entities no longer match the schema the steps build.

Tests run (H2):

  • server/compile and server/javafmtCheckAll
  • BaselineMatchesEntitiesTest and MigrationStepRulesTest with UC_TEST_MIGRATION_CHECKS=true
  • SdkTableCRUDTest and SdkFunctionCRUDTest

🤖 Generated with Claude Code

s-maling-celonis and others added 2 commits September 25, 2026 15:37
On PostgreSQL Hibernate maps a @lob String to an oid large object, and pgjdbc
reads each one with separate lo_open/loread/lo_close round trips. listTables
reads type_text for every column of a page, so a page of a wide schema spends
tens of seconds on those reads and the caller times out. Plain text columns
come back with the row.

This covers every @lob in the model: column type text, view definitions,
function routine definitions and credentials. The credential column gets an
explicit length so it maps to text rather than varchar(255).

Existing PostgreSQL databases still hold oid columns; the next commit converts
them before Hibernate's schema update runs.

Signed-off-by: s-maling-celonis <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
PostgreSQL databases written by the @lob mapping hold these columns as oid.
Left to Hibernate's schema update, the type change would cast each oid to its
decimal string and lose the value. Before the session factory is built, read
each large object into the column with lo_get and change the type to text.

The conversion checks the column type, so it does nothing on H2, MySQL or once
converted, and servers starting together serialize on an advisory lock. It
gives up after 30 s waiting for the table lock rather than stalling queries
behind it; the next start retries. The large objects themselves are left for
vacuumlo: unlinking takes one lock each, more than a single transaction can
hold on a large catalog.

Signed-off-by: s-maling-celonis <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@s-maling-celonis
s-maling-celonis marked this pull request as ready for review September 25, 2026 13:41
s-maling-celonis and others added 2 commits September 25, 2026 17:10
The migration qualified tables with hibernate.default_schema unquoted. With
globally_quoted_identifiers, Hibernate targets "MixedCase" while PostgreSQL
folded the migration's MixedCase to mixedcase, so the oid columns went
unseen and the schema update cast them to decimal oid strings.

Take the names from the mapping metadata instead, formatted with the same
default schema, catalog and quoting settings the schema update uses, and
match them with to_regclass and parse_ident, which read quoted and unquoted
names as SQL does. The configurator builds the metadata first so the
migration can run between it and the session factory. The test now also
upgrades a quoted mixed-case default schema.

Signed-off-by: s-maling-celonis <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Upgrading now changes existing PostgreSQL column types. Describe what is
converted, the backup a rollback needs, stopping old servers first, the
downtime (the 30 s lock_timeout bounds only the wait; the conversion holds
ACCESS EXCLUSIVE locks until it commits), and the vacuumlo cleanup.

Signed-off-by: s-maling-celonis <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yili-db

yili-db commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

This is a major DB schema upgrade. I need to think through this.

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

some comment on the test coverage and one on isolation level for transaction.

Under repeatable read the check after the advisory lock would reuse the
snapshot of the first check and miss a conversion another server made in
the meantime, so set read committed for the transaction.

Add a PostgreSQL test that blocks the last table's conversion, lets it
time out, checks that all four columns are still large objects with
their values, and then converts them on retry.

Signed-off-by: s-maling-celonis <[email protected]>
@s-maling-celonis

s-maling-celonis commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

@timothyw553 thanks for the comments! Both are addressed in 69f76b4!

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for iterating! One more comment.

@timothyw553

Copy link
Copy Markdown
Collaborator

cc @yili-db on this schema migration.

With hbm2ddl.auto set to none or validate, the server now refuses to
start while the columns are still oid, instead of altering them.
Document converting them by hand for those deployments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: s-maling-celonis <[email protected]>
@shba24

shba24 commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Hi @s-maling-celonis, thanks for your patience on this one. The schema-upgrade work Yi mentioned has started landing on main, and it changes how this PR should do the conversion. #2045 added Flyway schema steps and bin/start-uc-server --upgrade-schema, and #2112 lets that command adopt an existing 0.7.0 database. Schema changes now go in as steps instead of as code that runs at server start. For this PR, that means:

1. Drop the startup conversion. Remove LargeObjectColumnMigration, its test and the HibernateConfigurator changes. --upgrade-schema already holds a PostgreSQL advisory lock for the whole run, and it is meant to run with the servers stopped.

2. Keep the entity change (drop @Lob, and add length = 16777215 on credential), and add one step per column change. I tried your 4 entity edits on main (c7242ae), and BaselineMatchesEntitiesTest shows what each database needs:

Database Columns that change
PostgreSQL uc_columns.type_text, uc_credentials.credential, uc_functions.routine_definition, uc_tables.view_definition: oid → text
MySQL uc_credentials.credential: tinytext (255) → mediumtext
H2 none, so no step

Each step is one SQL statement in server/src/main/resources/db/migration/<database>/, numbered after the last merged step for that database (V2 today). For PostgreSQL:

-- postgresql/V3__columns_type_text_as_text.sql
ALTER TABLE uc_columns ALTER COLUMN type_text TYPE text USING convert_from(lo_get(type_text), 'UTF8');

V4–V6 do the same for the other three columns. For MySQL:

-- mysql/V3__credentials_credential_as_mediumtext.sql
ALTER TABLE uc_credentials MODIFY COLUMN credential mediumtext NOT NULL;

The USING clause is your current conversion (ALTER TABLE, lo_get), so a value keeps its text instead of becoming the decimal string of its oid.

3. Write each step's effect file with build/sbt updateSchemaDumps (PostgreSQL and MySQL need Docker), and check in server/src/main/resources/schema-effects/<database>/V<n>.txt with the step. --upgrade-schema uses those files to tell what state a database is in.

4. Tests. build/sbt testPostgres18 and build/sbt testMySQL8 run BaselineMatchesEntitiesTest (the steps build the schema the entities describe) and MigrationStepRulesTest (every step has its effect file). For the data itself, please add a PostgreSQL case to SchemaMigratorTest: a database at version 2 whose rows hold large objects, then upgradeSchema(), then the same text read back.

5. Docs. The orphaned large objects still need vacuumlo, so the note in your docs still applies. Please put it next to the upgrade steps in docs/server/upgrades.md, along with a line that the PostgreSQL steps rewrite these four tables.

Happy to help with any of this. Ping me if something doesn't fit.

@yili-db yili-db mentioned this pull request Nov 12, 2026
3 of 4 tasks
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 12, 2026
---

[Server] Store credentials as text

- `CredentialDAO.credential` drops `@Lob` and takes `length = 16777215`
- Schema step `V3__credentials_as_text`:
  - MySQL: `tinytext` (255 bytes) to `mediumtext`
  - PostgreSQL: large object (`oid`) to `text`, freeing the large objects
  - H2: unchanged (`clob`)
- `SchemaMigratorTest.upgradeKeepsStoredCredentials` checks stored credentials survive on all three databases

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Address review: widen the credential column on MySQL only

- Keep `@Lob` on `CredentialDAO.credential`, so a server whose database has not run the step still reads its credentials
  - PostgreSQL keeps its large objects and H2 its `clob`
- Rename the step to `V3__widen_credential_column`; only MySQL changes, `tinytext` to `mediumtext`
- Test a credential longer than 255 bytes, using `UpgradeTestUtils.migrateTo`

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Store credentials as text, as unitycatalog#1928 plans

- `CredentialDAO.credential` drops `@Lob` and keeps `length = 16777215`
- `V3__credentials_credential_as_text`, one statement per database:
  - MySQL: `tinytext` to `mediumtext`
  - PostgreSQL: large object (`oid`) to `text`, through `convert_from(lo_get(credential), 'UTF8')`
  - H2: no change
- `docs/server/upgrades.md`: the PostgreSQL step reads every large object, leaves them for `vacuumlo`, and cannot be undone without the backup
- The upgrade test reads a large-object credential with non-ASCII text back as text

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Address review: vacuumlo scope, going back, and reading through Hibernate

- `docs/server/upgrades.md`: `vacuumlo` removes every unreferenced large object, so run it only on a database that holds only Unity Catalog, after a dry run; going back covers step 3 too
- The upgrade test also reads the migrated credentials through `CredentialDAO`

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 13, 2026
---

[Server] Store credentials as text

- `CredentialDAO.credential` drops `@Lob` and takes `length = 16777215`
- Schema step `V3__credentials_as_text`:
  - MySQL: `tinytext` (255 bytes) to `mediumtext`
  - PostgreSQL: large object (`oid`) to `text`, freeing the large objects
  - H2: unchanged (`clob`)
- `SchemaMigratorTest.upgradeKeepsStoredCredentials` checks stored credentials survive on all three databases

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Address review: widen the credential column on MySQL only

- Keep `@Lob` on `CredentialDAO.credential`, so a server whose database has not run the step still reads its credentials
  - PostgreSQL keeps its large objects and H2 its `clob`
- Rename the step to `V3__widen_credential_column`; only MySQL changes, `tinytext` to `mediumtext`
- Test a credential longer than 255 bytes, using `UpgradeTestUtils.migrateTo`

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Store credentials as text, as unitycatalog#1928 plans

- `CredentialDAO.credential` drops `@Lob` and keeps `length = 16777215`
- `V3__credentials_credential_as_text`, one statement per database:
  - MySQL: `tinytext` to `mediumtext`
  - PostgreSQL: large object (`oid`) to `text`, through `convert_from(lo_get(credential), 'UTF8')`
  - H2: no change
- `docs/server/upgrades.md`: the PostgreSQL step reads every large object, leaves them for `vacuumlo`, and cannot be undone without the backup
- The upgrade test reads a large-object credential with non-ASCII text back as text

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Address review: vacuumlo scope, going back, and reading through Hibernate

- `docs/server/upgrades.md`: `vacuumlo` removes every unreferenced large object, so run it only on a database that holds only Unity Catalog, after a dry run; going back covers step 3 too
- The upgrade test also reads the migrated credentials through `CredentialDAO`

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 13, 2026
---

[Server] Store credentials as text

- `CredentialDAO.credential` drops `@Lob` and takes `length = 16777215`
- Schema step `V3__credentials_as_text`:
  - MySQL: `tinytext` (255 bytes) to `mediumtext`
  - PostgreSQL: large object (`oid`) to `text`, freeing the large objects
  - H2: unchanged (`clob`)
- `SchemaMigratorTest.upgradeKeepsStoredCredentials` checks stored credentials survive on all three databases

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Address review: widen the credential column on MySQL only

- Keep `@Lob` on `CredentialDAO.credential`, so a server whose database has not run the step still reads its credentials
  - PostgreSQL keeps its large objects and H2 its `clob`
- Rename the step to `V3__widen_credential_column`; only MySQL changes, `tinytext` to `mediumtext`
- Test a credential longer than 255 bytes, using `UpgradeTestUtils.migrateTo`

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Store credentials as text, as unitycatalog#1928 plans

- `CredentialDAO.credential` drops `@Lob` and keeps `length = 16777215`
- `V3__credentials_credential_as_text`, one statement per database:
  - MySQL: `tinytext` to `mediumtext`
  - PostgreSQL: large object (`oid`) to `text`, through `convert_from(lo_get(credential), 'UTF8')`
  - H2: no change
- `docs/server/upgrades.md`: the PostgreSQL step reads every large object, leaves them for `vacuumlo`, and cannot be undone without the backup
- The upgrade test reads a large-object credential with non-ASCII text back as text

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Address review: vacuumlo scope, going back, and reading through Hibernate

- `docs/server/upgrades.md`: `vacuumlo` removes every unreferenced large object, so run it only on a database that holds only Unity Catalog, after a dry run; going back covers step 3 too
- The upgrade test also reads the migrated credentials through `CredentialDAO`

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 13, 2026
---

[Server] Store credentials as text

- `CredentialDAO.credential` drops `@Lob` and takes `length = 16777215`
- Schema step `V3__credentials_as_text`:
  - MySQL: `tinytext` (255 bytes) to `mediumtext`
  - PostgreSQL: large object (`oid`) to `text`, freeing the large objects
  - H2: unchanged (`clob`)
- `SchemaMigratorTest.upgradeKeepsStoredCredentials` checks stored credentials survive on all three databases

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Address review: widen the credential column on MySQL only

- Keep `@Lob` on `CredentialDAO.credential`, so a server whose database has not run the step still reads its credentials
  - PostgreSQL keeps its large objects and H2 its `clob`
- Rename the step to `V3__widen_credential_column`; only MySQL changes, `tinytext` to `mediumtext`
- Test a credential longer than 255 bytes, using `UpgradeTestUtils.migrateTo`

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Store credentials as text, as unitycatalog#1928 plans

- `CredentialDAO.credential` drops `@Lob` and keeps `length = 16777215`
- `V3__credentials_credential_as_text`, one statement per database:
  - MySQL: `tinytext` to `mediumtext`
  - PostgreSQL: large object (`oid`) to `text`, through `convert_from(lo_get(credential), 'UTF8')`
  - H2: no change
- `docs/server/upgrades.md`: the PostgreSQL step reads every large object, leaves them for `vacuumlo`, and cannot be undone without the backup
- The upgrade test reads a large-object credential with non-ASCII text back as text

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Address review: vacuumlo scope, going back, and reading through Hibernate

- `docs/server/upgrades.md`: `vacuumlo` removes every unreferenced large object, so run it only on a database that holds only Unity Catalog, after a dry run; going back covers step 3 too
- The upgrade test also reads the migrated credentials through `CredentialDAO`

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
yili-db added a commit to yili-db/unitycatalog that referenced this pull request Nov 13, 2026
---

[Server] Store credentials as text

- `CredentialDAO.credential` drops `@Lob` and takes `length = 16777215`
- Schema step `V3__credentials_as_text`:
  - MySQL: `tinytext` (255 bytes) to `mediumtext`
  - PostgreSQL: large object (`oid`) to `text`, freeing the large objects
  - H2: unchanged (`clob`)
- `SchemaMigratorTest.upgradeKeepsStoredCredentials` checks stored credentials survive on all three databases

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Address review: widen the credential column on MySQL only

- Keep `@Lob` on `CredentialDAO.credential`, so a server whose database has not run the step still reads its credentials
  - PostgreSQL keeps its large objects and H2 its `clob`
- Rename the step to `V3__widen_credential_column`; only MySQL changes, `tinytext` to `mediumtext`
- Test a credential longer than 255 bytes, using `UpgradeTestUtils.migrateTo`

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Store credentials as text, as unitycatalog#1928 plans

- `CredentialDAO.credential` drops `@Lob` and keeps `length = 16777215`
- `V3__credentials_credential_as_text`, one statement per database:
  - MySQL: `tinytext` to `mediumtext`
  - PostgreSQL: large object (`oid`) to `text`, through `convert_from(lo_get(credential), 'UTF8')`
  - H2: no change
- `docs/server/upgrades.md`: the PostgreSQL step reads every large object, leaves them for `vacuumlo`, and cannot be undone without the backup
- The upgrade test reads a large-object credential with non-ASCII text back as text

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>

---

Address review: vacuumlo scope, going back, and reading through Hibernate

- `docs/server/upgrades.md`: `vacuumlo` removes every unreferenced large object, so run it only on a database that holds only Unity Catalog, after a dry run; going back covers step 3 too
- The upgrade test also reads the migrated credentials through `CredentialDAO`

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
yili-db added a commit that referenced this pull request Nov 20, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2169/files) to
review incremental changes.
-
[stack/s3compat_spec](#2170)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2170/files)]
[MERGED]
-
[stack/s3compat_credentials](#2171)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2171/files)]
[MERGED]
-
[stack/s3compat_vending](#2172)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2172/files)]
[MERGED]
-
[stack/s3compat_hadoop_cli](#2173)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2173/files)]
[MERGED]
-
[stack/s3compat_test_storage](#2174)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2174/files)]
[MERGED]
-
[stack/s3compat_helm_key](#2175)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2175/files)]
[MERGED]
-
[**stack/s3compat_credentials_text**](#2169)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2169/files)]
← _this PR_
-
[stack/s3compat_location_endpoint](#2289)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2289/files/76859fc160061ad821312ef6bc69f986e9c44e5f..708dcb589fb36067a3e15464c2fd5513cddab4cb)]

---------
Last of a stack adding experimental S3-compatible storage (MinIO, Ceph,
SeaweedFS, RustFS, Garage): #2170 to #2175 are merged.

**Description of changes**

Stores credentials as text instead of PostgreSQL large objects, and
widens the column on MySQL, where `tinytext` (255 bytes) is too small
for real `s3_compatible` credentials with `assume_role`. It makes the
change #1928 plans for `uc_credentials.credential`, and is a placeholder
until #1928 and its follow-up merge.

Builds on #2117 (merged): the server starts only once the steps have
run, so it never sees the column before step V4.

- `CredentialDAO.credential` drops `@Lob` and adds `length = 16777215`
- Schema step `V4__credentials_credential_as_text`, one statement per
database:
  - MySQL: `tinytext` to `mediumtext`
- PostgreSQL: large object (`oid`) to `text`, through
`convert_from(lo_get(credential), 'UTF8')`
  - H2: no change
- Schema effect files for V4
- `docs/server/upgrades.md`:
- the PostgreSQL step reads every credential's large object as UTF-8, as
`hibernate.connection.username`; a missing or unreadable one fails it,
with how to recover
- the large objects stay (still holding the earlier stored values) for
`vacuumlo`, and a release from before the step cannot read the converted
column on PostgreSQL
- Removes the `TODO(#2169)` on `CredentialDAO.setS3Compatible`
- `SchemaMigratorTest.upgradeKeepsStoredCredentialsAndFitsLongerOnes`: a
credential stored before the step (a large object on PostgreSQL, with
two-, three- and four-byte characters) reads back as the same text, and
one longer than 255 bytes fits, on all three databases; on PostgreSQL
the old row is written through pgjdbc's large object path
- `SchemaMigratorTest.upgradeWithAMissingLargeObjectChangesNothing`: on
PostgreSQL, a credential whose large object is missing fails the step
and leaves the column and the row as they were
- `MigrationStepRulesTest`: MySQL `tinytext` widens to `text`,
`mediumtext` or `longtext`; on PostgreSQL an `oid` column may change
only as `TYPE text USING convert_from(lo_get(c), 'UTF8')`, the one
allowed change that rows can fail, with cases for it; a plain type
change of an `oid` column is refused
-
`SchemaMigratorTest.refusesAStepThatDropsAConstraintTheDatabaseNoLongerHasByThatName`
brings the database to step 3 itself instead of to the newest step, so a
later step no longer leaves a gap in its schema history
- `BaseCredentialCRUDTest.testLongS3CompatibleCredential`: a credential
over 1000 bytes, with non-ASCII text, round-trips through the server on
every database

Compatibility: no API change. Going back to an earlier release needs the
database backup.

Tests: `SchemaMigratorTest`, `BaselineMatchesEntitiesTest`,
`MigrationStepRulesTest` and the credential and external location CRUD
tests on H2, PostgreSQL 18 and MySQL 8 (`MigrationStepRulesTest` with
`UC_TEST_MIGRATION_CHECKS=true`); all pass.

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [x] If you've added or modified a feature, documentation in `docs` is
updated

This pull request and its description were written by Isaac.

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
Schema changes now ship as Flyway steps run by --upgrade-schema, so drop the startup conversion (LargeObjectColumnMigration, its test and the HibernateConfigurator changes) and the deployment guide section. Steps V17 to V19 in unitycatalog#2394 convert the PostgreSQL columns. CredentialDAO keeps main's mapping, which already stores the credential as text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: Simon Maling <[email protected]>
@s-maling-celonis s-maling-celonis changed the title [Server] Store @Lob strings as text and convert existing PostgreSQL columns [Server] Store view definitions, column type texts and function definitions as text Dec 1, 2026
@s-maling-celonis

Copy link
Copy Markdown
Contributor Author

@shba24 I've slimmed this down to the entity change only: @Lob is dropped from ColumnInfoDAO.typeText, TableInfoDAO.viewDefinition and FunctionInfoDAO.routineDefinition. The startup conversion, its test and the docs are gone, and CredentialDAO matches main. The conversion for existing databases is #2394's V17–V19. Ready for review, to merge right before #2394. The PostgreSQL CI jobs here are expected to fail until #2394 lands.

@timothyw553 your open threads were on the startup conversion, which is removed now. Could you take another look and dismiss your changes-requested review if this works for you?

shba24 added a commit to shba24/unitycatalog that referenced this pull request Dec 1, 2026
Main runs schema changes as Flyway steps through --upgrade-schema, so
the conversion unitycatalog#1928 ran at server start becomes three PostgreSQL steps,
V17 to V19, for uc_tables.view_definition, uc_columns.type_text and
uc_functions.routine_definition. They use the conversion unitycatalog#1928 wrote,
convert_from(lo_get(c), 'UTF8'), the same form unitycatalog#2169 used for
uc_credentials.credential in step V4. The steps change nothing on H2
(clob) and MySQL (mediumtext).

LargeObjectColumnMigration and its test go away: --upgrade-schema
already holds the lock and runs with the servers stopped.

SchemaMigratorTest stores the three values as large objects at step 16
and reads them back through the entities after the upgrade. The upgrade
guide gets the steps next to the credentials one.

Co-authored-by: s-maling-celonis <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]>
@yili-db
yili-db merged commit 74820c6 into unitycatalog:main Dec 2, 2026
33 of 37 checks passed
yili-db added a commit to shba24/unitycatalog that referenced this pull request Dec 2, 2026
- Resolve the three DAO conflicts by keeping this branch's comment above the former `@Lob` columns
- `@Lob` removal itself now comes from main (unitycatalog#1928)

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
yili-db added a commit that referenced this pull request Dec 2, 2026
…initions to text with schema steps (#2394)

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [x] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

Completes #1928 by @s-maling-celonis, which drops `@Lob` from the
entities that hold view definitions, column type texts and function
definitions, so PostgreSQL stores them as text instead of large objects
and listing tables no longer fetches each value separately. Schema steps
V17 to V19 convert the existing PostgreSQL columns during
`--upgrade-schema`, as step V4 does for credentials. H2 and MySQL are
unchanged.

**Changes on top of #1928:**
[diff](https://github.com/unitycatalog/unitycatalog/pull/2394/files/71db03c01d12f8f1d6701eab0e3934b6cdb55362..9d4b838068ea67ddbf48c9baeae1f638ba329dae),
from #1928's head.

**Also in this PR:** the Helm chart tests set up chart-testing once
more, after a pause, when the setup fails. Its download from GitHub
failed with HTTP 618 on this PR, a code the action's `curl --retry` does
not retry.

**Merge order:** #1928 first, then this PR right after. In between,
main's PostgreSQL schema checks fail.

**Known gap:** PostgreSQL text cannot hold a NUL character. A stored
definition containing one makes the steps fail on every run, and
`--check-schema` does not detect it beforehand.

<details><summary><b>📐 Design notes &amp; details</b></summary>

**Compatibility (PostgreSQL only):**

- Run `bin/start-uc-server --upgrade-schema` with the servers stopped.
- Each step rewrites its table and locks it until it commits.
- A release before these steps cannot read the converted columns, so
going back needs the backup.
- Database-level access to these values now follows table privileges
instead of per-large-object privileges. Unity Catalog's own
authorization is unchanged.
- The old large objects stay in the database. `vacuumlo` removes them,
but only run it when the database holds nothing but Unity Catalog, and
dry-run it with `-n` first.

**The gap in detail:** steps V17 to V19 also fail when the database's
encoding cannot hold a stored character, as step V4 does. After the
upgrade, creating a definition with a NUL character fails, as it already
does for other text columns.

**Possible follow-up for the gap:** `--check-schema` and
`--upgrade-schema` could run each pending conversion as a read-only
query before any step runs. That would report a NUL character, a missing
large object or one the user cannot read, before anything changes.

**Tests run:**

- `server/testOnly io.unitycatalog.server.migrate.*` with
`UC_TEST_MIGRATION_CHECKS=true` on H2, PostgreSQL 18 and MySQL 8.
- `RealUpgradeTest` with `UC_TEST_UPGRADES=true` on H2, PostgreSQL 18
and MySQL 8.
- `UC_TEST_DATABASE=POSTGRES_18 dev/run-tests.py`, every project: 240
suites, 4,058 tests, 0 failed.

</details>

This pull request and its description were written by Isaac.

---------

Signed-off-by: s-maling-celonis <[email protected]>
Signed-off-by: Simon Maling <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Signed-off-by: Yi Li <[email protected]>
Co-authored-by: s-maling-celonis <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: s-maling-celonis <[email protected]>
Co-authored-by: Isaac <[email protected]>
Co-authored-by: Yi Li <[email protected]>
yili-db added a commit that referenced this pull request Dec 2, 2026
… on the external location (#2289)

## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2289/files) to
review incremental changes.
-
[**stack/s3compat_location_endpoint**](#2289)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2289/files)]
← _this PR_
-
[stack/s3compat_external_location_id](#2395)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2395/files/279e4214f62311816d4cec93fd0150a021d5f495..8a58c1528404e758093091408a9a4266eeb581e4)]

---------
Finalizes S3-compatible storage, which the stack #2170 to #2175 and
#2169 (all merged) built.

**Description of changes**

**Why.** The S3 endpoint belongs to the storage a location is on, not to
the key pair that reaches it. With the endpoint on the credential, one
credential could not serve locations on several storage hosts, and
moving a bucket to a new host meant editing the credential. This PR
moves the endpoint, and whether its requests are path-style, to the
external location. The vend returns the location's settings beside the
keys, so a client always gets the endpoint, region and addressing style
that match the keys it signs with. It also takes the feature out of
experimental status.

**API** (`api/all.yaml`, `api/delta.yaml`, regenerated `api/` docs)

Storage credential and external location:

```json
{"name": "aistor_cred", "purpose": "STORAGE",
 "s3_compatible_access_key": {"access_key_id": "uc-user", "secret_access_key": "...",
                              "sts_endpoint": "https://sts.example.com", "role_arn": "arn:aws:iam:::role/uc-tables"}}

{"name": "aistor_loc", "url": "s3://sales/tables", "credential_name": "aistor_cred",
 "endpoint": "https://aistor.example.com", "path_style_access": true}
```

Vended credentials (`TemporaryCredentials`):

```json
{"aws_temp_credentials": {"access_key_id": "...", "secret_access_key": "...", "session_token": "..."},
 "expiration_time": 1764200000000,
 "external_location_settings": {
   "s3_compatible": {"endpoint": "https://aistor.example.com", "region": "us-east-1", "path_style_access": true}}}
```

- The credential field `s3_compatible` is renamed
`s3_compatible_access_key` (`S3CompatibleAccessKeyRequest`/`Response`).
It holds the keys plus the optional flat STS fields `sts_endpoint` and
`role_arn`. `s3_endpoint`, the nested `assume_role` (`S3AssumeRole`) and
`sts_region` are removed.
- `CreateExternalLocation`, `UpdateExternalLocation` and
`ExternalLocationInfo` get `endpoint` (`http[s]://host[:port]`, at most
2048 characters, without a path) and `path_style_access` (boolean).
`UpdateExternalLocation.path_style_access` has its own description: it
needs a stored `endpoint`, and leaving it out keeps the stored value.
- A location's `endpoint` and a credential's `sts_endpoint` are stored,
returned and vended with the scheme and host in lowercase. The
`sts_endpoint` text states the same `http[s]://host[:port]` form, and
`updateExternalLocation` says which rules fail with `INVALID_ARGUMENT`.
- The schemas carry the server's limits: `maxLength: 2048` on the
endpoint, `minLength: 1` on the keys, and `pattern: '^arn:'` on
`role_arn`. Vended credentials carry the location's `endpoint`; a
credential's `sts_endpoint` is only where the server calls STS, and is
never vended.
- `ui/src/types/api/catalog.gen.ts` is regenerated from `api/all.yaml`,
which also picks up earlier spec changes it was missing (`browse_only`,
`include_browse`, the required `purpose`).
- `TemporaryCredentials` gets `external_location_settings`
(`ExternalLocationSettings`), set exactly when the path is on
S3-compatible storage. It has `s3_compatible` (`endpoint`, `region`,
`path_style_access`). `AwsCredentials` carries only keys again:
`s3_endpoint` and `s3_region` are removed. An endpoint-only vend returns
the settings and `expiration_time` without `aws_temp_credentials`.
- Delta API: the credential `config` key map carries `s3.endpoint`,
`client.region` and `s3.path-style-access`, the same keys the Iceberg
REST config uses.
- No "EXPERIMENTAL" labels remain on S3-compatible storage.
- `spec/protocols/ManagedDeltaTablesSpec.md` matches `api/delta.yaml`:
the config carries `s3.endpoint`, `client.region` and the boolean
`s3.path-style-access`, so its values are strings or a boolean, and a
false or absent `s3.path-style-access` means virtual-hosted.

**Rules**
- A location has an `endpoint`, and may have `path_style_access`,
exactly when it is on S3-compatible storage: required with an
`s3_compatible_access_key` credential, refused with another, and kept
after its credential is force-deleted. An update that leaves either out
keeps the stored value.
- A missing or false `path_style_access` means virtual-hosted. Then the
bucket name must be a host name label: 3 to 63 lowercase letters, digits
and hyphens, a letter or digit at both ends, and no dots, since a dot
breaks wildcard TLS certificates. Create and update refuse other names
and name the bucket. `ExternalLocationInfo` always returns
`path_style_access` when the location has an `endpoint`.
- STS is on when `role_arn` is set. It holds the ARN of the role to
assume, for example `arn:aws:iam:::role/uc-tables`, sent unchanged as
AssumeRole's `RoleArn`; a value that doesn't start with `arn:` is
refused. Storage that ignores the role, such as MinIO, still needs an
ARN-shaped value. `sts_endpoint` is allowed only with `role_arn`.
Without it, AssumeRole goes to the location's endpoint, signed with the
bucket region the server detects.
- A location keeps its storage kind, which its stored `endpoint`
decides, also after its credential was force-deleted. A location with an
endpoint can only get another `s3_compatible_access_key` credential; one
without can get neither an endpoint, nor `path_style_access`, nor such a
credential. Moving a location to other storage means deleting it and
creating a new one, so an update can't clear `endpoint` or
`path_style_access`. A credential's type can't change while a location
uses it; new keys or a new role can.
- Changing `endpoint` or `path_style_access` of a location in use is
refused unless `force` is set, with the same in-use check as a URL
change. Resending the stored value isn't a change, and neither is an
`endpoint` that differs only in the case of its scheme or host.
- A location whose credential was force-deleted still checks its own
settings on update: the endpoint form and length, the `s3://` URL, and
the bucket rule for virtual-hosted addressing. Vending under it fails
until it is repaired.

**Server**
- Schema steps `V20__external_location_endpoint` (nullable
`varchar(2048)`) and `V21__external_location_path_style_access`
(nullable boolean, `bit` on MySQL), with their effect files. A
virtual-hosted location stores `false`, so the column is null exactly
without an endpoint.
- `ExternalLocationUtils.getExternalLocationCredentialForPath` returns
the location together with its credential, read from one snapshot
(`TransactionManager.snapshotIsolation`: REPEATABLE READ on PostgreSQL
and MySQL, SERIALIZABLE on H2), so a vend never pairs a location with a
credential from another committed state. A location of an
`s3_compatible_access_key` credential without an endpoint fails the vend
with `INTERNAL`, so keys are never sent to AWS S3 by mistake.
- The location's endpoint, detected region and path style travel through
`CredentialContext` and the vend cache key into
`external_location_settings`; the `endpoint-only` client response, built
after the cache in `StorageCredentialVendorImpl`, carries the same
settings; the Iceberg REST config (`s3.endpoint`, `client.region`,
`s3.path-style-access`) and the Delta config. Region discovery addresses
the bucket as the location says.
- The server property `server.s3-compatible-storage.enabled` is removed,
with every guard that read it. The encryption key
`server.credential-encryption-key` is now read whenever it's set: a
malformed key refuses startup. Without a key, creating or updating an
`s3_compatible_access_key` secret fails with `FAILED_PRECONDITION`,
while stored credentials stay readable, renamable and deletable.
`server.s3-compatible-storage.static-key-vending` is unchanged.

**Clients**
- Hadoop connector: reads the endpoint, region and path style from
`external_location_settings.s3_compatible`. Settings that are absent
mean AWS S3, and a missing `path_style_access` means virtual-hosted. It
sets `fs.s3a.bucket.<bucket>.path.style.access`, records the style per
bucket and in the file system cache id, and renewal refuses a changed
style just as it refuses a changed endpoint.
- CLI:
- `credential create`/`update`: `--s3_endpoint` and `--s3_sts_region`
are removed, and `--s3_role_arn` sets `role_arn`.
- `external_location create`/`update`: new `--endpoint` and
`--path_style_access`.
  - The Delta Kernel path reads the location's settings.
- `docs/usage/cli.md` documents `--endpoint` and `--path_style_access`
on `external_location create`/`update`, and that `--force` also covers
an endpoint or path-style change on a location in use.
- Docs, Helm and `etc/conf/server.properties` use the new names and no
longer mention the enable property. The chart needs only
`server.credentialEncryptionKeySecret`, and the Helm CI install case
passes only the key Secret.

**Tests**
- External location CRUD (SDK and CLI): the endpoint rules and forms
(including an over-long one), one credential on two endpoints, the
storage-kind refusals, key and role changes of credentials in use,
endpoint and path-style changes while in use (with and without `force`),
locations whose credential was force-deleted, and `path_style_access`
defaults, updates and the bucket-name rule.
- Vending under an S3-compatible location whose credential was
force-deleted fails, and works again after repair.
- Mixed-case `endpoint` and `sts_endpoint` values on create and update
are stored, returned and vended lowercased, and a case-only `endpoint`
edit on a location in use needs no `force`.
- Region discovery for one bucket on one endpoint with both addressing
styles: `forcePathStyle(true)` and `forcePathStyle(false)`, cached
apart.
- Credential CRUD and DAO: `role_arn` and `sts_endpoint` validation.
- Vending, unit and on real storage: the settings for STS sessions,
static keys and endpoint-only vends. AssumeRole gets the role's ARN, the
detected region, and the location endpoint as fallback.
- The cache key includes the path style.
- The Iceberg and Delta configs, for both path-style values.
- AWS S3 credentials from the UC API, the Delta API and the constructors
are equal: the path style is only kept with an endpoint, and a missing
flag is virtual-hosted.
- The cached credential id (`FileSystemCredId.create(Configuration)`)
differs by endpoint, region and path style.
- Connector and CLI settings, including renewal refusing a changed
style, a bucket whose two paths differ only in style, and a cached
credential not shared across styles. Both new connector tests fail when
the style check or the `pathStyle.` key of the cache id is removed.
- Secret store and repository behavior without a key or with a malformed
one.
- The real-storage harness reaches its containers at `127.0.0.1` ports,
so its locations set `path_style_access: true`. Virtual-hosted
addressing isn't run against real storage.

Follow-ups: `external_location_id` in `ExternalLocationSettings` (#2395,
stacked on this PR); `ExternalLocationSettings` entries for other
storage types: `s3` (with `region`), `adls` and `gcs`.

**Compatibility.** S3-compatible storage hasn't been released, so these
API, property and CLI changes need no compatibility shim, and no data is
migrated. Credentials, locations and vends for other storage are
unchanged.

**Tests run** on the final head, rebased onto main with #2268, #1928 and
#2394:
- `io.unitycatalog.server.migrate.*` with
`UC_TEST_MIGRATION_CHECKS=true` on H2, PostgreSQL 18 and MySQL 8: 241
tests each.
- `dev/run-tests.py`, full suite on H2: 4,085 tests.
- The server suite on PostgreSQL 18 and on MySQL 8: 1,779 tests each.
- On MinIO (`UC_TEST_STORAGE=MINIO`): the S3-compatible, external
location and credential tests plus `spark/test`, 576 tests.
- The Hadoop connector tests (1,530), on the head before the last
rebase.
- The Helm workflow's lint and render checks, and `helm/README.md`
regenerated with helm-docs v1.14.2.
- Regenerating the API docs and the UI types leaves no diff; `yarn
test:format` passes in `ui/`, and `tsc --noEmit` reports no errors
outside `node_modules`, as before.

On an earlier head, before the endpoint length limit: the S3-compatible
tests plus `spark/test` on Garage (555). All pass.

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [x] If you've added or modified a feature, documentation in `docs` is
updated

This pull request and its description were written by Isaac.

---------

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
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.

4 participants