use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testImplicitConstantNull.
@Test
public void testImplicitConstantNull() 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 StrFunction() {
@Override
public CharSequence getStr(Record rec) {
return null;
}
@Override
public CharSequence getStrB(Record rec) {
return null;
}
@Override
public boolean isConstant() {
return true;
}
};
}
});
Function function = parseFunction("x()", new GenericRecordMetadata(), createFunctionParser());
Assert.assertSame(StrConstant.NULL, function);
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testImplicitConstantSymbol.
@Test
public void testImplicitConstantSymbol() 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 SymbolConstant("xyz", 0);
}
});
Function function = parseFunction("x()", new GenericRecordMetadata(), createFunctionParser());
Assert.assertTrue(function instanceof SymbolConstant);
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testImplicitConstantStr.
@Test
public void testImplicitConstantStr() 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 StrFunction() {
private final String x = "abc";
@Override
public CharSequence getStr(Record rec) {
return x;
}
@Override
public CharSequence getStrB(Record rec) {
return x;
}
@Override
public boolean isConstant() {
return true;
}
};
}
});
Function function = parseFunction("x()", new GenericRecordMetadata(), createFunctionParser());
Assert.assertTrue(function instanceof StrConstant);
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method testImplicitConstantDate.
@Test
public void testImplicitConstantDate() 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 DateFunction() {
@Override
public long getDate(Record rec) {
return 0;
}
@Override
public boolean isConstant() {
return true;
}
};
}
});
Function function = parseFunction("x()", new GenericRecordMetadata(), createFunctionParser());
Assert.assertTrue(function instanceof DateConstant);
}
use of io.questdb.std.IntList in project questdb by bluestreak01.
the class FunctionParserTest method assertSignatureFailure.
private void assertSignatureFailure(String signature) throws SqlException {
functions.add(new OrFunctionFactory());
functions.add(new FunctionFactory() {
@Override
public String getSignature() {
return signature;
}
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
return null;
}
});
functions.add(new NotFunctionFactory());
final GenericRecordMetadata metadata = new GenericRecordMetadata();
metadata.add(new TableColumnMetadata("a", 1, ColumnType.BOOLEAN));
metadata.add(new TableColumnMetadata("b", 2, ColumnType.BOOLEAN));
FunctionParser functionParser = createFunctionParser();
Assert.assertNotNull(parseFunction("a or not b", metadata, functionParser));
Assert.assertEquals(2, functionParser.getFunctionCount());
}
Aggregations