class ExpressionParser {

  public static SelectExpression parseSelectExpression(final String expressionText) {
    final SqlBaseParser.SelectItemContext parseCtx = GrammarParseUtil.getParseTree(
        expressionText,
        SqlBaseParser::selectItem
    );
    if (!(parseCtx instanceof SqlBaseParser.SelectSingleContext)) {
      throw new IllegalArgumentException("Illegal select item type in: " + expressionText);
    }
    final SqlBaseParser.SelectSingleContext selectSingleContext =
        (SqlBaseParser.SelectSingleContext) parseCtx;
    if (selectSingleContext.identifier() == null) {
      throw new IllegalArgumentException("Select item must have identifier in: " + expressionText);
    }
    return SelectExpression.of(
        ColumnName.of(ParserUtil.getIdentifierText(selectSingleContext.identifier())),
        new AstBuilder(TypeRegistry.EMPTY).buildExpression(selectSingleContext.expression())
    );
  }

  private  ExpressionParser();

}