apache/shardingsphere · error · SQLFeatureNotSupportedException

Get input stream from `%s`

Error message

Get input stream from `%s`

What it means

SQLFederationResultSet.getInputStream(String) throws SQLFeatureNotSupportedException('Get input stream from `<type>`') whenever a binary/ascii stream getter (getAsciiStream, getUnicodeStream, getBinaryStream) is called. The federation ResultSet does not implement stream-based column access, only object-based getters routed through get(columnIndex).

Source

Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSet.java:508

        return result;
    }
    
    private Object getValue(final int columnIndex, final Class<?> type) throws SQLException {
        ShardingSpherePreconditions.checkNotContains(INVALID_FEDERATION_TYPES, type, () -> new SQLFeatureNotSupportedException(String.format("Get value from `%s`", type.getName())));
        Object result = currentRows[columnIndex - 1];
        wasNull = null == result;
        return null == columnTypeConverter ? result : columnTypeConverter.convertColumnValue(result);
    }
    
    private Object getCalendarValue(final int columnIndex) {
        // TODO implement with calendar
        Object result = currentRows[columnIndex - 1];
        wasNull = null == result;
        return result;
    }
    
    private InputStream getInputStream(final String type) throws SQLException {
        throw new SQLFeatureNotSupportedException(String.format("Get input stream from `%s`", type));
    }
}

View on GitHub (pinned to e952770a21)

Solutions

  1. Use object getters instead: getBytes(col)/getBlob(col) for binary, getString(col)/getClob(col) for text, then wrap the value in a stream if needed.
  2. Rewrite the query so it is not routed through the federation engine when stream access is required.
  3. Disable or narrow sql_federation rules so only queries that truly need federation use it.
  4. In generic row-consumer code, detect SQLFeatureNotSupportedException from stream getters and retry with getBytes/getString.

Example fix

// before
try (InputStream in = rs.getBinaryStream("data")) { ... } // throws on federated rs

// after
byte[] data = rs.getBytes("data");
try (InputStream in = data == null ? null : new ByteArrayInputStream(data)) { ... }
Defensive patterns

Strategy: try-catch

Try / catch

try (InputStream in = rs.getBinaryStream(col)) { ... } catch (final SQLFeatureNotSupportedException ex) { byte[] data = rs.getBytes(col); /* proceed from byte[] */ }

Prevention

When it happens

Trigger: Calling rs.getAsciiStream(col), rs.getBinaryStream(col), or rs.getUnicodeStream(col) on the ResultSet of a federation query (e.g. streaming a BLOB/CLOB out of a federated join result). The `%s` in the message names the stream type that was requested.

Common situations: File-download servlets that stream BLOBs via getBinaryStream; MyBatis/BLOB handlers using stream getters; code that worked on non-federated sharding results or a native driver and broke once sql_federation kicked in for the query.

Related errors


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