use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testFloatIndexed.
@Test
public void testFloatIndexed() throws SqlException {
bindVariableService.setFloat(2, Float.NaN);
bindVariableService.setFloat(0, 7.6f);
bindVariableService.setFloat(1, 9.21f);
Function func = expr("$1 + $2").withFunction(new AddFloatFunctionFactory()).$();
func.init(null, sqlExecutionContext);
Assert.assertEquals(16.81f, func.getFloat(builder.getRecord()), 0.001f);
bindVariableService.setFloat(1, 0.13f);
func.init(null, sqlExecutionContext);
Assert.assertEquals(7.73f, func.getFloat(builder.getRecord()), 0.001f);
func.close();
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testFloatExplicitlyIndexedTwoVars.
@Test
public void testFloatExplicitlyIndexedTwoVars() throws SqlException {
bindVariableService.setFloat(2, Float.NaN);
bindVariableService.setFloat(0, 7.6f);
bindVariableService.setFloat(1, 9.21f);
Function func = expr("$1 + $2").withFunction(new AddFloatFunctionFactory()).$();
func.init(null, sqlExecutionContext);
Assert.assertEquals(16.81, func.getFloat(builder.getRecord()), 0.001f);
bindVariableService.setFloat(0, 0.13f);
func.init(null, sqlExecutionContext);
Assert.assertEquals(9.34f, func.getFloat(builder.getRecord()), 0.001f);
func.close();
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testByte.
@Test
public void testByte() throws SqlException {
bindVariableService.setByte("xyz", (byte) 8);
Function func = expr("b + :xyz").withFunction(new AddByteFunctionFactory()).withColumn("b", ColumnType.BYTE, (byte) 22).$();
func.init(null, sqlExecutionContext);
Assert.assertEquals(30, func.getByte(builder.getRecord()));
bindVariableService.setByte("xyz", (byte) 10);
Assert.assertEquals(32, func.getByte(builder.getRecord()));
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testNonAsciiLowerCaseStr.
@Test
public void testNonAsciiLowerCaseStr() throws SqlException {
bindVariableService.setStr("str", "abcDEFghiJKLm...() { _; } >_[$($())] { <<< %(='%') \"noPQRstuVXZ");
Function func = expr("to_lowercase(:str)").withFunction(new ToLowercaseFunctionFactory()).$();
func.init(null, sqlExecutionContext);
TestUtils.assertEquals("abcdefghijklm...() { _; } >_[$($())] { <<< %(='%') \"nopqrstuvxz", func.getStr(builder.getRecord()));
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testFloat.
@Test
public void testFloat() throws SqlException {
bindVariableService.setFloat("xyz", 7.6f);
Function func = expr("a + :xyz").withFunction(new AddFloatFunctionFactory()).withColumn("a", ColumnType.FLOAT, 25.1f).$();
func.init(null, sqlExecutionContext);
Assert.assertEquals(32.7f, func.getFloat(builder.getRecord()), 0.001f);
bindVariableService.setFloat("xyz", 0.78f);
func.init(null, sqlExecutionContext);
Assert.assertEquals(25.88f, func.getFloat(builder.getRecord()), 0.001f);
func.close();
}
Aggregations