{"record":{"id":"f674ea068bc57f61","repo":"apache/shardingsphere","slug":"can-not-find-shorthand-projection-segment-owner-i","errorCode":null,"errorMessage":"Can not find shorthand projection segment, owner is `%s`","messagePattern":"Can not find shorthand projection segment, owner is `(.+?)`","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGenerator.java","lineNumber":417,"sourceCode":"        encryptColumn.getLikeQuery().ifPresent(optional -> result.add(new ColumnProjection(columOwner,\n                new IdentifierValue(getDerivedColumnName(columnProjection, optional.getName(), EncryptDerivedColumnSuffix.LIKE_QUERY), quoteCharacter), null, databaseType,\n                leftParentheses, rightParentheses)));\n        return result;\n    }\n    \n    private ShorthandProjection getShorthandProjection(final ShorthandProjectionSegment segment, final ProjectionsContext projectionsContext) {\n        Optional<String> owner = segment.getOwner().isPresent() ? Optional.of(segment.getOwner().get().getIdentifier().getValue()) : Optional.empty();\n        for (Projection each : projectionsContext.getProjections()) {\n            if (each instanceof ShorthandProjection) {\n                if (!owner.isPresent() && !((ShorthandProjection) each).getOwner().isPresent()) {\n                    return (ShorthandProjection) each;\n                }\n                if (owner.isPresent() && owner.get().equals(((ShorthandProjection) each).getOwner().map(IdentifierValue::getValue).orElse(null))) {\n                    return (ShorthandProjection) each;\n                }\n            }\n        }\n        throw new IllegalStateException(String.format(\"Can not find shorthand projection segment, owner is `%s`\", owner.orElse(null)));\n    }\n}\n","sourceCodeStart":399,"sourceCodeEnd":420,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/projection/EncryptProjectionTokenGenerator.java#L399-L420","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.*`.","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"],"exampleFix":"-- before\nSELECT u.*, o.* FROM users usr JOIN orders o ON ...;  -- 'u' vs alias 'usr'\n-- after\nSELECT usr.*, o.* FROM users usr JOIN orders o ON ...;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (IllegalStateException e) { if (e.getMessage().contains(\"shorthand projection segment\")) { /* retry with unqualified * or explicit columns */ } }","preventionTips":["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"],"tags":["encrypt","projection","shorthand","internal-invariant"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}