Skip to content

[Server] Widen uc_properties.property_value beyond varchar(255) - #1824

Merged
yili-db merged 3 commits into
unitycatalog:mainfrom
s-maling-celonis:fix/widen-uc-properties-value
Sep 21, 2026
Merged

yili-db merged 3 commits into
unitycatalog:mainfrom
s-maling-celonis:fix/widen-uc-properties-value

Conversation

@s-maling-celonis

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

Copy link
Copy Markdown
Contributor

Summary

  • Hibernate maps an unannotated String as varchar(255). Any uc_properties.property_value longer than that fails with ERROR: value too long for type character varying(255) on PropertyDAO insert.
  • #1830 stopped Spark from persisting Hive-style schema JSON (spark.sql.sources.schema.part.N) on createTable / createView. That does not cover every long value: Spark still forwards view.sqlConfig.* and other user TBLPROPERTIES. Those still hit varchar(255).
  • Map property_value with the same length = 16777215 used for ColumnInfoDAO.typeJson.
  • Existing deployments are not updated by this change. The server uses hibernate.hbm2ddl.auto=update, which creates missing tables/columns but does not change the type or length of a column that already exists. Upgrading the server JAR alone leaves varchar(255) in place. Operators must ALTER uc_properties.property_value (statements in docs/server/deployment.md).

Example that fails today

Delta CREATE TABLE with a wide schema succeeds: table schema is stored on uc_columns (type_json), not as a table property.

CREATE VIEW then calls TablesApi.createTable with Spark view properties (including view.sqlConfig.* and user TBLPROPERTIES). A value longer than 255 characters 500s the insert even though the view SQL itself is stored on uc_tables.view_definition (already a wide column).

io.unitycatalog.client.ApiException: createTable call failed with: 500
{"error_code":"INTERNAL","message":"Error creating table: cat.sch.activity_union: could not execute statement [ERROR: value too long for type character varying(255)] [/* insert for io.unitycatalog.server.persist.dao.PropertyDAO */ insert into uc_properties (entity_id,entity_type,property_key,property_value,id) values (?,?,?,?,?)]"}

The same 255-char limit still applies to any REST client that sends a long table/view property.

Test plan

  • SdkViewCRUDTest / BaseViewCRUDTest.testCreateViewAcceptsPropertyValueLongerThanDefaultVarchar persists a user property longer than 255 characters
  • Confirm a new database gets the wider column from Hibernate
  • Confirm an existing database still has varchar(255) until the documented ALTER is run, then CREATE VIEW with a long property succeeds

@yili-db

yili-db commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

The property of spark.sql.sources.schema.part.N seems a dup of ColumnInfo.typeJson. And in UC tables it doesn't seem to be useful at all.
An easier fix is to strip spark.sql.sources.schema.* properties before creating the table.

@s-maling-celonis

Copy link
Copy Markdown
Contributor Author

Superseded by #1830.

The parquet CREATE TABLE failure was Spark persisting Hive-metastore schema JSON (spark.sql.sources.schema.part.N) into uc_properties, not a column-width problem. #1830 strips those keys (and the other non-metadata properties) in the Spark connector instead of widening property_value.

