本文整理汇总了Java中org.apache.calcite.sql.SqlCall.getOperandList方法的典型用法代码示例。如果您正苦于以下问题:Java SqlCall.getOperandList方法的具体用法?Java SqlCall.getOperandList怎么用?Java SqlCall.getOperandList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.sql.SqlCall
的用法示例。
在下文中一共展示了SqlCall.getOperandList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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());
}
}
}
示例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);
}
示例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());
}