use of com.hazelcast.jet.sql.impl.validate.param.AnyToVarcharParameterConverter in project hazelcast by hazelcast.
the class HazelcastConcatOperator method checkOperandTypes.
@Override
public boolean checkOperandTypes(HazelcastCallBinding binding, boolean throwOnFailure) {
HazelcastSqlValidator validator = binding.getValidator();
for (int i = 0; i < binding.getOperandCount(); i++) {
SqlNode operand = binding.operand(i);
RelDataType operandType = binding.getOperandType(i);
if (operandType.getSqlTypeName() != VARCHAR) {
// Coerce everything to VARCHAR
RelDataType newOperandType = HazelcastTypeUtils.createType(validator.getTypeFactory(), VARCHAR, operandType.isNullable());
validator.getTypeCoercion().coerceOperandType(binding.getScope(), binding.getCall(), i, newOperandType);
}
// Set parameter converters
if (operand.getKind() == SqlKind.DYNAMIC_PARAM) {
int paramIndex = ((SqlDynamicParam) operand).getIndex();
ParameterConverter paramConverter = new AnyToVarcharParameterConverter(paramIndex, operand.getParserPosition());
validator.setParameterConverter(paramIndex, paramConverter);
}
}
return true;
}
use of com.hazelcast.jet.sql.impl.validate.param.AnyToVarcharParameterConverter in project hazelcast by hazelcast.
the class HazelcastConcatWSOperator method checkOperandTypes.
@Override
public boolean checkOperandTypes(HazelcastCallBinding binding, boolean throwOnFailure) {
HazelcastSqlValidator validator = binding.getValidator();
if (binding.getOperandType(0).getSqlTypeName() != VARCHAR) {
if (throwOnFailure) {
throw binding.newValidationSignatureError();
}
return false;
}
for (int i = 1; i < binding.getOperandCount(); i++) {
SqlNode operand = binding.operand(i);
RelDataType operandType = binding.getOperandType(i);
if (operandType.getSqlTypeName() != VARCHAR) {
// Coerce everything to VARCHAR
RelDataType newOperandType = HazelcastTypeUtils.createType(validator.getTypeFactory(), VARCHAR, operandType.isNullable());
validator.getTypeCoercion().coerceOperandType(binding.getScope(), binding.getCall(), i, newOperandType);
}
// Set parameter converters
if (operand.getKind() == SqlKind.DYNAMIC_PARAM) {
int paramIndex = ((SqlDynamicParam) operand).getIndex();
ParameterConverter paramConverter = new AnyToVarcharParameterConverter(paramIndex, operand.getParserPosition());
validator.setParameterConverter(paramIndex, paramConverter);
}
}
return true;
}
Aggregations