Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
panbingkun committed Oct 14, 2024
1 parent c0eba3b commit fcf256a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static UTF8String schemaOfJson(
JsonFactory jsonFactory,
JSONOptions jsonOptions,
JsonInferSchema jsonInferSchema,
UTF8String json) throws IOException {
UTF8String json) {
DataType schema;
try (JsonParser jsonParser = CreateJacksonParser.utf8String(jsonFactory, json)) {
jsonParser.nextToken();
Expand All @@ -112,15 +112,17 @@ public static UTF8String schemaOfJson(
schema = canonicalType.isDefined() ?
canonicalType.get() : new StructType(new StructField[0]);
} else if (inferSchema instanceof ArrayType at && at.elementType() instanceof StructType et) {
Option<DataType> canonicalType = jsonInferSchema.canonicalizeType(et, jsonOptions).
map(dt -> ArrayType.apply(dt, at.containsNull()));
Option<DataType> canonicalType = jsonInferSchema.canonicalizeType(et, jsonOptions)
.map(dt -> ArrayType.apply(dt, at.containsNull()));
schema = canonicalType.isDefined() ? canonicalType.get() :
ArrayType.apply(new StructType(new StructField[0]), at.containsNull());
} else {
Option<DataType> canonicalType = jsonInferSchema.canonicalizeType(inferSchema, jsonOptions);
schema = canonicalType.isDefined() ?
canonicalType.get() : SQLConf.get().defaultStringType();
}
} catch (IOException e) {
throw new RuntimeException(e);
}

return UTF8String.fromString(schema.sql());
Expand Down

0 comments on commit fcf256a

Please sign in to comment.