本文整理汇总了Java中com.alibaba.druid.sql.ast.statement.SQLTableSource类的典型用法代码示例。如果您正苦于以下问题:Java SQLTableSource类的具体用法?Java SQLTableSource怎么用?Java SQLTableSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLTableSource类属于com.alibaba.druid.sql.ast.statement包,在下文中一共展示了SQLTableSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parser
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
public void parser(){
masterTable="";
SQLTableSource table=mysqlQuery.getFrom();
parserTable(table,tableFilter,false);
parserFields(mysqlQuery.getSelectList());
parserMasterTable();
parserWhere(mysqlQuery.getWhere(),"");
// getJoinField();
parserOrderBy(mysqlQuery.getOrderBy());
parserLimit();
// LOGGER.info("field "+fieldAliasMap);
// LOGGER.info("master "+masterTable);
// LOGGER.info("join Lkey "+getJoinLkey());
// LOGGER.info("join Rkey "+getJoinRkey());
LOGGER.info("SQL: "+this.stmt);
}
示例2: parserTable
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
private void parserTable(SQLTableSource table,TableFilter tFilter,boolean isOutJoin){
if(table instanceof SQLJoinTableSource){
SQLJoinTableSource table1=(SQLJoinTableSource)table;
joinType=table1.getJoinType().toString();
if ((table1.getJoinType()==JoinType.COMMA)||(table1.getJoinType()==JoinType.JOIN)||(table1.getJoinType()==JoinType.INNER_JOIN)
||(table1.getJoinType()==JoinType.LEFT_OUTER_JOIN)) {
tFilter=setTableFilter(tFilter,getTableFilter(table1.getLeft(),isOutJoin));
if (tableFilter==null){
tableFilter=tFilter;
}
}
//parserTable(table1.getLeft()); //SQLExprTableSource
parserTable(table1.getRight(),tFilter,true);
SQLExpr expr=table1.getCondition();//SQLBinaryOpExpr
parserJoinKey(expr);
}
else {
tFilter=setTableFilter(tFilter,getTableFilter(table,isOutJoin));
LOGGER.info("table "+table.toString() +" Alias:"+table.getAlias()+" Hints:"+table.getHints());
}
}
示例3: parseLateralView
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
protected SQLTableSource parseLateralView(SQLTableSource tableSource) {
accept(Token.VIEW);
if ("LATERAL".equalsIgnoreCase(tableSource.getAlias())) {
tableSource.setAlias(null);
}
OdpsLateralViewTableSource lateralViewTabSrc = new OdpsLateralViewTableSource();
lateralViewTabSrc.setTableSource(tableSource);
SQLMethodInvokeExpr udtf = (SQLMethodInvokeExpr) this.exprParser.expr();
lateralViewTabSrc.setMethod(udtf);
String alias = as();
lateralViewTabSrc.setAlias(alias);
accept(Token.AS);
this.exprParser.names(lateralViewTabSrc.getColumns());
return parseTableSourceRest(lateralViewTabSrc);
}
示例4: findTableSource
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
public SQLTableSource findTableSource(long alias_hash) {
long hash = this.aliasHashCode64();
if (hash != 0 && hash == alias_hash) {
return this;
}
for (SQLName column : columns) {
if (column.nameHashCode64() == alias_hash) {
return this;
}
}
if (tableSource != null) {
return tableSource.findTableSource(alias_hash);
}
return null;
}
示例5: isFromJoinOrUnionTable
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
public static boolean isFromJoinOrUnionTable(SQLExpr expr) {
SQLObject temp = expr;
AtomicInteger counter = new AtomicInteger(10);
while (temp != null &&
!(expr instanceof SQLSelectQueryBlock) &&
!(expr instanceof SQLJoinTableSource) && !(expr instanceof SQLUnionQuery) && counter.get() > 0) {
counter.decrementAndGet();
temp = temp.getParent();
if (temp instanceof SQLSelectQueryBlock) {
SQLTableSource from = ((SQLSelectQueryBlock) temp).getFrom();
if (from instanceof SQLJoinTableSource || from instanceof SQLUnionQuery) {
return true;
}
}
if (temp instanceof SQLJoinTableSource || temp instanceof SQLUnionQuery) {
return true;
}
}
return false;
}
示例6: isSupportSelect
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
private static boolean isSupportSelect(String stmt) {
SQLStatementParser parser = new MySqlStatementParser(stmt);
SQLStatement statement = parser.parseStatement();
if (!(statement instanceof SQLSelectStatement)) {
return false;
}
SQLSelectQuery sqlSelectQuery = ((SQLSelectStatement) statement).getSelect().getQuery();
if (!(sqlSelectQuery instanceof MySqlSelectQueryBlock)) {
return false;
}
MySqlSelectQueryBlock selectQueryBlock = (MySqlSelectQueryBlock) sqlSelectQuery;
SQLTableSource mysqlFrom = selectQueryBlock.getFrom();
if (mysqlFrom != null) {
return false;
}
for (SQLSelectItem item : selectQueryBlock.getSelectList()) {
SQLExpr selectItem = item.getExpr();
if (!isVariantRef(selectItem)) {
return false;
}
}
return true;
}
示例7: visitorParse
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
@Override
public SchemaConfig visitorParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt,
ServerSchemaStatVisitor visitor, ServerConnection sc) throws SQLException {
SQLCreateIndexStatement createStmt = (SQLCreateIndexStatement) stmt;
SQLTableSource tableSource = createStmt.getTable();
if (tableSource instanceof SQLExprTableSource) {
String schemaName = schema == null ? null : schema.getName();
SchemaInfo schemaInfo = SchemaUtil.getSchemaInfo(sc.getUser(), schemaName, (SQLExprTableSource) tableSource);
String statement = RouterUtil.removeSchema(rrs.getStatement(), schemaInfo.getSchema());
rrs.setStatement(statement);
if (RouterUtil.isNoSharding(schemaInfo.getSchemaConfig(), schemaInfo.getTable())) {
RouterUtil.routeToSingleDDLNode(schemaInfo, rrs);
return schemaInfo.getSchemaConfig();
}
RouterUtil.routeToDDLNode(schemaInfo, rrs);
return schemaInfo.getSchemaConfig();
} else {
String msg = "The DDL is not supported, sql:" + stmt;
throw new SQLNonTransientException(msg);
}
}
示例8: getTableFilter
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
private TableFilter getTableFilter(SQLTableSource table,boolean isOutJoin){
String key ;
String value = table.toString().trim();
if (table.getAlias()==null) {
key=value;
}
else {
key = table.getAlias().trim();
}
return new TableFilter(value,key,isOutJoin);
}
示例9: getDisTable
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
private SQLExprTableSource getDisTable(SQLTableSource tableSource,RouteResultsetNode node) throws SQLSyntaxErrorException{
if(node.getSubTableName()==null){
String msg = " sub table not exists for " + node.getName() + " on " + tableSource;
LOGGER.error("DruidMycatRouteStrategyError " + msg);
throw new SQLSyntaxErrorException(msg);
}
SQLIdentifierExpr sqlIdentifierExpr = new SQLIdentifierExpr();
sqlIdentifierExpr.setParent(tableSource.getParent());
sqlIdentifierExpr.setName(node.getSubTableName());
SQLExprTableSource from2 = new SQLExprTableSource(sqlIdentifierExpr);
return from2;
}
示例10: parseTableSourceRest
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
if (lexer.token() == Token.AS && tableSource instanceof SQLExprTableSource) {
lexer.nextToken();
String alias = null;
if (lexer.token() == Token.IDENTIFIER) {
alias = lexer.stringVal();
lexer.nextToken();
}
if (lexer.token() == Token.LPAREN) {
SQLExprTableSource exprTableSource = (SQLExprTableSource) tableSource;
PGFunctionTableSource functionTableSource = new PGFunctionTableSource(exprTableSource.getExpr());
if (alias != null) {
functionTableSource.setAlias(alias);
}
lexer.nextToken();
parserParameters(functionTableSource.getParameters());
accept(Token.RPAREN);
return super.parseTableSourceRest(functionTableSource);
}
if (alias != null) {
tableSource.setAlias(alias);
return super.parseTableSourceRest(tableSource);
}
}
return super.parseTableSourceRest(tableSource);
}
示例11: parseTableSource
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
public SQLTableSource parseTableSource() {
if (lexer.token() == Token.VALUES) {
lexer.nextToken();
OdpsValuesTableSource tableSource = new OdpsValuesTableSource();
for (;;) {
accept(Token.LPAREN);
SQLListExpr listExpr = new SQLListExpr();
this.exprParser.exprList(listExpr.getItems(), listExpr);
accept(Token.RPAREN);
listExpr.setParent(tableSource);
tableSource.getValues().add(listExpr);
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
}
break;
}
String alias = this.tableAlias();
tableSource.setAlias(alias);
accept(Token.LPAREN);
this.exprParser.names(tableSource.getColumns(), tableSource);
accept(Token.RPAREN);
return tableSource;
}
return super.parseTableSource();
}
示例12: parseTableSourceRest
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
tableSource = super.parseTableSourceRest(tableSource);
if ("LATERAL".equalsIgnoreCase(tableSource.getAlias()) && lexer.token() == Token.VIEW) {
return parseLateralView(tableSource);
}
if (lexer.identifierEquals("LATERAL")) {
lexer.nextToken();
return parseLateralView(tableSource);
}
return tableSource;
}
示例13: findTableSourceWithColumn
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
public SQLTableSource findTableSourceWithColumn(long columnNameHash) {
for (SQLName column : columns) {
if (column.nameHashCode64() == columnNameHash) {
return this;
}
}
if (tableSource != null) {
return tableSource.findTableSourceWithColumn(columnNameHash);
}
return null;
}
示例14: updateRecordLog
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
private void updateRecordLog(LogOperate operate,String sql,Object ...args){
MySqlStatementParser mySqlStatementParser = new MySqlStatementParser(sql);
SQLUpdateStatement sqlUpdateStatement = mySqlStatementParser.parseUpdateStatement();
SQLTableSource tableSource = sqlUpdateStatement.getTableSource();
Assert.notNull(tableSource,"不匹配的操作类型,日志记录失败!");
List<SQLUpdateSetItem> items = sqlUpdateStatement.getItems();
JSONObject log = new JSONObject();
for (int i = 0; i < items.size(); i++) {
SQLUpdateSetItem sqlUpdateSetItem = items.get(i);
log.put(sqlUpdateSetItem.getColumn().toString(),args[i]);
}
logHandler.handle(operate,sqlUpdateStatement.getTableName().getSimpleName(),sqlUpdateStatement.getTableName().getSimpleName(),log);
}
示例15: getResolvedTableSource
import com.alibaba.druid.sql.ast.statement.SQLTableSource; //导入依赖的package包/类
public SQLTableSource getResolvedTableSource() {
return resolvedTableSource;
}