Search in sources :

Example 26 with Function

use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.

the class BindVariablesTest method testLong256Compare.

@Test
public void testLong256Compare() throws SqlException {
    bindVariableService.setLong256("x", 1, 2, 3, 4);
    bindVariableService.setLong256("y", 1, 2, 3, 4);
    Function func = expr(":x = :y").withFunction(new EqLong256FunctionFactory()).$();
    func.init(null, sqlExecutionContext);
    Assert.assertTrue(func.getBool(builder.getRecord()));
    bindVariableService.setLong256("y", 2, 4, 5, 6);
    Assert.assertFalse(func.getBool(builder.getRecord()));
}
Also used : Function(io.questdb.cairo.sql.Function) EqLong256FunctionFactory(io.questdb.griffin.engine.functions.eq.EqLong256FunctionFactory) Test(org.junit.Test)

Example 27 with Function

use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.

the class BindVariablesTest method testInt.

@Test
public void testInt() throws SqlException {
    bindVariableService.setInt("xyz", 10);
    bindVariableService.setInt("zz", 5);
    Function func = expr("a + :xyz + :xyz - :zz").withFunction(new AddIntFunctionFactory()).withFunction(new SubIntFunctionFactory()).withColumn("a", ColumnType.INT, 22).$();
    func.init(null, sqlExecutionContext);
    Assert.assertEquals(37, func.getInt(builder.getRecord()));
    bindVariableService.setInt("zz", 8);
    Assert.assertEquals(34, func.getInt(builder.getRecord()));
}
Also used : Function(io.questdb.cairo.sql.Function) Test(org.junit.Test)

Example 28 with Function

use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.

the class CastGeoHashFunctionFactoryTest method testCastStringToGeoHashSizesChar.

@Test
public void testCastStringToGeoHashSizesChar() throws SqlException {
    String longHash = "sp052w92bcde";
    for (int i = 0; i < longHash.length(); i++) {
        String expectedGeoHash = longHash.substring(0, i + 1);
        for (int j = 0; j <= i; j++) {
            int parsedGeoHashLen = j + 1;
            String castExpr = String.format("cast('%s' as geohash(%sc))", expectedGeoHash, parsedGeoHashLen);
            Function function = parseFunction(castExpr, metadata, functionParser);
            Assert.assertTrue(castExpr, function.isConstant());
            Assert.assertEquals(castExpr, parsedGeoHashLen * 5, ColumnType.getGeoHashBits(function.getType()));
        }
    }
}
Also used : Function(io.questdb.cairo.sql.Function) BaseFunctionFactoryTest(io.questdb.griffin.BaseFunctionFactoryTest) Test(org.junit.Test)

Example 29 with Function

use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.

the class BindVariableServiceImpl method setChar.

@Override
public void setChar(int index, char value) throws SqlException {
    indexedVariables.extendPos(index + 1);
    // variable exists
    Function function = indexedVariables.getQuick(index);
    if (function != null) {
        setChar0(function, value, index, null);
    } else {
        indexedVariables.setQuick(index, function = charVarPool.next());
        ((CharBindVariable) function).value = value;
    }
}
Also used : Function(io.questdb.cairo.sql.Function)

Example 30 with Function

use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.

the class BindVariableServiceImpl method setLong.

@Override
public void setLong(int index, long value) throws SqlException {
    indexedVariables.extendPos(index + 1);
    // variable exists
    Function function = indexedVariables.getQuick(index);
    if (function != null) {
        setLong0(function, value, index, null, ColumnType.LONG);
    } else {
        indexedVariables.setQuick(index, function = longVarPool.next());
        ((LongBindVariable) function).value = value;
    }
}
Also used : Function(io.questdb.cairo.sql.Function)

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