当前位置: 首页>>代码示例>>Java>>正文


Java SqlOperator.createCall方法代码示例

本文整理汇总了Java中org.apache.calcite.sql.SqlOperator.createCall方法的典型用法代码示例。如果您正苦于以下问题:Java SqlOperator.createCall方法的具体用法?Java SqlOperator.createCall怎么用?Java SqlOperator.createCall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.sql.SqlOperator的用法示例。


在下文中一共展示了SqlOperator.createCall方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: navigationInMeasure

import org.apache.calcite.sql.SqlOperator; //导入方法依赖的package包/类
private SqlNode navigationInMeasure(SqlNode node, boolean allRows) {
  final Set<String> prefix = node.accept(new PatternValidator(true));
  Util.discard(prefix);
  final List<SqlNode> ops = ((SqlCall) node).getOperandList();

  final SqlOperator defaultOp =
      allRows ? SqlStdOperatorTable.RUNNING : SqlStdOperatorTable.FINAL;
  final SqlNode op0 = ops.get(0);
  if (!isRunningOrFinal(op0.getKind())
      || !allRows && op0.getKind() == SqlKind.RUNNING) {
    SqlNode newNode = defaultOp.createCall(SqlParserPos.ZERO, op0);
    node = SqlStdOperatorTable.AS.createCall(SqlParserPos.ZERO, newNode, ops.get(1));
  }

  node = new NavigationExpander().go(node);
  return node;
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlValidatorImpl.java

示例2: toSql

import org.apache.calcite.sql.SqlOperator; //导入方法依赖的package包/类
/**
 * Converts a call to an aggregate function to an expression.
 */
final SqlNode toSql(AggregateCall aggCall) {
    SqlOperator op = aggCall.getAggregation();
    if (op instanceof SqlSumEmptyIsZeroAggFunction) {
        op = SqlStdOperatorTable.SUM;
    }
    final List<SqlNode> operands = Expressions.list();
    for (int arg : aggCall.getArgList()) {
        operands.add(field(arg));
    }
    return op.createCall(
            aggCall.isDistinct() ? SqlSelectKeyword.DISTINCT.symbol(POS) : null,
            POS, operands.toArray(new SqlNode[operands.size()]));
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:17,代码来源:JdbcImplementor.java

示例3: createLeftCall

import org.apache.calcite.sql.SqlOperator; //导入方法依赖的package包/类
private SqlNode createLeftCall(SqlOperator op, List<SqlNode> nodeList) {
    if (nodeList.size() == 2) {
        return op.createCall(new SqlNodeList(nodeList, POS));
    }
    final List<SqlNode> butLast = Util.skipLast(nodeList);
    final SqlNode last = nodeList.get(nodeList.size() - 1);
    final SqlNode call = createLeftCall(op, butLast);
    return op.createCall(new SqlNodeList(ImmutableList.of(call, last), POS));
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:10,代码来源:JdbcImplementor.java

示例4: createLeftCall

import org.apache.calcite.sql.SqlOperator; //导入方法依赖的package包/类
private SqlNode createLeftCall(SqlOperator op, List<SqlNode> nodeList) {
  if (nodeList.size() == 2) {
    return op.createCall(new SqlNodeList(nodeList, POS));
  }
  final List<SqlNode> butLast = Util.skipLast(nodeList);
  final SqlNode last = nodeList.get(nodeList.size() - 1);
  final SqlNode call = createLeftCall(op, butLast);
  return op.createCall(new SqlNodeList(ImmutableList.of(call, last), POS));
}
 
开发者ID:qubole,项目名称:quark,代码行数:10,代码来源:RelToSqlConverter.java

示例5: toSql

import org.apache.calcite.sql.SqlOperator; //导入方法依赖的package包/类
/**
 * Converts a call to an aggregate function to an expression.
 */
public SqlNode toSql(AggregateCall aggCall) {
  SqlOperator op = (SqlAggFunction) aggCall.getAggregation();
  if (op instanceof SqlSumEmptyIsZeroAggFunction) {
    op = SqlStdOperatorTable.SUM;
  }
  final List<SqlNode> operands = Expressions.list();
  for (int arg : aggCall.getArgList()) {
    operands.add(field(arg));
  }
  return op.createCall(
      aggCall.isDistinct() ? SqlSelectKeyword.DISTINCT.symbol(POS) : null,
      POS, operands.toArray(new SqlNode[operands.size()]));
}
 
开发者ID:qubole,项目名称:quark,代码行数:17,代码来源:RelToSqlConverter.java

示例6: toSql

import org.apache.calcite.sql.SqlOperator; //导入方法依赖的package包/类
/** Converts a call to an aggregate function to an expression. */
public SqlNode toSql(AggregateCall aggCall) {
  SqlOperator op = aggCall.getAggregation();
  if (op instanceof SqlSumEmptyIsZeroAggFunction) {
    op = SqlStdOperatorTable.SUM;
  }
  final List<SqlNode> operands = Expressions.list();
  for (int arg : aggCall.getArgList()) {
    operands.add(field(arg));
  }
  return op.createCall(
      aggCall.isDistinct() ? SqlSelectKeyword.DISTINCT.symbol(POS) : null,
      POS, operands.toArray(new SqlNode[operands.size()]));
}
 
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:SqlImplementor.java

示例7: createCall

import org.apache.calcite.sql.SqlOperator; //导入方法依赖的package包/类
/**
 * Creates a call.
 *
 * @param funName           Name of function
 * @param pos               Position in source code
 * @param funcType          Type of function
 * @param functionQualifier Qualifier
 * @param operands          Operands to call
 * @return Call
 */
protected SqlCall createCall(
    SqlIdentifier funName,
    SqlParserPos pos,
    SqlFunctionCategory funcType,
    SqlLiteral functionQualifier,
    SqlNode[] operands) {
  SqlOperator fun = null;

  // First, try a half-hearted resolution as a builtin function.
  // If we find one, use it; this will guarantee that we
  // preserve the correct syntax (i.e. don't quote builtin function
  /// name when regenerating SQL).
  if (funName.isSimple()) {
    final List<SqlOperator> list = Lists.newArrayList();
    opTab.lookupOperatorOverloads(funName, funcType, SqlSyntax.FUNCTION, list);
    if (list.size() == 1) {
      fun = list.get(0);
    }
  }

  // Otherwise, just create a placeholder function.  Later, during
  // validation, it will be resolved into a real function reference.
  if (fun == null) {
    fun = new SqlUnresolvedFunction(funName, null, null, null, null,
        funcType);
  }

  return fun.createCall(functionQualifier, pos, operands);
}
 
开发者ID:apache,项目名称:calcite,代码行数:40,代码来源:SqlAbstractParserImpl.java

示例8: visit

import org.apache.calcite.sql.SqlOperator; //导入方法依赖的package包/类
@Override public SqlNode visit(SqlIdentifier id) {
  if (id.isSimple()) {
    return id;
  }
  SqlOperator operator = id.names.get(0).equals(alpha)
      ? SqlStdOperatorTable.PREV : SqlStdOperatorTable.LAST;

  return operator.createCall(SqlParserPos.ZERO, id,
    SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO));
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:SqlValidatorImpl.java

示例9: convertConditionToSqlNode

import org.apache.calcite.sql.SqlOperator; //导入方法依赖的package包/类
/**
 * Convert {@link RexNode} condition into {@link SqlNode}
 *
 * @param node           condition Node
 * @param leftContext    LeftContext
 * @param rightContext   RightContext
 * @param leftFieldCount Number of field on left result
 * @return SqlJoin which represent the condition
 */
private SqlNode convertConditionToSqlNode(RexNode node,
                                          JdbcImplementor.Context leftContext,
                                          JdbcImplementor.Context rightContext, int leftFieldCount) {
    if (!(node instanceof RexCall)) {
        throw new AssertionError(node);
    }
    final List<RexNode> operands;
    final SqlOperator op;
    switch (node.getKind()) {
    case AND:
    case OR:
        operands = ((RexCall) node).getOperands();
        op = ((RexCall) node).getOperator();
        SqlNode sqlCondition = null;
        for (RexNode operand : operands) {
            SqlNode x = convertConditionToSqlNode(operand, leftContext,
                    rightContext, leftFieldCount);
            if (sqlCondition == null) {
                sqlCondition = x;
            } else {
                sqlCondition = op.createCall(POS, sqlCondition, x);
            }
        }
        return sqlCondition;

    case EQUALS:
    case IS_NOT_DISTINCT_FROM:
    case NOT_EQUALS:
    case GREATER_THAN:
    case GREATER_THAN_OR_EQUAL:
    case LESS_THAN:
    case LESS_THAN_OR_EQUAL:
        operands = ((RexCall) node).getOperands();
        op = ((RexCall) node).getOperator();
        if (operands.size() == 2
                && operands.get(0) instanceof RexInputRef
                && operands.get(1) instanceof RexInputRef) {
            final RexInputRef op0 = (RexInputRef) operands.get(0);
            final RexInputRef op1 = (RexInputRef) operands.get(1);

            if (op0.getIndex() < leftFieldCount
                    && op1.getIndex() >= leftFieldCount) {
                // Arguments were of form 'op0 = op1'
                return op.createCall(POS,
                        leftContext.field(op0.getIndex()),
                        rightContext.field(op1.getIndex() - leftFieldCount));
            }
            if (op1.getIndex() < leftFieldCount
                    && op0.getIndex() >= leftFieldCount) {
                // Arguments were of form 'op1 = op0'
                return reverseOperatorDirection(op).createCall(POS,
                        leftContext.field(op1.getIndex()),
                        rightContext.field(op0.getIndex() - leftFieldCount));
            }
        }
        final JdbcImplementor.Context joinContext =
                leftContext.implementor().joinContext(leftContext, rightContext);
        return joinContext.toSql(null, node);
    default:
        throw new AssertionError(node);
    }
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:72,代码来源:JdbcRules.java

示例10: convertConditionToSqlNode

import org.apache.calcite.sql.SqlOperator; //导入方法依赖的package包/类
/**
 * Convert {@link RexNode} condition into {@link SqlNode}
 *
 * @param node           condition Node
 * @param leftContext    LeftContext
 * @param rightContext   RightContext
 * @param leftFieldCount Number of field on left result
 * @return SqlJoin which represent the condition
 */
private SqlNode convertConditionToSqlNode(RexNode node,
                                          Context leftContext,
                                          Context rightContext,
                                          int leftFieldCount) {
  if (!(node instanceof RexCall)) {
    throw new AssertionError(node);
  }
  final List<RexNode> operands;
  final SqlOperator op;
  switch (node.getKind()) {
    case AND:
    case OR:
      operands = ((RexCall) node).getOperands();
      op = ((RexCall) node).getOperator();
      SqlNode sqlCondition = null;
      for (RexNode operand : operands) {
        SqlNode x = convertConditionToSqlNode(operand, leftContext,
            rightContext, leftFieldCount);
        if (sqlCondition == null) {
          sqlCondition = x;
        } else {
          sqlCondition = op.createCall(POS, sqlCondition, x);
        }
      }
      return sqlCondition;

    case EQUALS:
    case IS_NOT_DISTINCT_FROM:
    case NOT_EQUALS:
    case GREATER_THAN:
    case GREATER_THAN_OR_EQUAL:
    case LESS_THAN:
    case LESS_THAN_OR_EQUAL:
      operands = ((RexCall) node).getOperands();
      op = ((RexCall) node).getOperator();
      if (operands.get(0) instanceof RexInputRef
          && operands.get(1) instanceof RexInputRef) {
        final RexInputRef op0 = (RexInputRef) operands.get(0);
        final RexInputRef op1 = (RexInputRef) operands.get(1);

        if (op0.getIndex() < leftFieldCount
            && op1.getIndex() >= leftFieldCount) {
          // Arguments were of form 'op0 = op1'
          return op.createCall(POS,
              leftContext.field(op0.getIndex()),
              rightContext.field(op1.getIndex() - leftFieldCount));
        }
        if (op1.getIndex() < leftFieldCount
            && op0.getIndex() >= leftFieldCount) {
          // Arguments were of form 'op1 = op0'
          return reverseOperatorDirection(op).createCall(POS,
              leftContext.field(op1.getIndex()),
              rightContext.field(op0.getIndex() - leftFieldCount));
        }
      }
  }
  throw new AssertionError(node);
}
 
开发者ID:qubole,项目名称:quark,代码行数:68,代码来源:RelToSqlConverter.java


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