use of io.questdb.griffin.engine.functions.bool.NotFunctionFactory in project questdb by bluestreak01.
the class BindVariablesTest method testBooleanIndexed.
@Test
public void testBooleanIndexed() throws SqlException {
bindVariableService.setBoolean(1, false);
bindVariableService.setBoolean(0, false);
Function func = expr("not $1").withFunction(new NotFunctionFactory()).$();
func.init(null, sqlExecutionContext);
Assert.assertTrue(func.getBool(builder.getRecord()));
bindVariableService.setBoolean(0, true);
Assert.assertFalse(func.getBool(builder.getRecord()));
}
use of io.questdb.griffin.engine.functions.bool.NotFunctionFactory in project questdb by bluestreak01.
the class BindVariablesTest method testBoolean.
@Test
public void testBoolean() throws SqlException {
bindVariableService.setBoolean("xyz", false);
Function func = expr("not :xyz").withFunction(new NotFunctionFactory()).$();
func.init(null, sqlExecutionContext);
Assert.assertTrue(func.getBool(builder.getRecord()));
bindVariableService.setBoolean("xyz", true);
Assert.assertFalse(func.getBool(builder.getRecord()));
}
use of io.questdb.griffin.engine.functions.bool.NotFunctionFactory in project questdb by bluestreak01.
the class FunctionParserTest method testBooleanConstants.
@Test
public void testBooleanConstants() throws SqlException {
functions.add(new NotFunctionFactory());
functions.add(new OrFunctionFactory());
final Record record = new Record() {
@Override
public boolean getBool(int col) {
// col0 = false
return false;
}
};
final GenericRecordMetadata metadata = new GenericRecordMetadata();
metadata.add(new TableColumnMetadata("a", 1, ColumnType.BOOLEAN));
FunctionParser functionParser = createFunctionParser();
Function function = parseFunction("a or not false", metadata, functionParser);
Assert.assertEquals(ColumnType.BOOLEAN, function.getType());
Assert.assertTrue(function.getBool(record));
Function function2 = parseFunction("a or true", metadata, functionParser);
Assert.assertTrue(function2.getBool(record));
}
use of io.questdb.griffin.engine.functions.bool.NotFunctionFactory 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());
}
use of io.questdb.griffin.engine.functions.bool.NotFunctionFactory in project questdb by bluestreak01.
the class FunctionParserTest method testBooleanFunctions.
@Test
public void testBooleanFunctions() throws SqlException {
functions.add(new NotFunctionFactory());
functions.add(new OrFunctionFactory());
final Record record = new Record() {
@Override
public boolean getBool(int col) {
// col1 = true
return col != 0;
}
};
final GenericRecordMetadata metadata = new GenericRecordMetadata();
metadata.add(new TableColumnMetadata("a", 1, ColumnType.BOOLEAN));
metadata.add(new TableColumnMetadata("b", 2, ColumnType.BOOLEAN));
FunctionParser functionParser = createFunctionParser();
Function function = parseFunction("a or not b", metadata, functionParser);
Assert.assertEquals(ColumnType.BOOLEAN, function.getType());
Assert.assertFalse(function.getBool(record));
}
Aggregations