Search in sources :

Example 11 with Function

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()));
}
Also used : Function(io.questdb.cairo.sql.Function) Test(org.junit.Test)

Example 12 with Function

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()));
}
Also used : Function(io.questdb.cairo.sql.Function) Test(org.junit.Test)

Example 13 with Function

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()));
}
Also used : ToStrTimestampFunctionFactory(io.questdb.griffin.engine.functions.date.ToStrTimestampFunctionFactory) Function(io.questdb.cairo.sql.Function) ToStrDateFunctionFactory(io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory) Test(org.junit.Test)

Example 14 with Function

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()));
}
Also used : Function(io.questdb.cairo.sql.Function) Test(org.junit.Test)

Example 15 with Function

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()));
}
Also used : Function(io.questdb.cairo.sql.Function) Test(org.junit.Test)

Aggregations

Function (io.questdb.cairo.sql.Function)204 Test (org.junit.Test)101 UnaryFunction (io.questdb.griffin.engine.functions.UnaryFunction)39 IntList (io.questdb.std.IntList)33 Record (io.questdb.cairo.sql.Record)28 ToStrTimestampFunctionFactory (io.questdb.griffin.engine.functions.date.ToStrTimestampFunctionFactory)28 ToStrDateFunctionFactory (io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory)27 NotFunctionFactory (io.questdb.griffin.engine.functions.bool.NotFunctionFactory)26 InStrFunctionFactory (io.questdb.griffin.engine.functions.bool.InStrFunctionFactory)25 EqDoubleFunctionFactory (io.questdb.griffin.engine.functions.eq.EqDoubleFunctionFactory)25 EqIntFunctionFactory (io.questdb.griffin.engine.functions.eq.EqIntFunctionFactory)25 EqLongFunctionFactory (io.questdb.griffin.engine.functions.eq.EqLongFunctionFactory)25 OrFunctionFactory (io.questdb.griffin.engine.functions.bool.OrFunctionFactory)24 CastStrToGeoHashFunctionFactory (io.questdb.griffin.engine.functions.cast.CastStrToGeoHashFunctionFactory)23 CursorDereferenceFunctionFactory (io.questdb.griffin.engine.functions.catalogue.CursorDereferenceFunctionFactory)23 SysdateFunctionFactory (io.questdb.griffin.engine.functions.date.SysdateFunctionFactory)23 LengthStrFunctionFactory (io.questdb.griffin.engine.functions.str.LengthStrFunctionFactory)23 LengthSymbolFunctionFactory (io.questdb.griffin.engine.functions.str.LengthSymbolFunctionFactory)23 ToCharBinFunctionFactory (io.questdb.griffin.engine.functions.str.ToCharBinFunctionFactory)23 SwitchFunctionFactory (io.questdb.griffin.engine.functions.conditional.SwitchFunctionFactory)22