Java Code Examples for org.apache.calcite.sql.type.OperandTypes#or()

The following examples show how to use org.apache.calcite.sql.type.OperandTypes#or() . 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: SqlItemOperator.java    From Bats with Apache License 2.0 6 votes vote down vote up
private SqlSingleOperandTypeChecker getChecker(RelDataType operandType) {
  switch (operandType.getSqlTypeName()) {
  case ARRAY:
    return OperandTypes.family(SqlTypeFamily.INTEGER);
  case MAP:
    return OperandTypes.family(
        operandType.getKeyType().getSqlTypeName().getFamily());
  case ANY:
  case DYNAMIC_STAR:
    return OperandTypes.or(
        OperandTypes.family(SqlTypeFamily.INTEGER),
        OperandTypes.family(SqlTypeFamily.CHARACTER));
  default:
    throw new AssertionError(operandType.getSqlTypeName());
  }
}
 
Example 2
Source File: SqlListAggFunction.java    From flink with Apache License 2.0 6 votes vote down vote up
public SqlListAggFunction() {
	super("LISTAGG",
			null,
			SqlKind.LISTAGG,
			ReturnTypes.ARG0_NULLABLE,
			null,
			OperandTypes.or(
					OperandTypes.CHARACTER,
					OperandTypes.sequence(
							"'LISTAGG(<CHARACTER>, <CHARACTER_LITERAL>)'",
							OperandTypes.CHARACTER,
							OperandTypes.and(OperandTypes.CHARACTER, OperandTypes.LITERAL)
					)),
			SqlFunctionCategory.SYSTEM,
			false,
			false);
}
 
Example 3
Source File: SqlListAggFunction.java    From flink with Apache License 2.0 6 votes vote down vote up
public SqlListAggFunction() {
	super("LISTAGG",
			null,
			SqlKind.LISTAGG,
			ReturnTypes.ARG0_NULLABLE,
			null,
			OperandTypes.or(
					OperandTypes.CHARACTER,
					OperandTypes.sequence(
							"'LISTAGG(<CHARACTER>, <CHARACTER_LITERAL>)'",
							OperandTypes.CHARACTER,
							OperandTypes.and(OperandTypes.CHARACTER, OperandTypes.LITERAL)
					)),
			SqlFunctionCategory.SYSTEM,
			false,
			false);
}
 
Example 4
Source File: SqlItemOperator.java    From calcite with Apache License 2.0 6 votes vote down vote up
private SqlSingleOperandTypeChecker getChecker(SqlCallBinding callBinding) {
  final RelDataType operandType = callBinding.getOperandType(0);
  switch (operandType.getSqlTypeName()) {
  case ARRAY:
    return OperandTypes.family(SqlTypeFamily.INTEGER);
  case MAP:
    return OperandTypes.family(
        operandType.getKeyType().getSqlTypeName().getFamily());
  case ROW:
    return OperandTypes.CHARACTER;
  case ANY:
  case DYNAMIC_STAR:
    return OperandTypes.or(
        OperandTypes.family(SqlTypeFamily.INTEGER),
        OperandTypes.family(SqlTypeFamily.CHARACTER));
  default:
    throw callBinding.newValidationSignatureError();
  }
}
 
Example 5
Source File: SqlFloorFunction.java    From Bats with Apache License 2.0 5 votes vote down vote up
public SqlFloorFunction(SqlKind kind) {
  super(kind.name(), kind, ReturnTypes.ARG0_OR_EXACT_NO_SCALE, null,
      OperandTypes.or(OperandTypes.NUMERIC_OR_INTERVAL,
          OperandTypes.sequence(
              "'" + kind + "(<DATE> TO <TIME_UNIT>)'\n"
              + "'" + kind + "(<TIME> TO <TIME_UNIT>)'\n"
              + "'" + kind + "(<TIMESTAMP> TO <TIME_UNIT>)'",
              OperandTypes.DATETIME,
              OperandTypes.ANY)),
      SqlFunctionCategory.NUMERIC);
  Preconditions.checkArgument(kind == SqlKind.FLOOR || kind == SqlKind.CEIL);
}
 
