@@ -425,7 +425,9 @@ void SelectiveStructColumnReaderBase::read(
425425 }
426426
427427 const auto & childSpecs = scanSpec_->children ();
428- VELOX_CHECK (!childSpecs.empty ());
428+ if (!columnReaderOptions_.useColumnNamesForColumnMapping_ ) {
429+ VELOX_CHECK (!childSpecs.empty ());
430+ }
429431 for (size_t i = 0 ; i < childSpecs.size (); ++i) {
430432 const auto & childSpec = childSpecs[i];
431433
@@ -524,9 +526,12 @@ bool SelectiveStructColumnReaderBase::isChildMissing(
524526 // row type that doesn't exist
525527 // in the output.
526528 fileType_->type ()->kind () !=
527- TypeKind::MAP && // If this is the case it means this is a flat map,
528- // so it can't have "missing" fields.
529- childSpec.channel () >= fileType_->size ());
529+ TypeKind::MAP // If this is the case it means this is a flat map,
530+ // so it can't have "missing" fields.
531+ ) &&
532+ (columnReaderOptions_.useColumnNamesForColumnMapping_
533+ ? !asRowType (fileType_->type ())->containsChild (childSpec.fieldName ())
534+ : childSpec.channel () >= fileType_->size ());
530535}
531536
532537std::unique_ptr<velox::dwio::common::ColumnLoader>
@@ -538,7 +543,9 @@ SelectiveStructColumnReaderBase::makeColumnLoader(vector_size_t index) {
538543void SelectiveStructColumnReaderBase::getValues (
539544 const RowSet& rows,
540545 VectorPtr* result) {
541- VELOX_CHECK (!scanSpec_->children ().empty ());
546+ if (!columnReaderOptions_.useColumnNamesForColumnMapping_ ) {
547+ VELOX_CHECK (!scanSpec_->children ().empty ());
548+ }
542549 VELOX_CHECK_NOT_NULL (
543550 *result, " SelectiveStructColumnReaderBase expects a non-null result" );
544551 VELOX_CHECK (
0 commit comments