Bug fix: JDBC driver throws null pointer exception when metric columns are not present in Schema
Currently, JDBC driver assumed metric columns are mandatory in schema which is not the case in pinot.
This PR implements a simple null check so that exceptions are not thrown when metric columns are not present.
@@ -159,20 +159,26 @@ public class PinotConnectionMetaData extends AbstractBaseConnectionMetaData {
String tableName = schemaResponse.getSchemaName();
int ordinalPosition = 1;
+ if (schemaResponse.getDimensions() != null) {
for (JsonNode columns : schemaResponse.getDimensions()) {
appendColumnMeta(pinotMeta, tableName, ordinalPosition, columns);
ordinalPosition++;
}
+ }
+ if (schemaResponse.getMetrics() != null) {
for (JsonNode columns : schemaResponse.getMetrics()) {
appendColumnMeta(pinotMeta, tableName, ordinalPosition, columns);
ordinalPosition++;
}
+ }
+ if (schemaResponse.getDateTimeFieldSpecs() != null) {
for (JsonNode columns : schemaResponse.getDateTimeFieldSpecs()) {
appendColumnMeta(pinotMeta, tableName, ordinalPosition, columns);
ordinalPosition++;
}
+ }
JsonNode resultTable = OBJECT_MAPPER.valueToTree(pinotMeta);
return PinotResultSet.fromResultTable(new ResultTableResultSet(resultTable));
