@Test
public void testHashFunctionResolution(@Injectable DrillConfig config) throws JClassAlreadyExistsException, IOException {
FunctionImplementationRegistry registry = new FunctionImplementationRegistry(config);
// test required vs nullable Int input
resolveHash(config,
new TypedNullConstant(Types.optional(TypeProtos.MinorType.INT)),
Types.optional(TypeProtos.MinorType.INT),
Types.required(TypeProtos.MinorType.INT),
TypeProtos.DataMode.OPTIONAL,
registry);
resolveHash(config,
new ValueExpressions.IntExpression(1, ExpressionPosition.UNKNOWN),
Types.required(TypeProtos.MinorType.INT),
Types.required(TypeProtos.MinorType.INT),
TypeProtos.DataMode.REQUIRED,
registry);
// test required vs nullable float input
resolveHash(config,
new TypedNullConstant(Types.optional(TypeProtos.MinorType.FLOAT4)),
Types.optional(TypeProtos.MinorType.FLOAT4),
Types.required(TypeProtos.MinorType.FLOAT4),
TypeProtos.DataMode.OPTIONAL,
registry);
resolveHash(config,
new ValueExpressions.FloatExpression(5.0f, ExpressionPosition.UNKNOWN),
Types.required(TypeProtos.MinorType.FLOAT4),
Types.required(TypeProtos.MinorType.FLOAT4),
TypeProtos.DataMode.REQUIRED,
registry);
// test required vs nullable long input
resolveHash(config,
new TypedNullConstant(Types.optional(TypeProtos.MinorType.BIGINT)),
Types.optional(TypeProtos.MinorType.BIGINT),
Types.required(TypeProtos.MinorType.BIGINT),
TypeProtos.DataMode.OPTIONAL,
registry);
resolveHash(config,
new ValueExpressions.LongExpression(100L, ExpressionPosition.UNKNOWN),
Types.required(TypeProtos.MinorType.BIGINT),
Types.required(TypeProtos.MinorType.BIGINT),
TypeProtos.DataMode.REQUIRED,
registry);
// test required vs nullable double input
resolveHash(config,
new TypedNullConstant(Types.optional(TypeProtos.MinorType.FLOAT8)),
Types.optional(TypeProtos.MinorType.FLOAT8),
Types.required(TypeProtos.MinorType.FLOAT8),
TypeProtos.DataMode.OPTIONAL,
registry);