Java Code Examples for org.apache.calcite.util.Util#needToImplement()

The following examples show how to use org.apache.calcite.util.Util#needToImplement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelStructuredTypeFlattener.java    From Bats with Apache License 2.0 6 votes vote down vote up
public void rewriteRel(Sort rel) {
    RelCollation oldCollation = rel.getCollation();
    final RelNode oldChild = rel.getInput();
    final RelNode newChild = getNewForOldRel(oldChild);
    final Mappings.TargetMapping mapping = getNewForOldInputMapping(oldChild);

    // validate
    for (RelFieldCollation field : oldCollation.getFieldCollations()) {
        int oldInput = field.getFieldIndex();
        RelDataType sortFieldType = oldChild.getRowType().getFieldList().get(oldInput).getType();
        if (sortFieldType.isStruct()) {
            // TODO jvs 10-Feb-2005
            throw Util.needToImplement("sorting on structured types");
        }
    }
    RelCollation newCollation = RexUtil.apply(mapping, oldCollation);
    Sort newRel = LogicalSort.create(newChild, newCollation, rel.offset, rel.fetch);
    setNewForOldRel(rel, newRel);
}
 
Example 2
Source File: SqlOperator.java    From calcite with Apache License 2.0 6 votes vote down vote up
/**
 * Checks that the operand values in a {@link SqlCall} to this operator are
 * valid. Subclasses must either override this method or supply an instance
 * of {@link SqlOperandTypeChecker} to the constructor.
 *
 * @param callBinding    description of call
 * @param throwOnFailure whether to throw an exception if check fails
 *                       (otherwise returns false in that case)
 * @return whether check succeeded
 */
public boolean checkOperandTypes(
    SqlCallBinding callBinding,
    boolean throwOnFailure) {
  // Check that all of the operands are of the right type.
  if (null == operandTypeChecker) {
    // If you see this you must either give operandTypeChecker a value
    // or override this method.
    throw Util.needToImplement(this);
  }

  if (kind != SqlKind.ARGUMENT_ASSIGNMENT) {
    for (Ord<SqlNode> operand : Ord.zip(callBinding.operands())) {
      if (operand.e != null
          && operand.e.getKind() == SqlKind.DEFAULT
          && !operandTypeChecker.isOptional(operand.i)) {
        throw callBinding.newValidationError(RESOURCE.defaultForOptionalParameter());
      }
    }
  }

  return operandTypeChecker.checkOperandTypes(
      callBinding,
      throwOnFailure);
}
 
Example 3
Source File: SqlOperator.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a constraint on the number of operands expected by this operator.
 * Subclasses may override this method; when they don't, the range is
 * derived from the {@link SqlOperandTypeChecker} associated with this
 * operator.
 *
 * @return acceptable range
 */
public SqlOperandCountRange getOperandCountRange() {
  if (operandTypeChecker != null) {
    return operandTypeChecker.getOperandCountRange();
  }

  // If you see this error you need to override this method
  // or give operandTypeChecker a value.
  throw Util.needToImplement(this);
}
 
Example 4
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
public RelDataType getValidatedNodeType(SqlNode node) {
	RelDataType type = getValidatedNodeTypeIfKnown(node);
	if (type == null) {
		throw Util.needToImplement(node);
	} else {
		return type;
	}
}
 
Example 5
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public RelDataType visit(SqlNodeList nodeList) {
	// Operand is of a type that we can't derive a type for. If the
	// operand is of a peculiar type, such as a SqlNodeList, then you
	// should override the operator's validateCall() method so that it
	// doesn't try to validate that operand as an expression.
	throw Util.needToImplement(nodeList);
}
 
Example 6
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
public RelDataType visit(SqlNodeList nodeList) {
	// Operand is of a type that we can't derive a type for. If the
	// operand is of a peculiar type, such as a SqlNodeList, then you
	// should override the operator's validateCall() method so that it
	// doesn't try to validate that operand as an expression.
	throw Util.needToImplement(nodeList);
}
 
Example 7
Source File: VolcanoPlanner.java    From Bats with Apache License 2.0 5 votes vote down vote up
public void addListener(RelOptListener newListener) {
  // TODO jvs 6-Apr-2006:  new superclass AbstractRelOptPlanner
  // now defines a multicast listener; just need to hook it in
  if (listener != null) {
    throw Util.needToImplement("multiple VolcanoPlanner listeners");
  }
  listener = newListener;
}
 
Example 8
Source File: SqlNodeToRexConverterImpl.java    From calcite with Apache License 2.0 5 votes vote down vote up
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
  final SqlRexConvertlet convertlet = convertletTable.get(call);
  if (convertlet != null) {
    return convertlet.convertCall(cx, call);
  }

  // No convertlet was suitable. (Unlikely, because the standard
  // convertlet table has a fall-back for all possible calls.)
  throw Util.needToImplement(call);
}
 
Example 9
Source File: RelStructuredTypeFlattener.java    From Bats with Apache License 2.0 5 votes vote down vote up
private RexNode flattenComparison(RexBuilder rexBuilder, SqlOperator op, List<RexNode> exprs) {
    final List<Pair<RexNode, String>> flattenedExps = new ArrayList<>();
    flattenProjections(this, exprs, null, "", flattenedExps);
    int n = flattenedExps.size() / 2;
    boolean negate = false;
    if (op.getKind() == SqlKind.NOT_EQUALS) {
        negate = true;
        op = SqlStdOperatorTable.EQUALS;
    }
    if ((n > 1) && op.getKind() != SqlKind.EQUALS) {
        throw Util.needToImplement("inequality comparison for row types");
    }
    RexNode conjunction = null;
    for (int i = 0; i < n; ++i) {
        RexNode comparison = rexBuilder.makeCall(op, flattenedExps.get(i).left, flattenedExps.get(i + n).left);
        if (conjunction == null) {
            conjunction = comparison;
        } else {
            conjunction = rexBuilder.makeCall(SqlStdOperatorTable.AND, conjunction, comparison);
        }
    }
    if (negate) {
        return rexBuilder.makeCall(SqlStdOperatorTable.NOT, conjunction);
    } else {
        return conjunction;
    }
}
 
