use of com.questdb.cairo.sql.CairoEngine in project questdb by bluestreak01.
the class SqlLexerOptimiserTest method testTableNameCannotOpen.
@Test
public void testTableNameCannotOpen() {
final FilesFacade ff = new FilesFacadeImpl() {
@Override
public long openRO(LPSZ name) {
if (Chars.endsWith(name, TableUtils.META_FILE_NAME)) {
return -1;
}
return super.openRO(name);
}
};
CairoConfiguration configuration = new DefaultCairoConfiguration(root) {
@Override
public FilesFacade getFilesFacade() {
return ff;
}
};
CairoEngine engine = new Engine(configuration);
SqlLexerOptimiser lexer = new SqlLexerOptimiser(engine, configuration);
assertSyntaxError(lexer, engine, "select * from tab", 14, "Cannot open file", modelOf("tab").col("x", ColumnType.INT));
}
use of com.questdb.cairo.sql.CairoEngine in project questdb by bluestreak01.
the class IntervalFrameCursorTest method testReload.
public void testReload(int partitionBy, long increment, LongList intervals, int rowCount, CharSequence expected1, CharSequence expected2) throws Exception {
TestUtils.assertMemoryLeak(() -> {
try (TableModel model = new TableModel(configuration, "x", partitionBy).col("a", ColumnType.SYMBOL).indexed(true, 4).col("b", ColumnType.SYMBOL).indexed(true, 4).timestamp()) {
CairoTestUtils.create(model);
}
final Rnd rnd = new Rnd();
long timestamp = DateFormatUtils.parseDateTime("1980-01-01T00:00:00.000Z");
try (CairoEngine engine = new Engine(configuration)) {
final TableReaderRecord record = new TableReaderRecord();
final IntervalFrameCursorFactory factory = new IntervalFrameCursorFactory(engine, "x", intervals);
try (DataFrameCursor cursor = factory.getCursor()) {
// assert that there is nothing to start with
record.of(cursor.getReader());
assertEquals("", record, cursor);
try (TableWriter writer = new TableWriter(configuration, "x")) {
for (int i = 0; i < rowCount; i++) {
TableWriter.Row row = writer.newRow(timestamp);
row.putSym(0, rnd.nextChars(4));
row.putSym(1, rnd.nextChars(4));
row.append();
timestamp += increment;
}
writer.commit();
Assert.assertTrue(cursor.reload());
assertEquals(expected1, record, cursor);
timestamp = Dates.addYear(timestamp, 3);
for (int i = 0; i < rowCount; i++) {
TableWriter.Row row = writer.newRow(timestamp);
row.putSym(0, rnd.nextChars(4));
row.putSym(1, rnd.nextChars(4));
row.append();
timestamp += increment;
}
writer.commit();
Assert.assertTrue(cursor.reload());
if (expected2 != null) {
assertEquals(expected2, record, cursor);
} else {
assertEquals(expected1, record, cursor);
}
Assert.assertFalse(cursor.reload());
}
}
}
});
}
Aggregations