yili-db pushed a commit that referenced this pull request Sep 9, 2026
… keys (#1830)

## Summary
- Spark packages `StructType` JSON into table properties
(`spark.sql.sources.schema`, `spark.sql.sources.schema.part.N`,
partition/bucket lists, and `spark.sql.partitionSchema*`) so Hive
metastore can reconstruct schema. UC already stores schema on
`uc_columns`, and `schema.part.N` routinely exceeds
`uc_properties.property_value` (`varchar(255)`), so `CREATE TABLE …
USING PARQUET` 500s for anything but a tiny schema.
- One deny-list, `UCTableProperties.shouldPersistProperty`, is used by
`UCProxy.createTable` and Spark 4.2 `createView`. It drops reserved V2
keys, vended `fs.*` credentials, and Spark schema JSON, including the
`option.`-prefixed copies Spark adds from OPTIONS.
- Load still rebuilds Spark schema from columns. View-only metadata
(`view.sqlConfig.*`, schema mode, query column names) is still written
after the filter.
- Alternative to widening `property_value` for this Spark path
([#1824](#1824)). User
`TBLPROPERTIES` and REST clients with long values are unchanged.

## Test plan
- [x] `UCTablePropertiesTest` for schema keys, `option.` copies, `fs.*`,
reserved V2 keys, and keys that must still persist (user props,
`view.sqlConfig.*`)
- [x]
`ParquetExternalTableReadWriteTest.testCreateParquetTableDoesNotPersistSparkDatasourceSchema`
— seven-column parquet CREATE (the case that overflowed 255 chars),
columns persisted, no schema property keys, `SELECT *` works
- [x]
`ExternalTableReadWriteTest.testCreateExternalTableSendsNoCredentialProperties`
asserts every stored key passes `shouldPersistProperty`
- [ ] CI `spark` tests (4.0 / 4.1 / 4.2)

---------

Signed-off-by: s-maling-celonis <[email protected]>
Co-authored-by: Cursor <[email protected]>
s-maling-celonis and others added 2 commits September 17, 2026 18:09
Spark stores datasource schema JSON in table properties, which exceeds Hibernate's default 255-character mapping. hibernate.hbm2ddl.auto=update does not alter existing columns, so existing deployments must run the documented ALTER.

Signed-off-by: s-maling-celonis <[email protected]>
Co-authored-by: Cursor <[email protected]>
Signed-off-by: s-maling-celonis <[email protected]>
Co-authored-by: Cursor <[email protected]>
@s-maling-celonis
s-maling-celonis force-pushed the fix/widen-uc-properties-value branch from 26241b3 to 11fddd7 Compare September 17, 2026 16:09
@s-maling-celonis

Copy link
Copy Markdown
Contributor Author

@yili-db reopening this.

#1830 was the right fix for the parquet CREATE TABLE case (spark.sql.sources.schema.part.N). The same varchar(255) overflow just hit again on a normal Spark CREATE VIEW: UCProxyViewSupport.createView still persists view.sqlConfig.* (and other view properties) into uc_properties, and a value longer than 255 characters 500s the insert even though the view SQL itself is stored on uc_tables.view_definition.

Delta CREATE TABLE for the same wide schema succeeded; only the subsequent CREATE VIEW failed. Stripping schema JSON does not cover that path, so we still need a wider property_value.

.withMessageContaining("s3://bucket/");
}

/**

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.

I think this test should be folded into existing test of BaseViewCRUDTest

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.

Agreed. The parquet spark.sql.sources.schema.part.N test was the old #1830 story; Spark no longer persists that key.

Moved the coverage into BaseViewCRUDTest.testCreateViewAcceptsPropertyValueLongerThanDefaultVarchar: create/get a view with a user.note property longer than 255 characters. Also updated docs/server/deployment.md so the ALTER is justified by table/view properties (TBLPROPERTIES, view.sqlConfig.*) rather than schema JSON.

Fold the varchar(255) round-trip into the view suite using a user
property, and drop the parquet schema.part.N table test that Spark
no longer persists after unitycatalog#1830.

Co-authored-by: Cursor <[email protected]>

Signed-off-by: s-maling-celonis <[email protected]>
@yili-db
yili-db merged commit 63d35a3 into unitycatalog:main Sep 21, 2026
16 checks passed
newfront pushed a commit to newfront/unitycatalog that referenced this pull request Sep 24, 2026
…ycatalog#1824)

## Summary
- Hibernate maps an unannotated `String` as `varchar(255)`. Any
`uc_properties.property_value` longer than that fails with `ERROR: value
too long for type character varying(255)` on `PropertyDAO` insert.
- [unitycatalog#1830](unitycatalog#1830)
stopped Spark from persisting Hive-style schema JSON
(`spark.sql.sources.schema.part.N`) on `createTable` / `createView`.
That does **not** cover every long value: Spark still forwards
`view.sqlConfig.*` and other user `TBLPROPERTIES`. Those still hit
`varchar(255)`.
- Map `property_value` with the same `length = 16777215` used for
`ColumnInfoDAO.typeJson`.
- **Existing deployments are not updated by this change.** The server
uses `hibernate.hbm2ddl.auto=update`, which creates missing
tables/columns but does **not** change the type or length of a column
that already exists. Upgrading the server JAR alone leaves
`varchar(255)` in place. Operators must `ALTER`
`uc_properties.property_value` (statements in
`docs/server/deployment.md`).

## Example that fails today

Delta `CREATE TABLE` with a wide schema succeeds: table schema is stored
on `uc_columns` (`type_json`), not as a table property.

`CREATE VIEW` then calls `TablesApi.createTable` with Spark view
properties (including `view.sqlConfig.*` and user `TBLPROPERTIES`). A
value longer than 255 characters 500s the insert even though the view
SQL itself is stored on `uc_tables.view_definition` (already a wide
column).

```text
io.unitycatalog.client.ApiException: createTable call failed with: 500
{"error_code":"INTERNAL","message":"Error creating table: cat.sch.activity_union: could not execute statement [ERROR: value too long for type character varying(255)] [/* insert for io.unitycatalog.server.persist.dao.PropertyDAO */ insert into uc_properties (entity_id,entity_type,property_key,property_value,id) values (?,?,?,?,?)]"}
```

The same 255-char limit still applies to any REST client that sends a
long table/view property.

## Test plan
- [ ] `SdkViewCRUDTest` /
`BaseViewCRUDTest.testCreateViewAcceptsPropertyValueLongerThanDefaultVarchar`
persists a user property longer than 255 characters
- [ ] Confirm a **new** database gets the wider column from Hibernate
- [ ] Confirm an **existing** database still has `varchar(255)` until
the documented `ALTER` is run, then `CREATE VIEW` with a long property
succeeds

---------

Signed-off-by: s-maling-celonis <[email protected]>
Co-authored-by: Cursor <[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.

2 participants