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"
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
359348Result<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
465449Result<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 ));
0 commit comments