apache/shardingsphere · error · SQLFeatureNotSupportedException

Get input stream from `%s`

Error message

Get input stream from `%s`

What it means

MemoryMergedResult is the in-memory merge engine used for results that must be fully materialized and merged in ShardingSphere memory (e.g. GROUP BY, aggregate, pagination over merged rows). getInputStream(columnIndex, type) throws SQLFeatureNotSupportedException naming the requested stream type, because materialized memory rows cannot serve binary streams.

Source

Thrown at infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/memory/MemoryMergedResult.java:93

    @Override
    public final Object getValue(final int columnIndex, final Class<?> type) throws SQLException {
        ShardingSpherePreconditions.checkNotContains(INVALID_MEMORY_TYPES, type, () -> new SQLFeatureNotSupportedException(String.format("Get value from `%s`", type.getName())));
        Object result = currentResultSetRow.getCell(columnIndex);
        wasNull = null == result;
        return result;
    }
    
    @Override
    public final Object getCalendarValue(final int columnIndex, final Class<?> type, @SuppressWarnings("UseOfObsoleteDateTimeApi") final Calendar calendar) {
        // TODO implement with calendar
        Object result = currentResultSetRow.getCell(columnIndex);
        wasNull = null == result;
        return result;
    }
    
    @Override
    public final InputStream getInputStream(final int columnIndex, final String type) throws SQLException {
        throw new SQLFeatureNotSupportedException(String.format("Get input stream from `%s`", type));
    }
    
    @Override
    public Reader getCharacterStream(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("Get Character stream");
    }
    
    @Override
    public final boolean wasNull() {
        return wasNull;
    }
}

View on GitHub (pinned to e952770a21)

Solutions

  1. Read the column with rs.getBytes(i) or rs.getObject(i) instead of stream APIs for memory-merged results.
  2. Restructure the query so LOB columns are fetched in a separate statement without merge-triggering clauses.
  3. Catch SQLFeatureNotSupportedException and retry the read with getBytes.

Example fix

// before
InputStream blob = resultSet.getBinaryStream(3);

// after
byte[] blob = resultSet.getBytes(3);
Defensive patterns

Strategy: fallback

Try / catch

try (InputStream in = rs.getBinaryStream(i)) { ... } catch (SQLFeatureNotSupportedException e) { byte[] data = rs.getBytes(i); ... }

Prevention

When it happens

Trigger: Calling rs.getBinaryStream(i) / getAsciiStream(i) on a query whose results were merged in memory — any SELECT with aggregation, ORDER BY across shards, or LIMIT/OFFSET rewriting that routes to MemoryMergedResult.

Common situations: LOB-reading utility code applied uniformly to all result sets; queries that unexpectedly qualify for memory merge after adding GROUP BY/ORDER BY; migrations from single-DB drivers where getBinaryStream on BLOB columns worked.

Related errors


AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14). Data as JSON: /api/errors/0beef9529ea612ce. Report an issue: GitHub.