apache/shardingsphere · error · IllegalStateException
Can not find shorthand projection segment, owner is `%s`
Error message
Can not find shorthand projection segment, owner is `%s`
What it means
EncryptProjectionTokenGenerator.getShorthandProjection locates the ShorthandProjection in the built ProjectionsContext matching the owner of a ShorthandProjectionSegment (for `t.*` or `*` expansion). If no matching projection is found, IllegalStateException is thrown with the owner name — an internal invariant break between the parsed segment and the projections context, not a user SQL syntax error.
Source
Thrown at features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGenerator.java:417
encryptColumn.getLikeQuery().ifPresent(optional -> result.add(new ColumnProjection(columOwner,
new IdentifierValue(getDerivedColumnName(columnProjection, optional.getName(), EncryptDerivedColumnSuffix.LIKE_QUERY), quoteCharacter), null, databaseType,
leftParentheses, rightParentheses)));
return result;
}
private ShorthandProjection getShorthandProjection(final ShorthandProjectionSegment segment, final ProjectionsContext projectionsContext) {
Optional<String> owner = segment.getOwner().isPresent() ? Optional.of(segment.getOwner().get().getIdentifier().getValue()) : Optional.empty();
for (Projection each : projectionsContext.getProjections()) {
if (each instanceof ShorthandProjection) {
if (!owner.isPresent() && !((ShorthandProjection) each).getOwner().isPresent()) {
return (ShorthandProjection) each;
}
if (owner.isPresent() && owner.get().equals(((ShorthandProjection) each).getOwner().map(IdentifierValue::getValue).orElse(null))) {
return (ShorthandProjection) each;
}
}
}
throw new IllegalStateException(String.format("Can not find shorthand projection segment, owner is `%s`", owner.orElse(null)));
}
}
View on GitHub (pinned to e952770a21)
Solutions
- Align the shorthand owner with the actual table name or alias used elsewhere in the query (same case and quoting)
- Prefer unqualified `*` or explicit column lists for encrypted tables if owner matching keeps failing
- Upgrade ShardingSphere — owner-matching normalization bugs in projection rewrite are fixed over time
- Report with the exact SQL if a minimal reproducible query triggers it on current version
Example fix
-- before SELECT u.*, o.* FROM users usr JOIN orders o ON ...; -- 'u' vs alias 'usr' -- after SELECT usr.*, o.* FROM users usr JOIN orders o ON ...;
Defensive patterns
Strategy: try-catch
Try / catch
catch (IllegalStateException e) { if (e.getMessage().contains("shorthand projection segment")) { /* retry with unqualified * or explicit columns */ } } Prevention
- Match shorthand owners exactly with table aliases (case and quoting)
- Prefer explicit column lists or bare * on encrypted tables
- Report reproducible minimal SQL upstream; this is an internal invariant break
When it happens
Trigger: Rewriting a query containing `owner.*` where the projections context's shorthand projection owner differs — e.g. owner case/quoting mismatch ('T' vs 't', quoted vs unquoted identifier), an alias-vs-table-name mismatch, or a parser/context construction that dropped the shorthand projection.
Common situations: Queries mixing `alias.*` with table aliases; case-sensitive identifier handling across dialects; version changes in how projections contexts normalize owners; schema-qualified shorthand like `schema.t.*`.
Related errors
- Projections not in simple select, table subquery, join subqu
- Algorithm `%s` is unsupported to decrypt
- Row expression can only compare with subquery
- Can not use different encryptor for %s and %s in %s
- Failed to decrypt the ciphertext '%s' in '%s'.
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/f674ea068bc57f61.
Report an issue: GitHub.