Example 10
Source File: RelStructuredTypeFlattener.java    From Bats with Apache License 2.0 5 votes vote down vote up
public void rewriteRel(LogicalCorrelate rel) {
    ImmutableBitSet.Builder newPos = ImmutableBitSet.builder();
    for (int pos : rel.getRequiredColumns()) {
        RelDataType corrFieldType = rel.getLeft().getRowType().getFieldList().get(pos).getType();
        if (corrFieldType.isStruct()) {
            throw Util.needToImplement("correlation on structured type");
        }
        newPos.set(getNewForOldInput(pos));
    }
    LogicalCorrelate newRel = LogicalCorrelate.create(getNewForOldRel(rel.getLeft()),
            getNewForOldRel(rel.getRight()), rel.getCorrelationId(), newPos.build(), rel.getJoinType());
    setNewForOldRel(rel, newRel);
}
 
Example 11
Source File: Mappings.java    From Bats with Apache License 2.0 4 votes vote down vote up
public Iterator<IntPair> iterator() {
  throw Util.needToImplement(this);
}
 
Example 12
Source File: Mappings.java    From Bats with Apache License 2.0 4 votes vote down vote up
public Iterator<IntPair> iterator() {
  throw Util.needToImplement(this);
}
 
Example 13
Source File: RelStructuredTypeFlattener.java    From calcite with Apache License 2.0 4 votes vote down vote up
private RexNode flattenComparison(
    RexBuilder rexBuilder,
    SqlOperator op,
    List<RexNode> exprs) {
  final List<Pair<RexNode, String>> flattenedExps = new ArrayList<>();
  flattenProjections(this, exprs, null, "", flattenedExps);
  int n = flattenedExps.size() / 2;
  boolean negate = false;
  if (op.getKind() == SqlKind.NOT_EQUALS) {
    negate = true;
    op = SqlStdOperatorTable.EQUALS;
  }
  if ((n > 1) && op.getKind() != SqlKind.EQUALS) {
    throw Util.needToImplement(
        "inequality comparison for row types");
  }
  RexNode conjunction = null;
  for (int i = 0; i < n; ++i) {
    RexNode comparison =
        rexBuilder.makeCall(
            op,
            flattenedExps.get(i).left,
            flattenedExps.get(i + n).left);
    if (conjunction == null) {
      conjunction = comparison;
    } else {
      conjunction =
          rexBuilder.makeCall(
              SqlStdOperatorTable.AND,
              conjunction,
              comparison);
    }
  }
  if (negate) {
    return rexBuilder.makeCall(
        SqlStdOperatorTable.NOT,
        conjunction);
  } else {
    return conjunction;
  }
}
 
Example 14
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override public Void visit(SqlNodeList nodeList) {
	throw Util.needToImplement(nodeList);
}
 
Example 15
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override public Void visit(SqlDataTypeSpec type) {
	throw Util.needToImplement(type);
}
 
Example 16
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override public Void visit(SqlDynamicParam param) {
	throw Util.needToImplement(param);
}
 
Example 17
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override public Void visit(SqlIntervalQualifier intervalQualifier) {
	throw Util.needToImplement(intervalQualifier);
}
 
Example 18
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override public Void visit(SqlDynamicParam param) {
	throw Util.needToImplement(param);
}
 
Example 19
Source File: SqlSpecialOperator.java    From calcite with Apache License 2.0 2 votes vote down vote up
/**
 * Reduces a list of operators and arguments according to the rules of
 * precedence and associativity. Returns the ordinal of the node which
 * replaced the expression.
 *
 * <p>The default implementation throws
 * {@link UnsupportedOperationException}.
 *
 * @param ordinal indicating the ordinal of the current operator in the list
 *                on which a possible reduction can be made
 * @param list    List of alternating
 *     {@link org.apache.calcite.sql.parser.SqlParserUtil.ToTreeListItem} and
 *     {@link SqlNode}
 * @return ordinal of the node which replaced the expression
 */
public ReduceResult reduceExpr(
    int ordinal,
    TokenSequence list) {
  throw Util.needToImplement(this);
}
 
Example 20
Source File: SqlSpecialOperator.java    From Bats with Apache License 2.0 2 votes vote down vote up
/**
 * Reduces a list of operators and arguments according to the rules of
 * precedence and associativity. Returns the ordinal of the node which
 * replaced the expression.
 *
 * <p>The default implementation throws
 * {@link UnsupportedOperationException}.
 *
 * @param ordinal indicating the ordinal of the current operator in the list
 *                on which a possible reduction can be made
 * @param list    List of alternating
 *     {@link org.apache.calcite.sql.parser.SqlParserUtil.ToTreeListItem} and
 *     {@link SqlNode}
 * @return ordinal of the node which replaced the expression
 */
public ReduceResult reduceExpr(
    int ordinal,
    TokenSequence list) {
  throw Util.needToImplement(this);
}