Skip to content

Commit ed5857a

Browse files
suxiaogang223claude
andcommitted
style: apply clang-format fixes from pre-commit
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c5d3439 commit ed5857a

6 files changed

Lines changed: 50 additions & 72 deletions

File tree

src/paimon/core/catalog/file_system_catalog.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,8 @@ Result<std::shared_ptr<Schema>> FileSystemCatalog::LoadTableSchema(
283283
context.fs = fs_;
284284
context.warehouse = warehouse_;
285285
context.catalog_options = catalog_options_;
286-
PAIMON_ASSIGN_OR_RAISE(
287-
std::shared_ptr<SystemTable> system_table,
288-
GlobalSystemTableLoader::Load(identifier.GetTableName(), context));
286+
PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<SystemTable> system_table,
287+
GlobalSystemTableLoader::Load(identifier.GetTableName(), context));
289288
PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<arrow::Schema> arrow_schema,
290289
system_table->ArrowSchema());
291290
return std::make_shared<SystemTableSchema>(std::move(arrow_schema));

src/paimon/core/catalog/file_system_catalog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Logger;
3939
class FileSystemCatalog : public Catalog {
4040
public:
4141
FileSystemCatalog(const std::shared_ptr<FileSystem>& fs, const std::string& warehouse,
42-
const std::map<std::string, std::string>& catalog_options = {});
42+
const std::map<std::string, std::string>& catalog_options = {});
4343

4444
Status CreateDatabase(const std::string& db_name,
4545
const std::map<std::string, std::string>& options,

src/paimon/core/catalog/file_system_catalog_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,7 @@ TEST(FileSystemCatalogTest, TestInvalidList) {
616616
ASSERT_TRUE(std::find(sys_tables.begin(), sys_tables.end(), "all_table_options") !=
617617
sys_tables.end());
618618
ASSERT_TRUE(std::find(sys_tables.begin(), sys_tables.end(), "tables") != sys_tables.end());
619-
ASSERT_TRUE(std::find(sys_tables.begin(), sys_tables.end(), "partitions") !=
620-
sys_tables.end());
619+
ASSERT_TRUE(std::find(sys_tables.begin(), sys_tables.end(), "partitions") != sys_tables.end());
621620
}
622621

623622
TEST(FileSystemCatalogTest, TestValidateTableSchema) {

src/paimon/core/table/system/global_system_tables.cpp

Lines changed: 39 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@
3131
#include "paimon/common/data/binary_string.h"
3232
#include "paimon/common/data/generic_row.h"
3333
#include "paimon/common/utils/binary_row_partition_computer.h"
34-
#include "paimon/common/utils/string_utils.h"
3534
#include "paimon/common/utils/path_util.h"
35+
#include "paimon/common/utils/string_utils.h"
3636
#include "paimon/core/core_options.h"
37-
#include "paimon/defs.h"
3837
#include "paimon/core/io/data_file_meta.h"
3938
#include "paimon/core/manifest/file_entry.h"
4039
#include "paimon/core/manifest/file_kind.h"
@@ -50,6 +49,7 @@
5049
#include "paimon/core/utils/file_store_path_factory.h"
5150
#include "paimon/core/utils/snapshot_manager.h"
5251
#include "paimon/data/timestamp.h"
52+
#include "paimon/defs.h"
5353
#include "paimon/memory/memory_pool.h"
5454
#include "paimon/status.h"
5555

@@ -113,16 +113,13 @@ Result<std::map<std::string, FileStats>> AggregateFileStats(
113113
const std::map<std::string, std::string>& options) {
114114
std::map<std::string, FileStats> result;
115115

116-
SnapshotManager snapshot_manager(fs, table_path,
117-
BranchManager::DEFAULT_MAIN_BRANCH);
118-
PAIMON_ASSIGN_OR_RAISE(std::optional<Snapshot> snapshot,
119-
snapshot_manager.LatestSnapshot());
116+
SnapshotManager snapshot_manager(fs, table_path, BranchManager::DEFAULT_MAIN_BRANCH);
117+
PAIMON_ASSIGN_OR_RAISE(std::optional<Snapshot> snapshot, snapshot_manager.LatestSnapshot());
120118
if (!snapshot) {
121119
return result;
122120
}
123121

124-
PAIMON_ASSIGN_OR_RAISE(CoreOptions core_options,
125-
CoreOptions::FromMap(options));
122+
PAIMON_ASSIGN_OR_RAISE(CoreOptions core_options, CoreOptions::FromMap(options));
126123

127124
// Use SchemaManager to load the latest schema for field/partition info
128125
SchemaManager schema_mgr(fs, table_path, BranchManager::DEFAULT_MAIN_BRANCH);
@@ -144,31 +141,27 @@ Result<std::map<std::string, FileStats>> AggregateFileStats(
144141
std::shared_ptr<FileStorePathFactory> path_factory,
145142
FileStorePathFactory::Create(
146143
table_path, arrow_schema, table_schema->PartitionKeys(),
147-
core_options.GetPartitionDefaultName(),
148-
core_options.GetFileFormat()->Identifier(),
149-
core_options.DataFilePrefix(),
150-
core_options.LegacyPartitionNameEnabled(), external_paths,
151-
global_index_external_path, core_options.IndexFileInDataFileDir(), pool));
144+
core_options.GetPartitionDefaultName(), core_options.GetFileFormat()->Identifier(),
145+
core_options.DataFilePrefix(), core_options.LegacyPartitionNameEnabled(),
146+
external_paths, global_index_external_path, core_options.IndexFileInDataFileDir(),
147+
pool));
152148

153-
PAIMON_ASSIGN_OR_RAISE(
154-
std::unique_ptr<ManifestList> manifest_list,
155-
ManifestList::Create(fs, core_options.GetManifestFormat(),
156-
core_options.GetManifestCompression(), path_factory,
157-
core_options.GetCache(), pool));
149+
PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<ManifestList> manifest_list,
150+
ManifestList::Create(fs, core_options.GetManifestFormat(),
151+
core_options.GetManifestCompression(), path_factory,
152+
core_options.GetCache(), pool));
158153

