Source:
private boolean resolveAsAlias() { final String alias = getText(); final FromElement element = getWalker().getCurrentFromClause().getFromElement( alias ); if ( element == null ) { return false; } element.applyTreatAsDeclarations( getWalker().getTreatAsDeclarationsByPath( alias ) ); setType( SqlTokenTypes.ALIAS_REF ); setFromElement( element ); String[] columnExpressions = element.getIdentityColumns(); final Dialect dialect = getWalker().getSessionFactoryHelper().getFactory().getDialect(); final boolean isInCount = getWalker().isInCount(); final boolean isInDistinctCount = isInCount && getWalker().isInCountDistinct(); final boolean isInNonDistinctCount = isInCount && ! getWalker().isInCountDistinct(); final boolean isCompositeValue = columnExpressions.length > 1; if ( isCompositeValue ) { if ( isInNonDistinctCount && ! dialect.supportsTupleCounts() ) { setText( columnExpressions[0] ); } else { String joinedFragment = String.join( ", ", columnExpressions ); final boolean shouldSkipWrappingInParenthesis = (isInDistinctCount && ! dialect.requiresParensForTupleDistinctCounts()) || isInNonDistinctCount || getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.ORDER || getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.GROUP; if ( ! shouldSkipWrappingInParenthesis ) { joinedFragment = "(" + joinedFragment + ")"; } setText( joinedFragment ); } return true; } else if ( columnExpressions.length > 0 ) { setText( columnExpressions[0] ); return true; } return false; }

Target:
private boolean resolveAsAlias() { final String alias = getText(); final FromElement element = getWalker().getCurrentFromClause().getFromElement( alias ); if ( element == null ) { return false; } element.applyTreatAsDeclarations( getWalker().getTreatAsDeclarationsByPath( alias ) ); setType( SqlTokenTypes.ALIAS_REF ); setFromElement( element ); String[] columnExpressions = element.getIdentityColumns(); if ( ! isFromElementUpdateOrDeleteRoot( element ) ) { if ( StringHelper.isNotEmpty( element.getTableAlias() ) ) { columnExpressions = StringHelper.qualifyIfNot( element.getTableAlias(), columnExpressions ); } } final Dialect dialect = getWalker().getSessionFactoryHelper().getFactory().getDialect(); final boolean isInCount = getWalker().isInCount(); final boolean isInDistinctCount = isInCount && getWalker().isInCountDistinct(); final boolean isInNonDistinctCount = isInCount && ! getWalker().isInCountDistinct(); final boolean isCompositeValue = columnExpressions.length > 1; if ( isCompositeValue ) { if ( isInNonDistinctCount && ! dialect.supportsTupleCounts() ) { setText( columnExpressions[0] ); } else { String joinedFragment = String.join( ", ", columnExpressions ); final boolean shouldSkipWrappingInParenthesis = (isInDistinctCount && ! dialect.requiresParensForTupleDistinctCounts()) || isInNonDistinctCount || getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.ORDER || getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.GROUP; if ( ! shouldSkipWrappingInParenthesis ) { joinedFragment = "(" + joinedFragment + ")"; } setText( joinedFragment ); } return true; } else if ( columnExpressions.length > 0 ) { setText( columnExpressions[0] ); return true; } return false; }