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

The following examples show how to use com.alibaba.druid.sql.parser.SQLExprParser. 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 File: MySQLItemVisitor.java    From dble with 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 File: ESActionFactory.java    From elasticsearch-sql with 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 File: MycatSelectParser.java    From Mycat2 with GNU General Public License v3.0 4 votes vote down vote up
public MycatSelectParser(SQLExprParser exprParser)
{
    super(exprParser);
}
 
Example #4
Source File: ElasticSqlSelectParser.java    From elasticsearch-sql with Apache License 2.0 4 votes vote down vote up
public ElasticSqlSelectParser(SQLExprParser exprParser) {
    super(exprParser);
}
 
Example #5
Source File: ElasticSqlSelectParser.java    From elasticsearch-sql with Apache License 2.0 4 votes vote down vote up
public ElasticSqlSelectParser(SQLExprParser exprParser, SQLSelectListCache selectListCache){
    super(exprParser, selectListCache);
}