# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set(PAIMON_COMMON_SRCS
    common/compression/block_compression_factory.cpp
    common/compression/block_compressor.cpp
    common/compression/block_decompressor.cpp
    common/data/abstract_binary_writer.cpp
    common/data/binary_array.cpp
    common/data/binary_array_writer.cpp
    common/data/binary_row.cpp
    common/data/binary_row_writer.cpp
    common/data/binary_section.cpp
    common/data/binary_string.cpp
    common/data/blob.cpp
    common/data/blob_descriptor.cpp
    common/data/blob_view_struct.cpp
    common/data/blob_utils.cpp
    common/data/columnar/columnar_array.cpp
    common/data/columnar/columnar_map.cpp
    common/data/columnar/columnar_row.cpp
    common/data/columnar/columnar_row_ref.cpp
    common/data/decimal.cpp
    common/data/internal_row.cpp
    common/data/record_batch.cpp
    common/data/serializer/binary_row_serializer.cpp
    common/data/serializer/row_compacted_serializer.cpp
    common/data/serializer/binary_serializer_utils.cpp
    common/data/timestamp.cpp
    common/data/variant/generic_variant.cpp
    common/data/variant/infer_variant_shredding_schema.cpp
    common/data/variant/variant_shredding_inference_session.cpp
    common/data/variant/variant.cpp
    common/data/variant/variant_binary_util.cpp
    common/data/variant/variant_builder.cpp
    common/data/variant/variant_get.cpp
    common/data/variant/variant_json_utils.cpp
    common/data/variant/variant_path_segment.cpp
    common/data/variant/variant_reassembler.cpp
    common/data/variant/variant_shredding_batch_converter.cpp
    common/data/variant/variant_access_utils.cpp
    common/data/variant/variant_shredding_read_plan_factory.cpp
    common/data/variant/variant_shredding_utils.cpp
    common/data/variant/variant_shredding_write_plan.cpp
    common/data/variant/variant_shredding_write_plan_factory.cpp
    common/data/variant/variant_shredding_writer.cpp
    common/data/variant/variant_type_utils.cpp
    common/defs.cpp
    common/executor/executor.cpp
    common/factories/singleton.cpp
    common/factories/io_hook.cpp
    common/factories/factory_creator.cpp
    common/file_index/bitmap/bitmap_index_result.cpp
    common/file_index/file_indexer_factory.cpp
    common/file_index/file_index_format.cpp
    common/file_index/file_index_reader.cpp
    common/file_index/file_index_result.cpp
    common/format/column_stats.cpp
    common/format/file_format_factory.cpp
    common/fs/file_system.cpp
    common/fs/resolving_file_system.cpp
    common/fs/file_system_factory.cpp
    common/global_index/union_global_index_reader.cpp
    common/global_index/offset_global_index_reader.cpp
    common/global_index/complete_index_score_batch_reader.cpp
    common/global_index/bitmap_scored_global_index_result.cpp
    common/global_index/bitmap_global_index_result.cpp
    common/global_index/global_index_result.cpp
    common/global_index/global_indexer_factory.cpp
    common/io/buffered_input_stream.cpp
    common/io/byte_array_input_stream.cpp
    common/io/data_input_stream.cpp
    common/io/data_output_stream.cpp
    common/io/memory_segment_output_stream.cpp
    common/io/offset_input_stream.cpp
    common/io/cache/cache.cpp
    common/io/cache/cache_key.cpp
    common/io/cache/cache_manager.cpp
    common/io/cache/lru_cache.cpp
    common/logging/logging.cpp
    common/lookup/sort/sort_lookup_store_factory.cpp
    common/lookup/sort/sort_lookup_store_footer.cpp
    common/lookup/lookup_store_factory.cpp
    common/memory/bytes.cpp
    common/memory/memory_pool.cpp
    common/memory/memory_segment.cpp
    common/memory/memory_segment_utils.cpp
    common/memory/memory_slice.cpp
    common/memory/memory_slice_output.cpp
    common/metrics/metrics_impl.cpp
    common/metrics/histogram.cpp
    common/metrics/histogram_windowing.cpp
    common/options/memory_size.cpp
    common/options/time_duration.cpp
    common/predicate/and.cpp
    common/predicate/compound_predicate.cpp
    common/predicate/contains.cpp
    common/predicate/ends_with.cpp
    common/predicate/equal.cpp
    common/predicate/greater_or_equal.cpp
    common/predicate/greater_than.cpp
    common/predicate/in.cpp
    common/predicate/is_not_null.cpp
    common/predicate/is_null.cpp
    common/predicate/leaf_predicate.cpp
    common/predicate/less_or_equal.cpp
    common/predicate/less_than.cpp
    common/predicate/like.cpp
    common/predicate/literal_converter.cpp
    common/predicate/literal.cpp
    common/predicate/not_equal.cpp
    common/predicate/not_in.cpp
    common/predicate/or.cpp
    common/predicate/predicate.cpp
    common/predicate/predicate_builder.cpp
    common/predicate/predicate_utils.cpp
    common/predicate/starts_with.cpp
    common/reader/batch_reader.cpp
    common/reader/concat_batch_reader.cpp
    common/reader/predicate_batch_reader.cpp
    common/reader/prefetch_file_batch_reader_impl.cpp
    common/reader/reader_utils.cpp
    common/reader/blob_fallback_batch_reader.cpp
    common/reader/blob_view_resolving_batch_reader.cpp
    common/reader/complete_row_kind_batch_reader.cpp
    common/reader/data_evolution_file_reader.cpp
    common/sst/block_handle.cpp
    common/sst/block_iterator.cpp
    common/sst/block_trailer.cpp
    common/sst/block_reader.cpp
    common/sst/block_writer.cpp
    common/sst/sst_file_reader.cpp
    common/sst/sst_file_writer.cpp
    common/types/data_field.cpp
    common/types/data_type.cpp
    common/types/data_type_json_parser.cpp
    common/types/row_kind.cpp
    common/types/row_type.cpp
    common/utils/file_type.cpp
    common/utils/arrow/arrow_input_stream_adapter.cpp
    common/utils/arrow/arrow_output_stream_adapter.cpp
    common/utils/arrow/arrow_utils.cpp
    common/utils/arrow/mem_utils.cpp
    common/utils/binary_row_partition_computer.cpp
    common/utils/bit_set.cpp
    common/utils/bloom_filter.cpp
    common/utils/bloom_filter64.cpp
    common/utils/crc32c.cpp
    common/utils/decimal_utils.cpp
    common/data/shredding/map_shared_shredding_utils.cpp
    common/data/shredding/map_shared_shredding_schema_utils.cpp
    common/data/shredding/map_shared_shredding_write_plan_factory.cpp
    common/data/shredding/shredding_write_plan_factories.cpp
    common/data/shredding/map_shared_shredding_context.cpp
    common/data/shredding/map_shared_shredding_batch_converter.cpp
    common/data/shredding/map_shared_shredding_column_allocator.cpp
    common/data/shredding/lru_map_shared_shredding_column_allocator.cpp
    common/data/shredding/map_shared_shredding_file_reader.cpp
    common/data/shredding/shredding_file_reader.cpp
    common/utils/delta_varint_compressor.cpp
    common/utils/fields_comparator.cpp
    common/utils/path_util.cpp
    common/utils/range.cpp
    common/utils/read_ahead_cache.cpp
    common/utils/byte_range_combiner.cpp
    common/utils/roaring_bitmap32.cpp
    common/utils/roaring_bitmap64.cpp
    common/utils/row_range_index.cpp
    common/utils/status.cpp
    common/utils/string_utils.cpp)

