apache/shardingsphere · error · UnsupportedSQLOperationException

30001

30001

Error message

Unsupported SQL operation: %s.

What it means

UnsupportedSQLOperationException (error code 30001) thrown by DistSQLProxyBackendHandlerFactory when a DistSQL statement is not an RQLStatement, RULStatement, RDLStatement, or RALStatement. The factory maps RQL/RUL and queryable RAL to DistSQLQueryProxyBackendHandler, RDL and non-queryable RAL to DistSQLUpdateProxyBackendHandler; anything else (a statement outside the DistSQL rule-*, resource-*, etc. families) is rejected.

Source

Thrown at proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLProxyBackendHandlerFactory.java:63

     * @param queryContext query context
     * @param connectionSession connection session
     * @return proxy backend handler
     * @throws UnsupportedSQLOperationException unsupported SQL operation exception
     */
    public static ProxyBackendHandler newInstance(final DistSQLStatement sqlStatement, final QueryContext queryContext, final ConnectionSession connectionSession) {
        ContextManager contextManager = ProxyContext.getInstance().getContextManager();
        if (sqlStatement instanceof RQLStatement || sqlStatement instanceof RULStatement) {
            return new DistSQLQueryProxyBackendHandler(sqlStatement, queryContext, connectionSession, contextManager);
        }
        if (sqlStatement instanceof RDLStatement) {
            return new DistSQLUpdateProxyBackendHandler(sqlStatement, queryContext, connectionSession, contextManager);
        }
        if (sqlStatement instanceof RALStatement) {
            return sqlStatement instanceof QueryableRALStatement
                    ? new DistSQLQueryProxyBackendHandler(sqlStatement, queryContext, connectionSession, contextManager)
                    : new DistSQLUpdateProxyBackendHandler(sqlStatement, queryContext, connectionSession, contextManager);
        }
        throw new UnsupportedSQLOperationException(sqlStatement.getClass().getName());
    }
}

View on GitHub (pinned to e952770a21)

Solutions

  1. Verify the statement class extends one of RQLStatement/RULStatement/RDLStatement/RALStatement (for RAL, also decide QueryableRALStatement vs not to pick query vs update handler)
  2. Re-check the DistSQL syntax against the version's documented grammar; unsupported/misspelled statements may parse into an unexpected type
  3. Upgrade shardingsphere modules together so new DistSQL types are recognized by the factory

Example fix

// before
class MyCustomStatement extends AbstractSQLStatement { }

// after
class MyCustomStatement extends RDLStatement { }
Defensive patterns

Strategy: type-guard

Type guard

private boolean isSupportedDistSQL(final SQLStatement stmt) {
    return stmt instanceof RQLStatement || stmt instanceof RULStatement
            || stmt instanceof RDLStatement || stmt instanceof RALStatement;
}

Try / catch

try {
    handler = DistSQLProxyBackendHandlerFactory.newInstance(sqlStatement, queryContext, connectionSession);
} catch (final UnsupportedSQLOperationException ex) {
    // not a DistSQL family statement: check grammar/keyword and correct the client statement
}

Prevention

When it happens

Trigger: Executing a DistSQL statement whose parsed type does not extend any of the four DistSQL base interfaces — e.g. a custom or newly added DistSQL grammar whose statement class was not made to extend RDLStatement/RQLStatement/RULStatement/RALStatement, or a non-DistSQL statement misrouted into the DistSQL frontend handler.

Common situations: Custom DistSQL extension where the statement class forgot to extend a base DistSQL interface; parser/feature version mismatch after upgrading one module; sending native SQL (SHOW DATABASES) down a path that assumed DistSQL.

Related errors


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