Skip to content

[common] Extract a variant into a MAP whose STRING key is NOT NULL - #10876

Open
thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:fix/common-variant-map-not-null-string-key
Open

thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:fix/common-variant-map-not-null-string-key

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Purpose

fix #10875

  • VariantGet.cast and BaseVariantReader.create matched the map key with equals(DataTypes.STRING()), which also compares nullability, so a MAP<STRING NOT NULL, ...> target became an invalid cast (NULL for try, exception otherwise).
  • Spark 4.1 variant pushdown hits this by default: SparkTypeUtils makes map keys NOT NULL, so try_variant_get(v, '$.m', 'map<string,int>') returns NULL. Found by code trace and unit reproduction, not an end-to-end Spark run.
  • Match the key with equalsIgnoreNullable, as Spark matches MapType(_: StringType, _, _), the pattern ported in [variant] Introduce assemble shredded variant struct function #6652. The unreachable nested branch in create is dropped.

Tests

  • Existing map extraction tests only use nullable keys.
  • Added GenericVariantTest#testVariantGetMapWithNotNullStringKey (try and strict, nested in an array, INT key stays invalid), BaseVariantReaderTest#testMapReaderWithNotNullStringKey (shredded object), and a NOT NULL key case in PaimonShreddingUtilsTest#testAssembleAllTypes; all fail without the fix.
  • mvn -pl paimon-common -DfailIfNoTests=false clean install (JDK 11): BUILD SUCCESS, including checkstyle, spotless and rat.

VariantGet.cast and BaseVariantReader.create matched the map key with
equals(DataTypes.STRING()), which also compares nullability, so a
MAP<STRING NOT NULL, ...> target was treated as an invalid cast. Match the
key with equalsIgnoreNullable and drop the unreachable nested branch in
BaseVariantReader.create.

Generated-by: Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Variant extraction into MAP<STRING NOT NULL, ...> returns NULL

1 participant