This is an automated email from the ASF dual-hosted git repository.
jt2594838 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new a2368b2955f Fix C++ client reading FLOAT inference columns declared as
DOUBLE (#17759)
a2368b2955f is described below
commit a2368b2955f30fb72df22343c6907845945fdb1d
Author: Hongzhi Gao <[email protected]>
AuthorDate: Fri May 29 14:14:47 2026 +0800
Fix C++ client reading FLOAT inference columns declared as DOUBLE (#17759)
* Fix C++ client reading FLOAT inference columns declared as DOUBLE
CALL INFERENCE returns FLOAT data in TsBlock while the result schema
declares DOUBLE. Coerce by actual column type in getDouble/getFloat to
avoid Unsupported operation: getDouble when iterating RowRecord.
* Move column type coercion test into sessionIT.cpp
Avoid a separate test source file; keep the same coverage in session_tests.
* Implement numeric widening getters on C++ Column classes
Align with Java TsFile: IntColumn/FloatColumn/LongColumn support cross-type
getters (e.g. FloatColumn::getDouble). IoTDBRpcDataSet delegates directly to
column getters like the Java client. Fixes CALL INFERENCE crash when schema
declares DOUBLE but TsBlock stores FLOAT (including RLE-encoded columns).
---
iotdb-client/client-cpp/src/main/Column.cpp | 20 ++++++++++++++++++++
iotdb-client/client-cpp/src/main/Column.h | 5 +++++
iotdb-client/client-cpp/src/test/cpp/sessionIT.cpp | 20 ++++++++++++++++++++
3 files changed, 45 insertions(+)
diff --git a/iotdb-client/client-cpp/src/main/Column.cpp
b/iotdb-client/client-cpp/src/main/Column.cpp
index 203fcefd8d9..906a78968ed 100644
--- a/iotdb-client/client-cpp/src/main/Column.cpp
+++ b/iotdb-client/client-cpp/src/main/Column.cpp
@@ -152,6 +152,18 @@ int32_t IntColumn::getInt(int32_t position) const {
return values_[position + arrayOffset_];
}
+int64_t IntColumn::getLong(int32_t position) const {
+ return values_[position + arrayOffset_];
+}
+
+float IntColumn::getFloat(int32_t position) const {
+ return values_[position + arrayOffset_];
+}
+
+double IntColumn::getDouble(int32_t position) const {
+ return values_[position + arrayOffset_];
+}
+
std::vector<int32_t> IntColumn::getInts() const {
return values_;
}
@@ -204,6 +216,10 @@ float FloatColumn::getFloat(int32_t position) const {
return values_[position + arrayOffset_];
}
+double FloatColumn::getDouble(int32_t position) const {
+ return values_[position + arrayOffset_];
+}
+
std::vector<float> FloatColumn::getFloats() const {
return values_;
}
@@ -256,6 +272,10 @@ int64_t LongColumn::getLong(int32_t position) const {
return values_[position + arrayOffset_];
}
+double LongColumn::getDouble(int32_t position) const {
+ return values_[position + arrayOffset_];
+}
+
std::vector<int64_t> LongColumn::getLongs() const {
return values_;
}
diff --git a/iotdb-client/client-cpp/src/main/Column.h
b/iotdb-client/client-cpp/src/main/Column.h
index 8794e7b8d5e..c278c6ebe73 100644
--- a/iotdb-client/client-cpp/src/main/Column.h
+++ b/iotdb-client/client-cpp/src/main/Column.h
@@ -196,6 +196,9 @@ public:
ColumnEncoding getEncoding() const override;
int32_t getInt(int32_t position) const override;
+ int64_t getLong(int32_t position) const override;
+ float getFloat(int32_t position) const override;
+ double getDouble(int32_t position) const override;
std::vector<int32_t> getInts() const override;
bool mayHaveNull() const override;
@@ -220,6 +223,7 @@ public:
ColumnEncoding getEncoding() const override;
float getFloat(int32_t position) const override;
+ double getDouble(int32_t position) const override;
std::vector<float> getFloats() const override;
bool mayHaveNull() const override;
@@ -244,6 +248,7 @@ public:
ColumnEncoding getEncoding() const override;
int64_t getLong(int32_t position) const override;
+ double getDouble(int32_t position) const override;
std::vector<int64_t> getLongs() const override;
bool mayHaveNull() const override;
diff --git a/iotdb-client/client-cpp/src/test/cpp/sessionIT.cpp
b/iotdb-client/client-cpp/src/test/cpp/sessionIT.cpp
index 1f9abb153ef..0bf30bbbf1b 100644
--- a/iotdb-client/client-cpp/src/test/cpp/sessionIT.cpp
+++ b/iotdb-client/client-cpp/src/test/cpp/sessionIT.cpp
@@ -18,6 +18,7 @@
*/
#include "catch.hpp"
+#include "Column.h"
#include "Session.h"
#include "SessionBuilder.h"
#include "TsBlock.h"
@@ -878,4 +879,23 @@ TEST_CASE("TsBlock deserialize rejects truncated malicious
payload", "[TsBlockDe
std::string data(18, '\0');
data[3] = '\x10';
REQUIRE_THROWS_AS(TsBlock::deserialize(data), IoTDBException);
+}
+
+TEST_CASE("Numeric column widening getters align with Java TsFile",
"[column]") {
+ std::vector<bool> valueIsNull(1, false);
+
+ std::vector<float> floatValues = {120.00000762939453f};
+ auto floatColumn = std::make_shared<FloatColumn>(0, 1, valueIsNull,
floatValues);
+ auto rleColumn = std::make_shared<RunLengthEncodedColumn>(floatColumn, 20);
+ REQUIRE(floatColumn->getDouble(0) == Approx(120.0).margin(0.01));
+ REQUIRE(rleColumn->getDouble(0) == Approx(120.0).margin(0.01));
+
+ std::vector<int32_t> intValues = {42};
+ auto intColumn = std::make_shared<IntColumn>(0, 1, valueIsNull, intValues);
+ REQUIRE(intColumn->getLong(0) == 42);
+ REQUIRE(intColumn->getDouble(0) == Approx(42.0));
+
+ std::vector<int64_t> longValues = {1000};
+ auto longColumn = std::make_shared<LongColumn>(0, 1, valueIsNull,
longValues);
+ REQUIRE(longColumn->getDouble(0) == Approx(1000.0));
}
\ No newline at end of file