use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testPassNaNAsShort.
@Test
public void testPassNaNAsShort() {
functions.add(new FunctionFactory() {
@Override
public String getSignature() {
return "x(E)";
}
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
return null;
}
});
final GenericRecordMetadata metadata = new GenericRecordMetadata();
try {
parseFunction("x(NaN)", metadata, createFunctionParser());
Assert.fail();
} catch (SqlException e) {
Assert.assertEquals(0, e.getPosition());
TestUtils.assertContains(e.getFlyweightMessage(), "unexpected argument");
}
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testConstantPassThru.
private void testConstantPassThru(Function constant) throws SqlException {
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 constant;
}
});
Assert.assertSame(constant, parseFunction("x()", new GenericRecordMetadata(), createFunctionParser()));
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testImplicitConstantBin.
@Test
public void testImplicitConstantBin() throws SqlException {
BinFunction function = new BinFunction() {
@Override
public BinarySequence getBin(Record rec) {
return null;
}
@Override
public long getBinLen(Record rec) {
return -1;
}
@Override
public boolean isConstant() {
return true;
}
};
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 function;
}
});
Assert.assertSame(function, parseFunction("x()", new GenericRecordMetadata(), createFunctionParser()));
Assert.assertTrue(function.isConstant());
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testImplicitConstantDouble.
@Test
public void testImplicitConstantDouble() 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 DoubleFunction() {
@Override
public double getDouble(Record rec) {
return 0;
}
@Override
public boolean isConstant() {
return true;
}
};
}
});
Function function = parseFunction("x()", new GenericRecordMetadata(), createFunctionParser());
Assert.assertTrue(function instanceof DoubleConstant);
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testImplicitConstantShort.
@Test
public void testImplicitConstantShort() 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 ShortFunction() {
@Override
public short getShort(Record rec) {
return 0;
}
@Override
public boolean isConstant() {
return true;
}
};
}
});
Function function = parseFunction("x()", new GenericRecordMetadata(), createFunctionParser());
Assert.assertTrue(function instanceof ShortConstant);
}
Aggregations