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


Java SqlStdOperatorTable类代码示例

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


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

示例1: convert

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
public static DrillJoinRel convert(Join join, ConversionContext context) throws InvalidRelException{
  RelNode left = context.toRel(join.getLeft());
  RelNode right = context.toRel(join.getRight());

  List<RexNode> joinConditions = new ArrayList<RexNode>();
  // right fields appear after the LHS fields.
  final int rightInputOffset = left.getRowType().getFieldCount();
  for (JoinCondition condition : join.getConditions()) {
    RelDataTypeField leftField = left.getRowType().getField(ExprHelper.getFieldName(condition.getLeft()), true, false);
    RelDataTypeField rightField = right.getRowType().getField(ExprHelper.getFieldName(condition.getRight()), true, false);
      joinConditions.add(
          context.getRexBuilder().makeCall(
              SqlStdOperatorTable.EQUALS,
              context.getRexBuilder().makeInputRef(leftField.getType(), leftField.getIndex()),
              context.getRexBuilder().makeInputRef(rightField.getType(), rightInputOffset + rightField.getIndex())
              )
              );
  }
  RexNode rexCondition = RexUtil.composeConjunction(context.getRexBuilder(), joinConditions, false);
  DrillJoinRel joinRel = new DrillJoinRel(context.getCluster(), context.getLogicalTraits(), left, right, rexCondition, join.getJoinType());

  return joinRel;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:DrillJoinRel.java

示例2: rewrite

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
/** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.SCHEMATA ... */
@Override
public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
  SqlShowSchemas node = unwrap(sqlNode, SqlShowSchemas.class);
  List<SqlNode> selectList =
      ImmutableList.of((SqlNode) new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO));

  SqlNode fromClause = new SqlIdentifier(
      ImmutableList.of(IS_SCHEMA_NAME, TAB_SCHEMATA), null, SqlParserPos.ZERO, null);

  SqlNode where = null;
  final SqlNode likePattern = node.getLikePattern();
  if (likePattern != null) {
    where = DrillParserUtil.createCondition(new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO),
                                            SqlStdOperatorTable.LIKE, likePattern);
  } else if (node.getWhereClause() != null) {
    where = node.getWhereClause();
  }

  return new SqlSelect(SqlParserPos.ZERO, null, new SqlNodeList(selectList, SqlParserPos.ZERO),
      fromClause, where, null, null, null, null, null, null);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:23,代码来源:ShowSchemasHandler.java

