Fixes #31857, #31858: preserve table constraints and column custom properties on recursive CSV import - #31863
Fixes #31857, #31858: preserve table constraints and column custom properties on recursive CSV import#31863sonika-shah wants to merge 3 commits into
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 checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
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.
Code Review ✅ Approved 1 resolved / 1 findingsExpands recursive CSV import table hydration to preserve table constraints, partitions, and column custom properties. No issues found. ✅ 1 resolved✅ 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 |
✅ 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) 48m 19s ⏱️ Max setup 4m 5s · max shard execution 14m 35s · max shard-job elapsed before upload 17m 55s · reporting 3s 🌐 215.41 requests/attempt · 2.83 app boots/UI scenario · 16.00% 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 |
Problem
A recursive CSV import of a Database Service / Database / Database Schema silently loses two kinds of metadata on every table it touches — even though neither is represented in the CSV:
column.extension). 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, so a normal parent-level re-import in the UI drops them. Reproduced on 1.12.14 and on currentmain/2.0.Root cause
Both come from the field set
EntityCsv.createTableEntity(...)uses to load the existing table before the recursivecreateEntity(...)→repository.createOrUpdate(...):tableConstraints/tablePartitionwere not loaded, socreateOrUpdatepersisted them asnull→ constraints dropped.column.extensionis hydrated byTableRepository.setFieldsonly when bothcolumnsandextensionare requested;columnswas absent, so the persisted columns hadextension = null→ column custom properties dropped (before the column rows patched back).The recursive CSV has no column for constraints or column custom properties, so neither is re-added.
Fix
Load
tableConstraints,tablePartition, andcolumnsin thecreateTableEntityfetch so all three are carried through thecreateOrUpdateunchanged.Because the recursive import updates tables through the single-entity
createOrUpdatepath (→TableUpdater.updateTableConstraints, which add/deletes FKRELATED_TOedges only on a diff) — not the bulkclearEntitySpecificRelationshipsForManypath — an unchanged constraint set leaves the FK relationship edge intact too.Tests (
DatabaseServiceResourceIT)Added two recursive export→re-import ITs alongside the existing
test_importExportRecursive_withColumnTagsAndGlossaryTerms:test_importExportRecursive_preservesTableConstraints— a referenced table + a constrained table with PRIMARY_KEY, UNIQUE, and a FOREIGN_KEY (withreferredColumns); asserts all three survive, including the FK linkage.test_importExportRecursive_preservesColumnCustomProperties— columns carryingextension; asserts the values survive.All three recursive ITs pass together (constraints+FK, column custom properties, and the pre-existing tags/glossary regression guard):
Tests run: 3, Failures: 0, Errors: 0.Remaining known gap (out of scope, not a normal scenario): a Tier tag applied directly to a column is dropped on a table-level import — but Tier is an asset/table-level concept and is not normally placed on columns.
Greptile Summary
The PR expands recursive CSV table hydration to preserve constraints, partitions, columns, and column extensions across re-imports.
Confidence Score: 4/5
The PR is not yet safe to merge because recursive imports still remove the relationship edge representing a preserved foreign key.
The normal existing-table import path uses the bulk updater, which clears table-to-table RELATED_TO relationships and restores only schema containment; preserving tableConstraints JSON does not recreate the foreign-key edge, and the new test does not inspect that relationship.
Files Needing Attention: openmetadata-service/src/main/java/org/openmetadata/csv/EntityCsv.java; openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TableRepository.java; openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DatabaseServiceResourceIT.java
Important Files Changed
Reviews (3): Last reviewed commit: "Fixes #31858: preserve column custom pro..." | Re-trigger Greptile