Search in sources :

Example 1 with InStrFunctionFactory

use of io.questdb.griffin.engine.functions.bool.InStrFunctionFactory in project questdb by bluestreak01.

the class FunctionParserTest method testConstVarArgFunction.

@Test
public void testConstVarArgFunction() throws SqlException {
    functions.add(new InStrFunctionFactory());
    final GenericRecordMetadata metadata = new GenericRecordMetadata();
    metadata.add(new TableColumnMetadata("a", 1, ColumnType.STRING));
    FunctionParser functionParser = createFunctionParser();
    Function function = parseFunction("a in ('xu', 'yk')", metadata, functionParser);
    Assert.assertEquals(ColumnType.BOOLEAN, function.getType());
    Assert.assertTrue(function.getBool(new Record() {

        @Override
        public CharSequence getStr(int col) {
            return "yk";
        }
    }));
}
Also used : Function(io.questdb.cairo.sql.Function) InStrFunctionFactory(io.questdb.griffin.engine.functions.bool.InStrFunctionFactory) Record(io.questdb.cairo.sql.Record) Test(org.junit.Test)

Example 2 with InStrFunctionFactory

use of io.questdb.griffin.engine.functions.bool.InStrFunctionFactory in project questdb by bluestreak01.

the class FunctionParserTest method testVarArgFunction.

@Test
public void testVarArgFunction() throws SqlException {
    functions.add(new InStrFunctionFactory());
    final GenericRecordMetadata metadata = new GenericRecordMetadata();
    metadata.add(new TableColumnMetadata("a", 1, ColumnType.STRING));
    FunctionParser functionParser = createFunctionParser();
    Record record = new Record() {

        @Override
        public CharSequence getStr(int col) {
            return "YZ";
        }
    };
    Function function = parseFunction("a in ('XY', 'YZ')", metadata, functionParser);
    Assert.assertEquals(ColumnType.BOOLEAN, function.getType());
    Assert.assertTrue(function.getBool(record));
}
Also used : Function(io.questdb.cairo.sql.Function) InStrFunctionFactory(io.questdb.griffin.engine.functions.bool.InStrFunctionFactory) Record(io.questdb.cairo.sql.Record) Test(org.junit.Test)

Example 3 with InStrFunctionFactory

use of io.questdb.griffin.engine.functions.bool.InStrFunctionFactory in project questdb by bluestreak01.

the class FunctionParserTest method testVarArgFunctionNoArg.

@Test
public void testVarArgFunctionNoArg() throws SqlException {
    functions.add(new InStrFunctionFactory());
    final GenericRecordMetadata metadata = new GenericRecordMetadata();
    metadata.add(new TableColumnMetadata("a", 1, ColumnType.STRING));
    FunctionParser functionParser = createFunctionParser();
    Record record = new Record() {

        @Override
        public CharSequence getStr(int col) {
            return "Y";
        }
    };
    Function function = parseFunction("a in ()", metadata, functionParser);
    Assert.assertEquals(ColumnType.BOOLEAN, function.getType());
    Assert.assertFalse(function.getBool(record));
}
Also used : Function(io.questdb.cairo.sql.Function) InStrFunctionFactory(io.questdb.griffin.engine.functions.bool.InStrFunctionFactory) Record(io.questdb.cairo.sql.Record) Test(org.junit.Test)

Example 4 with InStrFunctionFactory

use of io.questdb.griffin.engine.functions.bool.InStrFunctionFactory in project questdb by bluestreak01.

the class FunctionParserTest method testPassColumnToConstVarArgFunction.

@Test
public void testPassColumnToConstVarArgFunction() {
    functions.add(new InStrFunctionFactory());
    final GenericRecordMetadata metadata = new GenericRecordMetadata();
    metadata.add(new TableColumnMetadata("a", 1, ColumnType.STRING));
    metadata.add(new TableColumnMetadata("b", 2, ColumnType.STRING));
    assertFail(6, "constant expected", "a in (b, 'y')", metadata);
}
Also used : InStrFunctionFactory(io.questdb.griffin.engine.functions.bool.InStrFunctionFactory) Test(org.junit.Test)

Aggregations

InStrFunctionFactory (io.questdb.griffin.engine.functions.bool.InStrFunctionFactory)4 Test (org.junit.Test)4 Function (io.questdb.cairo.sql.Function)3 Record (io.questdb.cairo.sql.Record)3