Repository navigation
Fixes #31857, #31858: preserve table constraints and column custom properties on recursive CSV import - #31863
Conversation
createTableEntity fetched the existing table without tableConstraints/ tablePartition, so the subsequent createOrUpdate persisted them as null and the recursive CSV import silently dropped every table's PK/UNIQUE/FK. Load those fields so they carry through unchanged. Adds DatabaseServiceResourceIT.test_importExportRecursive_preservesTableConstraints.
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
Adds a referenced table and a FOREIGN_KEY constraint (with referredColumns) so the recursive round trip also asserts the referenced-table linkage survives, not just PRIMARY_KEY/UNIQUE.
|
The Java checkstyle failed. Please run You can install the pre-commit hooks with |
createTableEntity fetched the table with "extension" but not "columns"; TableRepository.setFields only hydrates column.extension when both fields are requested, so the recursive table-row createOrUpdate persisted columns with null extension and dropped column custom properties before the column rows patched back. Add "columns" to the fetch so column extension is hydrated and carried through. Adds DatabaseServiceResourceIT.test_importExportRecursive_preservesColumnCustomProperties. Verified: 3 recursive round-trip ITs pass (constraints+FK, column custom properties, and the pre-existing column tags/glossary test) — Tests run: 3, Failures: 0, Errors: 0.
✅ Playwright Results — workflow succeededValidated commit ✅ 553 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 51m 9s ⏱️ Max setup 4m 14s · max shard execution 17m 6s · max shard-job elapsed before upload 20m 30s · reporting 4s 🌐 213.22 requests/attempt · 2.83 app boots/UI scenario · 4.29% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…fields createTableEntity now fetches tableConstraints,tablePartition,columns; the unit test stubbed getEntityWithDependencyResolution on the exact old field string, so the stub stopped matching and returned null -> NPE. Update the stub to the new field string. EntityCsvTest: Tests run: 65, Failures: 0.
…d N+1) The prior fix looped removeExtension(entity) per entity, which fires one DELETE per custom-property field -- an N+1 for bulk imports of many entities. Restore a single batched delete but scope it to the entity's own custom-property rows via a new jsonSchema-filtered DAO batch: DELETE FROM entity_extension WHERE id IN (<ids>) AND jsonSchema = 'customFieldSchema' run one statement per chunk (updateInChunks). This keeps columnExtension (and version) rows untouched -- so column custom properties still survive a bulk import that updates table-level extension -- without the per-field N+1. Verified: EntityCsvTest 65/0; DatabaseServiceResourceIT recursive tests 0 fail (incl. table+column custom properties); ColumnCustomPropertiesIT 30/0.
Code Review ✅ Approved 2 resolved / 2 findingsPreserves table constraints and column custom properties during recursive CSV imports by including table fields in lookups and targeting entity-level extension cleanup. All new regression tests pass. ✅ 2 resolved✅ Performance: removeExtensions replaces one batched delete with per-field deletes
✅ Quality: FK test asserts JSON only, not the RELATED_TO edge
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
Failed to cherry-pick changes to the 2.0 branch. |
|
Failed to cherry-pick changes to the 1.13 branch. |
Fixes #31857
Problem
A recursive CSV import of a Database Service / Database / Database Schema silently loses metadata on tables it touches — even though none of it is represented in the CSV:
column.extension) — when the table also carries table-level custom properties (the realistic governance scenario). Fixes CSV import at schema/database/service level wipes column-level custom properties (column.extension) #31858.Both are user-reachable from the UI: Manage (⋮) → Export/Import on a Service / Database / Schema page issues
importAsync?...&recursive=true. Reproduced on 1.12.14 and on currentmain/2.0, and verified fixed on a locally-built 2.0 stack.Root causes & fixes
#31857 — constraints.
EntityCsv.createTableEntityfetched the existing table withouttableConstraints/tablePartition, so the subsequentcreateOrUpdatepersisted them as null and the recursive import dropped them. Fix: includetableConstraints,tablePartitionin that fetch so they carry through unchanged. (The recursive table update uses the single-entity constraint diff inTableUpdater, so an unchanged constraint set also leaves the FKRELATED_TOedge intact — see the FK test.)#31858 — column custom properties. The bulk import update path
updateManyEntitiesForImportcalledremoveExtensions(originals), which did a blanketentityExtensionDAO.deleteAllBatch(id)— deleting everyentity_extensionrow for the table, including itscolumnExtensionrows — whenever the entity carried table-level extension, then re-stored only the table-level extension. So a table with both table- and column-level custom properties lost the column ones on recursive import. Fix: makeremoveExtensionstargeted (mirror the single-entityremoveExtension, deleting only the entity's own custom-property rows) socolumnExtensionrows are not collateral-deleted.Tests (
DatabaseServiceResourceIT)test_importExportRecursive_preservesTableConstraints— service → database → schema → a referenced table + a constrained table with PRIMARY_KEY, UNIQUE and a FOREIGN_KEY (withreferredColumns); recursive export → re-import; asserts all three survive incl. the FK linkage.test_importExportRecursive_preservesColumnCustomProperties— a table carrying both a table-level custom property and column-level custom properties; asserts both survive the recursive round trip (this combination is the CSV import at schema/database/service level wipes column-level custom properties (column.extension) #31858 trigger; testing them separately false-greens).test_importExportRecursive_withColumnTagsAndGlossaryTermsstill passes.EntityCsvTest65/0; the three recursive ITs pass; and a live 2.0 stack confirms table + column custom properties and table constraints all survive export→re-import at table/schema/database/service levels.Out of scope (not a normal scenario): a Tier tag applied directly to a column is dropped on a table-level import — Tier is an asset/table-level concept and is not normally placed on columns.
Greptile Summary
The PR preserves table constraints, table partitions, and column custom-property rows during recursive CSV import.
Confidence Score: 4/5
The PR is not yet safe to merge because recursive batch import still removes the relationship edge backing a preserved FOREIGN_KEY constraint.
The earlier reply from sonika-shah states that the recursive path uses the diff-based single-entity updater, but the current path queues the table for updateManyEntitiesForImport; that batch path deletes table-to-table RELATED_TO edges and restores only containment, so the constraint JSON survives while relationship-based consumers lose the foreign-key linkage.
Files Needing Attention: openmetadata-service/src/main/java/org/openmetadata/csv/EntityCsv.java, openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java, openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java
Important Files Changed
Reviews (8): Last reviewed commit: "perf(csv-import): batch removeExtensions..." | Re-trigger Greptile