Java Code Examples for com.alibaba.druid.sql.parser.SQLExprParser

The following examples show how to use com.alibaba.druid.sql.parser.SQLExprParser. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dble   Source File: MySQLItemVisitor.java    License: GNU General Public License v2.0 5 votes vote down vote up
private CastType getCastType(String dataType) {
    SQLExprParser expr = new SQLExprParser(dataType);
    SQLDataType dataTypeImpl = expr.parseDataType();
    if (dataTypeImpl == null) {
        return null;
    }
    return getCastType((SQLDataTypeImpl) dataTypeImpl);
}
 
Example 2
Source Project: elasticsearch-sql   Source File: ESActionFactory.java    License: Apache License 2.0 5 votes vote down vote up
private static SQLExpr toSqlExpr(String sql) {
    SQLExprParser parser = new ElasticSqlExprParser(sql); //zhongshu-comment 这个SQLExprParser parser应该就是语法解析器
    SQLExpr expr = parser.expr(); //zhongshu-comment 这个expr应该就是解析sql之后得到的AST了

    //zhongshu-comment 调用parser.expr()方法解析完sql语句后,发现最后一个token不是End Of File的话,即该sql语句貌似是残缺的,可能是用户输入了一个未结束的sql
    if (parser.getLexer().token() != Token.EOF) {
        throw new ParserException("illegal sql expr : " + sql);
    }

    return expr;
}
 
Example 3
Source Project: Mycat2   Source File: MycatSelectParser.java    License: GNU General Public License v3.0 4 votes vote down vote up
public MycatSelectParser(SQLExprParser exprParser)
{
    super(exprParser);
}
 
Example 4
Source Project: elasticsearch-sql   Source File: ElasticSqlSelectParser.java    License: Apache License 2.0 4 votes vote down vote up
public ElasticSqlSelectParser(SQLExprParser exprParser) {
    super(exprParser);
}
 
Example 5
Source Project: elasticsearch-sql   Source File: ElasticSqlSelectParser.java    License: Apache License 2.0 4 votes vote down vote up
public ElasticSqlSelectParser(SQLExprParser exprParser, SQLSelectListCache selectListCache){
    super(exprParser, selectListCache);
}