本文整理汇总了Java中org.apache.calcite.sql.SqlCall.operandCount方法的典型用法代码示例。如果您正苦于以下问题:Java SqlCall.operandCount方法的具体用法?Java SqlCall.operandCount怎么用?Java SqlCall.operandCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.sql.SqlCall
的用法示例。
在下文中一共展示了SqlCall.operandCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unparseCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec, int rightPrec) {
if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
SqlUtil.unparseFunctionSyntax(OracleSqlOperatorTable.SUBSTR, writer, call);
} else {
switch (call.getKind()) {
case FLOOR:
if (call.operandCount() != 2) {
super.unparseCall(writer, call, leftPrec, rightPrec);
return;
}
final SqlLiteral timeUnitNode = call.operand(1);
final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class);
SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, timeUnit.name(),
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
break;
default:
super.unparseCall(writer, call, leftPrec, rightPrec);
}
}
}
示例2: unparseCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec, int rightPrec) {
if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
if (call.operandCount() != 3) {
throw new IllegalArgumentException("MSSQL SUBSTRING requires FROM and FOR arguments");
}
SqlUtil.unparseFunctionSyntax(MSSQL_SUBSTRING, writer, call);
} else {
switch (call.getKind()) {
case FLOOR:
if (call.operandCount() != 2) {
super.unparseCall(writer, call, leftPrec, rightPrec);
return;
}
unparseFloor(writer, call);
break;
default:
super.unparseCall(writer, call, leftPrec, rightPrec);
}
}
}
示例3: unparseCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec, int rightPrec) {
switch (call.getKind()) {
case FLOOR:
if (call.operandCount() != 2) {
super.unparseCall(writer, call, leftPrec, rightPrec);
return;
}
final SqlLiteral timeUnitNode = call.operand(1);
final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class);
final String translatedLit = convertTimeUnit(timeUnit);
SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, translatedLit,
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
break;
default:
super.unparseCall(writer, call, leftPrec, rightPrec);
}
}
示例4: unparseCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec, int rightPrec) {
switch (call.getKind()) {
case FLOOR:
if (call.operandCount() != 2) {
super.unparseCall(writer, call, leftPrec, rightPrec);
return;
}
unparseFloor(writer, call);
break;
default:
super.unparseCall(writer, call, leftPrec, rightPrec);
}
}
示例5: unparseCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override public void unparseCall(SqlWriter writer, SqlCall call,
int leftPrec, int rightPrec) {
switch (call.getKind()) {
case FLOOR:
if (call.operandCount() != 2) {
super.unparseCall(writer, call, leftPrec, rightPrec);
return;
}
final SqlLiteral timeUnitNode = call.operand(1);
final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.class);
SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, timeUnit.name(),
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, call2, "DATE_TRUNC", false);
break;
default:
super.unparseCall(writer, call, leftPrec, rightPrec);
}
}
示例6: unparse
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public void unparse(
SqlWriter writer,
SqlCall call,
int leftPrec,
int rightPrec) {
final SqlWriter.Frame frame = writer.startFunCall(getName());
call.operand(0).unparse(writer, leftPrec, rightPrec);
writer.sep("FROM");
call.operand(1).unparse(writer, leftPrec, rightPrec);
if (3 == call.operandCount()) {
writer.sep("FOR");
call.operand(2).unparse(writer, leftPrec, rightPrec);
}
writer.endFunCall(frame);
}
示例7: unparse
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public void unparse(
SqlWriter writer,
SqlCall call,
int leftPrec,
int rightPrec) {
final SqlWriter.Frame frame = writer.startList("", "");
call.operand(0).unparse(writer, getLeftPrec(), getRightPrec());
writer.sep(getName());
call.operand(1).unparse(writer, getLeftPrec(), getRightPrec());
if (call.operandCount() == 3) {
writer.sep("ESCAPE");
call.operand(2).unparse(writer, getLeftPrec(), getRightPrec());
}
writer.endList(frame);
}
示例8: unparse
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public void unparse(
SqlWriter writer,
SqlCall call,
int leftPrec,
int rightPrec) {
final SqlWriter.Frame frame = writer.startFunCall(getName());
call.operand(0).unparse(writer, leftPrec, rightPrec);
writer.sep("PLACING");
call.operand(1).unparse(writer, leftPrec, rightPrec);
writer.sep("FROM");
call.operand(2).unparse(writer, leftPrec, rightPrec);
if (4 == call.operandCount()) {
writer.sep("FOR");
call.operand(3).unparse(writer, leftPrec, rightPrec);
}
writer.endFunCall(frame);
}
示例9: checkIntervalConv
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public void checkIntervalConv(String sql, String expected) {
SqlValidator validator = getValidator();
final SqlCall n = (SqlCall) parseAndValidate(validator, sql);
SqlNode node = null;
for (int i = 0; i < n.operandCount(); i++) {
node = stripAs(n.operand(i));
if (node instanceof SqlCall) {
node = ((SqlCall) node).operand(0);
break;
}
}
assertNotNull(node);
SqlIntervalLiteral intervalLiteral = (SqlIntervalLiteral) node;
SqlIntervalLiteral.IntervalValue interval =
(SqlIntervalLiteral.IntervalValue) intervalLiteral.getValue();
long l =
interval.getIntervalQualifier().isYearMonth()
? SqlParserUtil.intervalToMonths(interval)
: SqlParserUtil.intervalToMillis(interval);
String actual = l + "";
assertEquals(expected, actual);
}
示例10: effectiveArgCount
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private int effectiveArgCount(SqlCall call) {
switch (call.getKind()) {
case GROUPING:
return call.operandCount();
case GROUP_ID:
return groupExprs.size();
default:
throw new AssertionError(call.getKind());
}
}
示例11: isSimpleCount
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private boolean isSimpleCount(SqlCall call) {
if (call.getOperator().isName("COUNT") && call.operandCount() == 1) {
final SqlNode parm = call.operand(0);
if ((parm instanceof SqlIdentifier || parm instanceof SqlNumericLiteral) //
&& call.getFunctionQuantifier() == null) {
return true;
}
}
return false;
}
示例12: effectiveArgCount
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private int effectiveArgCount(SqlCall call) {
switch (call.getKind()) {
case GROUPING:
return call.operandCount();
case GROUP_ID:
return groupExprs.size();
default:
throw new AssertionError(call.getKind());
}
}
示例13: convertFloorCeil
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
protected RexNode convertFloorCeil(SqlRexContext cx, SqlCall call) {
final boolean floor = call.getKind() == SqlKind.FLOOR;
// Rewrite floor, ceil of interval
if (call.operandCount() == 1
&& call.operand(0) instanceof SqlIntervalLiteral) {
final SqlIntervalLiteral literal = call.operand(0);
SqlIntervalLiteral.IntervalValue interval =
(SqlIntervalLiteral.IntervalValue) literal.getValue();
BigDecimal val =
interval.getIntervalQualifier().getStartUnit().multiplier;
RexNode rexInterval = cx.convertExpression(literal);
final RexBuilder rexBuilder = cx.getRexBuilder();
RexNode zero = rexBuilder.makeExactLiteral(BigDecimal.valueOf(0));
RexNode cond = ge(rexBuilder, rexInterval, zero);
RexNode pad =
rexBuilder.makeExactLiteral(val.subtract(BigDecimal.ONE));
RexNode cast = rexBuilder.makeReinterpretCast(
rexInterval.getType(), pad, rexBuilder.makeLiteral(false));
RexNode sum = floor
? minus(rexBuilder, rexInterval, cast)
: plus(rexBuilder, rexInterval, cast);
RexNode kase = floor
? case_(rexBuilder, rexInterval, cond, sum)
: case_(rexBuilder, sum, cond, rexInterval);
RexNode factor = rexBuilder.makeExactLiteral(val);
RexNode div = divideInt(rexBuilder, kase, factor);
return multiply(rexBuilder, div, factor);
}
// normal floor, ceil function
return convertFunction(cx, (SqlFunction) call.getOperator(), call);
}
示例14: registerSubQueries
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
private void registerSubQueries(
SqlValidatorScope parentScope,
SqlNode node) {
if (node == null) {
return;
}
if (node.getKind().belongsTo(SqlKind.QUERY)
|| node.getKind() == SqlKind.MULTISET_QUERY_CONSTRUCTOR
|| node.getKind() == SqlKind.MULTISET_VALUE_CONSTRUCTOR) {
registerQuery(parentScope, null, node, node, null, false);
} else if (node instanceof SqlCall) {
validateNodeFeature(node);
SqlCall call = (SqlCall) node;
for (int i = 0; i < call.operandCount(); i++) {
registerOperandSubQueries(parentScope, call, i);
}
} else if (node instanceof SqlNodeList) {
SqlNodeList list = (SqlNodeList) node;
for (int i = 0, count = list.size(); i < count; i++) {
SqlNode listNode = list.get(i);
if (listNode.getKind().belongsTo(SqlKind.QUERY)) {
listNode =
SqlStdOperatorTable.SCALAR_QUERY.createCall(
listNode.getParserPosition(),
listNode);
list.set(i, listNode);
}
registerSubQueries(parentScope, listNode);
}
} else {
// atomic node -- can be ignored
}
}
示例15: validateCall
import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public void validateCall(
SqlCall call,
SqlValidatorScope scope) {
final SqlOperator operator = call.getOperator();
if ((call.operandCount() == 0)
&& (operator.getSyntax() == SqlSyntax.FUNCTION_ID)
&& !call.isExpanded()
&& !conformance.allowNiladicParentheses()) {
// For example, "LOCALTIME()" is illegal. (It should be
// "LOCALTIME", which would have been handled as a
// SqlIdentifier.)
throw handleUnresolvedFunction(call, (SqlFunction) operator,
ImmutableList.<RelDataType>of(), null);
}
SqlValidatorScope operandScope = scope.getOperandScope(call);
if (operator instanceof SqlFunction
&& ((SqlFunction) operator).getFunctionType()
== SqlFunctionCategory.MATCH_RECOGNIZE
&& !(operandScope instanceof MatchRecognizeScope)) {
throw newValidationError(call,
Static.RESOURCE.functionMatchRecognizeOnly(call.toString()));
}
// Delegate validation to the operator.
operator.validateCall(call, this, scope, operandScope);
}