use of com.hazelcast.sql.impl.ParameterConverter 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;
}
use of com.hazelcast.sql.impl.ParameterConverter in project hazelcast by hazelcast.
the class HazelcastSqlValidator method getArgumentAt.
public Object getArgumentAt(int index) {
ParameterConverter parameterConverter = parameterConverterMap.get(index);
Object argument = arguments.get(index);
return parameterConverter.convert(argument);
}
use of com.hazelcast.sql.impl.ParameterConverter in project hazelcast by hazelcast.
the class HazelcastSqlValidator method getParameterConverters.
public ParameterConverter[] getParameterConverters(SqlNode node) {
// Get original parameter row type.
RelDataType rowType = getParameterRowType(node);
// Create precedence-based converters with optional override by a more specialized converters.
ParameterConverter[] res = new ParameterConverter[rowType.getFieldCount()];
for (int i = 0; i < res.length; i++) {
ParameterConverter converter = parameterConverterMap.get(i);
if (converter == null) {
QueryDataType targetType = HazelcastTypeUtils.toHazelcastType(rowType.getFieldList().get(i).getType());
converter = AbstractParameterConverter.from(targetType, i, parameterPositionMap.get(i));
}
res[i] = converter;
}
return res;
}
use of com.hazelcast.sql.impl.ParameterConverter in project hazelcast by hazelcast.
the class HazelcastComparisonPredicateUtils method setNumericParameterConverter.
private static void setNumericParameterConverter(HazelcastSqlValidator validator, SqlNode node, QueryDataType type) {
if (node.getKind() == SqlKind.DYNAMIC_PARAM) {
SqlDynamicParam node0 = (SqlDynamicParam) node;
ParameterConverter converter = new NumericPrecedenceParameterConverter(node0.getIndex(), node.getParserPosition(), type);
validator.setParameterConverter(node0.getIndex(), converter);
}
}
Aggregations