static void setReadColumns ( Configuration conf , StructTypeInfo actualStructTypeInfo ) { StructTypeInfo readStructTypeInfo = getTypeInfo ( conf ) ; LOG . info ( "Read StructTypeInfo: {}" , readStructTypeInfo ) ; List < Integer > ids = new ArrayList <> ( ) ; List < String > names = new ArrayList <> ( ) ; List < String > readNames = readStructTypeInfo . getAllStructFieldNames ( ) ; List < String > actualNames = actualStructTypeInfo . getAllStructFieldNames ( ) ; for ( int i = 0 ; i < actualNames . size ( ) ; i ++ ) { String actualName = actualNames . get ( i ) ; if ( readNames . contains ( actualName ) ) { // make sure they are the same type TypeInfo actualTypeInfo = actualStructTypeInfo . getStructFieldTypeInfo ( actualName ) ; TypeInfo readTypeInfo = readStructTypeInfo . getStructFieldTypeInfo ( actualName ) ; if ( ! actualTypeInfo . equals ( readTypeInfo ) ) { throw new IllegalStateException ( "readTypeInfo [" + readTypeInfo + "] does not match actualTypeInfo [" + actualTypeInfo + "]" ) ; } // mark the column as to-be-read ids . add ( i ) ; names . add ( actualName ) ; } } if ( ids . size ( ) == 0 ) { throw new IllegalStateException ( "None of the selected columns were found in the ORC file." ) ; } LOG . info ( "Set column projection on columns: {} ({})" , ids , names ) ; ColumnProjectionUtils . appendReadColumns ( conf , ids , names ) ; }
Sets which fields are to be read from the ORC file