org.apache.calcite.sql.type.SqlSingleOperandTypeChecker Java Examples
The following examples show how to use
org.apache.calcite.sql.type.SqlSingleOperandTypeChecker.
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 |
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: SqlDotOperator.java From Bats with Apache License 2.0 | 6 votes |
@Override public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure) { final SqlNode left = callBinding.operand(0); final SqlNode right = callBinding.operand(1); final RelDataType type = callBinding.getValidator().deriveType(callBinding.getScope(), left); if (type.getSqlTypeName() != SqlTypeName.ROW) { return false; } else if (type.getSqlIdentifier().isStar()) { return false; } final RelDataType operandType = callBinding.getOperandType(0); final SqlSingleOperandTypeChecker checker = getChecker(operandType); return checker.checkSingleOperandType(callBinding, right, 0, throwOnFailure); }
Example #3
Source File: SqlItemOperator.java From calcite with Apache License 2.0 | 6 votes |
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 #4
Source File: SqlDotOperator.java From calcite with Apache License 2.0 | 6 votes |
@Override public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure) { final SqlNode left = callBinding.operand(0); final SqlNode right = callBinding.operand(1); final RelDataType type = callBinding.getValidator().deriveType(callBinding.getScope(), left); if (type.getSqlTypeName() != SqlTypeName.ROW) { return false; } else if (type.getSqlIdentifier().isStar()) { return false; } final RelDataType operandType = callBinding.getOperandType(0); final SqlSingleOperandTypeChecker checker = getChecker(operandType); // Actually operand0 always comes from parsing the SqlIdentifier, so there // is no need to make implicit type coercion. return checker.checkSingleOperandType(callBinding, right, 0, throwOnFailure); }
Example #5
Source File: SqlItemOperator.java From Bats with Apache License 2.0 | 5 votes |
@Override public boolean checkOperandTypes( SqlCallBinding callBinding, boolean throwOnFailure) { final SqlNode left = callBinding.operand(0); final SqlNode right = callBinding.operand(1); if (!ARRAY_OR_MAP.checkSingleOperandType(callBinding, left, 0, throwOnFailure)) { return false; } final RelDataType operandType = callBinding.getOperandType(0); final SqlSingleOperandTypeChecker checker = getChecker(operandType); return checker.checkSingleOperandType(callBinding, right, 0, throwOnFailure); }
Example #6
Source File: SqlDotOperator.java From Bats with Apache License 2.0 | 5 votes |
private SqlSingleOperandTypeChecker getChecker(RelDataType operandType) { switch (operandType.getSqlTypeName()) { case ROW: return OperandTypes.family(SqlTypeFamily.STRING); default: throw new AssertionError(operandType.getSqlTypeName()); } }
Example #7
Source File: SqlOverlapsOperator.java From Bats with Apache License 2.0 | 5 votes |
public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure) { if (!OperandTypes.PERIOD.checkSingleOperandType(callBinding, callBinding.operand(0), 0, throwOnFailure)) { return false; } final SqlSingleOperandTypeChecker rightChecker; switch (kind) { case CONTAINS: rightChecker = OperandTypes.PERIOD_OR_DATETIME; break; default: rightChecker = OperandTypes.PERIOD; break; } if (!rightChecker.checkSingleOperandType(callBinding, callBinding.operand(1), 0, throwOnFailure)) { return false; } final RelDataType t0 = callBinding.getOperandType(0); final RelDataType t1 = callBinding.getOperandType(1); if (!SqlTypeUtil.isDatetime(t1)) { final RelDataType t00 = t0.getFieldList().get(0).getType(); final RelDataType t10 = t1.getFieldList().get(0).getType(); if (!SqlTypeUtil.sameNamedType(t00, t10)) { if (throwOnFailure) { throw callBinding.newValidationSignatureError(); } return false; } } return true; }
Example #8
Source File: SqlItemOperator.java From calcite with Apache License 2.0 | 5 votes |
@Override public boolean checkOperandTypes( SqlCallBinding callBinding, boolean throwOnFailure) { final SqlNode left = callBinding.operand(0); final SqlNode right = callBinding.operand(1); if (!ARRAY_OR_MAP.checkSingleOperandType(callBinding, left, 0, throwOnFailure)) { return false; } final SqlSingleOperandTypeChecker checker = getChecker(callBinding); return checker.checkSingleOperandType(callBinding, right, 0, throwOnFailure); }
Example #9
Source File: SqlDotOperator.java From calcite with Apache License 2.0 | 5 votes |
private SqlSingleOperandTypeChecker getChecker(RelDataType operandType) { switch (operandType.getSqlTypeName()) { case ROW: return OperandTypes.family(SqlTypeFamily.STRING); default: throw new AssertionError(operandType.getSqlTypeName()); } }
Example #10
Source File: SqlOverlapsOperator.java From calcite with Apache License 2.0 | 5 votes |
public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure) { if (!OperandTypes.PERIOD.checkSingleOperandType(callBinding, callBinding.operand(0), 0, throwOnFailure)) { return false; } final SqlSingleOperandTypeChecker rightChecker; switch (kind) { case CONTAINS: rightChecker = OperandTypes.PERIOD_OR_DATETIME; break; default: rightChecker = OperandTypes.PERIOD; break; } if (!rightChecker.checkSingleOperandType(callBinding, callBinding.operand(1), 0, throwOnFailure)) { return false; } final RelDataType t0 = callBinding.getOperandType(0); final RelDataType t1 = callBinding.getOperandType(1); if (!SqlTypeUtil.isDatetime(t1)) { final RelDataType t00 = t0.getFieldList().get(0).getType(); final RelDataType t10 = t1.getFieldList().get(0).getType(); if (!SqlTypeUtil.sameNamedType(t00, t10)) { if (throwOnFailure) { throw callBinding.newValidationSignatureError(); } return false; } } return true; }
Example #11
Source File: SqlTrimFunction.java From Bats with Apache License 2.0 | 4 votes |
public SqlTrimFunction(String name, SqlKind kind, SqlTypeTransformCascade returnTypeInference, SqlSingleOperandTypeChecker operandTypeChecker) { super(name, kind, returnTypeInference, null, operandTypeChecker, SqlFunctionCategory.STRING); }
Example #12
Source File: SqlTrimFunction.java From calcite with Apache License 2.0 | 4 votes |
public SqlTrimFunction(String name, SqlKind kind, SqlTypeTransformCascade returnTypeInference, SqlSingleOperandTypeChecker operandTypeChecker) { super(name, kind, returnTypeInference, null, operandTypeChecker, SqlFunctionCategory.STRING); }