use of io.questdb.cairo.TableReader in project questdb by bluestreak01.
the class AlterTableRenameColumnTest method testRenameColumnExistingReader.
@Test
public void testRenameColumnExistingReader() throws Exception {
TestUtils.assertMemoryLeak(() -> {
try {
createX();
try (TableReader reader = engine.getReader(AllowAllCairoSecurityContext.INSTANCE, "x", TableUtils.ANY_TABLE_ID, TableUtils.ANY_TABLE_VERSION)) {
Assert.assertEquals(ALTER, compiler.compile("alter table x rename column e to z", sqlExecutionContext).getType());
String expected = "{\"columnCount\":16,\"columns\":[{\"index\":0,\"name\":\"i\",\"type\":\"INT\"},{\"index\":1,\"name\":\"sym\",\"type\":\"SYMBOL\"},{\"index\":2,\"name\":\"amt\",\"type\":\"DOUBLE\"},{\"index\":3,\"name\":\"timestamp\",\"type\":\"TIMESTAMP\"},{\"index\":4,\"name\":\"b\",\"type\":\"BOOLEAN\"},{\"index\":5,\"name\":\"c\",\"type\":\"STRING\"},{\"index\":6,\"name\":\"d\",\"type\":\"DOUBLE\"},{\"index\":7,\"name\":\"z\",\"type\":\"FLOAT\"},{\"index\":8,\"name\":\"f\",\"type\":\"SHORT\"},{\"index\":9,\"name\":\"g\",\"type\":\"DATE\"},{\"index\":10,\"name\":\"ik\",\"type\":\"SYMBOL\"},{\"index\":11,\"name\":\"j\",\"type\":\"LONG\"},{\"index\":12,\"name\":\"k\",\"type\":\"TIMESTAMP\"},{\"index\":13,\"name\":\"l\",\"type\":\"BYTE\"},{\"index\":14,\"name\":\"m\",\"type\":\"BINARY\"},{\"index\":15,\"name\":\"n\",\"type\":\"STRING\"}],\"timestampIndex\":3}";
sink.clear();
reader.reload();
reader.getMetadata().toJson(sink);
TestUtils.assertEquals(expected, sink);
}
Assert.assertEquals(0, engine.getBusyWriterCount());
Assert.assertEquals(0, engine.getBusyReaderCount());
} finally {
engine.clear();
}
});
}
use of io.questdb.cairo.TableReader in project questdb by bluestreak01.
the class AlterTableRenameColumnTest method testRenameColumnAndCheckOpenReader.
@Test
public void testRenameColumnAndCheckOpenReader() throws Exception {
assertMemoryLeak(() -> {
compiler.compile("create table x1 (a int, b double, t timestamp) timestamp(t)", sqlExecutionContext);
try (TableReader reader = engine.getReader(sqlExecutionContext.getCairoSecurityContext(), "x1")) {
Assert.assertEquals("b", reader.getMetadata().getColumnName(1));
try (TableWriter writer = engine.getWriter(sqlExecutionContext.getCairoSecurityContext(), "x1", "testing")) {
Assert.assertEquals("b", writer.getMetadata().getColumnName(1));
writer.renameColumn("b", "bb");
Assert.assertEquals("bb", writer.getMetadata().getColumnName(1));
}
Assert.assertTrue(reader.reload());
Assert.assertEquals("bb", reader.getMetadata().getColumnName(1));
}
});
}
Aggregations