Skip to content

Commit 7ca6e23

Browse files
fix(csharp): address issue #544 (1 review thread)
Addresses: - #3450631606 at csharp/src/DatabricksStatement.cs:938
1 parent 3a67726 commit 7ca6e23

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

csharp/src/DatabricksStatement.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,9 +932,9 @@ private RecordBatch NormalizeBatch(RecordBatch batch)
932932
// so they arrive as StringArray. If a future schema change makes either column a
933933
// different string layout (e.g. LargeStringArray), the `is StringArray` checks below
934934
// fail and the column falls through to the unnormalized `else` branch — silently
935-
// reopening issue #527. The two index conditions are kept separate from the type
936-
// check so that mismatch is visible here in review rather than at runtime; add a
937-
// LargeStringArray branch (or generalize NormalizeStringColumn) if that ever changes.
935+
// reopening issue #527. The Debug.Assert below makes that mismatch observable in
936+
// debug builds instead of failing silently; add a LargeStringArray branch (or
937+
// generalize NormalizeStringColumn) if the schema ever changes.
938938
if (i == _tableTypeIndex && batch.Column(i) is StringArray tableTypeArray)
939939
{
940940
columns[i] = NormalizeStringColumn(tableTypeArray, DefaultTableType, normalizeUnknown: false);
@@ -950,6 +950,13 @@ private RecordBatch NormalizeBatch(RecordBatch batch)
950950
}
951951
else
952952
{
953+
// Guardrail: if this is a column we intended to normalize but its array type is
954+
// not StringArray, the type guards above fell through and #527 is silently
955+
// reopened. Surface that as an assertion failure in debug builds rather than
956+
// leaving it invisible at runtime.
957+
Debug.Assert(
958+
i != _tableTypeIndex && i != _remarksIndex,
959+
$"Expected TABLE_TYPE/REMARKS column at index {i} to be a StringArray but got {batch.Column(i).GetType().Name}; normalization (issue #527) was skipped.");
953960
columns[i] = batch.Column(i);
954961
}
955962
}

0 commit comments

Comments
 (0)