diff --git a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java index e7f5159e8751..62d5b786dd47 100755 --- a/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java +++ b/plugin/trino-pinot/src/main/java/io/trino/plugin/pinot/client/PinotClient.java @@ -499,7 +499,8 @@ public static ResultsIterator fromResultTable(BrokerResponseNative brokerRespons int[] indices = new int[columnNames.length]; int[] inverseIndices = new int[columnNames.length]; for (int i = 0; i < columnHandles.size(); i++) { - indices[i] = columnIndices.get(columnHandles.get(i).getColumnName().toLowerCase(ENGLISH)); + String columnName = columnHandles.get(i).getColumnName().toLowerCase(ENGLISH); + indices[i] = requireNonNull(columnIndices.get(columnName), format("column index for '%s' was not found", columnName)); inverseIndices[indices[i]] = i; } List rows = resultTable.getRows(); diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotIntegrationSmokeTest.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotIntegrationSmokeTest.java index c3aa7d6be8cc..3593f269dddb 100644 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotIntegrationSmokeTest.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestPinotIntegrationSmokeTest.java @@ -1603,7 +1603,7 @@ public void testPassthroughQueriesWithPushdowns() " FROM " + ALL_TYPES_TABLE + " WHERE string_col IS NOT null AND string_col != 'array_null'\"")) .withRootCauseInstanceOf(RuntimeException.class) - .withMessage("java.lang.NullPointerException"); + .withMessage("column index for 'int_col2' was not found"); assertThat(query("SELECT int_col2, count(*) FROM " + "\"SELECT int_col AS int_col2, long_col AS long_col2" +