test(csharp): compare MAP columns order-insensitively in E2E tests - #662
Merged
eric-wang-1990 merged 2 commits intoSep 4, 2026
Merged
Conversation
Databricks MAP key order is unspecified — the server may return keys in any order (the MAP type is an unordered set), and it demonstrably does: the same commit produced sorted keys in one CI run and insertion order in another. JDBC preserves the server's order via LinkedHashMap without sorting, and #509 (adbc-drivers/databricks) removed the client-side SortedDictionary that used to normalize SEA/Thrift map output to sorted. With that normalization gone, ComplexTypesValueTests.TestMapData and ClientTests.VerifyTypesAndValues — which compared the serialized map JSON by exact string — flake on both protocols whenever the server returns a non-sorted order. Fix the tests to assert map CONTENT, not an unspecified key order: add DatabricksTestEnvironment.NormalizeMapJson (sorts the top-level object's keys, preserving each value's raw JSON so nested STRUCT field order is untouched) and compare normalized expected vs actual in both tests. The driver keeps #509's no-sort behavior (matches JDBC and the unordered MAP semantics). Co-authored-by: Isaac
There was a problem hiding this comment.
Verdict: 1 Low
Looks good — a focused test-only fix that compares MAP columns by content rather than an unspecified server key order. NormalizeMapJson, the ColumnNetTypeArrowTypeValue(..., bool, isValid) overload it uses, and the overridden ValidateTestMapData all line up correctly; normalization is applied identically to both sides so the assertion is order-invariant. One low note about the normalization being intentionally shallow (top-level keys only).
Addresses: - #3919678255 at csharp/test/E2E/DatabricksTestEnvironment.cs:71 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 4, 2026
eric-wang-1990
deleted the
eric-wang/csharp-map-tests-order-insensitive
branch
September 4, 2026 04:36
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.
Problem
ComplexTypesValueTests.TestMapDataandClientTests.VerifyTypesAndValuescompare a serializedMAPcolumn by exact JSON string, which bakes in a specific key order. But DatabricksMAPkey order is unspecified — theMAPtype is an unordered set, and the server demonstrably returns keys in different orders on different runs.This surfaced in #509's merge queue: on the identical commit, E2E (thrift + rest) passed at 17:39 (server returned sorted keys) and failed at ~22:00 (server returned insertion order):
#509 removed the client-side
SortedDictionaryinComplexTypeSerializingStreamthat used to normalize map output to sorted order (on both Thrift and SEA — both wrap with that serializer). That normalization was masking the fact that these tests asserted an order the server never guaranteed. With it gone, the tests flake on both protocols.Why not just re-sort in the driver?
Because the driver shouldn't. JDBC — the reference contract this driver matches — does not sort map keys; it preserves the server's order via
LinkedHashMap. The oldSortedDictionarywas an ADBC-only divergence from JDBC (and astringsort, so it mis-ordered numeric keys as1,10,2). #509's no-sort behavior is the more JDBC-conformant, spec-faithful choice. The tests are what needed fixing.Fix
Assert map content, not an unspecified key order:
DatabricksTestEnvironment.NormalizeMapJson— sorts the top-level object's keys (Ordinal), preserving each value's raw JSON so nestedSTRUCTfield order (which is significant) is untouched.TestMapDataoverride and theVerifyTypesAndValuesmapsample column now compareNormalizeMapJson(expected)vsNormalizeMapJson(actual)(the latter via the existingisValidvalidator hook).No driver/serializer changes; no submodule or upstream
arrow-adbcchanges.Verification
dotnet buildof the test project succeeds.Unblocks #509's merge queue: order-insensitive comparison passes on both the old (sorted) and #509 (server-order) serializer output, so this can land on
mainindependently, after which #509 rebases and passes.This pull request and its description were written by Isaac.