Skip to content

fix(csharp): normalize TypeName once in TryGetSchemaFromManifest#337

Merged
eric-wang-1990 merged 4 commits intomainfrom
fix/pr330-followup
Mar 12, 2026
Merged

fix(csharp): normalize TypeName once in TryGetSchemaFromManifest#337
eric-wang-1990 merged 4 commits intomainfrom
fix/pr330-followup

Conversation

@eric-wang-1990
Copy link
Collaborator

@eric-wang-1990 eric-wang-1990 commented Mar 12, 2026

PR #330 follow-up: the two uses of column.TypeName on lines 485 and 497 were inconsistent — the Arrow type mapping had no null guard while the metadata assignment used ?? string.Empty. Extract a single typeName local to make null handling uniform and remove the silent divergence.

Add two unit tests:

  • null TypeName falls back to StringType without throwing
  • DECIMAL(10,2), ARRAY, MAP, STRUCT are all mapped without exception

What's Changed

Please fill in a description of the changes here.

This contains breaking changes.

Closes #NNN.

… complex/null type tests

PR #330 follow-up: the two uses of column.TypeName on lines 485 and 497 were
inconsistent — the Arrow type mapping had no null guard while the metadata
assignment used `?? string.Empty`. Extract a single `typeName` local to make
null handling uniform and remove the silent divergence.

Add two unit tests:
- null TypeName falls back to StringType without throwing
- DECIMAL(10,2), ARRAY, MAP, STRUCT are all mapped without exception

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@eric-wang-1990 eric-wang-1990 changed the title fix(csharp): normalize TypeName once in TryGetSchemaFromManifest; add… fix(csharp): normalize TypeName once in TryGetSchemaFromManifest Mar 12, 2026
…complex type test

The DECIMAL metadata value is already covered by ColumnMetadataHelperTests.
Keep the Arrow type assertions (Decimal128Type, StringType) since those test
MapDatabricksTypeToArrowType end-to-end, which is not exercised by the helper tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@eric-wang-1990
Copy link
Collaborator Author

Re the ComplexAndDecimalTypesAreMappedCorrectly test: Good catch — removed the redundant Spark:DataType:SqlName assertion for DECIMAL (already covered by ColumnMetadataHelperTests). Kept the Arrow type assertions (Decimal128Type, StringType for ARRAY/MAP/STRUCT) since those exercise MapDatabricksTypeToArrowType end-to-end through the statement execution path, which ColumnMetadataHelperTests doesn't cover.

}

[Fact]
public async Task ExecuteQuery_EmptyTable_ComplexAndDecimalTypesAreMappedCorrectly()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need add these, we already have csharp/test/ColumnMetadataHelperTests.cs which test all type mapping?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point — removed the redundant Spark:DataType:SqlName assertion for DECIMAL (already covered by ColumnMetadataHelperTests).

Kept the two tests because they cover things ColumnMetadataHelperTests doesn't:

  • ComplexAndDecimalTypesAreMappedCorrectly: exercises MapDatabricksTypeToArrowType end-to-end (e.g. DECIMAL(10,2)Decimal128Type, ARRAYStringType) — the existing ArrowTypesAreMappedCorrectly test doesn't include these types
  • NullTypeName_TreatedAsUnknownType: verifies null TypeName doesn't throw — not covered anywhere else

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, removed it. The production change is just extracting a typeName local — the complex/decimal type mapping is out of scope.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it — added [InlineData("", "")] to the existing GetBaseTypeName and GetSparkSqlName theories in ColumnMetadataHelperTests and removed the statement-level test entirely.

Out of scope for this PR — the production change is just extracting a
typeName local for null consistency, not touching type mapping logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add empty-string cases to GetBaseTypeName and GetSparkSqlName theories
instead of a full statement-level integration test.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Collaborator

@msrathore-db msrathore-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@eric-wang-1990 eric-wang-1990 added this pull request to the merge queue Mar 12, 2026
Merged via the queue into main with commit 4fcf36b Mar 12, 2026
20 checks passed
@eric-wang-1990 eric-wang-1990 deleted the fix/pr330-followup branch March 12, 2026 06:25
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.

2 participants