String schemaUrlString = table.getProperty(AVRO_SCHEMA_URL_PROPERTY_NAME);
if (schemaUrlString != null) {
try {
builder.schemaUri(new URI(schemaUrlString));
} catch (IOException e) {
throw new MetadataProviderException("Could not read schema", e);
} catch (URISyntaxException e) {
// this library sets the URI, so it should always be valid
throw new MetadataProviderException("[BUG] Invalid schema URI", e);
}
}
String schemaLiteral = table.getProperty(AVRO_SCHEMA_LITERAL_PROPERTY_NAME);
if (schemaLiteral != null) {
builder.schemaLiteral(schemaLiteral);
}
try {
return builder.build();
} catch (IllegalStateException ex) {
throw new MetadataProviderException("Cannot find schema: missing metadata");
}
}