Java Code Examples for org.apache.calcite.sql.type.SqlTypeUtil#isCharTypeComparable()

The following examples show how to use org.apache.calcite.sql.type.SqlTypeUtil#isCharTypeComparable() . 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: SqlPosixRegexOperator.java    From calcite with Apache License 2.0 6 votes vote down vote up
public boolean checkOperandTypes(
    SqlCallBinding callBinding,
    boolean throwOnFailure) {
  int operandCount = callBinding.getOperandCount();
  if (operandCount != 2 && operandCount != 3) {
    throw new AssertionError(
        "Unexpected number of args to " + callBinding.getCall() + ": " + operandCount);
  }

  RelDataType op1Type = callBinding.getOperandType(0);
  RelDataType op2Type = callBinding.getOperandType(1);

  if (!SqlTypeUtil.isComparable(op1Type, op2Type)) {
    throw new AssertionError(
        "Incompatible first two operand types " + op1Type + " and " + op2Type);
  }

  return SqlTypeUtil.isCharTypeComparable(
      callBinding,
      callBinding.operands().subList(0, 2),
      throwOnFailure);
}
 
Example 2
Source File: SqlLikeOperator.java    From Bats with Apache License 2.0 5 votes vote down vote up
public boolean checkOperandTypes(
    SqlCallBinding callBinding,
    boolean throwOnFailure) {
  switch (callBinding.getOperandCount()) {
  case 2:
    if (!OperandTypes.STRING_SAME_SAME.checkOperandTypes(
        callBinding,
        throwOnFailure)) {
      return false;
    }
    break;
  case 3:
    if (!OperandTypes.STRING_SAME_SAME_SAME.checkOperandTypes(
        callBinding,
        throwOnFailure)) {
      return false;
    }

    // calc implementation should
    // enforce the escape character length to be 1
    break;
  default:
    throw new AssertionError("unexpected number of args to "
        + callBinding.getCall() + ": " + callBinding.getOperandCount());
  }

  return SqlTypeUtil.isCharTypeComparable(
      callBinding,
      callBinding.operands(),
      throwOnFailure);
}
 
Example 3
Source File: SqlTrimFunction.java    From Bats with Apache License 2.0 5 votes vote down vote up
public boolean checkOperandTypes(
    SqlCallBinding callBinding,
    boolean throwOnFailure) {
  if (!super.checkOperandTypes(callBinding, throwOnFailure)) {
    return false;
  }
  switch (kind) {
  case TRIM:
    return SqlTypeUtil.isCharTypeComparable(callBinding,
        ImmutableList.of(callBinding.operand(1), callBinding.operand(2)),
        throwOnFailure);
  default:
    return true;
  }
}
 
Example 4
Source File: SqlLikeOperator.java    From calcite with Apache License 2.0 5 votes vote down vote up
public boolean checkOperandTypes(
    SqlCallBinding callBinding,
    boolean throwOnFailure) {
  switch (callBinding.getOperandCount()) {
  case 2:
    if (!OperandTypes.STRING_SAME_SAME.checkOperandTypes(
        callBinding,
        throwOnFailure)) {
      return false;
    }
    break;
  case 3:
    if (!OperandTypes.STRING_SAME_SAME_SAME.checkOperandTypes(
        callBinding,
        throwOnFailure)) {
      return false;
    }

    // calc implementation should
    // enforce the escape character length to be 1
    break;
  default:
    throw new AssertionError("unexpected number of args to "
        + callBinding.getCall() + ": " + callBinding.getOperandCount());
  }

  return SqlTypeUtil.isCharTypeComparable(
      callBinding,
      callBinding.operands(),
      throwOnFailure);
}
 
Example 5
Source File: SqlTrimFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
public boolean checkOperandTypes(
    SqlCallBinding callBinding,
    boolean throwOnFailure) {
  if (!super.checkOperandTypes(callBinding, throwOnFailure)) {
    return false;
  }
  switch (kind) {
  case TRIM:
    return SqlTypeUtil.isCharTypeComparable(callBinding,
        ImmutableList.of(callBinding.operand(1), callBinding.operand(2)),
        throwOnFailure);
  default:
    return true;
  }
}