use of io.questdb.cairo.sql.RecordCursor in project questdb by bluestreak01.
the class MinDoubleGroupByFunctionFactoryTest method testNonNull.
@Test
public void testNonNull() throws SqlException {
compiler.compile("create table tab (f double)", sqlExecutionContext);
final Rnd rnd = new Rnd();
try (TableWriter w = engine.getWriter(sqlExecutionContext.getCairoSecurityContext(), "tab", "testing")) {
for (int i = 100; i > 10; i--) {
TableWriter.Row r = w.newRow();
r.putDouble(0, rnd.nextDouble());
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select min(f) from tab", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
Record record = cursor.getRecord();
Assert.assertEquals(1, cursor.size());
Assert.assertTrue(cursor.hasNext());
Assert.assertEquals(0.0011075139045715332, record.getDouble(0), 0.0001);
}
}
}
use of io.questdb.cairo.sql.RecordCursor in project questdb by bluestreak01.
the class MinDoubleGroupByFunctionFactoryTest method testFirstNull.
@Test
public void testFirstNull() throws SqlException {
compiler.compile("create table tab (f double)", sqlExecutionContext);
final Rnd rnd = new Rnd();
try (TableWriter w = engine.getWriter(sqlExecutionContext.getCairoSecurityContext(), "tab", "testing")) {
TableWriter.Row r = w.newRow();
r.append();
for (int i = 100; i > 10; i--) {
r = w.newRow();
r.putDouble(0, rnd.nextDouble());
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select min(f) from tab", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
Record record = cursor.getRecord();
Assert.assertEquals(1, cursor.size());
Assert.assertTrue(cursor.hasNext());
Assert.assertEquals(0.0011075139045715332, record.getDouble(0), 0.0001);
}
}
}
use of io.questdb.cairo.sql.RecordCursor in project questdb by bluestreak01.
the class MinDoubleGroupByFunctionFactoryTest method testAllNull.
@Test
public void testAllNull() throws SqlException {
compiler.compile("create table tab (f double)", sqlExecutionContext);
try (TableWriter w = engine.getWriter(sqlExecutionContext.getCairoSecurityContext(), "tab", "testing")) {
for (int i = 100; i > 10; i--) {
TableWriter.Row r = w.newRow();
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select min(f) from tab", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
Record record = cursor.getRecord();
Assert.assertEquals(1, cursor.size());
Assert.assertTrue(cursor.hasNext());
Assert.assertTrue(Double.isNaN(record.getDouble(0)));
}
}
}
use of io.questdb.cairo.sql.RecordCursor in project questdb by bluestreak01.
the class MinFloatGroupByFunctionFactoryTest method testNonNull.
@Test
public void testNonNull() throws SqlException {
compiler.compile("create table tab (f float)", sqlExecutionContext);
final Rnd rnd = new Rnd();
try (TableWriter w = engine.getWriter(sqlExecutionContext.getCairoSecurityContext(), "tab", "testing")) {
for (int i = 100; i > 10; i--) {
TableWriter.Row r = w.newRow();
r.putFloat(0, rnd.nextFloat());
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select min(f) from tab", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
Record record = cursor.getRecord();
Assert.assertEquals(1, cursor.size());
Assert.assertTrue(cursor.hasNext());
Assert.assertEquals(0.0011075139045715332, record.getFloat(0), 0.0001);
}
}
}
use of io.questdb.cairo.sql.RecordCursor in project questdb by bluestreak01.
the class MinFloatGroupByFunctionFactoryTest method testAllNull.
@Test
public void testAllNull() throws SqlException {
compiler.compile("create table tab (f float)", sqlExecutionContext);
try (TableWriter w = engine.getWriter(sqlExecutionContext.getCairoSecurityContext(), "tab", "testing")) {
for (int i = 100; i > 10; i--) {
TableWriter.Row r = w.newRow();
r.append();
}
w.commit();
}
try (RecordCursorFactory factory = compiler.compile("select min(f) from tab", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
Record record = cursor.getRecord();
Assert.assertEquals(1, cursor.size());
Assert.assertTrue(cursor.hasNext());
Assert.assertTrue(Float.isNaN(record.getFloat(0)));
}
}
}
Aggregations