Repository navigation
[Server] Widen uc_properties.property_value beyond varchar(255) - #1824
Conversation
|
The property of |
|
Superseded by #1830. The parquet CREATE TABLE failure was Spark persisting Hive-metastore schema JSON ( |
… 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]>
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]>
26241b3 to
11fddd7
Compare
|
@yili-db reopening this. #1830 was the right fix for the parquet Delta |
| .withMessageContaining("s3://bucket/"); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
I think this test should be folded into existing test of BaseViewCRUDTest
There was a problem hiding this comment.
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]>
…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]>
Summary
Stringasvarchar(255). Anyuc_properties.property_valuelonger than that fails withERROR: value too long for type character varying(255)onPropertyDAOinsert.spark.sql.sources.schema.part.N) oncreateTable/createView. That does not cover every long value: Spark still forwardsview.sqlConfig.*and other userTBLPROPERTIES. Those still hitvarchar(255).property_valuewith the samelength = 16777215used forColumnInfoDAO.typeJson.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 leavesvarchar(255)in place. Operators mustALTERuc_properties.property_value(statements indocs/server/deployment.md).Example that fails today
Delta
CREATE TABLEwith a wide schema succeeds: table schema is stored onuc_columns(type_json), not as a table property.CREATE VIEWthen callsTablesApi.createTablewith Spark view properties (includingview.sqlConfig.*and userTBLPROPERTIES). A value longer than 255 characters 500s the insert even though the view SQL itself is stored onuc_tables.view_definition(already a wide column).The same 255-char limit still applies to any REST client that sends a long table/view property.
Test plan
SdkViewCRUDTest/BaseViewCRUDTest.testCreateViewAcceptsPropertyValueLongerThanDefaultVarcharpersists a user property longer than 255 charactersvarchar(255)until the documentedALTERis run, thenCREATE VIEWwith a long property succeeds