本文整理汇总了Java中org.apache.calcite.sql.SqlCall类的典型用法代码示例。如果您正苦于以下问题:Java SqlCall类的具体用法?Java SqlCall怎么用?Java SqlCall使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SqlCall类属于org.apache.calcite.sql包,在下文中一共展示了SqlCall类的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包/类
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
assert call.operandCount() == 1;
final SqlNode arg = call.operand(0);
final SqlNode expr;
switch (subtype) {
case AVG:
expr = expandAvg(arg);
break;
case STDDEV_POP:
expr = expandVariance(arg, true, true);
break;
case STDDEV_SAMP:
expr = expandVariance(arg, false, true);
break;
case VAR_POP:
expr = expandVariance(arg, true, false);
break;
case VAR_SAMP:
expr = expandVariance(arg, false, false);
break;
default:
throw Util.unexpected(subtype);
}
return cx.convertExpression(expr);
}
示例4: 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);
}
示例5: 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);
}
示例6: convertCall
import org.apache.calcite.sql.SqlCall; //导入依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
final RexBuilder rexBuilder = cx.getRexBuilder();
final SqlLiteral literal = (SqlLiteral) call.getOperandList().get(0);
final String value = ((NlsString)literal.getValue()).getValue();
TimeUnitRange range = VALID_PERIODS.get(value.toLowerCase());
Preconditions.checkNotNull(range, "Unhandle range type: %s.", value);
List<RexNode> exprs = new ArrayList<>();
exprs.add(rexBuilder.makeFlag(range));
exprs.add(cx.convertExpression(call.getOperandList().get(1)));
RelDataTypeFactory typeFactory = cx.getTypeFactory();
final RelDataType returnType
= typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());
return rexBuilder.makeCall(returnType, SqlStdOperatorTable.EXTRACT, exprs);
}
示例7: 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));
}
示例8: containsInOperator
import org.apache.calcite.sql.SqlCall; //导入依赖的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;
}
}
示例9: convertSetOp
import org.apache.calcite.sql.SqlCall; //导入依赖的package包/类
/**
* Converts a set operation (UNION, INTERSECT, MINUS) into relational
* expressions.
*
* @param call Call to set operator
* @return Relational expression
*/
protected RelNode convertSetOp(SqlCall call) {
final RelNode left =
convertQueryRecursive(call.operand(0), false, null).project();
final RelNode right =
convertQueryRecursive(call.operand(1), false, null).project();
switch (call.getKind()) {
case UNION:
return LogicalUnion.create(ImmutableList.of(left, right), all(call));
case INTERSECT:
return LogicalIntersect.create(ImmutableList.of(left, right), all(call));
case EXCEPT:
return LogicalMinus.create(ImmutableList.of(left, right), all(call));
default:
throw Util.unexpected(call.getKind());
}
}
示例10: AggConverter
import org.apache.calcite.sql.SqlCall; //导入依赖的package包/类
/**
* Creates an AggConverter.
*
* <p>The <code>select</code> parameter provides enough context to name
* aggregate calls which are top-level select list items.
*
* @param bb Blackboard
* @param select Query being translated; provides context to give
*/
public AggConverter(Blackboard bb, SqlSelect select) {
this.bb = bb;
this.aggregatingSelectScope =
(AggregatingSelectScope) bb.getValidator().getSelectScope(select);
// Collect all expressions used in the select list so that aggregate
// calls can be named correctly.
final SqlNodeList selectList = select.getSelectList();
for (int i = 0; i < selectList.size(); i++) {
SqlNode selectItem = selectList.get(i);
String name = null;
if (SqlUtil.isCallTo(
selectItem,
SqlStdOperatorTable.AS)) {
final SqlCall call = (SqlCall) selectItem;
selectItem = call.operand(0);
name = call.operand(1).toString();
}
if (name == null) {
name = validator.deriveAlias(selectItem, i);
}
nameMap.put(selectItem.toString(), name);
}
}
示例11: addGroupExpr
import org.apache.calcite.sql.SqlCall; //导入依赖的package包/类
public int addGroupExpr(SqlNode expr) {
int ref = lookupGroupExpr(expr);
if (ref >= 0) {
return ref;
}
final int index = groupExprs.size();
groupExprs.add(expr);
String name = nameMap.get(expr.toString());
RexNode convExpr = bb.convertExpression(expr);
addExpr(convExpr, name);
if (expr instanceof SqlCall) {
SqlCall call = (SqlCall) expr;
for (Pair<SqlNode, AuxiliaryConverter> p
: SqlStdOperatorTable.convertGroupToAuxiliaryCalls(call)) {
addAuxiliaryGroupExpr(p.left, index, p.right);
}
}
return index;
}
示例12: visit
import org.apache.calcite.sql.SqlCall; //导入依赖的package包/类
@Override public Void visit(SqlCall call) {
// ignore window aggregates and ranking functions (associated with OVER operator)
if (call.getOperator().getKind() == SqlKind.OVER) {
return null;
}
if (call.getOperator().isAggregator()) {
list.add(call);
return null;
}
// Don't traverse into sub-queries, even if they contain aggregate
// functions.
if (call instanceof SqlSelect) {
return null;
}
return call.getOperator().acceptCall(this, call);
}
示例13: convertGroupToAuxiliaryCalls
import org.apache.calcite.sql.SqlCall; //导入依赖的package包/类
/** Converts a call to a grouped window function to a call to its auxiliary
* window function(s). For other calls returns null.
*
* <p>For example, converts {@code TUMBLE_START(rowtime, INTERVAL '1' HOUR))}
* to {@code TUMBLE(rowtime, INTERVAL '1' HOUR))}. */
public static List<Pair<SqlNode, AuxiliaryConverter>>
convertGroupToAuxiliaryCalls(SqlCall call) {
final SqlOperator op = call.getOperator();
if (op instanceof SqlGroupFunction
&& op.isGroup()) {
ImmutableList.Builder<Pair<SqlNode, AuxiliaryConverter>> builder =
ImmutableList.builder();
for (final SqlGroupFunction f
: ((SqlGroupFunction) op).getAuxiliaryFunctions()) {
builder.add(
Pair.<SqlNode, AuxiliaryConverter>of(copy(call, f),
new AuxiliaryConverter.Impl(f)));
}
return builder.build();
}
return ImmutableList.of();
}
示例14: containsInOperator
import org.apache.calcite.sql.SqlCall; //导入依赖的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;
}
}
示例15: convertSetOp
import org.apache.calcite.sql.SqlCall; //导入依赖的package包/类
/**
* Converts a set operation (UNION, INTERSECT, MINUS) into relational
* expressions.
*
* @param call Call to set operator
* @return Relational expression
*/
protected RelNode convertSetOp(SqlCall call) {
final RelNode left =
convertQueryRecursive(call.operand(0), false, null).project();
final RelNode right =
convertQueryRecursive(call.operand(1), false, null).project();
switch (call.getKind()) {
case UNION:
return LogicalUnion.create(ImmutableList.of(left, right), all(call));
case INTERSECT:
return LogicalIntersect.create(ImmutableList.of(left, right), all(call));
case EXCEPT:
return LogicalMinus.create(ImmutableList.of(left, right), all(call));
default:
throw Util.unexpected(call.getKind());
}
}