159154
std::vector<ManifestFileMeta> manifests;
160-
PAIMON_RETURN_NOT_OK(
161-
manifest_list->ReadDataManifests(*snapshot, &manifests));
155+
PAIMON_RETURN_NOT_OK(manifest_list->ReadDataManifests(*snapshot, &manifests));
162156

163157
PAIMON_ASSIGN_OR_RAISE(
164158
std::shared_ptr<arrow::Schema> partition_schema,
165159
FieldMapping::GetPartitionSchema(arrow_schema, table_schema->PartitionKeys()));
166-
PAIMON_ASSIGN_OR_RAISE(
167-
std::unique_ptr<ManifestFile> manifest_file,
168-
ManifestFile::Create(fs, core_options.GetManifestFormat(),
169-
core_options.GetManifestCompression(), path_factory,
170-
core_options.GetManifestTargetFileSize(), pool,
171-
core_options, partition_schema));
160+
PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<ManifestFile> manifest_file,
161+
ManifestFile::Create(fs, core_options.GetManifestFormat(),
162+
core_options.GetManifestCompression(), path_factory,
163+
core_options.GetManifestTargetFileSize(), pool,
164+
core_options, partition_schema));
172165

173166
std::vector<ManifestEntry> entries;
174167
for (const auto& manifest : manifests) {
@@ -188,12 +181,10 @@ Result<std::map<std::string, FileStats>> AggregateFileStats(
188181
// Convert partition BinaryRow to string representation
189182
std::string partition_key;
190183
if (entry.Partition().GetFieldCount() > 0) {
191-
PAIMON_ASSIGN_OR_RAISE(
192-
partition_key,
193-
BinaryRowPartitionComputer::PartToSimpleString(
194-
partition_schema, entry.Partition(), ",",
195-
/*max_length=*/255,
196-
/*legacy_partition_name_enabled=*/false));
184+
PAIMON_ASSIGN_OR_RAISE(partition_key, BinaryRowPartitionComputer::PartToSimpleString(
185+
partition_schema, entry.Partition(), ",",
186+
/*max_length=*/255,
187+
/*legacy_partition_name_enabled=*/false));
197188
partition_key = "{" + partition_key + "}";
198189
}
199190

@@ -301,11 +292,9 @@ Result<std::vector<GenericRow>> AllTableOptionsSystemTable::BuildRows() const {
301292
PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<arrow::Schema> schema, ArrowSchema());
302293
std::vector<GenericRow> rows;
303294

304-
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> databases,
305-
context_.catalog->ListDatabases());
295+
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> databases, context_.catalog->ListDatabases());
306296
for (const auto& db : databases) {
307-
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> tables,
308-
context_.catalog->ListTables(db));
297+
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> tables, context_.catalog->ListTables(db));
309298
for (const auto& table : tables) {
310299
Identifier id(db, table);
311300
auto schema_result = context_.catalog->LoadTableSchema(id);
@@ -351,20 +340,18 @@ Result<std::shared_ptr<arrow::Schema>> TablesSystemTable::ArrowSchema() const {
351340
arrow::field("record_count", arrow::int64(), /*nullable=*/true),
352341
arrow::field("file_size_in_bytes", arrow::int64(), /*nullable=*/true),
353342
arrow::field("file_count", arrow::int64(), /*nullable=*/true),
354-
arrow::field("last_file_creation_time",
355-
arrow::timestamp(arrow::TimeUnit::MILLI), /*nullable=*/true),
343+
arrow::field("last_file_creation_time", arrow::timestamp(arrow::TimeUnit::MILLI),
344+
/*nullable=*/true),
356345
});
357346
}
358347

