Search in sources :

Example 16 with TableModel

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

the class AbstractSqlParserTest method assertSyntaxError.

private static void assertSyntaxError(SqlCompiler compiler, String query, int position, String contains, TableModel... tableModels) throws Exception {
    try {
        assertMemoryLeak(() -> {
            try {
                for (int i = 0, n = tableModels.length; i < n; i++) {
                    CairoTestUtils.create(tableModels[i]);
                }
                compiler.compile(query, sqlExecutionContext);
                Assert.fail("Exception expected");
            } catch (SqlException e) {
                Assert.assertEquals(position, e.getPosition());
                TestUtils.assertContains(e.getFlyweightMessage(), contains);
            }
        });
    } finally {
        for (int i = 0, n = tableModels.length; i < n; i++) {
            TableModel tableModel = tableModels[i];
            Path path = tableModel.getPath().of(tableModel.getConfiguration().getRoot()).concat(tableModel.getName()).slash$();
            Assert.assertEquals(0, configuration.getFilesFacade().rmdir(path));
            tableModel.close();
        }
    }
}
Also used : Path(io.questdb.std.str.Path) TableModel(io.questdb.cairo.TableModel)

Example 17 with TableModel

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

the class AbstractSqlParserTest method createModelsAndRun.

private void createModelsAndRun(SqlParserTest.CairoAware runnable, TableModel... tableModels) throws SqlException {
    try {
        for (int i = 0, n = tableModels.length; i < n; i++) {
            CairoTestUtils.create(tableModels[i]);
        }
        runnable.run();
    } finally {
        Assert.assertTrue(engine.releaseAllReaders());
        for (int i = 0, n = tableModels.length; i < n; i++) {
            TableModel tableModel = tableModels[i];
            Path path = tableModel.getPath().of(tableModel.getConfiguration().getRoot()).concat(tableModel.getName()).slash$();
            Assert.assertEquals(0, configuration.getFilesFacade().rmdir(path));
            tableModel.close();
        }
    }
}
Also used : Path(io.questdb.std.str.Path) TableModel(io.questdb.cairo.TableModel)

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