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


Java SqlCall.getOperandList方法代码示例

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

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

示例1: convertCall

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/** Converts a {@link SqlCall} to a {@link RexCall} with a perhaps different
 * operator. */
private RexNode convertCall(
    SqlRexContext cx,
    SqlCall call,
    SqlOperator op) {
  final List<SqlNode> operands = call.getOperandList();
  final RexBuilder rexBuilder = cx.getRexBuilder();
  final SqlOperandTypeChecker.Consistency consistency =
      op.getOperandTypeChecker() == null
          ? SqlOperandTypeChecker.Consistency.NONE
          : op.getOperandTypeChecker().getConsistency();
  final List<RexNode> exprs =
      convertExpressionList(cx, operands, consistency);
  RelDataType type = rexBuilder.deriveReturnType(op, exprs);
  return rexBuilder.makeCall(type, op, RexUtil.flatten(exprs, op));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:ConvertletTable.java


示例2: convertCall

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  final RexBuilder rexBuilder = cx.getRexBuilder();
  final List<SqlNode> operands = call.getOperandList();
  final List<RexNode> exprs = new LinkedList<>();

  RelDataTypeFactory typeFactory = cx.getTypeFactory();

  //RelDataType nullableReturnType =

  for (SqlNode node: operands) {
     exprs.add(cx.convertExpression(node));
  }

  // Determine NULL-able using 2nd argument's Null-able.
  RelDataType returnType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());

  return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:20,代码来源:DrillExtractConvertlet.java


示例3: convertCall

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  SqlFlattenOperator operator = (SqlFlattenOperator) call.getOperator();
  final List<RexNode> exprs = new LinkedList<>();

  for (SqlNode node : call.getOperandList()) {
    exprs.add(cx.convertExpression(node));
  }

  SqlFlattenOperator indexedOperator = operator.withIndex(((SqlValidatorImpl)cx.getValidator()).nextFlattenIndex());
  final RexBuilder rexBuilder = cx.getRexBuilder();
  // Since we don't have any way of knowing if the output of the flatten is nullable, we should always assume it is.
  // This is especially important when accelerating a count(column) query, because the normalizer will convert it to
  // a count(1) if it thinks this column is non-nullable, and then remove the flatten altogether. This is actually a
  // problem with the fact that flatten is not really a project operator (because it can output more than one row per input).
  RelDataType type = rexBuilder
    .getTypeFactory()
    .createTypeWithNullability(
      rexBuilder
        .getTypeFactory()
        .createSqlType(SqlTypeName.ANY),
      true
    );
  return rexBuilder.makeCall(type, indexedOperator, exprs);

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:27,代码来源:FlattenConvertlet.java


示例4: convertCall

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  final RexBuilder rexBuilder = cx.getRexBuilder();
  final List<SqlNode> operands = call.getOperandList();
  final List<RexNode> exprs = new LinkedList<>();

  String timeUnit = ((SqlIntervalQualifier) operands.get(0)).timeUnitRange.toString();

  RelDataTypeFactory typeFactory = cx.getTypeFactory();

  //RelDataType nullableReturnType =

  for (SqlNode node: operands) {
     exprs.add(cx.convertExpression(node));
  }

  final RelDataType returnType
      = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());
  return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:ExtractConvertlet.java


