Search in sources :

Example 6 with QueryColumn

use of io.questdb.griffin.model.QueryColumn in project questdb by bluestreak01.

the class SampleByTest method testSampleByFirstLastRecordCursorFactoryInvalidNotFirstLast.

@Test
public void testSampleByFirstLastRecordCursorFactoryInvalidNotFirstLast() {
    try {
        GenericRecordMetadata groupByMeta = new GenericRecordMetadata();
        TableColumnMetadata column = new TableColumnMetadata("col1", 1, ColumnType.LONG, false, 0, false, null);
        groupByMeta.add(column);
        GenericRecordMetadata meta = new GenericRecordMetadata();
        meta.add(column);
        ObjList<QueryColumn> columns = new ObjList<>();
        ExpressionNode first = ExpressionNode.FACTORY.newInstance().of(ColumnType.LONG, "min", 0, 0);
        first.rhs = ExpressionNode.FACTORY.newInstance().of(ColumnType.LONG, "col1", 0, 0);
        QueryColumn col = QueryColumn.FACTORY.newInstance().of("col1", first);
        columns.add(col);
        new SampleByFirstLastRecordCursorFactory(null, new MicroTimestampSampler(100L), groupByMeta, columns, meta, null, 0, null, 0, 0, getSymbolFilter(), -1);
        Assert.fail();
    } catch (SqlException e) {
        TestUtils.assertContains(e.getFlyweightMessage(), "expected first() or last() functions but got min");
    }
}
Also used : ObjList(io.questdb.std.ObjList) QueryColumn(io.questdb.griffin.model.QueryColumn) ExpressionNode(io.questdb.griffin.model.ExpressionNode) SqlException(io.questdb.griffin.SqlException) Test(org.junit.Test) AbstractGriffinTest(io.questdb.griffin.AbstractGriffinTest)

Example 7 with QueryColumn

use of io.questdb.griffin.model.QueryColumn in project questdb by bluestreak01.

the class SampleByTest method testSampleByFirstLastRecordCursorFactoryInvalidColumns.

@Test
public void testSampleByFirstLastRecordCursorFactoryInvalidColumns() {
    try {
        GenericRecordMetadata groupByMeta = new GenericRecordMetadata();
        groupByMeta.add(new TableColumnMetadata("col1", 1, ColumnType.STRING, false, 0, false, null));
        GenericRecordMetadata meta = new GenericRecordMetadata();
        meta.add(new TableColumnMetadata("col1", 2, ColumnType.LONG, false, 0, false, null));
        ObjList<QueryColumn> columns = new ObjList<>();
        ExpressionNode first = ExpressionNode.FACTORY.newInstance().of(ColumnType.LONG, "first", 0, 0);
        first.rhs = ExpressionNode.FACTORY.newInstance().of(ColumnType.LONG, "col1", 0, 0);
        QueryColumn col = QueryColumn.FACTORY.newInstance().of("col1", first);
        columns.add(col);
        new SampleByFirstLastRecordCursorFactory(null, new MicroTimestampSampler(100L), groupByMeta, columns, meta, null, 0, null, 0, 0, getSymbolFilter(), -1);
        Assert.fail();
    } catch (SqlException e) {
        TestUtils.assertContains(e.getFlyweightMessage(), "first(), last() is not supported on data type");
    }
}
Also used : ObjList(io.questdb.std.ObjList) QueryColumn(io.questdb.griffin.model.QueryColumn) ExpressionNode(io.questdb.griffin.model.ExpressionNode) SqlException(io.questdb.griffin.SqlException) Test(org.junit.Test) AbstractGriffinTest(io.questdb.griffin.AbstractGriffinTest)

Aggregations

QueryColumn (io.questdb.griffin.model.QueryColumn)7 ExpressionNode (io.questdb.griffin.model.ExpressionNode)6 Function (io.questdb.cairo.sql.Function)2 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)2 SqlException (io.questdb.griffin.SqlException)2 GroupByFunction (io.questdb.griffin.engine.functions.GroupByFunction)2 SymbolFunction (io.questdb.griffin.engine.functions.SymbolFunction)2 QueryModel (io.questdb.griffin.model.QueryModel)2 ObjList (io.questdb.std.ObjList)2 Test (org.junit.Test)2