本文整理汇总了Java中org.apache.calcite.sql.util.SqlVisitor类的典型用法代码示例。如果您正苦于以下问题:Java SqlVisitor类的具体用法?Java SqlVisitor怎么用?Java SqlVisitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlVisitor类属于org.apache.calcite.sql.util包,在下文中一共展示了SqlVisitor类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: containsInOperator
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
/**
* Returns whether a given node contains a {@link SqlInOperator}.
*
* @param node a RexNode tree
*/
private static boolean containsInOperator(
SqlNode node) {
try {
SqlVisitor<Void> visitor =
new SqlBasicVisitor<Void>() {
public Void visit(SqlCall call) {
if (call.getOperator() instanceof SqlInOperator) {
throw new Util.FoundOne(call);
}
return super.visit(call);
}
};
node.accept(visitor);
return false;
} catch (Util.FoundOne e) {
Util.swallow(e, null);
return true;
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:SqlToRelConverter.java
示例2: ensureNoAliasInExpr
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
public static void ensureNoAliasInExpr(String expr) {
SqlNode sqlNode = getExpNode(expr);
SqlVisitor sqlVisitor = new SqlBasicVisitor() {
@Override
public Object visit(SqlIdentifier id) {
if (id.names.size() > 1) {
throw new IllegalArgumentException(
"Column Identifier in the computed column expression should only contain COLUMN");
}
return null;
}
};
sqlNode.accept(sqlVisitor);
}
开发者ID:apache,项目名称:kylin,代码行数:17,代码来源:CalciteParser.java
示例3: containsInOperator
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
/**
* Returns whether a given node contains a {@link SqlInOperator}.
*
* @param node a RexNode tree
*/
private static boolean containsInOperator(
SqlNode node) {
try {
SqlVisitor<Void> visitor =
new SqlBasicVisitor<Void>() {
public Void visit(SqlCall call) {
if (call.getOperator() instanceof SqlInOperator) {
throw new Util.FoundOne(call);
}
return super.visit(call);
}
};
node.accept(visitor);
return false;
} catch (Util.FoundOne e) {
Util.swallow(e, null);
return true;
}
}
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:SqlToRelConverter.java
示例4: acceptCall
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
/**
* Accepts a {@link SqlVisitor}, and tells it to visit each child.
*
* @param visitor Visitor
*/
public <R> void acceptCall(
SqlVisitor<R> visitor,
SqlCall call,
boolean onlyExpressions,
SqlBasicVisitor.ArgHandler<R> argHandler) {
if (onlyExpressions) {
for (Ord<SqlNode> operand : Ord.zip(call.getOperandList())) {
// if the second param is an Identifier then it's supposed to
// be a name from a window clause and isn't part of the
// group by check
if (operand == null) {
continue;
}
if (operand.i == 1 && operand.e instanceof SqlIdentifier) {
continue;
}
argHandler.visitChild(visitor, call, operand.i, operand.e);
}
} else {
super.acceptCall(visitor, call, onlyExpressions, argHandler);
}
}
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:SqlOverOperator.java
示例5: acceptCall
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
public <R> void acceptCall(
SqlVisitor<R> visitor,
SqlCall call,
boolean onlyExpressions,
SqlBasicVisitor.ArgHandler<R> argHandler) {
if (onlyExpressions) {
for (Ord<SqlNode> operand : Ord.zip(call.getOperandList())) {
// if the second param is an Identifier then it's supposed to
// be a name from a window clause and isn't part of the
// group by check
if (operand.e == null) {
continue;
}
if (operand.i == 1 && operand.e instanceof SqlIdentifier) {
// skip refName
continue;
}
argHandler.visitChild(visitor, call, operand.i, operand.e);
}
} else {
super.acceptCall(visitor, call, onlyExpressions, argHandler);
}
}
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:SqlWindow.java
示例6: acceptCall
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
@Override public <R> void acceptCall(
SqlVisitor<R> visitor,
SqlCall call,
boolean onlyExpressions,
SqlBasicVisitor.ArgHandler<R> argHandler) {
if (onlyExpressions) {
List<SqlNode> operands = call.getOperandList();
for (int i = 0; i < operands.size(); i++) {
SqlNode operand = operands.get(i);
if (operand == null) {
continue;
}
argHandler.visitChild(visitor, call, i, operand);
}
} else {
super.acceptCall(visitor, call, onlyExpressions, argHandler);
}
}
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:SqlMatchRecognize.java
示例7: visitChild
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
@Override
public SqlNode visitChild(
SqlVisitor<SqlNode> visitor,
SqlNode expr,
int i,
SqlNode operand) {
if (operand == null) {
return null;
}
boolean localEnableComplex = enableComplex;
if(rewriteTypes != null){
switch(rewriteTypes[i]){
case DISABLE:
enableComplex = false;
break;
case ENABLE:
enableComplex = true;
}
}
SqlNode newOperand = operand.accept(CompoundIdentifierConverter.this);
enableComplex = localEnableComplex;
if (newOperand != operand) {
update = true;
}
clonedOperands[i] = newOperand;
return newOperand;
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:29,代码来源:CompoundIdentifierConverter.java
示例8: insertAliasInExpr
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
public static String insertAliasInExpr(String expr, String alias) {
String prefix = "select ";
String suffix = " from t";
String sql = prefix + expr + suffix;
SqlNode sqlNode = getOnlySelectNode(sql);
final Set<SqlIdentifier> s = Sets.newHashSet();
SqlVisitor sqlVisitor = new SqlBasicVisitor() {
@Override
public Object visit(SqlIdentifier id) {
if (id.names.size() > 1) {
throw new IllegalArgumentException("SqlIdentifier " + id + " contains DB/Table name");
}
s.add(id);
return null;
}
};
sqlNode.accept(sqlVisitor);
List<SqlIdentifier> sqlIdentifiers = Lists.newArrayList(s);
descSortByPosition(sqlIdentifiers);
for (SqlIdentifier sqlIdentifier : sqlIdentifiers) {
Pair<Integer, Integer> replacePos = getReplacePos(sqlIdentifier, sql);
int start = replacePos.getFirst();
sql = sql.substring(0, start) + alias + "." + sql.substring(start);
}
return sql.substring(prefix.length(), sql.length() - suffix.length());
}
开发者ID:apache,项目名称:kylin,代码行数:32,代码来源:CalciteParser.java
示例9: replaceAliasInExpr
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
public static String replaceAliasInExpr(String expr, Map<String, String> renaming) {
String prefix = "select ";
String suffix = " from t";
String sql = prefix + expr + suffix;
SqlNode sqlNode = CalciteParser.getOnlySelectNode(sql);
final Set<SqlIdentifier> s = Sets.newHashSet();
SqlVisitor sqlVisitor = new SqlBasicVisitor() {
@Override
public Object visit(SqlIdentifier id) {
Preconditions.checkState(id.names.size() == 2);
s.add(id);
return null;
}
};
sqlNode.accept(sqlVisitor);
List<SqlIdentifier> sqlIdentifiers = Lists.newArrayList(s);
CalciteParser.descSortByPosition(sqlIdentifiers);
for (SqlIdentifier sqlIdentifier : sqlIdentifiers) {
Pair<Integer, Integer> replacePos = CalciteParser.getReplacePos(sqlIdentifier, sql);
int start = replacePos.getFirst();
int end = replacePos.getSecond();
String aliasInExpr = sqlIdentifier.names.get(0);
String col = sqlIdentifier.names.get(1);
String renamedAlias = renaming.get(aliasInExpr);
Preconditions.checkNotNull(renamedAlias,
"rename for alias " + aliasInExpr + " in expr (" + expr + ") is not found");
sql = sql.substring(0, start) + renamedAlias + "." + col + sql.substring(end);
}
return sql.substring(prefix.length(), sql.length() - suffix.length());
}
开发者ID:apache,项目名称:kylin,代码行数:36,代码来源:CalciteParser.java
示例10: acceptCall
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
public <R> void acceptCall(
SqlVisitor<R> visitor,
SqlCall call,
boolean onlyExpressions,
SqlBasicVisitor.ArgHandler<R> argHandler) {
if (onlyExpressions) {
// Do not visit operands[1] -- it is not an expression.
argHandler.visitChild(visitor, call, 0, call.operand(0));
} else {
super.acceptCall(visitor, call, onlyExpressions, argHandler);
}
}
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:SqlAsOperator.java
示例11: acceptCall
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
@Override public <R> void acceptCall(SqlVisitor<R> visitor, SqlCall call,
boolean onlyExpressions, SqlBasicVisitor.ArgHandler<R> argHandler) {
if (onlyExpressions) {
// Do not visit operands[1] -- it is not an expression.
argHandler.visitChild(visitor, call, 0, call.operand(0));
} else {
super.acceptCall(visitor, call, onlyExpressions, argHandler);
}
}
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:SqlDotOperator.java
示例12: acceptCall
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
public <R> void acceptCall(
SqlVisitor<R> visitor,
SqlCall call,
boolean onlyExpressions,
SqlBasicVisitor.ArgHandler<R> argHandler) {
if (!onlyExpressions) {
// None of the arguments to the SELECT operator are expressions.
super.acceptCall(visitor, call, onlyExpressions, argHandler);
}
}
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:SqlSelectOperator.java
示例13: acceptCall
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
/**
* Accepts a {@link SqlVisitor}, visiting each operand of a call. Returns
* null.
*
* @param visitor Visitor
* @param call Call to visit
*/
public <R> R acceptCall(SqlVisitor<R> visitor, SqlCall call) {
for (SqlNode operand : call.getOperandList()) {
if (operand == null) {
continue;
}
operand.accept(visitor);
}
return null;
}
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:SqlOperator.java
示例14: createConverter
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
protected SqlVisitor<SqlNode> createConverter() {
return new CompoundIdentifierConverter();
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:4,代码来源:DrillParserWithCompoundIdConverter.java
示例15: accept
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
public <R> R accept(SqlVisitor<R> visitor) {
return visitor.visit(this);
}
开发者ID:apache,项目名称:calcite,代码行数:4,代码来源:SqlDynamicParam.java
示例16: accept
import org.apache.calcite.sql.util.SqlVisitor; //导入依赖的package包/类
/**
* Accepts a generic visitor.
*
* <p>Implementations of this method in subtypes simply call the appropriate
* <code>visit</code> method on the
* {@link org.apache.calcite.sql.util.SqlVisitor visitor object}.
*
* <p>The type parameter <code>R</code> must be consistent with the type
* parameter of the visitor.
*/
public abstract <R> R accept(SqlVisitor<R> visitor);
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:SqlNode.java
注:本文中的org.apache.calcite.sql.util.SqlVisitor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论