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


Java SqlCall.getOperator方法代码示例

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


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

示例1: 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

示例2: 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;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:SqlToRelConverter.java

示例3: 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();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:SqlStdOperatorTable.java

示例4: 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;
  }
}
 
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:SqlToRelConverter.java

示例5: validateNoAggs

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/**
 * Throws an error if there is an aggregate or windowed aggregate in the
 * given clause.
 *
 * @param aggFinder Finder for the particular kind(s) of aggregate function
 * @param node      Parse tree
 * @param clause    Name of clause: "WHERE", "GROUP BY", "ON"
 */
private void validateNoAggs(AggFinder aggFinder, SqlNode node,
                            String clause) {
  final SqlCall agg = aggFinder.findAgg(node);
  if (agg == null) {
    return;
  }
  final SqlOperator op = agg.getOperator();
  if (op == SqlStdOperatorTable.OVER) {
    throw newValidationError(agg,
        RESOURCE.windowedAggregateIllegalInClause(clause));
  } else if (op.isGroup() || op.isGroupAuxiliary()) {
    throw newValidationError(agg,
        RESOURCE.groupFunctionMustAppearInGroupByClause(op.getName()));
  } else {
    throw newValidationError(agg,
        RESOURCE.aggregateIllegalInClause(clause));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:SqlValidatorImpl.java

示例6: 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);
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:OracleSqlDialect.java

示例7: 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);
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:MssqlSqlDialect.java

示例8: 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 SqlGroupedWindowFunction
      && op.isGroup()) {
    ImmutableList.Builder<Pair<SqlNode, AuxiliaryConverter>> builder =
        ImmutableList.builder();
    for (final SqlGroupedWindowFunction f
        : ((SqlGroupedWindowFunction) op).getAuxiliaryFunctions()) {
      builder.add(
          Pair.<SqlNode, AuxiliaryConverter>of(copy(call, f),
              new AuxiliaryConverter.Impl(f)));
    }
    return builder.build();
  }
  return ImmutableList.of();
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:SqlStdOperatorTable.java

示例9: visit

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public RexNode visit(SqlCall call) {
	if (agg != null) {
		final SqlOperator op = call.getOperator();
		if (window == null
			&& (op.isAggregator() || op.getKind() == SqlKind.FILTER)) {
			return agg.lookupAggregates(call);
		}
	}
	return exprConverter.convertCall(this,
		new SqlCallBinding(validator, scope, call).permutedCall());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:SqlToRelConverter.java

示例10: convertAuxiliaryToGroupCall

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
/** Converts a call to a grouped auxiliary function
 * to a call to the grouped window function. 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 SqlCall convertAuxiliaryToGroupCall(SqlCall call) {
	final SqlOperator op = call.getOperator();
	if (op instanceof SqlGroupFunction
		&& op.isGroupAuxiliary()) {
		return copy(call, ((SqlGroupFunction) op).groupFunction);
	}
	return null;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:SqlStdOperatorTable.java

示例11: 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

示例12: get

import org.apache.calcite.sql.SqlCall; //导入方法依赖的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);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:23,代码来源:DrillConvertletTable.java

示例13: 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

示例14: visit

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
@Override
public Expression visit(SqlCall call) {
    SqlOperator sqlOperator = call.getOperator();
    if (sqlOperator instanceof SqlBinaryOperator) {
        return visitBinaryOperator((SqlBinaryOperator) sqlOperator, call.getOperandList().get(0),
                call.getOperandList().get(1));
    } else if (sqlOperator instanceof SqlSpecialOperator) {
        return visitSqlSpecialOperator((SqlSpecialOperator) sqlOperator, call.getOperandList());
    } else if (sqlOperator instanceof SqlFunction) {
        SqlFunction sqlFunction = (SqlFunction) sqlOperator;
        if (sqlFunction instanceof SqlAggFunction) {
            return visitAggregateFunction(sqlFunction.getName(), call.getOperandList());
        } else if (sqlFunction instanceof SqlUnresolvedFunction) {
            String udfName = sqlFunction.getName().toUpperCase();
            if (catalogUdfs.containsKey(udfName)) {
                Udf udfInfo = catalogUdfs.get(udfName);
                if (udfInfo.isAggregate()) {
                    return visitUserDefinedAggregateFunction(udfInfo, call.getOperandList());
                } else {
                    return visitUserDefinedFunction(udfInfo, call.getOperandList());
                }
            } else {
                throw new UnsupportedOperationException("Unknown built-in or User defined function '" + udfName + "'");
            }
        } else {
            return visitFunction(sqlFunction.getName(), call.getOperandList());
        }
    } else {
        throw new UnsupportedOperationException("Operator " + sqlOperator.getName() + " is not supported");
    }
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:32,代码来源:ExpressionGenerator.java

示例15: visit

import org.apache.calcite.sql.SqlCall; //导入方法依赖的package包/类
public RexNode visit(SqlCall call) {
  if (agg != null) {
    final SqlOperator op = call.getOperator();
    if (window == null
        && (op.isAggregator() || op.getKind() == SqlKind.FILTER)) {
      return agg.lookupAggregates(call);
    }
  }
  return exprConverter.convertCall(this,
      new SqlCallBinding(validator, scope, call).permutedCall());
}
 
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:SqlToRelConverter.java


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