• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SqlBasicVisitor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.calcite.sql.util.SqlBasicVisitor的典型用法代码示例。如果您正苦于以下问题:Java SqlBasicVisitor类的具体用法?Java SqlBasicVisitor怎么用?Java SqlBasicVisitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SqlBasicVisitor类属于org.apache.calcite.sql.util包,在下文中一共展示了SqlBasicVisitor类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: containsInOperator

import org.apache.calcite.sql.util.SqlBasicVisitor; //导入依赖的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.SqlBasicVisitor; //导入依赖的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.SqlBasicVisitor; //导入依赖的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.SqlBasicVisitor; //导入依赖的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.SqlBasicVisitor; //导入依赖的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.SqlBasicVisitor; //导入依赖的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: insertAliasInExpr

import org.apache.calcite.sql.util.SqlBasicVisitor; //导入依赖的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


示例8: replaceAliasInExpr

import org.apache.calcite.sql.util.SqlBasicVisitor; //导入依赖的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


示例9: acceptCall

import org.apache.calcite.sql.util.SqlBasicVisitor; //导入依赖的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


示例10: acceptCall

import org.apache.calcite.sql.util.SqlBasicVisitor; //导入依赖的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


示例11: acceptCall

import org.apache.calcite.sql.util.SqlBasicVisitor; //导入依赖的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


示例12: acceptCall

import org.apache.calcite.sql.util.SqlBasicVisitor; //导入依赖的package包/类
/**
 * Accepts a {@link SqlVisitor}, directing an
 * {@link org.apache.calcite.sql.util.SqlBasicVisitor.ArgHandler}
 * to visit an operand of a call.
 *
 * <p>The argument handler allows fine control about how the operands are
 * visited, and how the results are combined.
 *
 * @param visitor         Visitor
 * @param call            Call to visit
 * @param onlyExpressions If true, ignores operands which are not
 *                        expressions. For example, in the call to the
 *                        <code>AS</code> operator
 * @param argHandler      Called for each operand
 */
public <R> void acceptCall(
    SqlVisitor<R> visitor,
    SqlCall call,
    boolean onlyExpressions,
    SqlBasicVisitor.ArgHandler<R> argHandler) {
  List<SqlNode> operands = call.getOperandList();
  for (int i = 0; i < operands.size(); i++) {
    argHandler.visitChild(visitor, call, i, operands.get(i));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:SqlOperator.java



注:本文中的org.apache.calcite.sql.util.SqlBasicVisitor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DumpTube类代码示例发布时间:2022-05-23
下一篇:
Java CircuitFilter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap