fix: import unity struct and array columns as structured ODCS types#1300
Merged
Conversation
…1280) The unity importer only emitted the flat Spark DDL type string (physicalType: struct<value:bigint>) with logicalType: object for all complex types. Now it parses Unity's type_json (Spark StructField JSON, pure-Python parser, no JVM needed) and emits nested properties for structs and items for arrays, reusing the spark importer's recursive conversion. Arrays also get the correct logicalType: array via map_type_from_sql, which fixes the sql and snowflake importers too. Map columns keep the flat map<k,v> physicalType until ODCS v3.2 adds logicalType: map (RFC 0030).
PaulMag
reviewed
Jun 12, 2026
Contributor
Author
|
@copilot resolve the merge conflicts in this pull request |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the import side of #1280.
Problem
datacontract import unityemitted complex column types only as a flat Spark DDL string (physicalType: struct<value:bigint>,array<bigint>) withlogicalType: object, whiledatacontract testand the ODCS spec expect the structured representation (nestedpropertiesfor structs,itemsfor arrays,logicalType: arrayfor arrays).Changes
type_json(Spark StructField JSON;StructField.fromJsonis pure Python, no JVM or SparkSession needed) and emits nestedpropertiesfor struct columns anditemsfor array columns, reusing the spark importer's recursive conversion. Nested field comments are carried over. If pyspark is unavailable ortype_jsonis missing/unparseable, it logs a warning and falls back to the previous flat output instead of failing the import.map_type_from_sqlnow mapsarray<...>tologicalType: array(previouslyobject), with explicitstruct/mapbranches. This also corrects thesqlandsnowflakeimporters, which share the function.map<k,v>string inphysicalTypewithlogicalType: objectfor now: ODCS v3.1 has no map representation. Once ODCS v3.2 lands (logicalType: mapwithmap.key/map.value, RFC 0030) and the model library supports it, the importer can emit structured maps from the already-parsedMapTypein the same helper.Tests
New fixture modeled on the issue's repro table (
bigint,array<bigint>,struct<value:bigint>, plusarray<struct<...>>andmap<string,bigint>) with a test asserting the structured output and that the result passes lint. The issue's example table now imports as exactly the contract the reporter had to write by hand.Note: this does not change the test engine's type checking, which still compares only top-level type categories (the v1.0.x part of the issue). The imported contracts now carry the nested type information, so deeper validation can build on this.
🤖 Generated with Claude Code