359348
Result<std::vector<GenericRow>> TablesSystemTable::BuildRows() const {
360349
PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<arrow::Schema> schema, ArrowSchema());
361350
std::vector<GenericRow> rows;
362351

363-
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> databases,
364-
context_.catalog->ListDatabases());
352+
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> databases, context_.catalog->ListDatabases());
365353
for (const auto& db : databases) {
366-
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> tables,
367-
context_.catalog->ListTables(db));
354+
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> tables, context_.catalog->ListTables(db));
368355
for (const auto& table : tables) {
369356
Identifier id(db, table);
370357
auto schema_result = context_.catalog->LoadTableSchema(id);
@@ -397,20 +384,17 @@ Result<std::vector<GenericRow>> TablesSystemTable::BuildRows() const {
397384
row.SetField(1, StringValue(table));
398385
row.SetField(2, StringValue(table_type_str));
399386
row.SetField(3, partitioned);
400-
row.SetField(4, primary_keys_str.empty()
401-
? VariantType(NullType())
402-
: VariantType(StringValue(primary_keys_str)));
387+
row.SetField(4, primary_keys_str.empty() ? VariantType(NullType())
388+
: VariantType(StringValue(primary_keys_str)));
403389

404390
// Get table path and aggregate file stats from manifest entries
405-
PAIMON_ASSIGN_OR_RAISE(std::string table_path,
406-
context_.catalog->GetTableLocation(id));
391+
PAIMON_ASSIGN_OR_RAISE(std::string table_path, context_.catalog->GetTableLocation(id));
407392

408393
auto file_stats_result =
409394
AggregateFileStats(context_.fs, table_path, data_schema->Options());
410395
if (file_stats_result.ok()) {
411396
auto& all_stats = file_stats_result.value();
412-
int64_t total_record = 0, total_size = 0, total_files = 0,
413-
max_creation = 0;
397+
int64_t total_record = 0, total_size = 0, total_files = 0, max_creation = 0;
414398
for (const auto& [key, stats] : all_stats) {
415399
total_record += stats.record_count;
416400
total_size += stats.file_size_in_bytes;
@@ -457,20 +441,18 @@ Result<std::shared_ptr<arrow::Schema>> PartitionsSystemTable::ArrowSchema() cons
457441
arrow::field("record_count", arrow::int64(), /*nullable=*/true),
458442
arrow::field("file_size_in_bytes", arrow::int64(), /*nullable=*/true),
459443
arrow::field("file_count", arrow::int64(), /*nullable=*/true),
460-
arrow::field("last_update_time",
461-
arrow::timestamp(arrow::TimeUnit::MILLI), /*nullable=*/true),
444+
arrow::field("last_update_time", arrow::timestamp(arrow::TimeUnit::MILLI),
445+
/*nullable=*/true),
462446
});
463447
}
464448

465449
Result<std::vector<GenericRow>> PartitionsSystemTable::BuildRows() const {
466450
PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<arrow::Schema> schema, ArrowSchema());
467451
std::vector<GenericRow> rows;
468452

469-
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> databases,
470-
context_.catalog->ListDatabases());
453+
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> databases, context_.catalog->ListDatabases());
471454
for (const auto& db : databases) {
472-
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> tables,
473-
context_.catalog->ListTables(db));
455+
PAIMON_ASSIGN_OR_RAISE(std::vector<std::string> tables, context_.catalog->ListTables(db));
474456
for (const auto& table : tables) {
475457
Identifier id(db, table);
476458
auto schema_result = context_.catalog->LoadTableSchema(id);
@@ -509,9 +491,8 @@ Result<std::vector<GenericRow>> PartitionsSystemTable::BuildRows() const {
509491
GenericRow row(schema->num_fields());
510492
row.SetField(0, StringValue(db));
511493
row.SetField(1, StringValue(table));
512-
row.SetField(2, partition_key.empty()
513-
? VariantType(NullType())
514-
: VariantType(StringValue(partition_key)));
494+
row.SetField(2, partition_key.empty() ? VariantType(NullType())
495+
: VariantType(StringValue(partition_key)));
515496
row.SetField(3, VariantType(stats.record_count));
516497
row.SetField(4, VariantType(stats.file_size_in_bytes));
517498
row.SetField(5, VariantType(stats.file_count));

src/paimon/core/table/system/global_system_tables.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ class GlobalSystemTableLoader {
108108
public:
109109
static bool IsSupported(const std::string& table_name);
110110

111-
static Result<std::shared_ptr<SystemTable>> Load(
112-
const std::string& table_name, const GlobalSystemTableContext& context);
111+
static Result<std::shared_ptr<SystemTable>> Load(const std::string& table_name,
112+
const GlobalSystemTableContext& context);
113113

114114
static std::vector<std::string> GetSupportedTableNames();
115115
};

test/inte/read_inte_test.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@
5050
#include "paimon/core/table/source/data_split_impl.h"
5151
#include "paimon/core/table/source/deletion_file.h"
5252
#include "paimon/core/table/source/fallback_data_split.h"
53+
#include "paimon/core/table/system/global_system_tables.h"
5354
#include "paimon/core/tag/tag.h"
5455
#include "paimon/data/decimal.h"
5556
#include "paimon/data/timestamp.h"
5657
#include "paimon/defs.h"
57-
#include "paimon/core/table/system/global_system_tables.h"
5858
#include "paimon/fs/file_system.h"
5959
#include "paimon/fs/local/local_file_system.h"
6060
#include "paimon/memory/memory_pool.h"
@@ -3362,9 +3362,8 @@ TEST_P(ReadInteTest, TestSpecificFs) {
33623362
namespace {
33633363

33643364
Result<SystemTableReadResult> ReadGlobalSystemTable(
3365-
const std::string& table_name, Catalog* catalog,
3366-
const std::shared_ptr<FileSystem>& fs, const std::string& warehouse,
3367-
const std::map<std::string, std::string>& options) {
3365+
const std::string& table_name, Catalog* catalog, const std::shared_ptr<FileSystem>& fs,
3366+
const std::string& warehouse, const std::map<std::string, std::string>& options) {
33683367
GlobalSystemTableContext ctx;
33693368
ctx.catalog = catalog;
33703369
ctx.fs = fs;
@@ -3585,8 +3584,8 @@ TEST(SystemTableReadInteTest, TestReadGlobalPartitions) {
35853584

35863585
// Unpartitioned tables are skipped by sys.partitions → empty result.
35873586
// CollectResult returns null shared_ptr when result is empty.
3588-
ASSERT_OK_AND_ASSIGN(auto part_result,
3589-
ReadGlobalSystemTable("partitions", catalog.get(), fs, warehouse, options));
3587+
ASSERT_OK_AND_ASSIGN(auto part_result, ReadGlobalSystemTable("partitions", catalog.get(), fs,
3588+
warehouse, options));
35903589
ASSERT_FALSE(part_result.array) << "expected null array for empty partitions result";
35913590
}
35923591

0 commit comments

Comments
 (0)