prestodb/presto · error · SQLException

Invalid column index:

Error message

Invalid column index: 

What it means

In the private column(index) accessor, checkOpen() and checkValidRow() run first, then the 1-based index is bounds-checked against the column count; out-of-range values (<=0 or greater than getColumnCount()) throw this SQLException. It is a bounds-validation error caused by an invalid column index argument.

Source

Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java:1677

            throw new SQLException("ResultSet is closed");
        }
    }

    private void checkValidRow()
            throws SQLException
    {
        if (row.get() == null) {
            throw new SQLException("Not on a valid row");
        }
    }

    private Object column(int index)
            throws SQLException
    {
        checkOpen();
        checkValidRow();
        if ((index <= 0) || (index > resultSetMetaData.getColumnCount())) {
            throw new SQLException("Invalid column index: " + index);
        }
        Object value = row.get().get(index - 1);
        wasNull.set(value == null);
        return value;
    }

    private ColumnInfo columnInfo(int index)
            throws SQLException
    {
        checkOpen();
        checkValidRow();
        if ((index <= 0) || (index > columnInfoList.size())) {
            throw new SQLException("Invalid column index: " + index);
        }
        return columnInfoList.get(index - 1);
    }

    private Object column(String label)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use valid 1-based indices from 1 through ResultSetMetaData.getColumnCount()
  2. Derive indices from getFindColumn/getColumnCount rather than hard-coding
  3. Catch SQLException for dynamic column access paths and validate index first
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java:1677 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/34fe78fa097ec0d0. Report an issue: GitHub.