diff --git a/.github/workflows/clang_test.yaml b/.github/workflows/clang_test.yaml index 4f98e761..7f0339c7 100644 --- a/.github/workflows/clang_test.yaml +++ b/.github/workflows/clang_test.yaml @@ -46,4 +46,4 @@ jobs: env: CC: clang CXX: clang++ - run: ci/scripts/build_paimon.sh $(pwd) + run: ci/scripts/build_paimon.sh $(pwd) false true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7d2472f6..977a0f96 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -69,7 +69,7 @@ repos: ] - repo: https://github.com/cpplint/cpplint - rev: 1.6.1 + rev: 2.0.2 hooks: - id: cpplint alias: cpp @@ -77,7 +77,7 @@ repos: args: - "--quiet" - "--verbose=2" - - "--filter=-whitespace/line_length,-whitespace/parens,-build/c++11,-readability/nolint,-runtime/references" + - "--filter=-whitespace/line_length,-whitespace/parens,-whitespace/indent_namespace,-build/include_what_you_use,-build/c++11,-build/c++17,-readability/nolint,-runtime/references" types_or: - c++ diff --git a/CMakeLists.txt b/CMakeLists.txt index 428bc0f1..ef02f3ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,7 +118,7 @@ if(PAIMON_LINT_GIT_DIFF_MODE) set(GIT_DIFF_FILE_PATH ${CMAKE_BINARY_DIR}/git_diff_files.txt) add_custom_target(update_diff_files # get git-diff file list - COMMAND git diff-index --name-only --diff-filter=a --cached + COMMAND git diff-index --name-only --diff-filter=d --cached ${PAIMON_LINT_GIT_TARGET_COMMIT} > ${GIT_DIFF_FILE_PATH} # convert to absolute path COMMAND sed -i \"s|^|${CMAKE_SOURCE_DIR}/|\" ${GIT_DIFF_FILE_PATH} diff --git a/ci/scripts/build_paimon.sh b/ci/scripts/build_paimon.sh index 0b9cff74..7fd8d9a2 100755 --- a/ci/scripts/build_paimon.sh +++ b/ci/scripts/build_paimon.sh @@ -18,6 +18,7 @@ set -eux source_dir=${1} enable_sanitizer=${2:-false} +check_clang_tidy=${3:-false} build_dir=${1}/build mkdir ${build_dir} @@ -42,6 +43,10 @@ cmake "${CMAKE_ARGS[@]}" ${source_dir} cmake --build . -- -j$(nproc) ctest --output-on-failure -j $(nproc) +if [[ "${check_clang_tidy}" == "true" ]]; then + cmake --build . --target check-clang-tidy +fi + popd rm -rf ${build_dir} diff --git a/include/paimon/result.h b/include/paimon/result.h index 377a9eb3..1683031b 100644 --- a/include/paimon/result.h +++ b/include/paimon/result.h @@ -37,13 +37,14 @@ class PAIMON_MUST_USE_TYPE PAIMON_EXPORT Result { status_.~Status(); } + // NOLINTBEGIN(google-explicit-constructor, runtime/explicit) /// Construct a successful result with a copy of the given value. /// @param data The value to store in result. - Result(const T& data) : status_(), data_(data) {} // NOLINT(runtime/explicit) + Result(const T& data) : status_(), data_(data) {} /// Construct a successful result by moving the given value. /// @param data The value to move into result. - Result(T&& data) : status_(), data_(std::move(data)) {} // NOLINT(runtime/explicit) + Result(T&& data) : status_(), data_(std::move(data)) {} /// Template constructor for converting compatible pointer types. /// Support T = std::unique_ptr and U = std::unique_ptr convert, where D is derived class @@ -53,11 +54,12 @@ class PAIMON_MUST_USE_TYPE PAIMON_EXPORT Result { std::enable_if_t< is_pointer::value && is_pointer::value && std::is_convertible_v, value_type_traits_t>>* = nullptr> - Result(U&& data) : status_(), data_(std::move(data)) {} // NOLINT(runtime/explicit) + Result(U&& data) : status_(), data_(std::move(data)) {} /// Construct a failed result with the given status. /// @param status The status object describing the error. - Result(const Status& status) : status_(status) {} // NOLINT(runtime/explicit) + Result(const Status& status) : status_(status) {} + // NOLINTEND(google-explicit-constructor, runtime/explicit) /// Copy constructor. /// @param other The result to copy from. @@ -79,13 +81,14 @@ class PAIMON_MUST_USE_TYPE PAIMON_EXPORT Result { MakeStatus(other.status_); } + // NOLINTBEGIN(google-explicit-constructor, runtime/explicit) /// Template move constructor for converting compatible `Result` types. /// @param other The result to move from. template ::value && is_pointer::value && std::is_convertible_v, value_type_traits_t>>* = nullptr> - Result(Result&& other) noexcept { // NOLINT(runtime/explicit) + Result(Result&& other) noexcept { if (other.ok()) { MakeValue(std::move(other).value()); } @@ -93,6 +96,7 @@ class PAIMON_MUST_USE_TYPE PAIMON_EXPORT Result { // value hasn't been constructed => crash on other destructor. MakeStatus(other.status()); } + // NOLINTEND(google-explicit-constructor, runtime/explicit) /// Copy assignment operator. /// @param other The result to copy from. diff --git a/src/paimon/common/data/binary_row_test.cpp b/src/paimon/common/data/binary_row_test.cpp index 307dccc3..31fa189b 100644 --- a/src/paimon/common/data/binary_row_test.cpp +++ b/src/paimon/common/data/binary_row_test.cpp @@ -74,7 +74,7 @@ TEST_F(BinaryRowTest, TestBasic) { row.SetInt(0, 5); row.SetDouble(1, 5.8); ASSERT_EQ(5, row.GetInt(0)); - ASSERT_EQ((double)5.8, row.GetDouble(1)); + ASSERT_EQ(static_cast(5.8), row.GetDouble(1)); row.Clear(); std::shared_ptr bytes1 = Bytes::AllocateBytes(100, pool.get()); @@ -405,10 +405,10 @@ TEST_F(BinaryRowTest, TestCompatibleWithJava) { int32_t arity = 1; BinaryRow row(arity); BinaryRowWriter writer(&row, 0, pool.get()); - writer.WriteInt(0, static_cast(18)); + writer.WriteInt(0, 18); writer.Complete(); - ASSERT_EQ(row.GetInt(0), (int32_t)18); + ASSERT_EQ(row.GetInt(0), 18); auto bytes = SerializationUtils::SerializeBinaryRow(row, pool.get()); std::string bytes_view(bytes->data(), bytes->size()); @@ -418,7 +418,7 @@ TEST_F(BinaryRowTest, TestCompatibleWithJava) { ASSERT_EQ(bytes_view, expect_view); ASSERT_OK_AND_ASSIGN(auto de_row, SerializationUtils::DeserializeBinaryRow(bytes)); ASSERT_EQ(1, de_row.GetFieldCount()); - ASSERT_EQ(de_row.GetInt(0), (int32_t)18); + ASSERT_EQ(de_row.GetInt(0), 18); } } @@ -564,8 +564,8 @@ TEST_F(BinaryRowTest, TestBinaryRowSerializer) { test_string1.reserve(str_size); test_string2.reserve(str_size); for (int32_t j = 0; j < str_size; j++) { - test_string1 += paimon::test::RandomNumber(0, 25) + 'a'; - test_string2 += paimon::test::RandomNumber(0, 25) + 'a'; + test_string1 += static_cast(paimon::test::RandomNumber(0, 25) + 'a'); + test_string2 += static_cast(paimon::test::RandomNumber(0, 25) + 'a'); } std::shared_ptr bytes1 = Bytes::AllocateBytes(test_string1, pool.get()); std::shared_ptr bytes2 = Bytes::AllocateBytes(test_string2, pool.get()); diff --git a/src/paimon/common/data/generic_row_test.cpp b/src/paimon/common/data/generic_row_test.cpp index b0dfac66..1e387c85 100644 --- a/src/paimon/common/data/generic_row_test.cpp +++ b/src/paimon/common/data/generic_row_test.cpp @@ -78,13 +78,13 @@ TEST(GenericRowTest, TestSimple) { // test get ASSERT_FALSE(row.IsNullAt(0)); ASSERT_EQ(row.GetBoolean(0), true); - ASSERT_EQ(row.GetByte(1), (char)1); - ASSERT_EQ(row.GetShort(2), (int16_t)2); - ASSERT_EQ(row.GetInt(3), (int32_t)3); - ASSERT_EQ(row.GetDate(3), (int32_t)3); - ASSERT_EQ(row.GetLong(4), (int64_t)4); - ASSERT_EQ(row.GetFloat(5), (float)5.1); - ASSERT_EQ(row.GetDouble(6), (double)6.12); + ASSERT_EQ(row.GetByte(1), static_cast(1)); + ASSERT_EQ(row.GetShort(2), static_cast(2)); + ASSERT_EQ(row.GetInt(3), static_cast(3)); + ASSERT_EQ(row.GetDate(3), static_cast(3)); + ASSERT_EQ(row.GetLong(4), static_cast(4)); + ASSERT_EQ(row.GetFloat(5), static_cast(5.1)); + ASSERT_EQ(row.GetDouble(6), static_cast(6.12)); ASSERT_EQ(row.GetString(7), str); ASSERT_EQ(*row.GetBinary(8), *bytes); ASSERT_EQ(std::string(row.GetStringView(9)), str9); diff --git a/src/paimon/common/data/record_batch_test.cpp b/src/paimon/common/data/record_batch_test.cpp index 8efeedf2..1287fd18 100644 --- a/src/paimon/common/data/record_batch_test.cpp +++ b/src/paimon/common/data/record_batch_test.cpp @@ -58,7 +58,7 @@ TEST(RecordBatchTest, TestSimple) { ASSERT_TRUE(struct_builder.Append().ok()); ASSERT_TRUE(string_builder->Append("20240813").ok()); ASSERT_TRUE(int_builder->Append(23).ok()); - ASSERT_TRUE(long_builder->Append((int64_t)1722848484308ll + i).ok()); + ASSERT_TRUE(long_builder->Append(static_cast(1722848484308ll + i)).ok()); ASSERT_TRUE(bool_builder->Append(static_cast(i % 2)).ok()); } std::shared_ptr array; diff --git a/src/paimon/common/file_index/file_index_format_test.cpp b/src/paimon/common/file_index/file_index_format_test.cpp index 4cd124b3..b23f7b2b 100644 --- a/src/paimon/common/file_index/file_index_format_test.cpp +++ b/src/paimon/common/file_index/file_index_format_test.cpp @@ -149,6 +149,7 @@ TEST_F(FileIndexFormatTest, TestSimple) { } } +// NOLINTNEXTLINE(google-readability-function-size) TEST_F(FileIndexFormatTest, TestBitmapIndexWithTimestamp) { auto schema = arrow::schema({ arrow::field("ts_sec", arrow::timestamp(arrow::TimeUnit::SECOND)), diff --git a/src/paimon/common/memory/memory_segment.h b/src/paimon/common/memory/memory_segment.h index 9e3707b5..03205d88 100644 --- a/src/paimon/common/memory/memory_segment.h +++ b/src/paimon/common/memory/memory_segment.h @@ -73,16 +73,16 @@ class PAIMON_EXPORT MemorySegment { template inline void Get(int32_t index, T* dst, int32_t offset, int32_t length) const { // check the byte array offset and length and the status - assert((int32_t)dst->size() >= (offset + length)); - assert((int32_t)heap_memory_->size() >= (index + length)); + assert(static_cast(dst->size()) >= (offset + length)); + assert(static_cast(heap_memory_->size()) >= (index + length)); std::memcpy(const_cast(dst->data()) + offset, heap_memory_->data() + index, length); } template inline void Put(int32_t index, const T& src, int32_t offset, int32_t length) { // check the byte array offset and length - assert((int32_t)src.size() >= (offset + length)); - assert((int32_t)heap_memory_->size() >= (index + length)); + assert(static_cast(src.size()) >= (offset + length)); + assert(static_cast(heap_memory_->size()) >= (index + length)); std::memcpy(heap_memory_->data() + index, src.data() + offset, length); } diff --git a/src/paimon/common/memory/memory_segment_test.cpp b/src/paimon/common/memory/memory_segment_test.cpp index a1d6cc37..14bdc32f 100644 --- a/src/paimon/common/memory/memory_segment_test.cpp +++ b/src/paimon/common/memory/memory_segment_test.cpp @@ -40,7 +40,8 @@ TEST(MemorySegmentTest, TestByteAccess) { } std::srand(seed); for (int32_t i = 0; i < page_size; i++) { - ASSERT_EQ(segment.Get(i), (char)std::rand()) << "seed: " << seed << ", idx: " << i; + ASSERT_EQ(segment.Get(i), static_cast(std::rand())) + << "seed: " << seed << ", idx: " << i; } // test expected correct behavior, random access @@ -72,7 +73,8 @@ TEST(MemorySegmentTest, TestByteAccess) { occupied[pos] = true; } - ASSERT_EQ(segment.Get(pos), (char)std::rand()) << "seed: " << seed << ", idx: " << pos; + ASSERT_EQ(segment.Get(pos), static_cast(std::rand())) + << "seed: " << seed << ", idx: " << pos; } delete[] occupied; } @@ -165,8 +167,8 @@ TEST(MemorySegmentTest, TestSwapBytes) { test_string1.reserve(str_size); test_string2.reserve(str_size); for (int32_t j = 0; j < str_size; j++) { - test_string1 += paimon::test::RandomNumber(0, 25) + 'a'; - test_string2 += paimon::test::RandomNumber(0, 25) + 'a'; + test_string1 += static_cast(paimon::test::RandomNumber(0, 25) + 'a'); + test_string2 += static_cast(paimon::test::RandomNumber(0, 25) + 'a'); } std::shared_ptr bytes1 = Bytes::AllocateBytes(test_string1, pool.get()); std::shared_ptr bytes2 = Bytes::AllocateBytes(test_string2, pool.get()); @@ -197,7 +199,7 @@ TEST(MemorySegmentTest, TestCharAccess) { std::srand(seed); for (int32_t i = 0; i <= page_size - 2; i += 2) { - ASSERT_EQ(segment.GetValue(i), (char)(std::rand() % (CHAR_MAX))) + ASSERT_EQ(segment.GetValue(i), static_cast(std::rand() % (CHAR_MAX))) << "seed: " << seed << ", idx: " << i; } @@ -231,7 +233,7 @@ TEST(MemorySegmentTest, TestCharAccess) { occupied[pos + 1] = true; } - ASSERT_EQ(segment.GetValue(pos), (char)(std::rand() % (CHAR_MAX))) + ASSERT_EQ(segment.GetValue(pos), static_cast(std::rand() % (CHAR_MAX))) << "seed: " << seed << ", idx:" << pos; } delete[] occupied; @@ -251,7 +253,7 @@ TEST(MemorySegmentTest, TestShortAccess) { std::srand(seed); for (int32_t i = 0; i <= page_size - 2; i += 2) { - ASSERT_EQ(segment.GetValue(i), (int16_t)std::rand()) + ASSERT_EQ(segment.GetValue(i), static_cast(std::rand())) << "seed: " << seed << ", idx:" << i; } @@ -285,7 +287,7 @@ TEST(MemorySegmentTest, TestShortAccess) { occupied[pos + 1] = true; } - ASSERT_EQ(segment.GetValue(pos), (int16_t)std::rand()) + ASSERT_EQ(segment.GetValue(pos), static_cast(std::rand())) << "seed: " << seed << ", idx:" << pos; } delete[] occupied; @@ -305,7 +307,7 @@ TEST(MemorySegmentTest, TestIntAccess) { std::srand(seed); for (int32_t i = 0; i <= page_size - 4; i += 4) { - ASSERT_EQ(segment.GetValue(i), (int32_t)std::rand()) + ASSERT_EQ(segment.GetValue(i), static_cast(std::rand())) << "seed: " << seed << ", idx:" << i; } @@ -343,7 +345,7 @@ TEST(MemorySegmentTest, TestIntAccess) { occupied[pos + 3] = true; } - ASSERT_EQ(segment.GetValue(pos), (int32_t)std::rand()) + ASSERT_EQ(segment.GetValue(pos), static_cast(std::rand())) << "seed: " << seed << ", idx:" << pos; } delete[] occupied; diff --git a/src/paimon/common/memory/memory_segment_utils_test.cpp b/src/paimon/common/memory/memory_segment_utils_test.cpp index dafb0045..286d78f2 100644 --- a/src/paimon/common/memory/memory_segment_utils_test.cpp +++ b/src/paimon/common/memory/memory_segment_utils_test.cpp @@ -71,8 +71,8 @@ TEST(MemorySegmentUtilsTest, TestCopyFromBytesAndGetBytes) { test_string1.reserve(str_size); test_string2.reserve(str_size); for (int32_t j = 0; j < str_size; j++) { - test_string1 += paimon::test::RandomNumber(0, 25) + 'a'; - test_string2 += paimon::test::RandomNumber(0, 25) + 'a'; + test_string1 += static_cast(paimon::test::RandomNumber(0, 25) + 'a'); + test_string2 += static_cast(paimon::test::RandomNumber(0, 25) + 'a'); } test_string2 += test_string1; std::shared_ptr bytes1 = Bytes::AllocateBytes(test_string1, pool.get()); @@ -110,8 +110,8 @@ TEST(MemorySegmentUtilsTest, TestCopyToUnsafe) { test_string1.reserve(str_size); test_string2.reserve(str_size); for (int32_t j = 0; j < str_size; j++) { - test_string1 += paimon::test::RandomNumber(0, 25) + 'a'; - test_string2 += paimon::test::RandomNumber(0, 25) + 'a'; + test_string1 += static_cast(paimon::test::RandomNumber(0, 25) + 'a'); + test_string2 += static_cast(paimon::test::RandomNumber(0, 25) + 'a'); } test_string2 += test_string1; std::shared_ptr bytes1 = Bytes::AllocateBytes(test_string1, pool.get()); @@ -140,8 +140,8 @@ TEST(MemorySegmentUtilsTest, TestSetAndUnSet) { test_string1.reserve(str_size); test_string2.reserve(str_size); for (int32_t j = 0; j < str_size; j++) { - test_string1 += paimon::test::RandomNumber(0, 25) + 'a'; - test_string2 += paimon::test::RandomNumber(0, 25) + 'a'; + test_string1 += static_cast(paimon::test::RandomNumber(0, 25) + 'a'); + test_string2 += static_cast(paimon::test::RandomNumber(0, 25) + 'a'); } test_string2 += test_string1; std::shared_ptr bytes2 = Bytes::AllocateBytes(test_string2, pool.get()); diff --git a/src/paimon/common/predicate/predicate_validator_test.cpp b/src/paimon/common/predicate/predicate_validator_test.cpp index a332263f..1c3b9327 100644 --- a/src/paimon/common/predicate/predicate_validator_test.cpp +++ b/src/paimon/common/predicate/predicate_validator_test.cpp @@ -150,7 +150,7 @@ TEST(PredicateValidatorTest, TestValidateSchema) { PredicateBuilder::Equal(/*field_index=*/7, /*field_name=*/"f7", FieldType::BINARY, Literal(FieldType::BINARY, str.data(), str.size())), PredicateBuilder::Equal(/*field_index=*/8, /*field_name=*/"f8", FieldType::TINYINT, - Literal((int8_t)20)), + Literal(static_cast(20))), })); ASSERT_OK(PredicateValidator::ValidatePredicateWithSchema(*schema, predicate, /*validate_field_idx=*/true)); diff --git a/src/paimon/common/utils/bloom_filter64_test.cpp b/src/paimon/common/utils/bloom_filter64_test.cpp index 7c8ea9c1..149586d5 100644 --- a/src/paimon/common/utils/bloom_filter64_test.cpp +++ b/src/paimon/common/utils/bloom_filter64_test.cpp @@ -56,7 +56,7 @@ TEST(BloomFilter64Test, TestSimple) { false_positives++; } } - ASSERT_TRUE((double)false_positives / num < 0.03); + ASSERT_TRUE(static_cast(false_positives) / num < 0.03); } TEST(BloomFilter64Test, TestCompatibleWithJava) { diff --git a/src/paimon/common/utils/concurrent_hash_map_test.cpp b/src/paimon/common/utils/concurrent_hash_map_test.cpp index d578f46c..2306682f 100644 --- a/src/paimon/common/utils/concurrent_hash_map_test.cpp +++ b/src/paimon/common/utils/concurrent_hash_map_test.cpp @@ -141,7 +141,7 @@ TEST(ConcurrentHashMapTest, TestMultiThreadInsertAndFindAndDelete) { thread3.join(); // check final states - ASSERT_TRUE(hash_map.Size() >= 0 && hash_map.Size() <= (size_t)map_size); + ASSERT_TRUE(hash_map.Size() >= 0 && hash_map.Size() <= static_cast(map_size)); for (int32_t i = 0; i < map_size; i++) { auto value = hash_map.Find(i); if (value) { diff --git a/src/paimon/common/utils/projected_row_test.cpp b/src/paimon/common/utils/projected_row_test.cpp index 657a71a1..e763a18a 100644 --- a/src/paimon/common/utils/projected_row_test.cpp +++ b/src/paimon/common/utils/projected_row_test.cpp @@ -85,13 +85,13 @@ TEST(ProjectedRowTest, TestSimple) { ASSERT_TRUE(projected_row.IsNullAt(16)); ASSERT_EQ(projected_row.GetBoolean(15), true); - ASSERT_EQ(projected_row.GetByte(14), (char)1); - ASSERT_EQ(projected_row.GetShort(13), (int16_t)2); - ASSERT_EQ(projected_row.GetInt(12), (int32_t)3); - ASSERT_EQ(projected_row.GetDate(12), (int32_t)3); - ASSERT_EQ(projected_row.GetLong(11), (int64_t)4); - ASSERT_EQ(projected_row.GetFloat(10), (float)5.1); - ASSERT_EQ(projected_row.GetDouble(9), (double)6.12); + ASSERT_EQ(projected_row.GetByte(14), static_cast(1)); + ASSERT_EQ(projected_row.GetShort(13), static_cast(2)); + ASSERT_EQ(projected_row.GetInt(12), static_cast(3)); + ASSERT_EQ(projected_row.GetDate(12), static_cast(3)); + ASSERT_EQ(projected_row.GetLong(11), static_cast(4)); + ASSERT_EQ(projected_row.GetFloat(10), static_cast(5.1)); + ASSERT_EQ(projected_row.GetDouble(9), static_cast(6.12)); ASSERT_EQ(projected_row.GetString(8), str); ASSERT_EQ(*projected_row.GetBinary(7), *bytes); ASSERT_EQ(std::string(projected_row.GetStringView(6)), str9); diff --git a/src/paimon/common/utils/string_utils_test.cpp b/src/paimon/common/utils/string_utils_test.cpp index 9f334942..3b421f76 100644 --- a/src/paimon/common/utils/string_utils_test.cpp +++ b/src/paimon/common/utils/string_utils_test.cpp @@ -307,10 +307,11 @@ TEST_F(StringUtilsTest, TestSplit) { } TEST_F(StringUtilsTest, TestStringToValueSimple) { - ASSERT_EQ((int32_t)233, StringUtils::StringToValue("233").value()); - ASSERT_EQ((int8_t)10, StringUtils::StringToValue("10").value()); + ASSERT_EQ(static_cast(233), StringUtils::StringToValue("233").value()); + ASSERT_EQ(static_cast(10), StringUtils::StringToValue("10").value()); ASSERT_EQ(std::nullopt, StringUtils::StringToValue("1024")); - ASSERT_EQ((int64_t)34785895352ll, StringUtils::StringToValue("34785895352").value()); + ASSERT_EQ(static_cast(34785895352), + StringUtils::StringToValue("34785895352").value()); ASSERT_EQ(std::nullopt, StringUtils::StringToValue("abc")); ASSERT_EQ(std::nullopt, StringUtils::StringToValue("")); diff --git a/src/paimon/core/casting/casted_row_test.cpp b/src/paimon/core/casting/casted_row_test.cpp index 3227f4a3..27974343 100644 --- a/src/paimon/core/casting/casted_row_test.cpp +++ b/src/paimon/core/casting/casted_row_test.cpp @@ -61,14 +61,14 @@ TEST(CastedRowTest, TestSimpleWithNoCasting) { ASSERT_EQ(casted_row->GetFieldCount(), 10); ASSERT_EQ(casted_row->GetRowKind().value(), RowKind::Insert()); ASSERT_EQ(casted_row->GetBoolean(0), true); - ASSERT_EQ(casted_row->GetByte(1), (char)0); - ASSERT_EQ(casted_row->GetShort(2), (int16_t)32767); + ASSERT_EQ(casted_row->GetByte(1), static_cast(0)); + ASSERT_EQ(casted_row->GetShort(2), static_cast(32767)); ASSERT_FALSE(casted_row->IsNullAt(3)); - ASSERT_EQ(casted_row->GetInt(3), (int32_t)2147483647); + ASSERT_EQ(casted_row->GetInt(3), static_cast(2147483647)); ASSERT_TRUE(casted_row->IsNullAt(4)); - ASSERT_EQ(casted_row->GetLong(5), (int64_t)4294967295); - ASSERT_EQ(casted_row->GetFloat(6), (float)0.5); - ASSERT_EQ(casted_row->GetDouble(7), (double)1.141592659); + ASSERT_EQ(casted_row->GetLong(5), static_cast(4294967295)); + ASSERT_EQ(casted_row->GetFloat(6), static_cast(0.5)); + ASSERT_EQ(casted_row->GetDouble(7), static_cast(1.141592659)); ASSERT_EQ(casted_row->GetString(8).ToString(), "2025-03-27"); ASSERT_EQ(*casted_row->GetBinary(9), Bytes("banana", pool.get())); diff --git a/src/paimon/core/global_index/global_index_scan_impl.cpp b/src/paimon/core/global_index/global_index_scan_impl.cpp index f29efeed..e143d882 100644 --- a/src/paimon/core/global_index/global_index_scan_impl.cpp +++ b/src/paimon/core/global_index/global_index_scan_impl.cpp @@ -72,8 +72,8 @@ Result> GlobalIndexScanImpl::GetRowRangeList() { const auto& global_index_meta = entry.index_file->GetGlobalIndexMeta(); assert(global_index_meta); const auto& index_meta = global_index_meta.value(); - index_ranges[entry.index_file->IndexType()].push_back( - Range(index_meta.row_range_start, index_meta.row_range_end)); + index_ranges[entry.index_file->IndexType()].emplace_back(index_meta.row_range_start, + index_meta.row_range_end); } std::string check_index_type; std::vector check_ranges; diff --git a/src/paimon/core/io/field_mapping_reader_test.cpp b/src/paimon/core/io/field_mapping_reader_test.cpp index 0f30bfa7..3d709ba8 100644 --- a/src/paimon/core/io/field_mapping_reader_test.cpp +++ b/src/paimon/core/io/field_mapping_reader_test.cpp @@ -292,7 +292,7 @@ TEST_F(FieldMappingReaderTest, TestGenerateSinglePartitionArray) { ASSERT_EQ( arrow::internal::checked_cast*>(p2_array.get()) ->Value(0), - (int16_t)2); + static_cast(2)); } { ASSERT_OK_AND_ASSIGN(auto p1_array, mapping_reader->GenerateSinglePartitionArray( diff --git a/src/paimon/core/operation/data_evolution_file_store_scan_test.cpp b/src/paimon/core/operation/data_evolution_file_store_scan_test.cpp index 76981912..6d0a1063 100644 --- a/src/paimon/core/operation/data_evolution_file_store_scan_test.cpp +++ b/src/paimon/core/operation/data_evolution_file_store_scan_test.cpp @@ -114,7 +114,8 @@ TEST_F(DataEvolutionFileStoreScanTest, TestEvolutionStatsSingleFile) { ASSERT_OK_AND_ASSIGN(auto result_stats, DataEvolutionFileStoreScan::EvolutionStats( {entry}, table_schema, schema_fetcher)); - ASSERT_EQ(result_stats.first, /*row_count=*/100); + auto result_row_count = result_stats.first; + ASSERT_EQ(result_row_count, 100); auto min_row = std::dynamic_pointer_cast(result_stats.second.min_values); ASSERT_TRUE(min_row); auto max_row = std::dynamic_pointer_cast(result_stats.second.max_values); @@ -501,7 +502,8 @@ TEST_F(DataEvolutionFileStoreScanTest, TestEvolutionStatsWithBlob) { {blob_entry0, blob_entry1, entry0, entry1}, table_schema, schema_fetcher)); - ASSERT_EQ(result_stats.first, /*row_count=*/100); + auto result_row_count = result_stats.first; + ASSERT_EQ(result_row_count, 100); auto min_row = std::dynamic_pointer_cast(result_stats.second.min_values); ASSERT_TRUE(min_row); auto max_row = std::dynamic_pointer_cast(result_stats.second.max_values); diff --git a/src/paimon/core/operation/data_evolution_split_read_test.cpp b/src/paimon/core/operation/data_evolution_split_read_test.cpp index 5f3426ba..aa6f9c9e 100644 --- a/src/paimon/core/operation/data_evolution_split_read_test.cpp +++ b/src/paimon/core/operation/data_evolution_split_read_test.cpp @@ -435,7 +435,7 @@ TEST_F(DataEvolutionSplitReadTest, TestComplexBlobBunchScenario2) { }; ASSERT_OK_AND_ASSIGN(std::vector> bunch, DataEvolutionSplitRead::SplitFieldBunches( - batch, blob_field_to_field_id, /*has_row_ids_selection=*/false)); + batch, blob_field_to_field_id, /*has_row_ranges_selection=*/false)); ASSERT_EQ(bunch.size(), 2); auto blob_bunch = std::dynamic_pointer_cast(bunch[1]); @@ -557,7 +557,7 @@ TEST_F(DataEvolutionSplitReadTest, TestComplexBlobBunchScenario3) { }; ASSERT_OK_AND_ASSIGN(std::vector> bunch, DataEvolutionSplitRead::SplitFieldBunches( - batch, blob_field_to_field_id, /*has_row_ids_selection=*/false)); + batch, blob_field_to_field_id, /*has_row_ranges_selection=*/false)); ASSERT_EQ(bunch.size(), 3); auto blob_bunch = std::dynamic_pointer_cast(bunch[1]); diff --git a/src/paimon/core/schema/schema_impl.h b/src/paimon/core/schema/schema_impl.h index 16d3227d..9492f0b8 100644 --- a/src/paimon/core/schema/schema_impl.h +++ b/src/paimon/core/schema/schema_impl.h @@ -22,6 +22,7 @@ #include #include "paimon/core/schema/table_schema.h" +#include "paimon/schema/schema.h" namespace paimon { diff --git a/src/paimon/core/utils/offset_row_test.cpp b/src/paimon/core/utils/offset_row_test.cpp index ebcb62d9..f8f47b80 100644 --- a/src/paimon/core/utils/offset_row_test.cpp +++ b/src/paimon/core/utils/offset_row_test.cpp @@ -43,13 +43,13 @@ TEST(OffsetRowTest, TestSimple) { ASSERT_EQ(row.GetRowKind().value(), RowKind::Insert()); ASSERT_EQ(row.GetFieldCount(), 12); ASSERT_FALSE(row.IsNullAt(0)); - ASSERT_EQ(row.GetByte(0), (char)1); - ASSERT_EQ(row.GetShort(1), (int16_t)11); - ASSERT_EQ(row.GetInt(2), (int32_t)111); - ASSERT_EQ(row.GetDate(2), (int32_t)111); - ASSERT_EQ(row.GetLong(3), (int64_t)1111); - ASSERT_EQ(row.GetFloat(4), (float)12.3); - ASSERT_EQ(row.GetDouble(5), (double)12.34); + ASSERT_EQ(row.GetByte(0), static_cast(1)); + ASSERT_EQ(row.GetShort(1), static_cast(11)); + ASSERT_EQ(row.GetInt(2), static_cast(111)); + ASSERT_EQ(row.GetDate(2), static_cast(111)); + ASSERT_EQ(row.GetLong(3), static_cast(1111)); + ASSERT_EQ(row.GetFloat(4), static_cast(12.3)); + ASSERT_EQ(row.GetDouble(5), static_cast(12.34)); ASSERT_EQ(row.GetBoolean(6), false); ASSERT_EQ(row.GetString(7).ToString(), "hello"); ASSERT_EQ(*row.GetBinary(8), *bytes); diff --git a/src/paimon/format/orc/orc_format_writer.cpp b/src/paimon/format/orc/orc_format_writer.cpp index a68cfab2..e0e0d0e9 100644 --- a/src/paimon/format/orc/orc_format_writer.cpp +++ b/src/paimon/format/orc/orc_format_writer.cpp @@ -129,11 +129,11 @@ Status OrcFormatWriter::AddBatch(ArrowArray* batch) { assert(batch); PAIMON_ASSIGN_OR_RAISE_FROM_ARROW(std::shared_ptr arrow_array, arrow::ImportArray(batch, data_type_)); - if (PAIMON_UNLIKELY((uint64_t)arrow_array->length() > orc_batch_->capacity)) { + if (PAIMON_UNLIKELY(static_cast(arrow_array->length()) > orc_batch_->capacity)) { PAIMON_RETURN_NOT_OK(ExpandBatch(arrow_array->length())); } PAIMON_RETURN_NOT_OK(OrcAdapter::WriteBatch(arrow_array, orc_batch_.get())); - assert(orc_batch_->numElements == (uint64_t)arrow_array->length()); + assert(orc_batch_->numElements == static_cast(arrow_array->length())); PAIMON_RETURN_NOT_OK(Flush()); return Status::OK(); } diff --git a/src/paimon/fs/local/local_file_system.cpp b/src/paimon/fs/local/local_file_system.cpp index 73061eb1..07a3fe34 100644 --- a/src/paimon/fs/local/local_file_system.cpp +++ b/src/paimon/fs/local/local_file_system.cpp @@ -288,7 +288,7 @@ void LocalInputStream::ReadAsync(char* buffer, uint32_t size, uint64_t offset, if (!read_size.ok()) { status = read_size.status(); } else { - assert(read_size.value() == (int32_t)size); + assert(read_size.value() == static_cast(size)); } callback(status); } diff --git a/src/paimon/testing/utils/timezone_guard.h b/src/paimon/testing/utils/timezone_guard.h index 93d59033..0b2da9f1 100644 --- a/src/paimon/testing/utils/timezone_guard.h +++ b/src/paimon/testing/utils/timezone_guard.h @@ -31,7 +31,7 @@ class TimezoneGuard { original_tz_.clear(); } - setenv("TZ", tz.c_str(), /*overwrite=*/1); + setenv("TZ", tz.c_str(), /*replace=*/1); tzset(); } @@ -39,7 +39,7 @@ class TimezoneGuard { if (original_tz_.empty()) { unsetenv("TZ"); } else { - setenv("TZ", original_tz_.c_str(), /*overwrite=*/1); + setenv("TZ", original_tz_.c_str(), /*replace=*/1); } tzset(); }