use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testLowercaseIndexedStr.
@Test
public void testLowercaseIndexedStr() throws SqlException {
bindVariableService.setLong(2, 10000);
bindVariableService.setInt(0, 1);
bindVariableService.setStr(1, "abcDEFghiJKLmnoPQRstuVXZ");
Function func = expr("to_lowercase($2)").withFunction(new ToLowercaseFunctionFactory()).$();
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 testChar.
@Test
public void testChar() throws SqlException {
bindVariableService.setChar("abc", 'x');
Function func = expr(":abc").$();
func.init(null, sqlExecutionContext);
Assert.assertEquals('x', func.getChar(builder.getRecord()));
bindVariableService.setChar("abc", 'y');
Assert.assertEquals('y', func.getChar(builder.getRecord()));
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testAmbiguousCall.
@Test
public void testAmbiguousCall() throws SqlException {
bindVariableService.setDate("xyz", 0);
Function func = expr("to_str(:xyz, 'yyyy-MM')").withFunction(new ToStrDateFunctionFactory()).withFunction(new ToStrTimestampFunctionFactory()).$();
func.init(null, sqlExecutionContext);
TestUtils.assertEquals("1970-01", func.getStr(builder.getRecord()));
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testStr.
@Test
public void testStr() throws SqlException {
bindVariableService.setStr("str", "abc");
Function func = expr("length(:str)").withFunction(new LengthStrFunctionFactory()).$();
func.init(null, sqlExecutionContext);
Assert.assertEquals(3, func.getInt(builder.getRecord()));
bindVariableService.setStr("str", "hello");
Assert.assertEquals(5, func.getInt(builder.getRecord()));
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class BindVariablesTest method testStr2Indexed.
@Test
public void testStr2Indexed() throws SqlException {
bindVariableService.setLong(2, 10000);
bindVariableService.setInt(0, 1);
bindVariableService.setStr(1, "abcd");
Function func = expr("right($2, $1)").withFunction(new RightFunctionFactory()).$();
func.init(null, sqlExecutionContext);
TestUtils.assertEquals("d", func.getStr(builder.getRecord()));
}
Aggregations