saihemanth-cloudera commented on code in PR #6549:
URL: https://github.com/apache/hive/pull/6549#discussion_r3546257070
##########
serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java:
##########
@@ -137,12 +141,28 @@ public static Schema
determineSchemaOrThrowException(Configuration conf, Propert
throw new AvroSerdeException(EXCEPTION_MESSAGE);
}
+ validateSchemaUrl(schemaString, conf);
+
try {
- Schema s = getSchemaFromFS(schemaString, conf);
- if (s == null) {
- //in case schema is not a file system
- return AvroSerdeUtils.getSchemaFor(new URL(schemaString));
+ Schema s;
+ if (requiresHttpFetch(schemaString)) {
+ URL url = new URL(schemaString);
+ java.net.URLConnection conn = url.openConnection();
+ if (conn instanceof java.net.HttpURLConnection) {
+ ((java.net.HttpURLConnection)
conn).setInstanceFollowRedirects(false);
+ }
+ try (InputStream in = conn.getInputStream()) {
+ s = getSchemaParser().parse(in);
+ }
+ } else {
+ s = getSchemaFromFS(schemaString, conf);
+ if (s == null) {
+ throw new AvroSerdeException("Unable to read Avro schema from: " +
schemaString
+ + ". avro.schema.url must refer to a Hadoop FileSystem URI (e.g.
hdfs://, s3a://). "
+ + "Consider using avro.schema.literal instead.");
+ }
}
+ materializeResolvedSchema(properties, conf, s);
Review Comment:
My thought was to do a small optimization to write the resolved schema into
avro.schema.literal and avro.serde.schema after fetching from avro.schema.url,
so downstream callers wouldn’t re-fetch. But I just realized
AvroSerDe.initialize() already does this after calling
determineSchemaOrThrowException.
So, I'm reverting this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]