if(PAIMON_ENABLE_S3)
    list(APPEND PAIMON_COMMON_SRCS common/fs/http_client.cpp
         common/fs/object_store_file_system.cpp)
    set(PAIMON_OBJECT_STORE_LINK_LIBS CURL::libcurl)
endif()

set(PAIMON_CORE_SRCS
    core/disk/file_io_channel.cpp
    core/mergetree/spill_reader.cpp
    core/mergetree/spill_writer.cpp
    core/append/append_only_writer.cpp
    core/append/bucketed_append_compact_manager.cpp
    core/bucket/bucket_select_converter.cpp
    core/append/append_compact_task.cpp
    core/append/append_compact_coordinator.cpp
    core/bucket/hive_bucket_function.cpp
    core/bucket/mod_bucket_function.cpp
    core/bucket/bucket_id_calculator.cpp
    core/casting/binary_to_blob_cast_executor.cpp
    core/casting/binary_to_string_cast_executor.cpp
    core/casting/boolean_to_decimal_cast_executor.cpp
    core/casting/boolean_to_numeric_cast_executor.cpp
    core/casting/boolean_to_string_cast_executor.cpp
    core/casting/casted_row.cpp
    core/casting/cast_executor_factory.cpp
    core/casting/date_to_string_cast_executor.cpp
    core/casting/date_to_timestamp_cast_executor.cpp
    core/casting/decimal_to_decimal_cast_executor.cpp
    core/casting/decimal_to_numeric_primitive_cast_executor.cpp
    core/casting/numeric_primitive_cast_executor.cpp
    core/casting/numeric_primitive_to_decimal_cast_executor.cpp
    core/casting/numeric_primitive_to_timestamp_cast_executor.cpp
    core/casting/numeric_to_boolean_cast_executor.cpp
    core/casting/numeric_to_string_cast_executor.cpp
    core/casting/string_to_binary_cast_executor.cpp
    core/casting/string_to_boolean_cast_executor.cpp
    core/casting/string_to_date_cast_executor.cpp
    core/casting/string_to_decimal_cast_executor.cpp
    core/casting/string_to_numeric_primitive_cast_executor.cpp
    core/casting/string_to_timestamp_cast_executor.cpp
    core/casting/timestamp_to_date_cast_executor.cpp
    core/casting/timestamp_to_numeric_primitive_cast_executor.cpp
    core/casting/timestamp_to_string_cast_executor.cpp
    core/casting/timestamp_to_timestamp_cast_executor.cpp
    core/casting/casting_utils.cpp
    core/catalog/catalog.cpp
    core/catalog/file_system_catalog.cpp
    core/catalog/identifier.cpp
    core/core_options.cpp
    core/deletionvectors/deletion_vector.cpp
    core/deletionvectors/deletion_file_writer.cpp
    core/deletionvectors/bitmap_deletion_vector.cpp
    core/deletionvectors/deletion_vectors_index_file.cpp
    core/deletionvectors/deletion_vector_index_file_writer.cpp
    core/global_index/global_index_evaluator_impl.cpp
    core/global_index/global_index_scan.cpp
    core/global_index/global_index_scan_impl.cpp
    core/global_index/global_index_write_task.cpp
    core/index/index_file_handler.cpp
    core/index/global_index_meta.cpp
    core/index/index_file_meta_serializer.cpp
    core/io/generic_row_to_arrow_array_converter.cpp
    core/io/meta_to_arrow_array_converter.cpp
    core/io/async_key_value_producer_and_consumer.cpp
    core/io/data_file_meta_09_serializer.cpp
    core/io/data_file_meta_10_serializer.cpp
    core/io/data_file_meta_12_serializer.cpp
    core/io/data_file_meta_first_row_id_legacy_serializer.cpp
    core/io/data_file_meta.cpp
    core/io/data_file_meta_serializer.cpp
    core/io/data_file_path_factory.cpp
    core/io/append_data_file_writer_factory.cpp
    core/io/blob_data_file_writer_factory.cpp
    core/io/data_file_writer_factory.cpp
    core/io/data_file_writer.cpp
    core/io/field_mapping_reader.cpp
    core/io/complete_row_tracking_fields_reader.cpp
    core/io/file_index_evaluator.cpp
    core/io/key_value_data_file_record_reader.cpp
    core/io/key_value_data_file_writer_factory.cpp
    core/io/key_value_data_file_writer.cpp
    core/io/key_value_in_memory_record_reader.cpp
    core/io/merged_key_value_record_reader.cpp
    core/io/key_value_meta_projection_consumer.cpp
    core/io/key_value_projection_consumer.cpp
    core/io/key_value_projection_reader.cpp
    core/io/shredding_append_data_file_writer_factory.cpp
    core/io/shredding_key_value_data_file_writer_factory.cpp
    core/io/multiple_blob_file_writer.cpp
    core/io/rolling_blob_file_writer.cpp
    core/manifest/file_kind.cpp
    core/manifest/file_source.cpp
    core/manifest/index_manifest_entry_serializer.cpp
    core/manifest/index_manifest_file.cpp
    core/manifest/manifest_entry.cpp
    core/manifest/manifest_entry_serializer.cpp
    core/manifest/manifest_entry_writer.cpp
    core/manifest/manifest_file.cpp
    core/manifest/manifest_file_meta.cpp
    core/manifest/manifest_file_meta_serializer.cpp
    core/manifest/manifest_list.cpp
    core/manifest/partition_entry.cpp
    core/manifest/index_manifest_file_handler.cpp
    core/memory/writer_memory_manager.cpp
    core/mergetree/compact/universal_compaction.cpp
    core/mergetree/compact/early_full_compaction.cpp
    core/mergetree/compact/aggregate/aggregate_merge_function.cpp
    core/mergetree/compact/aggregate/field_sum_agg.cpp
    core/mergetree/compact/interval_partition.cpp
    core/mergetree/compact/loser_tree.cpp
    core/mergetree/compact/merge_tree_compact_manager.cpp
    core/mergetree/compact/merge_tree_compact_manager_factory.cpp
    core/mergetree/compact/merge_tree_compact_rewriter.cpp
    core/mergetree/compact/merge_tree_compact_task.cpp
    core/mergetree/compact/partial_update_merge_function.cpp
    core/mergetree/compact/sort_merge_reader_with_loser_tree.cpp
    core/mergetree/compact/sort_merge_reader_with_min_heap.cpp
    core/mergetree/compact/lookup_merge_tree_compact_rewriter.cpp
    core/mergetree/compact/changelog_merge_tree_rewriter.cpp
    core/mergetree/merge_tree_writer.cpp
    core/mergetree/in_memory_sort_buffer.cpp
    core/mergetree/external_sort_buffer.cpp
    core/mergetree/spill_file_merger.cpp
    core/mergetree/write_buffer.cpp
    core/mergetree/levels.cpp
    core/mergetree/lookup_file.cpp
    core/mergetree/lookup_levels.cpp
    core/mergetree/lookup/remote_lookup_file_manager.cpp
    core/mergetree/row_count_accumulator.cpp
    core/migrate/file_meta_utils.cpp
    core/operation/data_evolution_file_store_scan.cpp
    core/operation/data_evolution_split_read.cpp
    core/operation/abstract_file_store_write.cpp
    core/operation/abstract_split_read.cpp
    core/operation/append_only_file_store_scan.cpp
    core/operation/append_only_file_store_write.cpp
    core/operation/metrics/commit_metrics.cpp
    core/operation/commit/conflict_detection.cpp
    core/operation/commit/commit_scanner.cpp
    core/operation/commit/commit_changes_provider.cpp
    core/operation/commit/compacted_changelog_path_resolver.cpp
    core/operation/commit/overwrite_changes_provider.cpp
    core/operation/commit/row_id_column_conflict_checker.cpp
    core/operation/commit/manifest_entry_changes.cpp
    core/operation/commit/row_tracking_commit_utils.cpp
    core/operation/commit/sequence_snapshot_properties.cpp
    core/operation/commit/retry_waiter.cpp
    core/operation/commit_context.cpp
    core/operation/expire_snapshots.cpp
    core/operation/file_store_commit.cpp
    core/operation/file_store_commit_impl.cpp
    core/operation/file_store_scan.cpp
    core/operation/file_store_write.cpp
    core/operation/internal_read_context.cpp
    core/operation/key_value_file_store_scan.cpp
    core/operation/key_value_file_store_write.cpp
    core/operation/manifest_file_merger.cpp
    core/operation/merge_file_split_read.cpp
    core/operation/blob_file_context.cpp
    core/operation/orphan_files_cleaner.cpp
    core/operation/orphan_files_cleaner_impl.cpp
    core/operation/raw_file_split_read.cpp
    core/operation/read_context.cpp
    core/operation/scan_context.cpp
    core/manifest/snapshot_live_manifest_entries.cpp
    core/operation/write_context.cpp
    core/operation/write_restore.cpp
    core/postpone/postpone_bucket_writer.cpp
    core/schema/arrow_schema_validator.cpp
    core/schema/schema_manager.cpp
    core/schema/schema_validation.cpp
    core/schema/table_schema.cpp
    core/snapshot.cpp
    core/snapshot_info.cpp
    core/stats/simple_stats_collector.cpp
    core/stats/simple_stats_converter.cpp
    core/stats/simple_stats.cpp
    core/stats/simple_stats_evolution.cpp
    core/table/table.cpp
    core/table/bucket_mode.cpp
    core/table/sink/commit_message.cpp
    core/table/sink/commit_message_impl.cpp
    core/table/sink/commit_message_serializer.cpp
    core/table/source/append_count_reader.cpp
    core/table/source/append_only_table_read.cpp
    core/table/source/split.cpp
    core/table/source/data_split_impl.cpp
    core/table/source/data_table_batch_scan.cpp
    core/table/source/data_table_stream_scan.cpp
    core/table/source/fallback_table_read.cpp
    core/table/source/key_value_table_read.cpp
    core/table/source/pk_count_reader.cpp
    core/table/source/merge_tree_split_generator.cpp
    core/table/source/data_evolution_split_generator.cpp
    core/table/source/plan_impl.cpp
    core/table/source/snapshot/snapshot_reader.cpp
    core/table/source/startup_mode.cpp
    core/table/source/table_read.cpp
    core/table/source/table_scan.cpp
    core/table/source/data_evolution_batch_scan.cpp
    core/table/system/audit_log_system_table.cpp
    core/table/system/binlog_system_table.cpp
    core/table/system/global_system_tables.cpp
    core/table/system/in_memory_system_table.cpp
    core/table/system/metadata_system_tables.cpp
    core/table/system/read_optimized_system_table.cpp
    core/table/system/system_table.cpp
    core/table/system/system_table_scan.cpp
    core/table/system/system_table_schema.cpp
    core/tag/tag.cpp
    core/utils/branch_manager.cpp
    core/utils/blob_view_lookup.cpp
    core/utils/consumer_manager.cpp
    core/utils/field_mapping.cpp
    core/utils/nested_projection_utils.cpp
    core/utils/file_store_path_factory.cpp
    core/utils/file_utils.cpp
    core/utils/manifest_meta_reader.cpp
    core/utils/partition_path_utils.cpp
    core/utils/primary_key_table_utils.cpp
    core/utils/snapshot_manager.cpp
    core/utils/tag_manager.cpp)

