apache/shardingsphere · error · IllegalStateException

Unsupported type: %s

Error message

Unsupported type: %s

What it means

InsertValue.getItemValue is an internal rewrite-engine invariant: every item inside a rewritten INSERT values tuple must be either an ExpressionSegment (parsed SQL expression) or a SQLToken (rewritten token). If an object of any other class ends up in the value items, the rewriter throws IllegalStateException naming the offending class. This is not a user-configuration error — it indicates a parser/rewriter mismatch or an unsupported INSERT form inside ShardingSphere itself.

Source

Thrown at infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/InsertValue.java:101

    
    private void getAddedItems(final int index, final StringJoiner joiner) {
        Collection<Object> currentAddedItems = orderedAddedItems.get(index);
        if (null == currentAddedItems) {
            return;
        }
        for (Object each : currentAddedItems) {
            joiner.add(getItemValue(each));
        }
    }
    
    private String getItemValue(final Object value) {
        if (value instanceof ExpressionSegment) {
            return doGetValue((ExpressionSegment) value);
        }
        if (value instanceof SQLToken) {
            return value.toString();
        }
        throw new IllegalStateException("Unsupported type: " + value.getClass().getName());
    }
    
    /**
     * Get value.
     *
     * @param index index
     * @return value
     */
    public String getValue(final int index) {
        SQLToken substitutedSQLToken = substitutedSQLTokens.get(index);
        return null == substitutedSQLToken ? doGetValue(values.get(index)) : substitutedSQLToken.toString();
    }
    
    private String doGetValue(final ExpressionSegment expressionSegment) {
        if (expressionSegment instanceof ParameterMarkerExpressionSegment) {
            ParameterMarkerExpressionSegment segment = (ParameterMarkerExpressionSegment) expressionSegment;
            return ParameterMarkerType.QUESTION == segment.getParameterMarkerType() ? "?" : "$" + (segment.getParameterMarkerIndex() + 1);
        }

View on GitHub (pinned to e952770a21)

Solutions

  1. Upgrade (or pin) ShardingSphere to a version where parser and rewriter are aligned — check the release notes/GitHub issues for the offending class name in the message.
  2. Simplify the INSERT to the plain VALUES (...) form and add exotic expressions via separate statements.
  3. If it comes from your own extension code feeding InsertValue, ensure every item you add is an ExpressionSegment or SQLToken.

Example fix

// before
INSERT INTO t_order (id, remark) VALUES (NEXTVAL('seq'), DEFAULT); // dialect-specific DEFAULT trips the rewriter

// after
INSERT INTO t_order (id, remark) VALUES (?, ?); // supply DEFAULT/sequence semantics via parameters or plain values
Defensive patterns

Strategy: try-catch

Try / catch

try { rewriteContext.insertValue(...) } catch (IllegalStateException e) { /* parser/rewriter mismatch: capture SQL + version, report upstream */ }

Prevention

When it happens

Trigger: Executing INSERT statements with unusual value forms (special parameter markers, dialect-specific defaults, function expressions, multi-value inserts) that make a dialect parser or extension put a non-segment, non-token object into the values list; custom code constructing InsertValue with arbitrary objects.

Common situations: Upgrading ShardingSphere to a version whose parser produces new segment types the rewriter does not recognize; using a less common dialect's INSERT syntax; plugins/extensions that inject custom value objects during rewriting.

Related errors


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