@@ -274,18 +274,14 @@ class PruneColumnVisitor {
274274
275275 Result<std::shared_ptr<Type>> Visit (const std::shared_ptr<Type>& type) const {
276276 switch (type->type_id ()) {
277- case TypeId::kStruct : {
277+ case TypeId::kStruct :
278278 return Visit (internal::checked_pointer_cast<StructType>(type));
279- }
280- case TypeId::kList : {
279+ case TypeId::kList :
281280 return Visit (internal::checked_pointer_cast<ListType>(type));
282- }
283- case TypeId::kMap : {
281+ case TypeId::kMap :
284282 return Visit (internal::checked_pointer_cast<MapType>(type));
285- }
286- default : {
283+ default :
287284 return nullptr ;
288- }
289285 }
290286 }
291287
@@ -353,21 +349,11 @@ class PruneColumnVisitor {
353349
354350 private:
355351 const std::unordered_set<int32_t >& selected_ids_;
356- bool select_full_types_;
352+ const bool select_full_types_;
357353};
358354
359- Result<std::unique_ptr<const Schema>> Schema::Select (std::span<const std::string> names,
360- bool case_sensitive) const {
361- return SelectInternal (names, case_sensitive);
362- }
363-
364- Result<std::unique_ptr<const Schema>> Schema::Select (
365- const std::initializer_list<std::string>& names, bool case_sensitive) const {
366- return SelectInternal (names, case_sensitive);
367- }
368-
369- Result<std::unique_ptr<const Schema>> Schema::SelectInternal (
370- std::span<const std::string> names, bool case_sensitive) const {
355+ Result<std::unique_ptr<Schema>> Schema::Select (std::span<const std::string> names,
356+ bool case_sensitive) const {
371357 const std::string kAllColumns = " *" ;
372358 if (std::ranges::find (names, kAllColumns ) != names.end ()) {
373359 return std::make_unique<Schema>(*this );
@@ -382,9 +368,8 @@ Result<std::unique_ptr<const Schema>> Schema::SelectInternal(
382368 }
383369
384370 PruneColumnVisitor visitor (selected_ids, /* select_full_types=*/ true );
385- auto self = std::shared_ptr<const StructType>(this , [](const StructType*) {});
386- ICEBERG_ASSIGN_OR_RAISE (auto result,
387- visitor.Visit (std::const_pointer_cast<StructType>(self)));
371+ ICEBERG_ASSIGN_OR_RAISE (
372+ auto result, visitor.Visit (std::shared_ptr<StructType>(ToStructType (*this ))));
388373
389374 if (!result) {
390375 return std::make_unique<Schema>(std::vector<SchemaField>{}, schema_id_);
@@ -394,17 +379,16 @@ Result<std::unique_ptr<const Schema>> Schema::SelectInternal(
394379 return InvalidSchema (" Projected type must be a struct type" );
395380 }
396381
397- auto & projected_struct = internal::checked_cast< const StructType&>(*result);
398-
399- return FromStructType ( std::move ( const_cast <StructType&>(projected_struct)), schema_id_);
382+ return FromStructType ( std::move ( const_cast < StructType&>(
383+ internal::checked_cast< const StructType&>(*result))),
384+ schema_id_);
400385}
401386
402- Result<std::unique_ptr<const Schema>> Schema::Project (
403- std::unordered_set<int32_t >& field_ids) const {
387+ Result<std::unique_ptr<Schema>> Schema::Project (
388+ const std::unordered_set<int32_t >& field_ids) const {
404389 PruneColumnVisitor visitor (field_ids, /* select_full_types=*/ false );
405- auto self = std::shared_ptr<const StructType>(this , [](const StructType*) {});
406- ICEBERG_ASSIGN_OR_RAISE (auto result,
407- visitor.Visit (std::const_pointer_cast<StructType>(self)));
390+ ICEBERG_ASSIGN_OR_RAISE (
391+ auto result, visitor.Visit (std::shared_ptr<StructType>(ToStructType (*this ))));
408392
409393 if (!result) {
410394 return std::make_unique<Schema>(std::vector<SchemaField>{}, schema_id_);
@@ -414,8 +398,9 @@ Result<std::unique_ptr<const Schema>> Schema::Project(
414398 return InvalidSchema (" Projected type must be a struct type" );
415399 }
416400
417- auto & projected_struct = internal::checked_cast<const StructType&>(*result);
418- return FromStructType (std::move (const_cast <StructType&>(projected_struct)), schema_id_);
401+ return FromStructType (std::move (const_cast <StructType&>(
402+ internal::checked_cast<const StructType&>(*result))),
403+ schema_id_);
419404}
420405
421406} // namespace iceberg
0 commit comments