add_paimon_lib(paimon
               SOURCES
               ${PAIMON_COMMON_SRCS}
               ${PAIMON_CORE_SRCS}
               DEPENDENCIES
               arrow
               tbb
               glog
               fmt
               roaring_bitmap
               xxhash
               Threads::Threads
               RapidJSON
               ${PAIMON_OBJECT_STORE_LINK_LIBS}
               STATIC_LINK_LIBS
               arrow
               tbb
               glog
               fmt
               roaring_bitmap
               xxhash
               Threads::Threads
               RapidJSON
               ${PAIMON_OBJECT_STORE_LINK_LIBS}
               SHARED_LINK_FLAGS
               ${PAIMON_VERSION_SCRIPT_FLAGS})

add_subdirectory(common/file_index)
add_subdirectory(common/global_index)

if(PAIMON_BUILD_TESTS)
    add_paimon_test(memory_test
                    SOURCES
                    common/memory/memory_pool_test.cpp
                    common/memory/bytes_test.cpp
                    common/memory/memory_segment_test.cpp
                    common/memory/memory_segment_utils_test.cpp
                    common/memory/memory_slice_test.cpp
                    STATIC_LINK_LIBS
                    paimon_shared
                    test_utils_static
                    fmt
                    ${GTEST_LINK_TOOLCHAIN})

    add_paimon_test(common_test
                    SOURCES
                    common/data/binary_array_test.cpp
                    common/data/binary_map_test.cpp
                    common/data/binary_row_test.cpp
                    common/data/binary_row_writer_test.cpp
                    common/data/binary_section_test.cpp
                    common/data/binary_string_test.cpp
                    common/data/columnar/columnar_array_test.cpp
                    common/data/columnar/columnar_row_test.cpp
                    common/data/columnar/columnar_utils_test.cpp
                    common/data/data_define_test.cpp
                    common/data/decimal_test.cpp
                    common/data/generic_row_test.cpp
                    common/data/internal_row_test.cpp
                    common/data/record_batch_test.cpp
                    common/data/serializer/binary_row_serializer_test.cpp
                    common/data/serializer/row_compacted_serializer_test.cpp
                    common/data/serializer/binary_serializer_utils_test.cpp
                    common/data/timestamp_test.cpp
                    common/data/blob_test.cpp
                    common/data/blob_descriptor_test.cpp
                    common/data/blob_view_struct_test.cpp
                    common/data/blob_utils_test.cpp
                    common/data/variant/generic_variant_test.cpp
                    common/data/variant/infer_variant_shredding_schema_test.cpp
                    common/data/variant/variant_access_utils_test.cpp
                    common/data/variant/variant_shredding_read_plan_factory_test.cpp
                    common/data/variant/variant_shredding_write_plan_factory_test.cpp
                    common/data/variant/variant_get_test.cpp
                    common/data/variant/variant_json_utils_test.cpp
                    common/data/variant/variant_shredding_test.cpp
                    common/data/variant/variant_test.cpp
                    common/data/variant/variant_type_utils_test.cpp
                    common/executor/default_executor_test.cpp
                    common/format/column_stats_test.cpp
                    common/fs/external_path_provider_test.cpp
                    common/file_index/file_indexer_factory_test.cpp
                    common/file_index/file_index_result_test.cpp
                    common/file_index/file_index_reader_test.cpp
                    common/file_index/file_index_format_test.cpp
                    common/file_index/empty/empty_file_index_reader_test.cpp
                    common/file_index/bitmap/bitmap_index_result_test.cpp
                    common/file_index/bitmap/bitmap_file_index_meta_test.cpp
                    common/file_index/bitmap/bitmap_file_index_test.cpp
                    common/file_index/bitmap/apply_bitmap_index_batch_reader_test.cpp
                    common/file_index/bsi/bit_slice_index_bitmap_file_index_test.cpp
                    common/file_index/bsi/bit_slice_index_roaring_bitmap_test.cpp
                    common/file_index/rangebitmap/bit_slice_index_bitmap_test.cpp
                    common/file_index/rangebitmap/dictionary/chunked_dictionary_test.cpp
                    common/file_index/rangebitmap/range_bitmap_file_index_test.cpp
                    common/file_index/rangebitmap/range_bitmap_io_test.cpp
                    common/file_index/bloomfilter/bloom_filter_file_index_test.cpp
                    common/file_index/bloomfilter/fast_hash_test.cpp
                    common/global_index/complete_index_score_batch_reader_test.cpp
                    common/global_index/global_index_result_test.cpp
                    common/global_index/global_index_utils_test.cpp
                    common/global_index/offset_global_index_reader_test.cpp
                    common/global_index/union_global_index_reader_test.cpp
                    common/global_index/global_indexer_factory_test.cpp
                    common/global_index/bitmap_global_index_result_test.cpp
                    common/global_index/bitmap_scored_global_index_result_test.cpp
                    common/global_index/bitmap/bitmap_global_index_test.cpp
                    common/global_index/btree/btree_index_meta_test.cpp
                    common/global_index/btree/btree_file_footer_test.cpp
                    common/global_index/btree/key_serializer_test.cpp
                    common/global_index/btree/btree_global_index_integration_test.cpp
                    common/global_index/btree/btree_compatibility_test.cpp
                    common/global_index/btree/btree_file_meta_selector_test.cpp
                    common/global_index/btree/lazy_filtered_btree_reader_test.cpp
                    common/global_index/rangebitmap/range_bitmap_global_index_test.cpp
                    common/global_index/wrap/file_index_reader_wrapper_test.cpp
                    common/io/byte_array_input_stream_test.cpp
                    common/io/data_input_output_stream_test.cpp
                    common/io/buffered_input_stream_test.cpp
                    common/io/memory_segment_output_stream_test.cpp
                    common/io/cache_input_stream_test.cpp
                    common/io/offset_input_stream_test.cpp
                    common/lookup/sort/sort_lookup_store_test.cpp
                    common/logging/logging_test.cpp
                    common/metrics/metrics_impl_test.cpp
                    common/metrics/histogram_test.cpp
                    common/metrics/histogram_windowing_test.cpp
                    common/options/memory_size_test.cpp
                    common/options/time_duration_test.cpp
                    common/predicate/literal_converter_test.cpp
                    common/predicate/literal_test.cpp
                    common/predicate/predicate_test.cpp
                    common/predicate/predicate_utils_test.cpp
                    common/predicate/predicate_validator_test.cpp
                    common/reader/concat_batch_reader_test.cpp
                    common/reader/predicate_batch_reader_test.cpp
                    common/reader/prefetch_file_batch_reader_impl_test.cpp
                    common/reader/reader_utils_test.cpp
                    common/reader/complete_row_kind_batch_reader_test.cpp
                    common/reader/blob_fallback_batch_reader_test.cpp
                    common/reader/blob_view_resolving_batch_reader_test.cpp
                    common/reader/data_evolution_file_reader_test.cpp
                    common/reader/data_evolution_array_test.cpp
                    common/reader/data_evolution_row_test.cpp
                    common/table/special_fields_test.cpp
                    common/types/data_field_test.cpp
                    common/types/data_type_json_parser_test.cpp
                    common/types/row_kind_test.cpp
                    common/types/data_type_test.cpp
                    common/utils/file_type_test.cpp
                    common/utils/row_range_index_test.cpp
                    common/utils/var_length_int_utils_test.cpp
                    common/utils/arrow/arrow_utils_test.cpp
                    common/utils/arrow/arrow_stream_adapter_test.cpp
                    common/utils/arrow/mem_utils_test.cpp
                    common/utils/arrow/status_utils_test.cpp
                    common/utils/concurrent_hash_map_test.cpp
                    common/utils/projected_row_test.cpp
                    common/utils/projected_array_test.cpp
                    common/utils/bit_set_test.cpp
                    common/utils/bloom_filter_test.cpp
                    common/utils/bloom_filter64_test.cpp
                    common/utils/xxhash_test.cpp
                    common/utils/binary_row_partition_computer_test.cpp
                    common/utils/bin_packing_test.cpp
                    common/utils/data_converter_utils_test.cpp
                    common/utils/date_time_utils_test.cpp
                    common/utils/delta_varint_compressor_test.cpp
                    common/utils/field_type_utils_test.cpp
                    common/utils/fields_comparator_test.cpp
                    common/utils/internal_row_utils_test.cpp
                    common/utils/jsonizable_test.cpp
                    common/utils/linked_hash_map_test.cpp
                    common/utils/long_counter_test.cpp
                    common/utils/math_test.cpp
                    common/utils/murmurhash_utils_test.cpp
                    common/utils/object_utils_test.cpp
                    common/utils/options_utils_test.cpp
                    common/utils/path_util_test.cpp
                    common/utils/preconditions_test.cpp
                    common/utils/rapidjson_util_test.cpp
                    common/utils/roaring_bitmap32_test.cpp
                    common/utils/roaring_bitmap64_test.cpp
                    common/utils/range_helper_test.cpp
                    common/utils/read_ahead_cache_test.cpp
                    common/io/cache/lru_cache_test.cpp
                    common/utils/byte_range_combiner_test.cpp
                    common/utils/scope_guard_test.cpp
                    common/utils/serialization_utils_test.cpp
                    common/utils/status_test.cpp
                    common/utils/stream_utils_test.cpp
                    common/utils/string_utils_test.cpp
                    common/utils/range_test.cpp
                    common/utils/uuid_test.cpp
                    common/utils/decimal_utils_test.cpp
                    common/utils/threadsafe_queue_test.cpp
                    common/utils/generic_lru_cache_test.cpp
                    common/data/shredding/map_shared_shredding_utils_test.cpp
                    common/data/shredding/map_shared_shredding_schema_utils_test.cpp
                    common/data/shredding/map_shared_shredding_batch_converter_test.cpp
                    common/data/shredding/lru_map_shared_shredding_column_allocator_test.cpp
                    common/data/shredding/plain_map_shared_shredding_column_allocator_test.cpp
                    common/data/shredding/sequential_map_shared_shredding_column_allocator_test.cpp
                    common/data/shredding/map_shared_shredding_field_dict_test.cpp
                    common/data/shredding/map_shared_shredding_context_test.cpp
                    common/data/shredding/map_shared_shredding_file_reader_test.cpp
                    STATIC_LINK_LIBS
                    paimon_shared
                    test_utils_static
                    ${TEST_STATIC_LINK_LIBS}
                    ${GTEST_LINK_TOOLCHAIN})

    add_paimon_test(common_factories_test
                    SOURCES
                    common/factories/factory_creator_test.cpp
                    common/factories/io_hook_test.cpp
                    STATIC_LINK_LIBS
                    paimon_shared
                    test_utils_static
                    ${GTEST_LINK_TOOLCHAIN})

    add_paimon_test(common_sst_file_format_test
                    SOURCES
                    common/compression/block_compression_factory_test.cpp
                    common/sst/sst_file_io_test.cpp
                    common/sst/block_cache_test.cpp
                    common/sst/block_meta_test.cpp
                    common/sst/block_write_read_test.cpp
                    common/utils/crc32c_test.cpp
                    STATIC_LINK_LIBS
                    paimon_shared
                    test_utils_static
                    ${PAIMON_LOCAL_FILE_SYSTEM_STATIC_LINK_LIBS}
                    ${GTEST_LINK_TOOLCHAIN})

    add_paimon_test(core_test
                    SOURCES
                    core/append/append_only_writer_test.cpp
                    core/append/append_compact_coordinator_test.cpp
                    core/append/bucketed_append_compact_manager_test.cpp
                    core/bucket/bucket_select_converter_test.cpp
                    core/bucket/default_bucket_function_test.cpp
                    core/bucket/hive_bucket_function_test.cpp
                    core/bucket/bucket_id_calculator_test.cpp
                    core/bucket/mod_bucket_function_test.cpp
                    core/casting/cast_executor_factory_test.cpp
                    core/casting/cast_executor_test.cpp
                    core/casting/casted_row_test.cpp
                    core/casting/casting_utils_test.cpp
                    core/catalog/commit_table_request_test.cpp
                    core/catalog/renaming_snapshot_commit_test.cpp
                    core/catalog/file_system_catalog_test.cpp
                    core/catalog/catalog_test.cpp
                    core/catalog/identifier_test.cpp
                    core/compact/compact_deletion_file_test.cpp
                    core/compact/compact_future_manager_test.cpp
                    core/compact/noop_compact_manager_test.cpp
                    core/core_options_test.cpp
                    core/options/lookup_strategy_test.cpp
                    core/deletionvectors/apply_deletion_vector_batch_reader_test.cpp
                    core/deletionvectors/bitmap_deletion_vector_test.cpp
                    core/deletionvectors/bucketed_dv_maintainer_test.cpp
                    core/deletionvectors/deletion_file_writer_test.cpp
                    core/deletionvectors/deletion_vector_test.cpp
                    core/deletionvectors/deletion_vector_index_file_writer_test.cpp
                    core/deletionvectors/deletion_vectors_index_file_test.cpp
                    core/disk/io_manager_test.cpp
                    core/index/index_in_data_file_dir_path_factory_test.cpp
                    core/index/deletion_vector_meta_test.cpp
                    core/index/index_file_meta_serializer_test.cpp
                    core/index/index_file_handler_test.cpp
                    core/io/compact_increment_test.cpp
                    core/io/infer_shredding_file_writer_test.cpp
                    core/io/concat_key_value_record_reader_test.cpp
                    core/io/data_file_meta_serializer_test.cpp
                    core/io/data_file_path_factory_test.cpp
                    core/io/data_increment_test.cpp
                    core/io/field_mapping_reader_test.cpp
                    core/io/key_value_data_file_record_reader_test.cpp
                    core/io/key_value_projection_reader_test.cpp
                    core/io/key_value_in_memory_record_reader_test.cpp
                    core/io/merged_key_value_record_reader_test.cpp
                    core/io/complete_row_tracking_fields_reader_test.cpp
                    core/io/data_file_meta_test.cpp
                    core/io/file_index_evaluator_test.cpp
                    core/io/single_file_writer_test.cpp
                    core/io/rolling_blob_file_writer_test.cpp
                    core/global_index/indexed_split_test.cpp
                    core/manifest/file_source_test.cpp
                    core/manifest/file_kind_test.cpp
                    core/manifest/manifest_entry_writer_test.cpp
                    core/manifest/manifest_committable_test.cpp
                    core/manifest/manifest_entry_serializer_test.cpp
                    core/manifest/manifest_file_meta_serializer_test.cpp
                    core/manifest/manifest_file_test.cpp
                    core/manifest/manifest_list_test.cpp
                    core/manifest/partition_entry_test.cpp
                    core/manifest/file_entry_test.cpp
                    core/manifest/index_manifest_entry_serializer_test.cpp
                    core/manifest/index_manifest_file_handler_test.cpp
                    core/memory/writer_memory_manager_test.cpp
                    core/mergetree/levels_test.cpp
                    core/mergetree/lookup_file_test.cpp
                    core/mergetree/lookup_levels_test.cpp
                    core/mergetree/compact/aggregate/aggregate_merge_function_test.cpp
                    core/mergetree/compact/aggregate/field_aggregator_factory_test.cpp
                    core/mergetree/compact/aggregate/field_bool_agg_test.cpp
                    core/mergetree/compact/aggregate/field_first_non_null_value_agg_test.cpp
                    core/mergetree/compact/aggregate/field_first_value_agg_test.cpp
                    core/mergetree/compact/aggregate/field_ignore_retract_agg_test.cpp
                    core/mergetree/compact/aggregate/field_last_non_null_value_agg_test.cpp
                    core/mergetree/compact/aggregate/field_last_value_agg_test.cpp
                    core/mergetree/compact/aggregate/field_listagg_agg_test.cpp
                    core/mergetree/compact/aggregate/field_min_max_agg_test.cpp
                    core/mergetree/compact/aggregate/field_primary_key_agg_test.cpp
                    core/mergetree/compact/aggregate/field_sum_agg_test.cpp
                    core/mergetree/compact/deduplicate_merge_function_test.cpp
                    core/mergetree/compact/first_row_merge_function_test.cpp
                    core/mergetree/compact/first_row_merge_function_wrapper_test.cpp
                    core/mergetree/compact/interval_partition_test.cpp
                    core/mergetree/compact/lookup_changelog_merge_function_wrapper_test.cpp
                    core/mergetree/compact/lookup_merge_tree_compact_rewriter_test.cpp
                    core/mergetree/compact/lookup_merge_function_test.cpp
                    core/mergetree/compact/partial_update_merge_function_test.cpp
                    core/mergetree/compact/reducer_merge_function_wrapper_test.cpp
                    core/mergetree/compact/sort_merge_reader_test.cpp
                    core/mergetree/compact/off_peak_hours_test.cpp
                    core/mergetree/compact/early_full_compaction_test.cpp
                    core/mergetree/compact/universal_compaction_test.cpp
                    core/mergetree/compact/force_up_level0_compaction_test.cpp
                    core/mergetree/compact/compact_strategy_test.cpp
                    core/mergetree/compact/file_rewrite_compact_task_test.cpp
                    core/mergetree/compact/merge_tree_compact_manager_test.cpp
                    core/mergetree/compact/merge_tree_compact_manager_factory_test.cpp
                    core/mergetree/compact/merge_tree_compact_rewriter_test.cpp
                    core/mergetree/lookup/persist_processor_test.cpp
                    core/mergetree/lookup/remote_lookup_file_manager_test.cpp
                    core/mergetree/drop_delete_reader_test.cpp
                    core/mergetree/merge_tree_writer_test.cpp
                    core/mergetree/write_buffer_test.cpp
                    core/mergetree/sort_buffer_test.cpp
                    core/mergetree/spill_file_merger_test.cpp
                    core/mergetree/sorted_run_test.cpp
                    core/mergetree/spill_channel_manager_test.cpp
                    core/mergetree/spill_reader_writer_test.cpp
                    core/migrate/file_meta_utils_test.cpp
                    core/operation/metrics/compaction_metrics_test.cpp
                    core/operation/metrics/commit_stats_test.cpp
                    core/operation/data_evolution_file_store_scan_test.cpp
                    core/operation/data_evolution_split_read_test.cpp
                    core/operation/commit/compacted_changelog_path_resolver_test.cpp
                    core/operation/commit/commit_changes_provider_test.cpp
                    core/operation/commit/commit_scanner_test.cpp
                    core/operation/commit/conflict_detection_test.cpp
                    core/operation/commit/manifest_entry_changes_test.cpp
                    core/operation/commit/overwrite_changes_provider_test.cpp
                    core/operation/commit/row_id_column_conflict_checker_test.cpp
                    core/operation/commit/row_tracking_commit_utils_test.cpp
                    core/operation/commit/sequence_snapshot_properties_test.cpp
                    core/operation/commit/retry_waiter_test.cpp
                    core/operation/key_value_file_store_write_test.cpp
                    core/operation/internal_read_context_test.cpp
                    core/operation/abstract_split_read_test.cpp
                    core/operation/append_only_file_store_write_test.cpp
                    core/operation/commit_metrics_test.cpp
                    core/operation/commit_context_test.cpp
                    core/operation/expire_snapshots_test.cpp
                    core/operation/file_store_commit_impl_test.cpp
                    core/operation/file_store_commit_test.cpp
                    core/operation/append_only_file_store_scan_test.cpp
                    core/operation/key_value_file_store_scan_test.cpp
                    core/operation/file_store_scan_test.cpp
                    core/operation/file_system_write_restore_test.cpp
                    core/operation/file_store_write_test.cpp
                    core/operation/manifest_file_merger_test.cpp
                    core/operation/merge_file_split_read_test.cpp
                    core/operation/blob_file_context_test.cpp
                    core/operation/orphan_files_cleaner_test.cpp
                    core/operation/raw_file_split_read_test.cpp
                    core/operation/read_context_test.cpp
                    core/operation/scan_context_test.cpp
                    core/operation/write_restore_test.cpp
                    core/operation/write_context_test.cpp
                    core/partition/partition_statistics_test.cpp
                    core/postpone/postpone_bucket_writer_test.cpp
                    core/schema/schema_manager_test.cpp
                    core/schema/schema_validation_test.cpp
                    core/schema/arrow_schema_validator_test.cpp
                    core/schema/table_schema_test.cpp
                    core/snapshot_test.cpp
                    core/stats/simple_stats_evolution_test.cpp
                    core/stats/simple_stats_collector_test.cpp
                    core/stats/simple_stats_test.cpp
                    core/table/table_test.cpp
                    core/table/bucket_mode_test.cpp
                    core/table/sink/commit_message_test.cpp
                    core/table/sink/commit_message_impl_test.cpp
                    core/table/source/fallback_data_split_test.cpp
                    core/table/source/table_read_test.cpp
                    core/table/source/append_count_reader_test.cpp
                    core/table/source/pk_count_reader_test.cpp
                    core/table/source/data_evolution_batch_scan_test.cpp
                    core/table/source/data_split_test.cpp
                    core/table/source/deletion_file_test.cpp
                    core/table/source/split_generator_test.cpp
                    core/table/source/snapshot/snapshot_reader_test.cpp
                    core/table/source/startup_mode_test.cpp
                    core/table/source/table_scan_test.cpp
                    core/table/system/system_table_test.cpp
                    core/tag/tag_test.cpp
                    core/utils/blob_view_lookup_test.cpp
                    core/utils/branch_manager_test.cpp
                    core/utils/consumer_manager_test.cpp
                    core/utils/file_store_path_factory_cache_test.cpp
                    core/utils/field_mapping_test.cpp
                    core/utils/nested_projection_utils_test.cpp
                    core/utils/file_store_path_factory_test.cpp
                    core/utils/file_utils_test.cpp
                    core/utils/manifest_meta_reader_test.cpp
                    core/utils/offset_row_test.cpp
                    core/utils/partition_path_utils_test.cpp
                    core/utils/snapshot_manager_test.cpp
                    core/utils/tag_manager_test.cpp
                    core/utils/primary_key_table_utils_test.cpp
                    core/utils/index_file_path_factories_test.cpp
                    STATIC_LINK_LIBS
                    paimon_shared
                    test_utils_static
                    ${TEST_STATIC_LINK_LIBS}
                    ${GTEST_LINK_TOOLCHAIN})

    set(PAIMON_JINDO_FS_TEST_SOURCES)
    set(PAIMON_JINDO_FS_TEST_LINK_LIBS)
    if(PAIMON_ENABLE_JINDO)
        # These unit tests do not access remote OSS.
        list(APPEND PAIMON_JINDO_FS_TEST_SOURCES fs/jindo/jindo_file_system_unit_test.cpp
             fs/jindo/jindo_utils_test.cpp)
        if(PAIMON_ENABLE_NETWORK_TESTS)
            # Factory and integration tests access real OSS.
            list(APPEND PAIMON_JINDO_FS_TEST_SOURCES
                 fs/jindo/jindo_file_system_factory_test.cpp
                 fs/jindo/jindo_file_system_test.cpp)
        endif()
        list(APPEND PAIMON_JINDO_FS_TEST_LINK_LIBS
             ${PAIMON_JINDO_FILE_SYSTEM_STATIC_LINK_LIBS})
    endif()

    set(PAIMON_OBJECT_STORE_FS_TEST_SOURCES)
    if(PAIMON_ENABLE_S3)
        list(APPEND PAIMON_OBJECT_STORE_FS_TEST_SOURCES
             common/fs/object_store_file_system_test.cpp)
    endif()

    add_paimon_test(fs_test
                    SOURCES
                    common/fs/file_system_test.cpp
                    common/fs/resolving_file_system_test.cpp
                    ${PAIMON_OBJECT_STORE_FS_TEST_SOURCES}
                    fs/local/local_file_test.cpp
                    ${PAIMON_JINDO_FS_TEST_SOURCES}
                    STATIC_LINK_LIBS
                    paimon_shared
                    ${PAIMON_LOCAL_FILE_SYSTEM_STATIC_LINK_LIBS}
                    ${PAIMON_JINDO_FS_TEST_LINK_LIBS}
                    test_utils_static
                    ${GTEST_LINK_TOOLCHAIN}
                    EXTRA_INCLUDES
                    ${JINDOSDK_INCLUDE_DIR})

endif()
