本文整理汇总了Java中org.apache.calcite.sql.SqlBasicCall类的典型用法代码示例。如果您正苦于以下问题:Java SqlBasicCall类的具体用法?Java SqlBasicCall怎么用?Java SqlBasicCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlBasicCall类属于org.apache.calcite.sql包,在下文中一共展示了SqlBasicCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasNestedAggregations
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
private boolean hasNestedAggregations(LogicalAggregate rel) {
List<AggregateCall> aggCallList = rel.getAggCallList();
HashSet<Integer> aggregatesArgs = new HashSet<>();
for (AggregateCall aggregateCall: aggCallList) {
aggregatesArgs.addAll(aggregateCall.getArgList());
}
for (Integer aggregatesArg : aggregatesArgs) {
SqlNode selectNode = ((SqlSelect) node).getSelectList().get(aggregatesArg);
if (!(selectNode instanceof SqlBasicCall)) {
continue;
}
for (SqlNode operand : ((SqlBasicCall) selectNode).getOperands()) {
if (operand instanceof SqlCall) {
final SqlOperator operator = ((SqlCall) operand).getOperator();
if (operator instanceof SqlAggFunction) {
return true;
}
}
}
}
return false;
}
示例2: convertCall
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
/**
* Converts a call to an operator into a {@link SqlCall} to the same
* operator.
*
* <p>Called automatically via reflection.
*
* @param converter Converter
* @param call Call
* @return Sql call
*/
public SqlNode convertCall(
RexToSqlNodeConverter converter,
RexCall call) {
if (get(call) == null) {
return null;
}
final SqlOperator op = call.getOperator();
final List<RexNode> operands = call.getOperands();
final SqlNode[] exprs = convertExpressionList(converter, operands);
if (exprs == null) {
return null;
}
return new SqlBasicCall(
op,
exprs,
SqlParserPos.ZERO);
}
示例3: registerTypeAppendOp
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
/**
* Creates and registers a convertlet for an operator in which
* the SQL representation needs the result type appended
* as an extra argument (e.g. CAST).
*
* @param op operator instance
*/
private void registerTypeAppendOp(final SqlOperator op) {
registerOp(
op,
new RexSqlConvertlet() {
public SqlNode convertCall(
RexToSqlNodeConverter converter,
RexCall call) {
SqlNode[] operands =
convertExpressionList(converter, call.operands);
if (operands == null) {
return null;
}
List<SqlNode> operandList =
new ArrayList<SqlNode>(Arrays.asList(operands));
SqlDataTypeSpec typeSpec =
SqlTypeUtil.convertTypeToSpec(call.getType());
operandList.add(typeSpec);
return new SqlBasicCall(
op,
operandList.toArray(new SqlNode[operandList.size()]),
SqlParserPos.ZERO);
}
});
}
示例4: getNode
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
public SqlNode getNode(SqlNode node){
SqlLiteral literal;
if(isArray){
literal = SqlLiteral.createExactNumeric(value, parserPos);
}else{
literal = SqlLiteral.createCharString(value, parserPos);
}
return new SqlBasicCall(SqlStdOperatorTable.ITEM, new SqlNode[]{ node, literal }, parserPos);
}
示例5: getNode
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
public static SqlNode getNode(SqlParserPos pos, Map<String, String> fieldMap, String queryString) {
SqlNode[] operands = new SqlNode[fieldMap.size() + 1];
for (String field : fieldMap.keySet()) {
int index = Integer.parseInt(fieldMap.get(field).substring(1));
operands[index] = getIdentifier(field);
}
SqlNode query = SqlLiteral.createCharString(queryString, pos);
operands[operands.length - 1] = query;
return new SqlBasicCall(OPERATOR, operands, pos);
}
示例6: convertNonCorrelatedSubQuery
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
/**
* Determines if a sub-query is non-correlated and if so, converts it to a
* constant.
*
* @param subQuery the call that references the sub-query
* @param bb blackboard used to convert the sub-query
* @param converted RelNode tree corresponding to the sub-query
* @param isExists true if the sub-query is part of an EXISTS expression
* @return Whether the sub-query can be converted to a constant
*/
private boolean convertNonCorrelatedSubQuery(
SubQuery subQuery,
Blackboard bb,
RelNode converted,
boolean isExists) {
SqlCall call = (SqlBasicCall) subQuery.node;
if (subQueryConverter.canConvertSubQuery()
&& isSubQueryNonCorrelated(converted, bb)) {
// First check if the sub-query has already been converted
// because it's a nested sub-query. If so, don't re-evaluate
// it again.
RexNode constExpr = mapConvertedNonCorrSubqs.get(call);
if (constExpr == null) {
constExpr =
subQueryConverter.convertSubQuery(
call,
this,
isExists,
config.isExplain());
}
if (constExpr != null) {
subQuery.expr = constExpr;
mapConvertedNonCorrSubqs.put(call, constExpr);
return true;
}
}
return false;
}
示例7: get
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
@Override
public SqlRexConvertlet get(SqlCall call) {
SqlRexConvertlet convertlet;
if(call.getOperator() instanceof DrillCalciteSqlWrapper) {
final SqlOperator wrapper = call.getOperator();
final SqlOperator wrapped = DrillCalciteWrapperUtility.extractSqlOperatorFromWrapper(call.getOperator());
if ((convertlet = map.get(wrapped)) != null) {
return convertlet;
}
((SqlBasicCall) call).setOperator(wrapped);
SqlRexConvertlet sqlRexConvertlet = StandardConvertletTable.INSTANCE.get(call);
((SqlBasicCall) call).setOperator(wrapper);
return sqlRexConvertlet;
}
if ((convertlet = map.get(call.getOperator())) != null) {
return convertlet;
}
return StandardConvertletTable.INSTANCE.get(call);
}
示例8: getColumnValues
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
@Override
protected List<Object> getColumnValues(List<Object> parameterValues) {
SqlBasicCall sourceNode = (SqlBasicCall) rootNode.getSource();
SqlBasicCall valuesNode = (SqlBasicCall) sourceNode.getOperandList().get(0);
List<SqlNode> operands = valuesNode.getOperandList();
List<Object> result = new ArrayList<>(operands.size());
for (SqlNode operand : operands) {
result.add(getOperandValue(operand, parameterValues));
}
return result;
}
示例9: getInput
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
private static void getInput(SqlNode node, ArrayList<String> inputSource) {
if (node instanceof SqlJoin) {
SqlJoin joinNode = (SqlJoin) node;
ArrayList<String> inputsLeft = new ArrayList<>();
ArrayList<String> inputsRight = new ArrayList<>();
getInput(joinNode.getLeft(), inputsLeft);
getInput(joinNode.getRight(), inputsRight);
if (!inputsLeft.isEmpty() && !inputsRight.isEmpty()) {
throw new SamzaException("Joins on two entities are not supported yet");
}
inputSource.addAll(inputsLeft);
inputSource.addAll(inputsRight);
} else if (node instanceof SqlIdentifier) {
inputSource.add(node.toString());
} else if (node instanceof SqlBasicCall) {
SqlBasicCall basicCall = ((SqlBasicCall) node);
if (basicCall.getOperator() instanceof SqlAsOperator) {
getInput(basicCall.operand(0), inputSource);
} else if (basicCall.getOperator() instanceof SqlUnnestOperator && basicCall.operand(0) instanceof SqlSelect) {
inputSource.add(getInputFromSelectQuery(basicCall.operand(0)));
return;
}
} else if (node instanceof SqlSelect) {
getInput(((SqlSelect) node).getFrom(), inputSource);
}
}
示例10: convertNonCorrelatedSubQuery
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
/**
* Determines if a sub-query is non-correlated and if so, converts it to a
* constant.
*
* @param subQuery the call that references the sub-query
* @param bb blackboard used to convert the sub-query
* @param converted RelNode tree corresponding to the sub-query
* @param isExists true if the sub-query is part of an EXISTS expression
* @return Whether the sub-query can be converted to a constant
*/
private boolean convertNonCorrelatedSubQuery(
SubQuery subQuery,
Blackboard bb,
RelNode converted,
boolean isExists) {
SqlCall call = (SqlBasicCall) subQuery.node;
if (subQueryConverter.canConvertSubQuery()
&& isSubQueryNonCorrelated(converted, bb)) {
// First check if the sub-query has already been converted
// because it's a nested sub-query. If so, don't re-evaluate
// it again.
RexNode constExpr = mapConvertedNonCorrSubqs.get(call);
if (constExpr == null) {
constExpr =
subQueryConverter.convertSubQuery(
call,
this,
isExists,
config.isExplain());
}
if (constExpr != null) {
subQuery.expr = constExpr;
mapConvertedNonCorrSubqs.put(call, constExpr);
return true;
}
}
return false;
}
示例11: visit
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
@Override public SqlNode visit(SqlIdentifier id) {
// First check for builtin functions which don't have
// parentheses, like "LOCALTIME".
SqlCall call =
SqlUtil.makeCall(
validator.getOperatorTable(),
id);
if (call != null) {
return call.accept(this);
}
final SqlIdentifier fqId = getScope().fullyQualify(id).identifier;
SqlNode expandedExpr = fqId;
// Convert a column ref into ITEM(*, 'col_name').
// select col_name from (select * from dynTable)
// SqlIdentifier "col_name" would be resolved to a dynamic star field in dynTable's rowType.
// Expand such SqlIdentifier to ITEM operator.
if (DynamicRecordType.isDynamicStarColName(Util.last(fqId.names))
&& !DynamicRecordType.isDynamicStarColName(Util.last(id.names))) {
SqlNode[] inputs = new SqlNode[2];
inputs[0] = fqId;
inputs[1] = SqlLiteral.createCharString(
Util.last(id.names),
id.getParserPosition());
SqlBasicCall item_call = new SqlBasicCall(
SqlStdOperatorTable.ITEM,
inputs,
id.getParserPosition());
expandedExpr = item_call;
}
validator.setOriginal(expandedExpr, id);
return expandedExpr;
}
示例12: rewriteSingleValueExpr
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
@Override public SqlNode rewriteSingleValueExpr(SqlNode aggCall) {
final SqlNode operand = ((SqlBasicCall) aggCall).operand(0);
final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO);
final SqlNode unionOperand = SqlStdOperatorTable.VALUES.createCall(SqlParserPos.ZERO,
SqlLiteral.createApproxNumeric("0", SqlParserPos.ZERO));
// For hsqldb, generate
// CASE COUNT(*)
// WHEN 0 THEN NULL
// WHEN 1 THEN MIN(<result>)
// ELSE (VALUES 1 UNION ALL VALUES 1)
// END
final SqlNode caseExpr =
new SqlCase(SqlParserPos.ZERO,
SqlStdOperatorTable.COUNT.createCall(SqlParserPos.ZERO, operand),
SqlNodeList.of(
SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO),
SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO)
),
SqlNodeList.of(
nullLiteral,
SqlStdOperatorTable.MIN.createCall(SqlParserPos.ZERO, operand)
),
SqlStdOperatorTable.SCALAR_QUERY.createCall(SqlParserPos.ZERO,
SqlStdOperatorTable.UNION_ALL
.createCall(SqlParserPos.ZERO, unionOperand, unionOperand)));
LOGGER.debug("SINGLE_VALUE rewritten into [{}]", caseExpr);
return caseExpr;
}
示例13: rewriteSingleValueExpr
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的package包/类
@Override public SqlNode rewriteSingleValueExpr(SqlNode aggCall) {
final SqlNode operand = ((SqlBasicCall) aggCall).operand(0);
final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO);
final SqlNode unionOperand = new SqlSelect(SqlParserPos.ZERO, SqlNodeList.EMPTY,
SqlNodeList.of(nullLiteral), null, null, null, null, SqlNodeList.EMPTY, null, null, null);
// For MySQL, generate
// CASE COUNT(*)
// WHEN 0 THEN NULL
// WHEN 1 THEN <result>
// ELSE (SELECT NULL UNION ALL SELECT NULL)
// END
final SqlNode caseExpr =
new SqlCase(SqlParserPos.ZERO,
SqlStdOperatorTable.COUNT.createCall(SqlParserPos.ZERO, operand),
SqlNodeList.of(
SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO),
SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO)
),
SqlNodeList.of(
nullLiteral,
operand
),
SqlStdOperatorTable.SCALAR_QUERY.createCall(SqlParserPos.ZERO,
SqlStdOperatorTable.UNION_ALL
.createCall(SqlParserPos.ZERO, unionOperand, unionOperand)));
LOGGER.debug("SINGLE_VALUE rewritten into [{}]", caseExpr);
return caseExpr;
}
示例14: copy
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的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());
}
示例15: copy
import org.apache.calcite.sql.SqlBasicCall; //导入依赖的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());
}