Source:
static JsonDataConverter deduceRowType(RelDataTypeFactory typeFactory, Source source) { final ObjectMapper objectMapper = new ObjectMapper(); List<Object> list = new ArrayList<>(); LinkedHashMap<String, Object> jsonFieldMap = new LinkedHashMap<>(1); Object jsonObj = null; try { objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true) .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true) .configure(JsonParser.Feature.ALLOW_COMMENTS, true); jsonObj = objectMapper.readValue(source.reader(), Object.class); } catch (MismatchedInputException e) { if (!e.getMessage().contains("No content")) { throw new RuntimeException(e); } } catch (Exception e) { throw new RuntimeException(e); } if (jsonObj == null) { list = new ArrayList<>(); jsonFieldMap.put("EmptyFileHasNoColumns", Boolean.TRUE); } else if (jsonObj instanceof Collection) { list = (List<Object>) jsonObj; jsonFieldMap = (LinkedHashMap) (list.get(0)); } else if (jsonObj instanceof Map) { jsonFieldMap = (LinkedHashMap) jsonObj; list = new ArrayList(((LinkedHashMap) jsonObj).values()); } else { jsonFieldMap.put("line", jsonObj); list = new ArrayList<>(); list.add(0, jsonObj); } final List<RelDataType> types = new ArrayList<RelDataType>(jsonFieldMap.size()); final List<String> names = new ArrayList<String>(jsonFieldMap.size()); for (Object key : jsonFieldMap.keySet()) { final RelDataType type = typeFactory.createJavaType(jsonFieldMap.get(key).getClass()); names.add(key.toString()); types.add(type); } RelDataType relDataType = typeFactory.createStructType(Pair.zip(names, types)); return new JsonDataConverter(relDataType, list); }

Target:
static JsonDataConverter deduceRowType(RelDataTypeFactory typeFactory, Source source) { final ObjectMapper objectMapper = new ObjectMapper(); List<Object> list = new ArrayList<>(); LinkedHashMap<String, Object> jsonFieldMap = new LinkedHashMap<>(1); Object jsonObj = null; try { objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true) .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true) .configure(JsonParser.Feature.ALLOW_COMMENTS, true); if ("file".equals(source.protocol()) && source.file().exists()) { jsonObj = objectMapper.readValue(source.file(), Object.class); } else if (Arrays.asList("http", "https", "ftp").contains(source.protocol())) { jsonObj = objectMapper.readValue(source.url(), Object.class); } else { jsonObj = objectMapper.readValue(source.reader(), Object.class); } } catch (MismatchedInputException e) { if (!e.getMessage().contains("No content")) { throw new RuntimeException("Couldn't read " + source, e); } } catch (Exception e) { throw new RuntimeException("Couldn't read " + source, e); } if (jsonObj == null) { list = new ArrayList<>(); jsonFieldMap.put("EmptyFileHasNoColumns", Boolean.TRUE); } else if (jsonObj instanceof Collection) { list = (List<Object>) jsonObj; jsonFieldMap = (LinkedHashMap) (list.get(0)); } else if (jsonObj instanceof Map) { jsonFieldMap = (LinkedHashMap) jsonObj; list = new ArrayList(((LinkedHashMap) jsonObj).values()); } else { jsonFieldMap.put("line", jsonObj); list = new ArrayList<>(); list.add(0, jsonObj); } final List<RelDataType> types = new ArrayList<RelDataType>(jsonFieldMap.size()); final List<String> names = new ArrayList<String>(jsonFieldMap.size()); for (Object key : jsonFieldMap.keySet()) { final RelDataType type = typeFactory.createJavaType(jsonFieldMap.get(key).getClass()); names.add(key.toString()); types.add(type); } RelDataType relDataType = typeFactory.createStructType(Pair.zip(names, types)); return new JsonDataConverter(relDataType, list); }