use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testFunctionFactoryNullSignature.
@Test
public void testFunctionFactoryNullSignature() {
functions.add(new FunctionFactory() {
@Override
public String getSignature() {
return null;
}
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
return new IntConstant(0);
}
});
FunctionParser parser = createFunctionParser();
Assert.assertEquals(0, parser.getFunctionCount());
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testImplicitConstantInt.
@Test
public void testImplicitConstantInt() throws SqlException {
functions.add(new FunctionFactory() {
@Override
public String getSignature() {
return "x()";
}
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration1, SqlExecutionContext sqlExecutionContext) {
return new IntFunction() {
@Override
public int getInt(Record rec) {
return 0;
}
@Override
public boolean isConstant() {
return true;
}
};
}
});
Function function = parseFunction("x()", new GenericRecordMetadata(), createFunctionParser());
Assert.assertTrue(function instanceof IntConstant);
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testFunctionFactoryException.
@Test
public void testFunctionFactoryException() {
functions.add(new FunctionFactory() {
@Override
public String getSignature() {
return "x()";
}
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
throw new RuntimeException("oops");
}
});
final GenericRecordMetadata metadata = new GenericRecordMetadata();
assertFail(0, "exception in function factory", "x()", metadata);
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testAmbiguousFunctionInvocation.
@Test
public void testAmbiguousFunctionInvocation() throws SqlException {
functions.add(new FunctionFactory() {
@Override
public String getSignature() {
// double,double
return "+(DD)";
}
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
return new DoubleFunction() {
@Override
public double getDouble(Record rec) {
return 123.123;
}
};
}
});
functions.add(new FunctionFactory() {
@Override
public String getSignature() {
// float,float
return "+(FF)";
}
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
return new FloatFunction() {
@Override
public float getFloat(Record rec) {
return 123.123f;
}
};
}
});
final GenericRecordMetadata metadata = new GenericRecordMetadata();
metadata.add(new TableColumnMetadata("a", 1, ColumnType.BYTE));
metadata.add(new TableColumnMetadata("c", 2, ColumnType.SHORT));
FunctionParser functionParser = createFunctionParser();
Function f = parseFunction("a + c", metadata, functionParser);
Assert.assertEquals(123.123f, f.getFloat(null), 0.0001);
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testFunctionFactoryNullFunction.
@Test
public void testFunctionFactoryNullFunction() {
functions.add(new FunctionFactory() {
@Override
public String getSignature() {
return "x()";
}
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
return null;
}
});
final GenericRecordMetadata metadata = new GenericRecordMetadata();
assertFail(0, "bad function factory (NULL), check log", "x()", metadata);
}
Aggregations