@@ -425,7 +425,9 @@ void SelectiveStructColumnReaderBase::read(
425425 }
426426
427427 const auto & childSpecs = scanSpec_->children ();
428- VELOX_CHECK (!childSpecs.empty ());
428+ if (!columnReaderOptions_.allowEnhancedSchemaEvolution_ ) {
429+ VELOX_CHECK (!childSpecs.empty ());
430+ }
429431 for (size_t i = 0 ; i < childSpecs.size (); ++i) {
430432 const auto & childSpec = childSpecs[i];
431433
@@ -512,6 +514,9 @@ void SelectiveStructColumnReaderBase::recordParentNullsInChildren(
512514
513515bool SelectiveStructColumnReaderBase::isChildMissing (
514516 const velox::common::ScanSpec& childSpec) const {
517+ bool enhancedSchemaEvolutionByName =
518+ columnReaderOptions_.useColumnNamesForColumnMapping_ &&
519+ columnReaderOptions_.allowEnhancedSchemaEvolution_ ;
515520 return
516521 // The below check is trying to determine if this is a missing field in a
517522 // struct that should be constant null.
@@ -524,9 +529,12 @@ bool SelectiveStructColumnReaderBase::isChildMissing(
524529 // row type that doesn't exist
525530 // in the output.
526531 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 ());
532+ TypeKind::MAP // If this is the case it means this is a flat map,
533+ // so it can't have "missing" fields.
534+ ) &&
535+ (enhancedSchemaEvolutionByName
536+ ? !asRowType (fileType_->type ())->containsChild (childSpec.fieldName ())
537+ : childSpec.channel () >= fileType_->size ());
530538}
531539
532540std::unique_ptr<velox::dwio::common::ColumnLoader>
@@ -538,7 +546,9 @@ SelectiveStructColumnReaderBase::makeColumnLoader(vector_size_t index) {
538546void SelectiveStructColumnReaderBase::getValues (
539547 const RowSet& rows,
540548 VectorPtr* result) {
541- VELOX_CHECK (!scanSpec_->children ().empty ());
549+ if (!columnReaderOptions_.allowEnhancedSchemaEvolution_ ) {
550+ VELOX_CHECK (!scanSpec_->children ().empty ());
551+ }
542552 VELOX_CHECK_NOT_NULL (
543553 *result, " SelectiveStructColumnReaderBase expects a non-null result" );
544554 VELOX_CHECK (
0 commit comments