use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testUppercaseStr.
@Test
public void testUppercaseStr() throws SqlException {
bindVariableService.setStr("str", "abcDEFghiJKLmnoPQRstuVXZ");
Function func = expr("to_uppercase(:str)").withFunction(new ToUppercaseFunctionFactory()).$();
func.init(null, sqlExecutionContext);
TestUtils.assertEquals("ABCDEFGHIJKLMNOPQRSTUVXZ", func.getStr(builder.getRecord()));
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testCharIndexed.
@Test
public void testCharIndexed() throws SqlException {
bindVariableService.setChar(0, 'C');
bindVariableService.setChar(1, 'A');
Function func = expr("$1 || $2").withFunction(new ConcatFunctionFactory()).$();
func.init(null, sqlExecutionContext);
TestUtils.assertEquals("CA", func.getStr(builder.getRecord()));
bindVariableService.setChar(1, '0');
func.init(null, sqlExecutionContext);
TestUtils.assertEquals("C0", func.getStr(builder.getRecord()));
func.close();
}
use of io.questdb.cairo.sql.Function 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.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testFloatExplicitlyIndexed.
@Test
public void testFloatExplicitlyIndexed() throws SqlException {
bindVariableService.setFloat(2, Float.NaN);
bindVariableService.setFloat(0, 7.6f);
bindVariableService.setFloat(1, 9.21f);
Function func = expr("$1 + $1").withFunction(new AddFloatFunctionFactory()).$();
func.init(null, sqlExecutionContext);
Assert.assertEquals(15.2f, func.getFloat(builder.getRecord()), 0.001f);
bindVariableService.setFloat(0, 0.13f);
func.init(null, sqlExecutionContext);
Assert.assertEquals(0.26f, func.getFloat(builder.getRecord()), 0.001f);
func.close();
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testDate.
@Test
public void testDate() throws SqlException, NumericException {
bindVariableService.setDate("xyz", DateFormatUtils.parseUTCDate("2015-04-10T10:00:00.000Z"));
Function func = expr("to_str(:xyz, 'yyyy-MM')").withFunction(new ToStrDateFunctionFactory()).$();
func.init(null, sqlExecutionContext);
TestUtils.assertEquals("2015-04", func.getStr(builder.getRecord()));
bindVariableService.setDate("xyz", DateFormatUtils.parseUTCDate("2015-08-10T10:00:00.000Z"));
TestUtils.assertEquals("2015-08", func.getStr(builder.getRecord()));
}
Aggregations