This is an automated email from the ASF dual-hosted git repository.
hongzhigao pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/develop by this push:
new c501bf4e Resolved case sensitivity issue when reading column names.
(#517)
c501bf4e is described below
commit c501bf4e0ac13cdbe0b7d404cd4ea3ef99904203
Author: Hongzhi Gao <[email protected]>
AuthorDate: Wed Jun 18 16:03:04 2025 +0800
Resolved case sensitivity issue when reading column names. (#517)
* Resolved case sensitivity issue when reading column names.
* [tsfile-cwrapper]Resolved case sensitivity issue when reading column
names.
---
cpp/src/cwrapper/tsfile_cwrapper.cc | 4 ++--
cpp/src/reader/table_query_executor.cc | 10 +++++++---
cpp/src/reader/table_result_set.cc | 2 +-
cpp/src/reader/tsfile_reader.cc | 6 +-----
cpp/src/utils/storage_utils.h | 2 --
cpp/test/cwrapper/c_release_test.cc | 4 ++--
6 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/cpp/src/cwrapper/tsfile_cwrapper.cc
b/cpp/src/cwrapper/tsfile_cwrapper.cc
index 656737df..0095dd13 100644
--- a/cpp/src/cwrapper/tsfile_cwrapper.cc
+++ b/cpp/src/cwrapper/tsfile_cwrapper.cc
@@ -316,7 +316,7 @@ bool tsfile_result_set_next(ResultSet result_set, ERRNO
*err_code) {
const char *column_name) {
\
auto *r = static_cast<storage::TableResultSet *>(result_set);
\
std::string column_name_(column_name);
\
- return r->get_value<type>(storage::to_lower(column_name_));
\
+ return r->get_value<type>(column_name_);
\
}
TSFILE_RESULT_SET_GET_VALUE_BY_NAME_DEF(bool);
@@ -329,7 +329,7 @@ char *tsfile_result_set_get_value_by_name_string(ResultSet
result_set,
auto *r = static_cast<storage::TableResultSet *>(result_set);
std::string column_name_(column_name);
common::String *ret =
- r->get_value<common::String *>(storage::to_lower(column_name_));
+ r->get_value<common::String *>(column_name_);
// Caller should free return's char* 's space.
char *dup = (char *)malloc(ret->len_ + 1);
if (dup) {
diff --git a/cpp/src/reader/table_query_executor.cc
b/cpp/src/reader/table_query_executor.cc
index 6249f9e7..97913c21 100644
--- a/cpp/src/reader/table_query_executor.cc
+++ b/cpp/src/reader/table_query_executor.cc
@@ -41,9 +41,13 @@ int TableQueryExecutor::query(const std::string &table_name,
ret_qds = nullptr;
return ret;
}
+ std::vector<std::string> std_column_names(columns);
+ for (auto &column : std_column_names) {
+ to_lowercase_inplace(column);
+ }
std::shared_ptr<ColumnMapping> column_mapping =
std::make_shared<ColumnMapping>();
- for (size_t i = 0; i < columns.size(); ++i) {
- column_mapping->add(columns[i], static_cast<int>(i), *table_schema);
+ for (size_t i = 0; i < std_column_names.size(); ++i) {
+ column_mapping->add(std_column_names[i], static_cast<int>(i),
*table_schema);
}
std::vector<common::TSDataType> data_types;
data_types.reserve(columns.size());
@@ -57,7 +61,7 @@ int TableQueryExecutor::query(const std::string &table_name,
// column_mapping.add(*measurement_filter);
auto device_task_iterator = std::unique_ptr<DeviceTaskIterator>(
- new DeviceTaskIterator(columns, table_root, column_mapping,
+ new DeviceTaskIterator(std_column_names, table_root, column_mapping,
meta_data_querier_, id_filter, table_schema));
std::unique_ptr<TsBlockReader> tsblock_reader;
diff --git a/cpp/src/reader/table_result_set.cc
b/cpp/src/reader/table_result_set.cc
index 23e35aaa..bbadc44a 100644
--- a/cpp/src/reader/table_result_set.cc
+++ b/cpp/src/reader/table_result_set.cc
@@ -80,7 +80,7 @@ int TableResultSet::next(bool& has_next) {
}
bool TableResultSet::is_null(const std::string& column_name) {
- auto iter = index_lookup_.find(to_lower(column_name));
+ auto iter = index_lookup_.find(column_name);
if (iter == index_lookup_.end()) {
return true;
} else {
diff --git a/cpp/src/reader/tsfile_reader.cc b/cpp/src/reader/tsfile_reader.cc
index 162fb6ad..bf3a2db7 100644
--- a/cpp/src/reader/tsfile_reader.cc
+++ b/cpp/src/reader/tsfile_reader.cc
@@ -97,15 +97,11 @@ int TsFileReader::query(const std::string &table_name,
if (table_schema == nullptr) {
return E_TABLE_NOT_EXIST;
}
- std::vector<std::string> columns_names_lowercase(columns_names);
- for (auto &column_name : columns_names_lowercase) {
- to_lowercase_inplace(column_name);
- }
std::vector<TSDataType> data_types = table_schema->get_data_types();
Filter* time_filter = new TimeBetween(start_time, end_time, false);
- ret = table_query_executor_->query(to_lower(table_name),
columns_names_lowercase, time_filter, nullptr, nullptr, result_set);
+ ret = table_query_executor_->query(to_lower(table_name), columns_names,
time_filter, nullptr, nullptr, result_set);
return ret;
}
diff --git a/cpp/src/utils/storage_utils.h b/cpp/src/utils/storage_utils.h
index f4d596b0..698a7303 100644
--- a/cpp/src/utils/storage_utils.h
+++ b/cpp/src/utils/storage_utils.h
@@ -19,8 +19,6 @@
#ifndef UTILS_STORAGE_UTILS_H
#define UTILS_STORAGE_UTILS_H
-#include <inttypes.h>
-#include <stdint.h>
#include <algorithm>
#include "common/datatype/value.h"
diff --git a/cpp/test/cwrapper/c_release_test.cc
b/cpp/test/cwrapper/c_release_test.cc
index bb73fb9d..0ccb0cdd 100644
--- a/cpp/test/cwrapper/c_release_test.cc
+++ b/cpp/test/cwrapper/c_release_test.cc
@@ -307,9 +307,9 @@ TEST_F(CReleaseTest, TsFileWriterMultiDataType) {
ASSERT_EQ("device1", std::string(str_value));
free(str_value);
ASSERT_EQ(value,
tsfile_result_set_get_value_by_name_int32_t(result_set,
- "int32"));
+ "INT32"));
ASSERT_EQ(value * 100, tsfile_result_set_get_value_by_name_int64_t(
- result_set, "int64"));
+ result_set, "INT64"));
ASSERT_EQ(value * 100.0, tsfile_result_set_get_value_by_name_float(
result_set, "FLOAT"));