Search in sources :

Example 6 with TableModel

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

the class CharGroupByFunctionTest method testSampleBy.

@Test
public void testSampleBy() throws SqlException, NumericException {
    try (TableModel tm = new TableModel(configuration, "tab", PartitionBy.DAY)) {
        tm.timestamp("ts").col("ch", ColumnType.CHAR);
        createPopulateTable(tm, 100, "2020-01-01", 2);
    }
    assertSql("select ts, min(ch), max(ch), first(ch), last(ch), count() from tab sample by d", "ts\tmin\tmax\tfirst\tlast\tcount\n" + "2020-01-01T00:28:47.990000Z\t\u0001\t3\t\u0001\t3\t51\n" + "2020-01-02T00:28:47.990000Z\t4\td\t4\td\t49\n");
}
Also used : TableModel(io.questdb.cairo.TableModel) AbstractGriffinTest(io.questdb.griffin.AbstractGriffinTest) Test(org.junit.Test)

Example 7 with TableModel

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

the class TableMetadataCursorFactoryTest method testMetadataQueryDefaultHysterisysParams.

@Test
public void testMetadataQueryDefaultHysterisysParams() throws Exception {
    configOverrideMaxUncommittedRows = 83737;
    configOverrideCommitLag = 28291;
    try (TableModel tm1 = new TableModel(configuration, "table1", PartitionBy.DAY)) {
        tm1.col("abc", ColumnType.STRING);
        tm1.timestamp("ts1");
        createPopulateTable(tm1, 0, "2020-01-01", 0);
    }
    assertSql("tables", "id\tname\tdesignatedTimestamp\tpartitionBy\tmaxUncommittedRows\tcommitLag\n" + "1\ttable1\tts1\tDAY\t83737\t28291\n");
}
Also used : TableModel(io.questdb.cairo.TableModel) AbstractGriffinTest(io.questdb.griffin.AbstractGriffinTest) Test(org.junit.Test)

Example 8 with TableModel

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

the class TableMetadataCursorFactoryTest method testMetadataQuery.

@Test
public void testMetadataQuery() throws Exception {
    try (TableModel tm1 = new TableModel(configuration, "table1", PartitionBy.DAY)) {
        tm1.col("abc", ColumnType.STRING);
        tm1.timestamp("ts1");
        createPopulateTable(tm1, 0, "2020-01-01", 0);
    }
    try (TableModel tm1 = new TableModel(configuration, "table2", PartitionBy.NONE)) {
        tm1.timestamp("ts2");
        createPopulateTable(tm1, 0, "2020-01-01", 0);
    }
    assertSql("tables order by id desc", "id\tname\tdesignatedTimestamp\tpartitionBy\tmaxUncommittedRows\tcommitLag\n" + "2\ttable2\tts2\tNONE\t1000\t0\n" + "1\ttable1\tts1\tDAY\t1000\t0\n");
}
Also used : TableModel(io.questdb.cairo.TableModel) AbstractGriffinTest(io.questdb.griffin.AbstractGriffinTest) Test(org.junit.Test)

Example 9 with TableModel

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

the class TableMetadataCursorFactoryTest method testMetadataQueryMissingMetaFile.

@Test
public void testMetadataQueryMissingMetaFile() throws Exception {
    try (TableModel tm1 = new TableModel(configuration, "table1", PartitionBy.DAY)) {
        tm1.col("abc", ColumnType.STRING);
        tm1.timestamp("ts1");
        createPopulateTable(tm1, 0, "2020-01-01", 0);
    }
    try (TableModel tm1 = new TableModel(configuration, "table2", PartitionBy.NONE)) {
        tm1.timestamp("ts2");
        createPopulateTable(tm1, 0, "2020-01-01", 0);
    }
    engine.releaseAllWriters();
    engine.releaseAllReaders();
    FilesFacade filesFacade = configuration.getFilesFacade();
    try (Path path = new Path()) {
        path.concat(configuration.getRoot()).concat("table1").concat(META_FILE_NAME).$();
        filesFacade.remove(path);
    }
    assertSql("tables", "id\tname\tdesignatedTimestamp\tpartitionBy\tmaxUncommittedRows\tcommitLag\n" + "2\ttable2\tts2\tNONE\t1000\t0\n");
}
Also used : Path(io.questdb.std.str.Path) FilesFacade(io.questdb.std.FilesFacade) TableModel(io.questdb.cairo.TableModel) AbstractGriffinTest(io.questdb.griffin.AbstractGriffinTest) Test(org.junit.Test)

Example 10 with TableModel

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

the class TableMetadataCursorFactoryTest method testMetadataQueryWithWhere.

@Test
public void testMetadataQueryWithWhere() throws Exception {
    try (TableModel tm1 = new TableModel(configuration, "table1", PartitionBy.DAY)) {
        tm1.col("abc", ColumnType.STRING);
        tm1.timestamp("ts1");
        createPopulateTable(tm1, 0, "2020-01-01", 0);
    }
    try (TableModel tm1 = new TableModel(configuration, "table2", PartitionBy.NONE)) {
        tm1.timestamp("ts2");
        createPopulateTable(tm1, 0, "2020-01-01", 0);
    }
    assertSql("tables where name = 'table1'", "id\tname\tdesignatedTimestamp\tpartitionBy\tmaxUncommittedRows\tcommitLag\n" + "1\ttable1\tts1\tDAY\t1000\t0\n");
}
Also used : TableModel(io.questdb.cairo.TableModel) AbstractGriffinTest(io.questdb.griffin.AbstractGriffinTest) 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