use of io.questdb.griffin.SqlCompiler in project questdb by bluestreak01.
the class LineTcpConnectionContextTest method testTableParameterRetentionOnAddColumn.
@Test
public void testTableParameterRetentionOnAddColumn() throws Exception {
String table = "retention";
runInContext(() -> {
try (SqlCompiler compiler = new SqlCompiler(engine);
SqlExecutionContext sqlExecutionContext = new SqlExecutionContextImpl(engine, 1)) {
compiler.compile("create table " + table + " (location SYMBOL, temperature DOUBLE, timestamp TIMESTAMP) timestamp(timestamp) partition by DAY WITH maxUncommittedRows=3, commitLag=250ms;", sqlExecutionContext);
} catch (SqlException ex) {
throw new RuntimeException(ex);
}
try (TableReader reader = engine.getReader(AllowAllCairoSecurityContext.INSTANCE, table)) {
Assert.assertEquals(3, reader.getMetadata().getMaxUncommittedRows());
Assert.assertEquals(250_000, reader.getMetadata().getCommitLag());
}
recvBuffer = table + ",location=us-midwest temperature=82 1465839830100400200\n" + table + ",location=us-midwest temperature=83 1465839830100500200\n" + table + ",location=us-eastcoast,city=york temperature=81 1465839830101400200\n" + table + ",location=us-midwest temperature=85 1465839830102300200\n" + table + ",location=us-eastcoast temperature=89 1465839830102400200\n" + table + ",location=us-eastcoast temperature=80 1465839830102400200\n" + table + ",location=us-westcost temperature=82 1465839830102500200\n";
do {
handleContextIO();
Assert.assertFalse(disconnected);
} while (recvBuffer.length() > 0);
closeContext();
String expected = "location\ttemperature\ttimestamp\tcity\n" + "us-midwest\t82.0\t2016-06-13T17:43:50.100400Z\t\n" + "us-midwest\t83.0\t2016-06-13T17:43:50.100500Z\t\n" + "us-eastcoast\t81.0\t2016-06-13T17:43:50.101400Z\tyork\n" + "us-midwest\t85.0\t2016-06-13T17:43:50.102300Z\t\n" + "us-eastcoast\t89.0\t2016-06-13T17:43:50.102400Z\t\n" + "us-eastcoast\t80.0\t2016-06-13T17:43:50.102400Z\t\n" + "us-westcost\t82.0\t2016-06-13T17:43:50.102500Z\t\n";
assertTable(expected, table);
try (TableReader reader = engine.getReader(AllowAllCairoSecurityContext.INSTANCE, table)) {
Assert.assertEquals(3, reader.getMetadata().getMaxUncommittedRows());
Assert.assertEquals(250_000, reader.getMetadata().getCommitLag());
}
});
}
use of io.questdb.griffin.SqlCompiler in project questdb by bluestreak01.
the class TimestampSequenceFunctionFactoryTest method setUp2.
@BeforeClass
public static void setUp2() {
engine = new CairoEngine(new StaticClockCairoConfiguration(root));
compiler = new SqlCompiler(engine);
sqlExecutionContext = new SqlExecutionContextImpl(engine, 1).with(AllowAllCairoSecurityContext.INSTANCE, bindVariableService, null, -1, null);
bindVariableService.clear();
}
use of io.questdb.griffin.SqlCompiler in project questdb by bluestreak01.
the class TelemetryTest method testTelemetryCanDeleteTableWhenDisabled.
@Test
public void testTelemetryCanDeleteTableWhenDisabled() throws Exception {
CairoConfiguration configuration = new DefaultCairoConfiguration(root) {
@Override
public TelemetryConfiguration getTelemetryConfiguration() {
return new DefaultTelemetryConfiguration() {
@Override
public boolean getEnabled() {
return false;
}
};
}
};
TestUtils.assertMemoryLeak(() -> {
try (CairoEngine engine = new CairoEngine(configuration);
SqlCompiler compiler = new SqlCompiler(engine, null);
TelemetryJob ignored = new TelemetryJob(engine);
SqlExecutionContext sqlExecutionContext = new SqlExecutionContextImpl(engine, 1)) {
try {
compiler.compile("drop table telemetry", sqlExecutionContext);
Assert.fail();
} catch (SqlException e) {
TestUtils.assertContains(e.getFlyweightMessage(), "table 'telemetry' does not exist");
}
}
});
}
use of io.questdb.griffin.SqlCompiler in project questdb by bluestreak01.
the class TxSerializerTest method setUpStatic.
@BeforeClass
public static void setUpStatic() {
setCairoStatic();
compiler = new SqlCompiler(engine);
BindVariableServiceImpl bindVariableService = new BindVariableServiceImpl(configuration);
sqlExecutionContext = new SqlExecutionContextImpl(engine, 1).with(AllowAllCairoSecurityContext.INSTANCE, bindVariableService, null, -1, null);
bindVariableService.clear();
}
use of io.questdb.griffin.SqlCompiler in project invesdwin-context-persistence by subes.
the class QuestDBPerformanceTest method readIterator.
private void readIterator(final CairoEngine engine) throws InterruptedException, SqlException {
final LoopInterruptedCheck loopCheck = new LoopInterruptedCheck(Duration.ONE_SECOND);
final Instant readsStart = new Instant();
final SqlExecutionContextImpl ctx = new SqlExecutionContextImpl(engine, 1);
try (SqlCompiler compiler = new SqlCompiler(engine)) {
for (int reads = 1; reads <= READS; reads++) {
FDate prevValue = null;
int count = 0;
try (RecordCursorFactory factory = compiler.compile("abc ORDER BY key ASC", ctx).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(ctx)) {
final io.questdb.cairo.sql.Record record = cursor.getRecord();
while (cursor.hasNext()) {
final FDate value = new FDate(record.getLong(0));
if (prevValue != null) {
Assertions.checkTrue(prevValue.isBefore(value));
}
prevValue = value;
count++;
}
}
}
Assertions.checkEquals(count, VALUES);
if (loopCheck.check()) {
printProgress("Reads", readsStart, VALUES * reads, VALUES * READS);
}
}
}
printProgress("ReadsFinished", readsStart, VALUES * READS, VALUES * READS);
}
Aggregations