示例3: visitCall

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
@Override
public Boolean visitCall(RexCall call) {
  if (call.getOperator() == SqlStdOperatorTable.ITEM) {
    final RexNode op0 = call.getOperands().get(0);
    final RexNode op1 = call.getOperands().get(1);

    if (op0 instanceof RexInputRef &&
        op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
      return true;
    } else if (op0 instanceof RexCall &&
        op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
      return op0.accept(this);
    }
  }

  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:DrillProjectRelBase.java

示例4: visit

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
@Override
public RelNode visit(TableScan tableScan) {
  if (tableScan instanceof ConvertibleScan) {
    return ((ConvertibleScan) tableScan).convert().accept(this);
  }
  if (!(tableScan instanceof IncrementallyUpdateable)) {
    return tableScan;
  }

  final RelNode newScan = updateScan((IncrementallyUpdateable) tableScan);

  // build new filter to apply refresh condition.
  final RexBuilder rexBuilder = tableScan.getCluster().getRexBuilder();
  final RexNode inputRef = rexBuilder.makeInputRef(newScan, newScan.getRowType().getField(UPDATE_COLUMN, false, false).getIndex());
  final RexNode literal = generateLiteral(rexBuilder, tableScan.getCluster().getTypeFactory());
  final RexNode condition = tableScan.getCluster().getRexBuilder().makeCall(SqlStdOperatorTable.GREATER_THAN, ImmutableList.of(inputRef, literal));
  return LogicalFilter.create(newScan, condition);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:IncrementalUpdateUtils.java

示例5: buildJoinCondition

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
private RexNode buildJoinCondition(RelNode convertedLeft, RelNode convertedRight, List<Integer> leftKeys,
    List<Integer> rightKeys, List<Boolean> filterNulls, RexBuilder builder) {
  List<RexNode> equijoinList = Lists.newArrayList();
  final int numLeftFields = convertedLeft.getRowType().getFieldCount();
  List<RelDataTypeField> leftTypes = convertedLeft.getRowType().getFieldList();
  List<RelDataTypeField> rightTypes = convertedRight.getRowType().getFieldList();

  for (int i=0; i < leftKeys.size(); i++) {
    int leftKeyOrdinal = leftKeys.get(i).intValue();
    int rightKeyOrdinal = rightKeys.get(i).intValue();

    equijoinList.add(builder.makeCall(
        filterNulls.get(i) ? SqlStdOperatorTable.EQUALS : SqlStdOperatorTable.IS_NOT_DISTINCT_FROM,
        builder.makeInputRef(leftTypes.get(leftKeyOrdinal).getType(), leftKeyOrdinal),
        builder.makeInputRef(rightTypes.get(rightKeyOrdinal).getType(), rightKeyOrdinal + numLeftFields)
    ));
  }
  return RexUtil.composeConjunction(builder, equijoinList, false);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:JoinRule.java

示例6: convert

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
public static JoinRel convert(Join join, ConversionContext context) throws InvalidRelException{
  RelNode left = context.toRel(join.getLeft());
  RelNode right = context.toRel(join.getRight());

  List<RexNode> joinConditions = new ArrayList<RexNode>();
  // right fields appear after the LHS fields.
  final int rightInputOffset = left.getRowType().getFieldCount();
  for (JoinCondition condition : join.getConditions()) {
    RelDataTypeField leftField = left.getRowType().getField(ExprHelper.getFieldName(condition.getLeft()), true, false);
    RelDataTypeField rightField = right.getRowType().getField(ExprHelper.getFieldName(condition.getRight()), true, false);
      joinConditions.add(
          context.getRexBuilder().makeCall(
              SqlStdOperatorTable.EQUALS,
              context.getRexBuilder().makeInputRef(leftField.getType(), leftField.getIndex()),
              context.getRexBuilder().makeInputRef(rightField.getType(), rightInputOffset + rightField.getIndex())
              )
              );
  }
  RexNode rexCondition = RexUtil.composeConjunction(context.getRexBuilder(), joinConditions, false);
  JoinRel joinRel = new JoinRel(context.getCluster(), context.getLogicalTraits(), left, right, rexCondition, join.getJoinType());

  return joinRel;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:24,代码来源:JoinRel.java

示例7: convertCall

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

示例8: simpleLiteralEquality

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
@Test
public void simpleLiteralEquality(){

  final RexNode node = builder.makeCall(SqlStdOperatorTable.EQUALS,
      builder.makeBigintLiteral(BigDecimal.ONE),
      builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0)
      );

  FindSimpleFilters finder = new FindSimpleFilters(builder);
  StateHolder holder = node.accept(finder);
  ImmutableList<RexCall> conditions = holder.getConditions();

  assertEquals(1, conditions.size());
  assertFalse(holder.hasRemainingExpression());

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:TestFilterFinder.java

示例9: halfTree

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
@Test
public void halfTree(){
  final RexNode node =
      builder.makeCall(SqlStdOperatorTable.AND,
      builder.makeCall(SqlStdOperatorTable.EQUALS,
          builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0),
          builder.makeBigintLiteral(BigDecimal.ONE)
          ),
      builder.makeApproxLiteral(BigDecimal.ONE)
      );

  FindSimpleFilters finder = new FindSimpleFilters(builder);
  StateHolder holder = node.accept(finder);
  ImmutableList<RexCall> conditions = holder.getConditions();

  assertEquals(1, conditions.size());
  assertEquals(SqlKind.EQUALS, conditions.get(0).getKind());
  assertEquals(SqlKind.LITERAL, holder.getNode().getKind());
  assertTrue(holder.hasRemainingExpression());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:TestFilterFinder.java

示例10: noOnOr

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
@Test
public void noOnOr(){
  final RexNode node =
      builder.makeCall(SqlStdOperatorTable.OR,
      builder.makeCall(SqlStdOperatorTable.EQUALS,
          builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0),
          builder.makeBigintLiteral(BigDecimal.ONE)
          ),
      builder.makeApproxLiteral(BigDecimal.ONE)
      );

  FindSimpleFilters finder = new FindSimpleFilters(builder);
  StateHolder holder = node.accept(finder);
  ImmutableList<RexCall> conditions = holder.getConditions();

  assertEquals(0, conditions.size());
  assertTrue(holder.hasRemainingExpression());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:TestFilterFinder.java

示例11: doubleAnd

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
@Test
public void doubleAnd(){
  final RexNode node =
      builder.makeCall(SqlStdOperatorTable.AND,
      builder.makeCall(SqlStdOperatorTable.EQUALS,
          builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0),
          builder.makeBigintLiteral(BigDecimal.ONE)
          ),
      builder.makeCall(SqlStdOperatorTable.EQUALS,
          builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0),
          builder.makeBigintLiteral(BigDecimal.ONE)
          )
      );

  FindSimpleFilters finder = new FindSimpleFilters(builder);
  StateHolder holder = node.accept(finder);
  ImmutableList<RexCall> conditions = holder.getConditions();

  assertEquals(2, conditions.size());
  assertEquals(SqlKind.EQUALS, conditions.get(0).getKind());
  assertEquals(SqlKind.EQUALS, conditions.get(1).getKind());
  assertFalse(holder.hasRemainingExpression());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:24,代码来源:TestFilterFinder.java

示例12: equalityWithCast

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
@Test
public void equalityWithCast(){

  final RexNode node = builder.makeCall(SqlStdOperatorTable.EQUALS,
      builder.makeCast(
          factory.createSqlType(SqlTypeName.ANY),
          builder.makeBigintLiteral(BigDecimal.ONE)
      ),
      builder.makeInputRef(factory.createSqlType(SqlTypeName.BIGINT), 0)
  );

  FindSimpleFilters finder = new FindSimpleFilters(builder);
  StateHolder holder = node.accept(finder);
  ImmutableList<RexCall> conditions = holder.getConditions();

  assertEquals(1, conditions.size());
  assertEquals(SqlKind.EQUALS, conditions.get(0).getKind());
  // Make sure CAST was removed
  assertEquals(SqlKind.LITERAL, conditions.get(0).getOperands().get(0).getKind());
  assertFalse(holder.hasRemainingExpression());

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:TestFilterFinder.java

示例13: SqlToRelConverter

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
public SqlToRelConverter(
	RelOptTable.ViewExpander viewExpander,
	SqlValidator validator,
	Prepare.CatalogReader catalogReader,
	RelOptCluster cluster,
	SqlRexConvertletTable convertletTable,
	Config config) {
	this.viewExpander = viewExpander;
	this.opTab =
		(validator
			== null) ? SqlStdOperatorTable.instance()
			: validator.getOperatorTable();
	this.validator = validator;
	this.catalogReader = catalogReader;
	this.subQueryConverter = new NoOpSubQueryConverter();
	this.rexBuilder = cluster.getRexBuilder();
	this.typeFactory = rexBuilder.getTypeFactory();
	this.cluster = Preconditions.checkNotNull(cluster);
	this.exprConverter = new SqlNodeToRexConverterImpl(convertletTable);
	this.explainParamCount = 0;
	this.config = new ConfigBuilder().withConfig(config).build();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:SqlToRelConverter.java

示例14: convertUsing

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
/**
 * Returns an expression for matching columns of a USING clause or inferred
 * from NATURAL JOIN. "a JOIN b USING (x, y)" becomes "a.x = b.x AND a.y =
 * b.y". Returns null if the column list is empty.
 *
 * @param leftNamespace Namespace of left input to join
 * @param rightNamespace Namespace of right input to join
 * @param nameList List of column names to join on
 * @return Expression to match columns from name list, or true if name list
 * is empty
 */
private RexNode convertUsing(SqlValidatorNamespace leftNamespace,
	SqlValidatorNamespace rightNamespace,
	List<String> nameList) {
	final SqlNameMatcher nameMatcher = catalogReader.nameMatcher();
	final List<RexNode> list = Lists.newArrayList();
	for (String name : nameList) {
		List<RexNode> operands = new ArrayList<>();
		int offset = 0;
		for (SqlValidatorNamespace n : ImmutableList.of(leftNamespace,
			rightNamespace)) {
			final RelDataType rowType = n.getRowType();
			final RelDataTypeField field = nameMatcher.field(rowType, name);
			operands.add(
				rexBuilder.makeInputRef(field.getType(),
					offset + field.getIndex()));
			offset += rowType.getFieldList().size();
		}
		list.add(rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, operands));
	}
	return RexUtil.composeConjunction(rexBuilder, list, false);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:33,代码来源:SqlToRelConverter.java

示例15: isConvertedSubq

import org.apache.calcite.sql.fun.SqlStdOperatorTable; //导入依赖的package包/类
/**
 * Determines whether a RexNode corresponds to a sub-query that's been
 * converted to a constant.
 *
 * @param rex the expression to be examined
 * @return true if the expression is a dynamic parameter, a literal, or
 * a literal that is being cast
 */
private boolean isConvertedSubq(RexNode rex) {
	if ((rex instanceof RexLiteral)
		|| (rex instanceof RexDynamicParam)) {
		return true;
	}
	if (rex instanceof RexCall) {
		RexCall call = (RexCall) rex;
		if (call.getOperator() == SqlStdOperatorTable.CAST) {
			RexNode operand = call.getOperands().get(0);
			if (operand instanceof RexLiteral) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:SqlToRelConverter.java


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