use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testDoubleIndexed.
@Test
public void testDoubleIndexed() throws SqlException {
bindVariableService.setDouble(2, Double.NaN);
bindVariableService.setDouble(0, 0.223232);
bindVariableService.setDouble(1, 9.222333);
Function func = expr("$1 + $2").withFunction(new AddDoubleFunctionFactory()).$();
func.init(null, sqlExecutionContext);
Assert.assertEquals(9.445565, func.getDouble(builder.getRecord()), 0.001);
bindVariableService.setDouble(1, 0.1322990);
func.init(null, sqlExecutionContext);
Assert.assertEquals(0.355531, func.getDouble(builder.getRecord()), 0.001);
func.close();
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testDateIndexed.
@Test
public void testDateIndexed() throws SqlException, NumericException {
bindVariableService.setDate(1, 0);
bindVariableService.setDate(0, DateFormatUtils.parseUTCDate("2015-04-10T10:00:00.000Z"));
Function func = expr("to_str($1, 'yyyy-MM')").withFunction(new ToStrDateFunctionFactory()).$();
func.init(null, sqlExecutionContext);
TestUtils.assertEquals("2015-04", func.getStr(builder.getRecord()));
bindVariableService.setDate(0, DateFormatUtils.parseUTCDate("2015-08-10T10:00:00.000Z"));
TestUtils.assertEquals("2015-08", func.getStr(builder.getRecord()));
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testShort.
@Test
public void testShort() throws SqlException {
bindVariableService.setShort("xyz", (short) 8);
Function func = expr("b + :xyz").withFunction(new AddShortFunctionFactory()).withColumn("b", ColumnType.SHORT, (short) 22).$();
func.init(null, sqlExecutionContext);
Assert.assertEquals(30, func.getShort(builder.getRecord()));
bindVariableService.setShort("xyz", (short) 33);
Assert.assertEquals(55, func.getShort(builder.getRecord()));
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testShortIndexed.
@Test
public void testShortIndexed() throws SqlException {
bindVariableService.setShort(1, (short) 2);
bindVariableService.setShort(0, (short) 8);
Function func = expr("b + $1").withFunction(new AddShortFunctionFactory()).withColumn("b", ColumnType.SHORT, (short) 22).$();
func.init(null, sqlExecutionContext);
Assert.assertEquals(30, func.getShort(builder.getRecord()));
bindVariableService.setShort(0, (short) 33);
Assert.assertEquals(55, func.getShort(builder.getRecord()));
}
use of io.questdb.cairo.sql.Function 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()));
}
Aggregations