Example 6
Source File: SqlRandFunction.java    From Bats with Apache License 2.0 5 votes vote down vote up
public SqlRandFunction() {
  super("RAND",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.DOUBLE,
      null,
      OperandTypes.or(OperandTypes.NILADIC, OperandTypes.NUMERIC),
      SqlFunctionCategory.NUMERIC);
}
 
Example 7
Source File: SqlRandIntegerFunction.java    From Bats with Apache License 2.0 5 votes vote down vote up
public SqlRandIntegerFunction() {
  super("RAND_INTEGER",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.INTEGER,
      null,
      OperandTypes.or(OperandTypes.NUMERIC, OperandTypes.NUMERIC_NUMERIC),
      SqlFunctionCategory.NUMERIC);
}
 
Example 8
Source File: SqlFloorFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
public SqlFloorFunction(SqlKind kind) {
  super(kind.name(), kind, ReturnTypes.ARG0_OR_EXACT_NO_SCALE, null,
      OperandTypes.or(OperandTypes.NUMERIC_OR_INTERVAL,
          OperandTypes.sequence(
              "'" + kind + "(<DATE> TO <TIME_UNIT>)'\n"
              + "'" + kind + "(<TIME> TO <TIME_UNIT>)'\n"
              + "'" + kind + "(<TIMESTAMP> TO <TIME_UNIT>)'",
              OperandTypes.DATETIME,
              OperandTypes.ANY)),
      SqlFunctionCategory.NUMERIC);
  Preconditions.checkArgument(kind == SqlKind.FLOOR || kind == SqlKind.CEIL);
}
 
Example 9
Source File: SqlRandFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
public SqlRandFunction() {
  super("RAND",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.DOUBLE,
      null,
      OperandTypes.or(OperandTypes.NILADIC, OperandTypes.NUMERIC),
      SqlFunctionCategory.NUMERIC);
}
 
Example 10
Source File: SqlJsonKeysFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
public SqlJsonKeysFunction() {
  super("JSON_KEYS", SqlKind.OTHER_FUNCTION,
        ReturnTypes.cascade(ReturnTypes.VARCHAR_2000, SqlTypeTransforms.FORCE_NULLABLE),
        null,
        OperandTypes.or(OperandTypes.ANY,
            OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER)),
        SqlFunctionCategory.SYSTEM);
}
 
Example 11
Source File: SqlJsonExistsFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
public SqlJsonExistsFunction() {
  super("JSON_EXISTS", SqlKind.OTHER_FUNCTION,
      ReturnTypes.cascade(ReturnTypes.BOOLEAN, SqlTypeTransforms.FORCE_NULLABLE), null,
      OperandTypes.or(
          OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER),
          OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER, SqlTypeFamily.ANY)),
      SqlFunctionCategory.SYSTEM);
}
 
Example 12
Source File: SqlRandIntegerFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
public SqlRandIntegerFunction() {
  super("RAND_INTEGER",
      SqlKind.OTHER_FUNCTION,
      ReturnTypes.INTEGER,
      null,
      OperandTypes.or(OperandTypes.NUMERIC, OperandTypes.NUMERIC_NUMERIC),
      SqlFunctionCategory.NUMERIC);
}
 
Example 13
Source File: SqlJsonLengthFunction.java    From calcite with Apache License 2.0 5 votes vote down vote up
public SqlJsonLengthFunction() {
  super("JSON_LENGTH", SqlKind.OTHER_FUNCTION,
      ReturnTypes.cascade(ReturnTypes.INTEGER,
          SqlTypeTransforms.FORCE_NULLABLE),
      null,
      OperandTypes.or(OperandTypes.ANY,
          OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER)),
      SqlFunctionCategory.SYSTEM);
}
 
Example 14
Source File: SqlJsonExistsFunction.java    From Bats with Apache License 2.0 4 votes vote down vote up
public SqlJsonExistsFunction() {
  super("JSON_EXISTS", SqlKind.OTHER_FUNCTION,
      ReturnTypes.BOOLEAN_FORCE_NULLABLE, null,
      OperandTypes.or(OperandTypes.ANY, OperandTypes.ANY_ANY),
      SqlFunctionCategory.SYSTEM);
}