Search in sources :

Example 11 with TableModel

use of io.questdb.cairo.TableModel in project questdb by bluestreak01.

the class MaxFloatGroupByFunctionTest method testSampleByWithFill.

@Test
public void testSampleByWithFill() throws SqlException, NumericException {
    try (TableModel tm = new TableModel(configuration, "tab", PartitionBy.DAY)) {
        tm.timestamp("ts").col("ch", ColumnType.FLOAT);
        createPopulateTable(tm, 100, "2020-01-01", 2);
    }
    assertSql("select ts, min(ch), max(ch), first(ch), last(ch), count() from tab sample by 1m FILL(LINEAR) LIMIT 2", "ts\tmin\tmax\tfirst\tlast\tcount\n" + "2020-01-01T00:28:47.990000Z\t0.0010\t0.0010\t0.0010\t0.0010\t1\n" + "2020-01-01T00:29:47.990000Z\t0.0010\t0.0010\t0.0010\t0.0010\t1\n");
}
Also used : TableModel(io.questdb.cairo.TableModel) AbstractGriffinTest(io.questdb.griffin.AbstractGriffinTest) Test(org.junit.Test)

Example 12 with TableModel

use of io.questdb.cairo.TableModel in project questdb by bluestreak01.

the class TimestampQueryTest method testTimestampConversion.

@Test
public void testTimestampConversion() throws Exception {
    assertMemoryLeak(() -> {
        try (TableModel m = new TableModel(configuration, "tt", PartitionBy.DAY)) {
            m.timestamp("dts").col("ts", ColumnType.TIMESTAMP);
            createPopulateTable(m, 31, "2021-03-14", 31);
            String expected = "dts\tts\n" + "2021-04-02T23:59:59.354820Z\t2021-04-02T23:59:59.354820Z\n";
            assertQuery(expected, "tt where dts > '2021-04-02T13:45:49.207Z' and dts < '2021-04-03 13:45:49.207'", "dts", true, true);
            assertQuery(expected, "tt where ts > '2021-04-02T13:45:49.207Z' and ts < '2021-04-03 13:45:49.207'", "dts", true, false);
        }
    });
}
Also used : TableModel(io.questdb.cairo.TableModel) Test(org.junit.Test)

Example 13 with TableModel

use of io.questdb.cairo.TableModel in project questdb by bluestreak01.

the class TimestampQueryTest method testTimestampSymbolConversion.

@Test
public void testTimestampSymbolConversion() throws Exception {
    assertMemoryLeak(() -> {
        try (TableModel m = new TableModel(configuration, "tt", PartitionBy.DAY)) {
            m.timestamp("dts").col("ts", ColumnType.TIMESTAMP);
            createPopulateTable(m, 31, "2021-03-14", 31);
            String expected = "dts\tts\n" + "2021-04-02T23:59:59.354820Z\t2021-04-02T23:59:59.354820Z\n";
            assertQuery(expected, "tt where dts > cast('2021-04-02T13:45:49.207Z' as symbol) and dts < cast('2021-04-03 13:45:49.207' as symbol)", "dts", true, true);
            assertQuery(expected, "tt where ts > cast('2021-04-02T13:45:49.207Z' as symbol) and ts < cast('2021-04-03 13:45:49.207' as symbol)", "dts", true, false);
        }
    });
}
Also used : TableModel(io.questdb.cairo.TableModel) Test(org.junit.Test)

Example 14 with TableModel

use of io.questdb.cairo.TableModel in project questdb by bluestreak01.

the class SimpleTableTest method testWhereIsColumnNameInsensitive.

@Test
public void testWhereIsColumnNameInsensitive() throws SqlException, NumericException {
    try (TableModel tm = new TableModel(configuration, "tab1", PartitionBy.NONE)) {
        tm.timestamp("ts").col("ID", ColumnType.INT);
        createPopulateTable(tm, 2, "2020-01-01", 1);
    }
    assertSql("select ts from tab1 where id > 1", "ts\n" + "2020-01-01T00:00:00.000000Z\n");
}
Also used : TableModel(io.questdb.cairo.TableModel) Test(org.junit.Test)

Example 15 with TableModel

use of io.questdb.cairo.TableModel in project questdb by bluestreak01.

the class KeyedAggregationTest method testCountAggregationWithConst.

@Test
public void testCountAggregationWithConst() throws Exception {
    try (TableModel tt1 = new TableModel(configuration, "tt1", PartitionBy.DAY)) {
        tt1.col("tts", ColumnType.LONG).timestamp("ts");
        createPopulateTable(tt1, 100, "2020-01-01", 2);
    }
    String expected = "ts\tcount\n" + "2020-01-01T00:28:47.990000Z:TIMESTAMP\t51:LONG\n" + "2020-01-02T00:28:47.990000Z:TIMESTAMP\t49:LONG\n";
    String sql = "select ts, count() from tt1 SAMPLE BY d";
    assertSqlWithTypes(sql, expected);
}
Also used : TableModel(io.questdb.cairo.TableModel) Test(org.junit.Test)

Aggregations

TableModel (io.questdb.cairo.TableModel)17 Test (org.junit.Test)14 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)8 Path (io.questdb.std.str.Path)3 FilesFacade (io.questdb.std.FilesFacade)1 Rnd (io.questdb.std.Rnd)1