private void checkAndLearnSchema(){
if (mutator.isSchemaChanged()) {
outgoing.buildSchema(SelectionVectorMode.NONE);
final BatchSchema newSchema = mutator.transformFunction.apply(outgoing.getSchema());
if (config.mayLearnSchema() && tableSchemaPath != null) {
try {
schemaUpdater.observedSchemaChange(tableSchemaPath, config.getSchema(), newSchema, currentReader.getSchemaChangeMutator());
} catch(Exception ex){
throw UserException.schemaChangeError(ex)
.addContext("Original schema", config.getSchema())
.addContext("New schema", newSchema)
.message("Schema change detected but unable to learn schema, query failed. A full table scan may be necessary to fully learn the schema.")
.build(logger);
}
throw UserException.schemaChangeError()
.addContext("Original Schema", config.getSchema().toString())
.addContext("New Schema", newSchema.toString())
.message("New schema found and recorded. Please reattempt the query. Multiple attempts may be necessary to fully learn the schema.").build(logger);
} else {
throw UserException.schemaChangeError().message("Schema change detected but unable to learn schema, query failed. Original: %s, New: %s.", config.getSchema(), newSchema).build(logger);
}
}
}