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


Java SqlOperator类代码示例

本文整理汇总了Java中org.apache.calcite.sql.SqlOperator的典型用法代码示例。如果您正苦于以下问题:Java SqlOperator类的具体用法?Java SqlOperator怎么用?Java SqlOperator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: convertCall

import org.apache.calcite.sql.SqlOperator; //导入依赖的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));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:ConvertletTable.java

示例2: getConvertFunctionException

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
private UserException getConvertFunctionException(final String functionName, final String typeName) {
  final String newFunctionName = functionName + typeName;
  final String typeNameToPrint = typeName.length()==0 ? "<empty_string>" : typeName;
  final UserException.Builder exceptionBuilder = UserException.unsupportedError()
          .message("%s does not support conversion %s type '%s'.", functionName, functionName.substring(8).toLowerCase(), typeNameToPrint);
  // Build a nice error message
  if (typeName.length()>0) {
    List<String> ops = new ArrayList<>();
    for (SqlOperator op : table.getOperatorList()) {
      ops.add(op.getName());
    }
    final String bestMatch = ApproximateStringMatcher.getBestMatch(ops, newFunctionName);
    if (bestMatch != null && bestMatch.length() > 0 && bestMatch.toLowerCase().startsWith("convert")) {
      final StringBuilder s = new StringBuilder("Did you mean ")
              .append(bestMatch.substring(functionName.length()))
              .append("?");
      exceptionBuilder.addContext(s.toString());
    }
  }
  return exceptionBuilder.build(logger);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:22,代码来源:PreProcessLogicalRel.java

示例3: lookupOperatorOverloads

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
@Override
public void lookupOperatorOverloads(SqlIdentifier opName, SqlFunctionCategory category, SqlSyntax syntax, List<SqlOperator> operatorList) {
  if (syntax == SqlSyntax.FUNCTION) {

    // add optiq.
    inner.lookupOperatorOverloads(opName, category, syntax, operatorList);

    if(!operatorList.isEmpty()){
      return;
    }

    List<SqlOperator> drillOps = opMap.get(opName.getSimple().toLowerCase());
    if(drillOps != null){
      operatorList.addAll(drillOps);
    }

  } else {
    inner.lookupOperatorOverloads(opName, category, syntax, operatorList);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:21,代码来源:DrillOperatorTable.java

示例4: register

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
public void register(DrillOperatorTable operatorTable) {
  SqlOperator op;
  for (Entry<String, Collection<DrillFuncHolder>> function : methods.asMap().entrySet()) {
    Set<Integer> argCounts = Sets.newHashSet();
    String name = function.getKey().toUpperCase();
    for (DrillFuncHolder func : function.getValue()) {
      if (argCounts.add(func.getParamCount())) {
        if (func.isAggregating()) {
          op = new DrillSqlAggOperator(name, func.getParamCount());
        } else {
          boolean isDeterministic;
          // prevent Drill from folding constant functions with types that cannot be materialized
          // into literals
          if (DrillConstExecutor.NON_REDUCIBLE_TYPES.contains(func.getReturnType().getMinorType())) {
            isDeterministic = false;
          } else {
            isDeterministic = func.isDeterministic();
          }
          op = new DrillSqlOperator(name, func.getParamCount(), func.getReturnType(), isDeterministic);
        }
        operatorTable.add(function.getKey(), op);
      }
    }
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:26,代码来源:DrillFunctionRegistry.java

示例5: getConvertFunctionException

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
private UserException getConvertFunctionException(final String functionName, final String typeName) {
  final String newFunctionName = functionName + typeName;
  final boolean emptyTypeName = typeName.isEmpty();
  final String typeNameToPrint = emptyTypeName ? "<empty_string>" : typeName;
  final UserException.Builder exceptionBuilder = UserException.unsupportedError()
    .message("%s does not support conversion %s type '%s'.", functionName, functionName.substring(8).toLowerCase(), typeNameToPrint);
  // Build a nice error message
  if (!emptyTypeName) {
    List<String> ops = new ArrayList<>();
    for (SqlOperator op : table.getOperatorList()) {
      ops.add(op.getName());
    }
    final String bestMatch = ApproximateStringMatcher.getBestMatch(ops, newFunctionName);
    if (bestMatch != null && bestMatch.length() > 0 && bestMatch.toLowerCase().startsWith("convert")) {
      final StringBuilder s = new StringBuilder("Did you mean ")
        .append(bestMatch.substring(functionName.length()))
        .append("?");
      exceptionBuilder.addContext(s.toString());
    }
  }
  return exceptionBuilder.build(logger);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:PreProcessRel.java

示例6: convertGroupToAuxiliaryCalls

import org.apache.calcite.sql.SqlOperator; //导入依赖的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

示例7: evaluate

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
/**
 * Evaluates a {@link NumericHaving}.
 *
 * @param having  The NumericHaving filter to be evaluated.
 * @param builder  The RelBuilder used with Calcite to make queries.
 * @param apiToFieldMapper  A function to get the aliased aggregation's name from the metric name.
 *
 * @return the equivalent {@link RexNode} to be used in a sql query.
 */
public RexNode evaluate(NumericHaving having, RelBuilder builder, ApiToFieldMapper apiToFieldMapper) {
    Having.DefaultHavingType havingType = (Having.DefaultHavingType) having.getType();
    SqlOperator operator = null;
    switch (havingType) {
        case EQUAL_TO:
            operator = SqlStdOperatorTable.EQUALS;
            break;
        case LESS_THAN:
            operator = SqlStdOperatorTable.LESS_THAN;
            break;
        case GREATER_THAN:
            operator = SqlStdOperatorTable.GREATER_THAN;
            break;
    }
    return builder.call(
            operator,
            builder.field(apiToFieldMapper.apply(having.getAggregation())),
            builder.literal(having.getValue())
    );
}
 
开发者ID:yahoo,项目名称:fili,代码行数:30,代码来源:HavingEvaluator.java

示例8: listEvaluate

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
/**
 * Evaluates a {@link MultiClauseHaving} filter by performing it's operation over a list of other havings.
 *
 * @param multiClauseHaving  The MultiClauseHaving filter to be evaluated.
 * @param operator  The operator to be performed over the inner clauses of this having filter.
 * @param builder  The RelBuilder used with Calcite to make queries.
 * @param apiToFieldMapper  A function to get the aliased aggregation's name from the metric name.
 *
 * @return the equivalent {@link RexNode} to be used in a sql query.
 */
public RexNode listEvaluate(
        MultiClauseHaving multiClauseHaving,
        SqlOperator operator,
        RelBuilder builder,
        ApiToFieldMapper apiToFieldMapper
) {
    List<RexNode> rexNodes = multiClauseHaving.getHavings()
            .stream()
            .map(having -> dispatcher.invoke(having, builder, apiToFieldMapper))
            .collect(Collectors.toList());

    return builder.call(
            operator,
            rexNodes
    );
}
 
开发者ID:yahoo,项目名称:fili,代码行数:27,代码来源:HavingEvaluator.java

示例9: listEvaluate

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
/**
 * Evaluates a complex filter by performing a {@link SqlOperator} over a list of dimensions.
 *
 * @param complexFilter  A complexFilter to be evaluated.
 * @param operator  The sql operator to be applied to a complexFilter's fields.
 * @param builder  The RelBuilder used to build queries with Calcite.
 * @param apiToFieldMapper  A function to get the aliased aggregation's name from the metric name.
 *
 * @return a RexNode containing an equivalent filter to the one given.
 */
private RexNode listEvaluate(
        ComplexFilter complexFilter,
        SqlOperator operator,
        RelBuilder builder,
        ApiToFieldMapper apiToFieldMapper
) {
    List<RexNode> rexNodes = complexFilter.getFields()
            .stream()
            .map(filter -> dispatcher.invoke(filter, builder, apiToFieldMapper))
            .collect(Collectors.toList());

    return builder.call(
            operator,
            rexNodes
    );
}
 
开发者ID:yahoo,项目名称:fili,代码行数:27,代码来源:FilterEvaluator.java

示例10: getConvertFunctionException

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
private UserException getConvertFunctionException(final String functionName, final String typeName) {
  final String newFunctionName = functionName + typeName;
  final String typeNameToPrint = typeName.length()==0 ? "<empty_string>" : typeName;
  final UserException.Builder exceptionBuilder = UserException.unsupportedError()
          .message("%s does not support conversion %s type '%s'.", functionName, functionName.substring(8).toLowerCase(), typeNameToPrint);
  // Build a nice error message
  if (typeName.length()>0) {
    List<String> ops = new ArrayList<>();
    for (SqlOperator op : table.getOperatorList()) {
      ops.add(op.getName());
    }
    final String bestMatch = ApproximateStringMatcher.getBestMatch(ops, newFunctionName);
    if (bestMatch != null && bestMatch.length() > functionName.length() && bestMatch.toLowerCase().startsWith("convert")) {
      final StringBuilder s = new StringBuilder("Did you mean ")
              .append(bestMatch.substring(functionName.length()))
              .append("?");
      exceptionBuilder.addContext(s.toString());
    }
  }
  return exceptionBuilder.build(logger);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:22,代码来源:PreProcessLogicalRel.java

示例11: populateFromTypeInference

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
private void populateFromTypeInference(SqlIdentifier opName, SqlFunctionCategory category,
    SqlSyntax syntax, List<SqlOperator> operatorList) {
  final List<SqlOperator> calciteOperatorList = Lists.newArrayList();
  inner.lookupOperatorOverloads(opName, category, syntax, calciteOperatorList);
  if(!calciteOperatorList.isEmpty()) {
    for(SqlOperator calciteOperator : calciteOperatorList) {
      if(calciteToWrapper.containsKey(calciteOperator)) {
        operatorList.add(calciteToWrapper.get(calciteOperator));
      } else {
        operatorList.add(calciteOperator);
      }
    }
  } else {
    // if no function is found, check in Drill UDFs
    if (operatorList.isEmpty() && (syntax == SqlSyntax.FUNCTION || syntax == SqlSyntax.FUNCTION_ID) && opName.isSimple()) {
      List<SqlOperator> drillOps = drillOperatorsWithInferenceMap.get(opName.getSimple().toLowerCase());
      if (drillOps != null && !drillOps.isEmpty()) {
        operatorList.addAll(drillOps);
      }
    }
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:23,代码来源:DrillOperatorTable.java

示例12: populateWrappedCalciteOperators

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
private void populateWrappedCalciteOperators() {
  for(SqlOperator calciteOperator : inner.getOperatorList()) {
    final SqlOperator wrapper;
    if(calciteOperator instanceof SqlAggFunction) {
      wrapper = new DrillCalciteSqlAggFunctionWrapper((SqlAggFunction) calciteOperator,
          getFunctionListWithInference(calciteOperator.getName()));
    } else if(calciteOperator instanceof SqlFunction) {
      wrapper = new DrillCalciteSqlFunctionWrapper((SqlFunction) calciteOperator,
          getFunctionListWithInference(calciteOperator.getName()));
    } else {
      final String drillOpName = FunctionCallFactory.replaceOpWithFuncName(calciteOperator.getName());
      final List<DrillFuncHolder> drillFuncHolders = getFunctionListWithInference(drillOpName);
      if(drillFuncHolders.isEmpty() || calciteOperator == SqlStdOperatorTable.UNARY_MINUS || calciteOperator == SqlStdOperatorTable.UNARY_PLUS) {
        continue;
      }

      wrapper = new DrillCalciteSqlOperatorWrapper(calciteOperator, drillOpName, drillFuncHolders);
    }
    calciteToWrapper.put(calciteOperator, wrapper);
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:22,代码来源:DrillOperatorTable.java

示例13: registerOperatorsWithoutInference

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
private void registerOperatorsWithoutInference(DrillOperatorTable operatorTable) {
  SqlOperator op;
  for (Entry<String, Collection<DrillFuncHolder>> function : registeredFunctions.asMap().entrySet()) {
    Set<Integer> argCounts = Sets.newHashSet();
    String name = function.getKey().toUpperCase();
    for (DrillFuncHolder func : function.getValue()) {
      if (argCounts.add(func.getParamCount())) {
        if (func.isAggregating()) {
          op = new DrillSqlAggOperatorWithoutInference(name, func.getParamCount());
        } else {
          boolean isDeterministic;
          // prevent Drill from folding constant functions with types that cannot be materialized
          // into literals
          if (DrillConstExecutor.NON_REDUCIBLE_TYPES.contains(func.getReturnType().getMinorType())) {
            isDeterministic = false;
          } else {
            isDeterministic = func.isDeterministic();
          }
          op = new DrillSqlOperatorWithoutInference(name, func.getParamCount(), func.getReturnType(), isDeterministic);
        }
        operatorTable.addOperatorWithoutInference(function.getKey(), op);
      }
    }
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:26,代码来源:DrillFunctionRegistry.java

示例14: registerOperatorsWithoutInference

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
private void registerOperatorsWithoutInference(DrillOperatorTable operatorTable, Map<String, Collection<DrillFuncHolder>> registeredFunctions) {
  SqlOperator op;
  for (Entry<String, Collection<DrillFuncHolder>> function : registeredFunctions.entrySet()) {
    Set<Integer> argCounts = Sets.newHashSet();
    String name = function.getKey().toUpperCase();
    for (DrillFuncHolder func : function.getValue()) {
      if (argCounts.add(func.getParamCount())) {
        if (func.isAggregating()) {
          op = new DrillSqlAggOperatorWithoutInference(name, func.getParamCount());
        } else {
          boolean isDeterministic;
          // prevent Drill from folding constant functions with types that cannot be materialized
          // into literals
          if (DrillConstExecutor.NON_REDUCIBLE_TYPES.contains(func.getReturnType().getMinorType())) {
            isDeterministic = false;
          } else {
            isDeterministic = func.isDeterministic();
          }
          op = new DrillSqlOperatorWithoutInference(name, func.getParamCount(), func.getReturnType(), isDeterministic, func.isNiladic());
        }
        operatorTable.addOperatorWithoutInference(function.getKey(), op);
      }
    }
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:26,代码来源:LocalFunctionRegistry.java

示例15: reverseOperatorDirection

import org.apache.calcite.sql.SqlOperator; //导入依赖的package包/类
private static SqlOperator reverseOperatorDirection(SqlOperator op) {
    switch (op.kind) {
    case GREATER_THAN:
        return SqlStdOperatorTable.LESS_THAN;
    case GREATER_THAN_OR_EQUAL:
        return SqlStdOperatorTable.LESS_THAN_OR_EQUAL;
    case LESS_THAN:
        return SqlStdOperatorTable.GREATER_THAN;
    case LESS_THAN_OR_EQUAL:
        return SqlStdOperatorTable.GREATER_THAN_OR_EQUAL;
    case EQUALS:
    case IS_NOT_DISTINCT_FROM:
    case NOT_EQUALS:
        return op;
    default:
        throw new AssertionError(op);
    }
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:19,代码来源:JdbcRules.java


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