Skip to content

Commit 9fb873a

Browse files
CritasWangclaude
andcommitted
Fix GetRow() type handling, GetInt overflow, and timezone fallback in RpcDataSet
- Identify time column by tsBlockColumnIndex==-1 instead of TSDataType.TIMESTAMP to correctly set RowRecord.Timestamps and preserve TIMESTAMP-typed value columns - Return proper types for DATE (DateTime) and BLOB (byte[]) in GetRow() to match RowRecord.ToBytes() expectations and prevent InvalidCastException - Guard BLOB null with binary?.Data to avoid NullReferenceException - Use checked cast in GetIntByTsBlockColumnIndex for time column to surface OverflowException instead of silently returning truncated values - Throw TimeZoneNotFoundException instead of silently falling back to TimeZoneInfo.Local when zone ID cannot be resolved Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6e2c057 commit 9fb873a

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/Apache.IoTDB/DataStructure/RpcDataSet.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ private int GetIntByTsBlockColumnIndex(int tsBlockColumnIndex)
414414
CheckRecord();
415415
if (!IsNull(tsBlockColumnIndex, _tsBlockIndex))
416416
{
417-
if (tsBlockColumnIndex == -1) return (int)_curTsBlock.GetTimeByIndex(_tsBlockIndex);
417+
if (tsBlockColumnIndex == -1) return checked((int)_curTsBlock.GetTimeByIndex(_tsBlockIndex));
418418
_lastReadWasNull = false;
419419
TSDataType dataType = _curTsBlock.GetColumn(tsBlockColumnIndex).GetDataType();
420420
if (dataType == TSDataType.INT64)
@@ -638,6 +638,15 @@ public RowRecord GetRow()
638638
string typeStr = _columnTypeList[i];
639639
TSDataType dataType = Client.GetDataTypeByStr(typeStr);
640640

641+
// Identify the real time column by tsBlock index, not by data type
642+
int tsBlockColumnIndex = GetTsBlockColumnIndexForColumnName(columnName);
643+
if (tsBlockColumnIndex == -1)
644+
{
645+
timestamp = GetLong(columnName);
646+
i += 1;
647+
continue;
648+
}
649+
641650
switch (dataType)
642651
{
643652
case TSDataType.BOOLEAN:
@@ -650,8 +659,7 @@ public RowRecord GetRow()
650659
localfield = GetLong(columnName);
651660
break;
652661
case TSDataType.TIMESTAMP:
653-
localfield = null;
654-
timestamp = GetLong(columnName);
662+
localfield = GetLong(columnName);
655663
break;
656664
case TSDataType.FLOAT:
657665
localfield = GetFloat(columnName);
@@ -661,9 +669,14 @@ public RowRecord GetRow()
661669
break;
662670
case TSDataType.TEXT:
663671
case TSDataType.STRING:
672+
localfield = GetString(columnName);
673+
break;
664674
case TSDataType.BLOB:
675+
var binary = GetBinary(columnName);
676+
localfield = binary?.Data;
677+
break;
665678
case TSDataType.DATE:
666-
localfield = GetString(columnName);
679+
localfield = GetDate(columnName);
667680
break;
668681
default:
669682
string err_msg = "value format not supported";
@@ -846,7 +859,9 @@ internal static TimeZoneInfo FindTimeZoneSafe(string zoneId)
846859
}
847860
}
848861

849-
return TimeZoneInfo.Local;
862+
throw new TimeZoneNotFoundException(
863+
$"Cannot resolve time zone ID '{zoneId}'. " +
864+
$"Ensure it is a valid IANA (e.g. 'Asia/Shanghai') or Windows (e.g. 'China Standard Time') time zone ID.");
850865
}
851866
}
852867

0 commit comments

Comments
 (0)