@@ -810,15 +810,30 @@ pub struct TableSchema {
810810
811811 /// the table's columns by their name
812812 pub columns : ColumnsByName ,
813+
814+ /// Whether or not iceberg is enabled for this table
815+ pub iceberg_enabled : bool ,
813816}
814817
815818impl TableSchema {
816- /// Initialize new `TableSchema` from the information in the given `Table`.
819+ /// Initialize new [ `TableSchema`] from the information in the given [ `Table`] .
817820 pub fn new_empty_from ( table : & Table ) -> Self {
818821 Self {
819822 id : table. id ,
820823 partition_template : table. partition_template . clone ( ) ,
821824 columns : ColumnsByName :: default ( ) ,
825+ iceberg_enabled : table. iceberg_enabled ,
826+ }
827+ }
828+
829+ /// Initialize a new [`TableSchema`] with the given id, no columns, default partition, and
830+ /// iceberg disabled.
831+ pub fn new_with ( id : TableId ) -> Self {
832+ Self {
833+ id,
834+ partition_template : TablePartitionTemplateOverride :: default ( ) ,
835+ columns : ColumnsByName :: default ( ) ,
836+ iceberg_enabled : false ,
822837 }
823838 }
824839
@@ -1077,8 +1092,8 @@ pub struct ParquetFile {
10771092 pub table_id : TableId ,
10781093 /// the partition identifier
10791094 pub partition_id : PartitionId ,
1080- /// the optional partition hash id
1081- pub partition_hash_id : Option < PartitionHashId > ,
1095+ /// the partition hash id
1096+ pub partition_hash_id : PartitionHashId ,
10821097 /// the uuid used in the object store path for this file
10831098 pub object_store_id : ObjectStoreId ,
10841099 /// the min timestamp of data in this file
@@ -1178,11 +1193,7 @@ impl ParquetFile {
11781193
11791194 /// Estimate the memory consumption of this object and its contents
11801195 pub fn size ( & self ) -> usize {
1181- let hash_id = self
1182- . partition_hash_id
1183- . as_ref ( )
1184- . map ( |x| x. size ( ) )
1185- . unwrap_or_default ( ) ;
1196+ let hash_id = self . partition_hash_id . size ( ) ;
11861197
11871198 size_of_val ( self ) + hash_id + self . column_set . size ( ) - size_of_val ( & self . column_set )
11881199 }
@@ -1211,7 +1222,7 @@ impl ParquetFile {
12111222
12121223 /// Temporary to aid incremental migration
12131224 pub fn transition_partition_id ( & self ) -> TransitionPartitionId {
1214- TransitionPartitionId :: from_parts ( self . partition_id , self . partition_hash_id . clone ( ) )
1225+ TransitionPartitionId :: from_parts ( self . partition_id , Some ( self . partition_hash_id . clone ( ) ) )
12151226 }
12161227}
12171228
@@ -1222,10 +1233,7 @@ impl From<ParquetFile> for catalog_proto::ParquetFile {
12221233 namespace_id : v. namespace_id . get ( ) ,
12231234 table_id : v. table_id . get ( ) ,
12241235 partition_id : v. partition_id . get ( ) ,
1225- partition_hash_id : v
1226- . partition_hash_id
1227- . map ( |x| x. as_bytes ( ) . to_vec ( ) )
1228- . unwrap_or_default ( ) ,
1236+ partition_hash_id : v. partition_hash_id . as_bytes ( ) . to_vec ( ) ,
12291237 object_store_id : v. object_store_id . to_string ( ) ,
12301238 min_time : v. min_time . get ( ) ,
12311239 max_time : v. max_time . get ( ) ,
@@ -1266,11 +1274,7 @@ impl TryFrom<catalog_proto::ParquetFile> for ParquetFile {
12661274 namespace_id : NamespaceId :: new ( v. namespace_id ) ,
12671275 table_id : TableId :: new ( v. table_id ) ,
12681276 partition_id : PartitionId :: new ( v. partition_id ) ,
1269- partition_hash_id : if v. partition_hash_id . is_empty ( ) {
1270- None
1271- } else {
1272- Some ( v. partition_hash_id [ ..] . try_into ( ) ?)
1273- } ,
1277+ partition_hash_id : v. partition_hash_id [ ..] . try_into ( ) ?,
12741278 object_store_id : ObjectStoreId :: from_str ( & v. object_store_id ) ?,
12751279 min_time : Timestamp :: new ( v. min_time ) ,
12761280 max_time : Timestamp :: new ( v. max_time ) ,
@@ -1346,7 +1350,7 @@ pub struct ParquetFileParams {
13461350 /// the partition identifier
13471351 pub partition_id : PartitionId ,
13481352 /// the partition hash ID
1349- pub partition_hash_id : Option < PartitionHashId > ,
1353+ pub partition_hash_id : PartitionHashId ,
13501354 /// the uuid used in the object store path for this file
13511355 pub object_store_id : ObjectStoreId ,
13521356 /// the min timestamp of data in this file
@@ -3329,6 +3333,7 @@ mod tests {
33293333 id : TableId :: new ( 1 ) ,
33303334 partition_template : Default :: default ( ) ,
33313335 columns : ColumnsByName :: default ( ) ,
3336+ iceberg_enabled : false ,
33323337 } ;
33333338 let schema2 = TableSchema {
33343339 id : TableId :: new ( 2 ) ,
@@ -3339,6 +3344,7 @@ mod tests {
33393344 name : String :: from ( "foo" ) ,
33403345 column_type : ColumnType :: Bool ,
33413346 } ] ) ,
3347+ iceberg_enabled : false ,
33423348 } ;
33433349 assert ! ( schema1. size( ) < schema2. size( ) ) ;
33443350 }
@@ -3361,11 +3367,7 @@ mod tests {
33613367 id : NamespaceId :: new ( 1 ) ,
33623368 active_tables : BTreeMap :: from ( [ (
33633369 String :: from ( "foo" ) ,
3364- TableSchema {
3365- id : TableId :: new ( 1 ) ,
3366- columns : ColumnsByName :: default ( ) ,
3367- partition_template : Default :: default ( ) ,
3368- } ,
3370+ TableSchema :: new_with ( TableId :: new ( 1 ) ) ,
33693371 ) ] ) ,
33703372 deleted_tables : BTreeSet :: new ( ) ,
33713373 partition_template : Default :: default ( ) ,
@@ -3412,41 +3414,13 @@ mod tests {
34123414
34133415 #[ test]
34143416 fn catalog_service_parquet_file_serde_roundtrip ( ) {
3415- // This part of the test can be removed when all partitions have hash IDs.
3416- let old_style_parquet_file = ParquetFile {
3417- id : ParquetFileId :: new ( 3 ) ,
3418- namespace_id : NamespaceId :: new ( 4 ) ,
3419- table_id : TableId :: new ( 5 ) ,
3420- partition_id : PartitionId :: new ( 6 ) ,
3421- partition_hash_id : None , // this is the important part for this test
3422- object_store_id : ObjectStoreId :: new ( ) ,
3423- min_time : Timestamp :: new ( 30 ) ,
3424- max_time : Timestamp :: new ( 50 ) ,
3425- to_delete : None ,
3426- file_size_bytes : 1024 ,
3427- row_count : 42 ,
3428- compaction_level : CompactionLevel :: Initial ,
3429- created_at : Timestamp :: new ( 70 ) ,
3430- column_set : ColumnSet :: empty ( ) ,
3431- max_l0_created_at : Timestamp :: new ( 70 ) ,
3432- source : None ,
3433- } ;
3434- let catalog_proto_old_style_parquet_file =
3435- catalog_proto:: ParquetFile :: from ( old_style_parquet_file. clone ( ) ) ;
3436- let round_trip_old_style_parquet_file =
3437- ParquetFile :: try_from ( catalog_proto_old_style_parquet_file) . unwrap ( ) ;
3438- assert_eq ! ( old_style_parquet_file, round_trip_old_style_parquet_file) ;
3439-
34403417 let table_id = TableId :: new ( 5 ) ;
34413418 let parquet_file = ParquetFile {
34423419 id : ParquetFileId :: new ( 3 ) ,
34433420 namespace_id : NamespaceId :: new ( 4 ) ,
34443421 table_id,
34453422 partition_id : PartitionId :: new ( 6 ) ,
3446- partition_hash_id : Some ( PartitionHashId :: new (
3447- table_id,
3448- & PartitionKey :: from ( "arbitrary" ) ,
3449- ) ) ,
3423+ partition_hash_id : PartitionHashId :: new ( table_id, & PartitionKey :: from ( "arbitrary" ) ) ,
34503424 object_store_id : ObjectStoreId :: new ( ) ,
34513425 min_time : Timestamp :: new ( 30 ) ,
34523426 max_time : Timestamp :: new ( 50 ) ,
0 commit comments