示例5: extractAS

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private static ASNode extractAS(SqlCall call) {
  if (call.getOperator().getKind() == SqlKind.AS) {
    List<SqlNode> operandList = call.getOperandList();
    if (operandList.size() == 2) {
      SqlNode exp = operandList.get(0);
      SqlNode colID = operandList.get(1);
      if (isSimpleID(colID)) {
        return new ASNode((SqlIdentifier)colID, exp);
      } else {
        throw new UnsupportedOperationException("Unexpected AS " + colID + "\n" + SqlNodes.toTreeString(call));
      }
    } else {
      throw new UnsupportedOperationException("Unexpected AS operands in field: \n" + SqlNodes.toTreeString(call));
    }
  }
  throw new UnsupportedOperationException("AS not understood: " + SqlNodes.toSQLString(call));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:QuerySemantics.java


示例6: makeNullableIfOperandsAre

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/**
 * Recreates a given RelDataType with nullability iff any of the operands
 * of a call are nullable.
 */
public static RelDataType makeNullableIfOperandsAre(
        final SqlValidator validator,
        final SqlValidatorScope scope,
        final SqlCall call,
        RelDataType type) {
    for (SqlNode operand : call.getOperandList()) {
        RelDataType operandType = validator.deriveType(scope, operand);

        if (containsNullable(operandType)) {
            RelDataTypeFactory typeFactory = validator.getTypeFactory();
            type = typeFactory.createTypeWithNullability(type, true);
            break;
        }
    }
    return type;
}
 
开发者ID:apache,项目名称:kylin,代码行数:21,代码来源:SqlTypeUtil.java


示例7: makeNullableIfOperandsAre

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/**
 * Recreates a given RelDataType with nullability iff any of the operands
 * of a call are nullable.
 */
public static RelDataType makeNullableIfOperandsAre(
    final SqlValidator validator,
    final SqlValidatorScope scope,
    final SqlCall call,
    RelDataType type) {
  for (SqlNode operand : call.getOperandList()) {
    RelDataType operandType = validator.deriveType(scope, operand);

    if (containsNullable(operandType)) {
      RelDataTypeFactory typeFactory = validator.getTypeFactory();
      type = typeFactory.createTypeWithNullability(type, true);
      break;
    }
  }
  return type;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:SqlTypeUtil.java


示例8: convertFunction

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public RexNode convertFunction(
    SqlRexContext cx,
    SqlFunction fun,
    SqlCall call) {
  final List<SqlNode> operands = call.getOperandList();
  final List<RexNode> exprs = convertExpressionList(cx, operands,
      SqlOperandTypeChecker.Consistency.NONE);
  if (fun.getFunctionType() == SqlFunctionCategory.USER_DEFINED_CONSTRUCTOR) {
    return makeConstructorCall(cx, fun, exprs);
  }
  RelDataType returnType =
      cx.getValidator().getValidatedNodeTypeIfKnown(call);
  if (returnType == null) {
    returnType = cx.getRexBuilder().deriveReturnType(fun, exprs);
  }
  return cx.getRexBuilder().makeCall(returnType, fun, exprs);
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:StandardConvertletTable.java


示例9: convertAggregateFunction

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public RexNode convertAggregateFunction(
    SqlRexContext cx,
    SqlAggFunction fun,
    SqlCall call) {
  final List<SqlNode> operands = call.getOperandList();
  final List<RexNode> exprs;
  if (call.isCountStar()) {
    exprs = ImmutableList.of();
  } else {
    exprs = convertExpressionList(cx, operands,
        SqlOperandTypeChecker.Consistency.NONE);
  }
  RelDataType returnType =
      cx.getValidator().getValidatedNodeTypeIfKnown(call);
  final int groupCount = cx.getGroupCount();
  if (returnType == null) {
    RexCallBinding binding =
        new RexCallBinding(cx.getTypeFactory(), fun, exprs, ImmutableList.<RelCollation>of()) {
          @Override public int getGroupCount() {
            return groupCount;
          }
        };
    returnType = fun.inferReturnType(binding);
  }
  return cx.getRexBuilder().makeCall(returnType, fun, exprs);
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:StandardConvertletTable.java


示例10: convertRow

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/**
 * Converts a ROW.
 *
 * <p>Called automatically via reflection.
 */
public RexNode convertRow(
    SqlRexContext cx,
    SqlRowOperator op,
    SqlCall call) {
  if (cx.getValidator().getValidatedNodeType(call).getSqlTypeName()
      != SqlTypeName.COLUMN_LIST) {
    return convertCall(cx, call);
  }
  final RexBuilder rexBuilder = cx.getRexBuilder();
  final List<RexNode> columns = new ArrayList<>();
  for (SqlNode operand : call.getOperandList()) {
    columns.add(
        rexBuilder.makeLiteral(
            ((SqlIdentifier) operand).getSimple()));
  }
  final RelDataType type =
      rexBuilder.deriveReturnType(SqlStdOperatorTable.COLUMN_LIST, columns);
  return rexBuilder.makeCall(type, SqlStdOperatorTable.COLUMN_LIST, columns);
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:StandardConvertletTable.java


示例11: registerSetop

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private void registerSetop(
    SqlValidatorScope parentScope,
    SqlValidatorScope usingScope,
    SqlNode node,
    SqlNode enclosingNode,
    String alias,
    boolean forceNullable) {
  SqlCall call = (SqlCall) node;
  final SetopNamespace setopNamespace =
      createSetopNamespace(call, enclosingNode);
  registerNamespace(usingScope, alias, setopNamespace, forceNullable);

  // A setop is in the same scope as its parent.
  scopes.put(call, parentScope);
  for (SqlNode operand : call.getOperandList()) {
    registerQuery(
        parentScope,
        null,
        operand,
        operand,
        null,
        false);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:SqlValidatorImpl.java


示例12: visit

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override public SqlNode visit(SqlCall call) {
  SqlKind kind = call.getKind();
  if (isLogicalNavigation(kind)
      || isAggregation(kind)
      || isRunningOrFinal(kind)) {
    return call;
  }

  switch (kind) {
  case PREV:
    final List<SqlNode> operands = call.getOperandList();
    if (operands.get(0) instanceof SqlIdentifier) {
      String name = ((SqlIdentifier) operands.get(0)).names.get(0);
      return name.equals(alpha) ? call
          : SqlStdOperatorTable.LAST.createCall(SqlParserPos.ZERO, operands);
    }
  }
  return super.visit(call);
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:SqlValidatorImpl.java


示例13: validateCall

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public void validateCall(
    SqlCall call,
    SqlValidator validator,
    SqlValidatorScope scope,
    SqlValidatorScope operandScope) {
  // per the SQL std, each string fragment must be on a different line
  final List<SqlNode> operandList = call.getOperandList();
  for (int i = 1; i < operandList.size(); i++) {
    SqlParserPos prevPos = operandList.get(i - 1).getParserPosition();
    final SqlNode operand = operandList.get(i);
    SqlParserPos pos = operand.getParserPosition();
    if (pos.getLineNum() <= prevPos.getLineNum()) {
      throw validator.newValidationError(operand,
          RESOURCE.stringFragsOnSameLine());
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlLiteralChainOperator.java


示例14: unparseCube

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private static void unparseCube(SqlWriter writer, SqlCall call) {
  writer.keyword(call.getOperator().getName());
  final SqlWriter.Frame frame =
      writer.startList(SqlWriter.FrameTypeEnum.FUN_CALL, "(", ")");
  for (SqlNode operand : call.getOperandList()) {
    writer.sep(",");
    if (operand.getKind() == SqlKind.ROW) {
      final SqlWriter.Frame frame2 =
          writer.startList(SqlWriter.FrameTypeEnum.SIMPLE, "(", ")");
      for (SqlNode operand2 : ((SqlCall) operand).getOperandList()) {
        writer.sep(",");
        operand2.unparse(writer, 0, 0);
      }
      writer.endList(frame2);
    } else if (operand instanceof SqlNodeList
        && ((SqlNodeList) operand).size() == 0) {
      writer.keyword("()");
    } else {
      operand.unparse(writer, 0, 0);
    }
  }
  writer.endList(frame);
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:SqlRollupOperator.java


示例15: ComplexExpressionAware

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public ComplexExpressionAware(SqlCall call) {
  this.call = call;
  this.update = false;
  final List<SqlNode> operands = call.getOperandList();
  this.clonedOperands = operands.toArray(new SqlNode[operands.size()]);
  rewriteTypes = REWRITE_RULES.get(call.getClass());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:8,代码来源:CompoundIdentifierConverter.java


示例16: ComplexExpressionAware

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public ComplexExpressionAware(SqlCall call) {
  this.call = call;
  this.update = false;
  final List<SqlNode> operands = call.getOperandList();
  this.clonedOperands = operands.toArray(new SqlNode[operands.size()]);
  rewriteTypes = REWRITE_RULES.get(call.getClass());

  // TODO: this check is reasonable, but there are regressions, so fix the rules and uncomment
  // if (rewriteTypes != null) {
  //   Preconditions.checkArgument(rewriteTypes.length == clonedOperands.length,
  //       "Rewrite rule for %s is incomplete in CompoundIdentifierConverter#REWRITE_RULES (%s types and %s operands)",
  //       call.getClass().getSimpleName(), rewriteTypes.length, clonedOperands.length);
  // }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:15,代码来源:CompoundIdentifierConverter.java


示例17: convertCall

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  final List<RexNode> exprs = new LinkedList<>();

  for (SqlNode node : call.getOperandList()) {
    exprs.add(cx.convertExpression(node));
  }

  final RexBuilder rexBuilder = cx.getRexBuilder();

  // The result of IS [NOT] DISTINCT FROM is NOT NULL because it can only return TRUE or FALSE.
  final RelDataType returnType = rexBuilder.getTypeFactory().createSqlType(SqlTypeName.BOOLEAN);

  return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:16,代码来源:DistinctFromConvertlet.java


示例18: convertRowConstructor

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/**
 * Converts a row constructor into a relational expression.
 *
 * @param bb             Blackboard
 * @param rowConstructor Row constructor expression
 * @return Relational expression which returns a single row.
 */
private RelNode convertRowConstructor(
	Blackboard bb,
	SqlCall rowConstructor) {
	Preconditions.checkArgument(isRowConstructor(rowConstructor));
	final List<SqlNode> operands = rowConstructor.getOperandList();
	return convertMultisets(operands, bb);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:15,代码来源:SqlToRelConverter.java


示例19: convertCall

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  final RexBuilder rexBuilder = cx.getRexBuilder();
  final List<SqlNode> operands = call.getOperandList();
  final List<RexNode> exprs = new LinkedList<>();

  String timeUnit = ((SqlIntervalQualifier) operands.get(0)).timeUnitRange.toString();

  RelDataTypeFactory typeFactory = cx.getTypeFactory();

  //RelDataType nullableReturnType =

  for (SqlNode node: operands) {
     exprs.add(cx.convertExpression(node));
  }

  final RelDataType returnType;
  if(call.getOperator() == SqlStdOperatorTable.EXTRACT) {
    // Legacy code:
    // The return type is wrong!
    // Legacy code choose SqlTypeName.BIGINT simply to avoid conflicting against Calcite's inference mechanism
    // (, which chose BIGINT in validation phase already)
    // Determine NULL-able using 2nd argument's Null-able.
    returnType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());
  } else {
    // Determine NULL-able using 2nd argument's Null-able.
    returnType = typeFactory.createTypeWithNullability(
        typeFactory.createSqlType(
            TypeInferenceUtils.getSqlTypeNameForTimeUnit(timeUnit)),
        exprs.get(1).getType().isNullable());
  }

  return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:35,代码来源:DrillExtractConvertlet.java


示例20: visit

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override
public SqlNode visit(SqlCall call) {
    if (call instanceof SqlSelect) {
        int i = 0;
        for (SqlNode operand : call.getOperandList()) {
            // FROM operand
            if (i == 2)
                nodeStack.push(State.FROM);
            else
                nodeStack.push(State.NOT_FROM);

            i++;

            if (operand == null)
                continue;

            operand.accept(this);
            nodeStack.pop();
        }
        return null;
    }

    SqlOperator operator = call.getOperator();
    if (operator != null && operator.getKind() == SqlKind.AS) {
        // AS operator will be probed only if it is in FROM clause
        if (nodeStack.peek() == State.FROM)
            call.operand(0).accept(this);
        return null;
    }

    return super.visit(call);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:33,代码来源:SqlTableIdentifierFindVisitor.java


示例21: convertRowConstructor

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/**
 * Converts a row constructor into a relational expression.
 *
 * @param bb             Blackboard
 * @param rowConstructor Row constructor expression
 * @return Relational expression which returns a single row.
 */
private RelNode convertRowConstructor(
    Blackboard bb,
    SqlCall rowConstructor) {
  Preconditions.checkArgument(isRowConstructor(rowConstructor));
  final List<SqlNode> operands = rowConstructor.getOperandList();
  return convertMultisets(operands, bb);
}
 
开发者ID:apache,项目名称:kylin,代码行数:15,代码来源:SqlToRelConverter.java


示例22: validateAggregateParams

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public void validateAggregateParams(SqlCall aggCall, SqlNode filter,
    SqlValidatorScope scope) {
  // For "agg(expr)", expr cannot itself contain aggregate function
  // invocations.  For example, "SUM(2 * MAX(x))" is illegal; when
  // we see it, we'll report the error for the SUM (not the MAX).
  // For more than one level of nesting, the error which results
  // depends on the traversal order for validation.
  //
  // For a windowed aggregate "agg(expr)", expr can contain an aggregate
  // function. For example,
  //   SELECT AVG(2 * MAX(x)) OVER (PARTITION BY y)
  //   FROM t
  //   GROUP BY y
  // is legal. Only one level of nesting is allowed since non-windowed
  // aggregates cannot nest aggregates.

  // Store nesting level of each aggregate. If an aggregate is found at an invalid
  // nesting level, throw an assert.
  final AggFinder a;
  if (inWindow) {
    a = overFinder;
  } else {
    a = aggOrOverFinder;
  }

  for (SqlNode param : aggCall.getOperandList()) {
    if (a.findAgg(param) != null) {
      throw newValidationError(aggCall, RESOURCE.nestedAggIllegal());
    }
  }
  if (filter != null) {
    if (a.findAgg(filter) != null) {
      throw newValidationError(filter, RESOURCE.aggregateInFilterIllegal());
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:37,代码来源:SqlValidatorImpl.java


示例23: CallCopyingArgHandler

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public CallCopyingArgHandler(SqlCall call, boolean alwaysCopy) {
  this.call = call;
  this.update = false;
  final List<SqlNode> operands = call.getOperandList();
  this.clonedOperands = operands.toArray(new SqlNode[operands.size()]);
  this.alwaysCopy = alwaysCopy;
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:SqlShuttle.java


示例24: rewriteCall

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override public SqlNode rewriteCall(SqlValidator validator, SqlCall call) {
  final List<SqlNode> operands = call.getOperandList();
  final SqlParserPos pos = call.getParserPosition();
  return SqlStdOperatorTable.EXTRACT.createCall(pos,
      new SqlIntervalQualifier(timeUnit, null, SqlParserPos.ZERO),
      operands.get(0));
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:SqlDatePartFunction.java


示例25: unparse

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public void unparse(
    SqlWriter writer,
    SqlCall call,
    int leftPrec,
    int rightPrec) {
  writer.keyword(getName()); // "MULTISET" or "ARRAY"
  final SqlWriter.Frame frame = writer.startList("[", "]");
  for (SqlNode operand : call.getOperandList()) {
    writer.sep(",");
    operand.unparse(writer, leftPrec, rightPrec);
  }
  writer.endList(frame);
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:SqlMultisetValueConstructor.java


示例26: unparse

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override public void unparse(SqlWriter writer, SqlCall call, int leftPrec,
    int rightPrec) {
  final SqlWriter.Frame frame = writer.startFunCall("TRANSLATE");
  for (SqlNode sqlNode : call.getOperandList()) {
    writer.sep(",");
    sqlNode.unparse(writer, leftPrec, rightPrec);
  }
  writer.endFunCall(frame);
}
 
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:SqlTranslate3Function.java


示例27: convertValuesImpl

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/**
 * Converts a values clause (as in "INSERT INTO T(x,y) VALUES (1,2)") into a
 * relational expression.
 *
 * @param bb            Blackboard
 * @param values        Call to SQL VALUES operator
 * @param targetRowType Target row type
 */
private void convertValuesImpl(
	Blackboard bb,
	SqlCall values,
	RelDataType targetRowType) {
	// Attempt direct conversion to LogicalValues; if that fails, deal with
	// fancy stuff like sub-queries below.
	RelNode valuesRel =
		convertRowValues(
			bb,
			values,
			values.getOperandList(),
			true,
			targetRowType);
	if (valuesRel != null) {
		bb.setRoot(valuesRel, true);
		return;
	}

	final List<RelNode> unionRels = new ArrayList<>();
	for (SqlNode rowConstructor1 : values.getOperandList()) {
		SqlCall rowConstructor = (SqlCall) rowConstructor1;
		Blackboard tmpBb = createBlackboard(bb.scope, null, false);
		replaceSubQueries(tmpBb, rowConstructor,
			RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
		final List<Pair<RexNode, String>> exps = new ArrayList<>();
		for (Ord<SqlNode> operand : Ord.zip(rowConstructor.getOperandList())) {
			exps.add(
				Pair.of(
					tmpBb.convertExpression(operand.e),
					validator.deriveAlias(operand.e, operand.i)));
		}
		RelNode in =
			(null == tmpBb.root)
				? LogicalValues.createOneRow(cluster)
				: tmpBb.root;
		unionRels.add(
			RelOptUtil.createProject(
				in,
				Pair.left(exps),
				Pair.right(exps),
				true));
	}

	if (unionRels.size() == 0) {
		throw new AssertionError("empty values clause");
	} else if (unionRels.size() == 1) {
		bb.setRoot(
			unionRels.get(0),
			true);
	} else {
		bb.setRoot(
			LogicalUnion.create(unionRels, true),
			true);
	}

	// REVIEW jvs 22-Jan-2004:  should I add
	// mapScopeToLux.put(validator.getScope(values),bb.root);
	// ?
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:68,代码来源:SqlToRelConverter.java


示例28: copy

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/** Creates a copy of a call with a new operator. */
private static SqlCall copy(SqlCall call, SqlOperator operator) {
	final List<SqlNode> list = call.getOperandList();
	return new SqlBasicCall(operator, list.toArray(new SqlNode[list.size()]),
		call.getParserPosition());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:7,代码来源:SqlStdOperatorTable.java


示例29: convertValuesImpl

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/**
 * Converts a values clause (as in "INSERT INTO T(x,y) VALUES (1,2)") into a
 * relational expression.
 *
 * @param bb            Blackboard
 * @param values        Call to SQL VALUES operator
 * @param targetRowType Target row type
 */
private void convertValuesImpl(
    Blackboard bb,
    SqlCall values,
    RelDataType targetRowType) {
  // Attempt direct conversion to LogicalValues; if that fails, deal with
  // fancy stuff like sub-queries below.
  RelNode valuesRel =
      convertRowValues(
          bb,
          values,
          values.getOperandList(),
          true,
          targetRowType);
  if (valuesRel != null) {
    bb.setRoot(valuesRel, true);
    return;
  }

  final List<RelNode> unionRels = new ArrayList<>();
  for (SqlNode rowConstructor1 : values.getOperandList()) {
    SqlCall rowConstructor = (SqlCall) rowConstructor1;
    Blackboard tmpBb = createBlackboard(bb.scope, null, false);
    replaceSubQueries(tmpBb, rowConstructor,
        RelOptUtil.Logic.TRUE_FALSE_UNKNOWN);
    final List<Pair<RexNode, String>> exps = new ArrayList<>();
    for (Ord<SqlNode> operand : Ord.zip(rowConstructor.getOperandList())) {
      exps.add(
          Pair.of(
              tmpBb.convertExpression(operand.e),
              validator.deriveAlias(operand.e, operand.i)));
    }
    RelNode in =
        (null == tmpBb.root)
            ? LogicalValues.createOneRow(cluster)
            : tmpBb.root;
    unionRels.add(
        RelOptUtil.createProject(
            in,
            Pair.left(exps),
            Pair.right(exps),
            true));
  }

  if (unionRels.size() == 0) {
    throw new AssertionError("empty values clause");
  } else if (unionRels.size() == 1) {
    bb.setRoot(
        unionRels.get(0),
        true);
  } else {
    bb.setRoot(
        LogicalUnion.create(unionRels, true),
        true);
  }

  // REVIEW jvs 22-Jan-2004:  should I add
  // mapScopeToLux.put(validator.getScope(values),bb.root);
  // ?
}
 
开发者ID:apache,项目名称:kylin,代码行数:68,代码来源:SqlToRelConverter.java


示例30: validateGroupingSets

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private void validateGroupingSets(SqlValidatorScope groupScope,
    AggregatingSelectScope aggregatingScope, SqlCall groupItem) {
  for (SqlNode node : groupItem.getOperandList()) {
    validateGroupItem(groupScope, aggregatingScope, node);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:7,代码来源:SqlValidatorImpl.java


示例31: convertGroupSet

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/** Analyzes a GROUPING SETS item in a GROUP BY clause. */
private static void convertGroupSet(SqlValidatorScope scope,
    GroupAnalyzer groupAnalyzer,
    ImmutableList.Builder<ImmutableBitSet> builder, SqlNode groupExpr) {
  switch (groupExpr.getKind()) {
  case GROUPING_SETS:
    final SqlCall call = (SqlCall) groupExpr;
    for (SqlNode node : call.getOperandList()) {
      convertGroupSet(scope, groupAnalyzer, builder, node);
    }
    return;
  case ROW:
    final List<ImmutableBitSet> bitSets =
        analyzeGroupTuple(scope, groupAnalyzer,
            ((SqlCall) groupExpr).getOperandList());
    builder.add(ImmutableBitSet.union(bitSets));
    return;
  case ROLLUP:
  case CUBE: {
    // GROUPING SETS ( (a), ROLLUP(c,b), CUBE(d,e) )
    // is EQUIVALENT to
    // GROUPING SETS ( (a), (c,b), (b) ,(), (d,e), (d), (e) ).
    // Expand all ROLLUP/CUBE nodes
    List<ImmutableBitSet> operandBitSet =
        analyzeGroupTuple(scope, groupAnalyzer,
            ((SqlCall) groupExpr).getOperandList());
    switch (groupExpr.getKind()) {
    case ROLLUP:
      builder.addAll(rollup(operandBitSet));
      return;
    default:
      builder.addAll(cube(operandBitSet));
      return;
    }
  }
  default:
    builder.add(
        analyzeGroupExpr(scope, groupAnalyzer, groupExpr));
    return;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:42,代码来源:SqlValidatorUtil.java


示例32: copy

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/** Creates a copy of a call with a new operator. */
private static SqlCall copy(SqlCall call, SqlOperator operator) {
  final List<SqlNode> list = call.getOperandList();
  return new SqlBasicCall(operator, list.toArray(new SqlNode[list.size()]),
      call.getParserPosition());
}
 
开发者ID:apache,项目名称:calcite,代码行数:7,代码来源:SqlStdOperatorTable.java



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