use of io.questdb.cairo.sql.RecordCursorFactory in project questdb by bluestreak01.
the class LikeFunctionFactoryTest method testLikeStringUnderscoreAndPercentage.
@Test
public void testLikeStringUnderscoreAndPercentage() throws Exception {
assertMemoryLeak(() -> {
String sql = "create table x as (\n" + "select cast('ABCGE' as string) as name from long_sequence(1)\n" + "union\n" + "select cast('SBDHDJ' as string) as name from long_sequence(1)\n" + "union\n" + "select cast('BDGDGGG' as string) as name from long_sequence(1)\n" + "union\n" + "select cast('AAAAVVV' as string) as name from long_sequence(1)\n" + ")";
compiler.compile(sql, sqlExecutionContext);
try (RecordCursorFactory factory = compiler.compile("select * from x where name like '_B%'", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
sink.clear();
printer.print(cursor, factory.getMetadata(), false, sink);
Assert.assertEquals(sink.toString().split("\n").length, 2);
}
}
});
}
use of io.questdb.cairo.sql.RecordCursorFactory in project questdb by bluestreak01.
the class LikeFunctionFactoryTest method testNotLikeStringMatch.
@Test
public void testNotLikeStringMatch() throws Exception {
assertMemoryLeak(() -> {
compiler.compile("create table x as (select rnd_str() name from long_sequence(2000))", sqlExecutionContext);
try (RecordCursorFactory factory = compiler.compile("select * from x where not name like 'XJ'", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
sink.clear();
printer.print(cursor, factory.getMetadata(), true, sink);
Assert.assertNotEquals(sink.toString().indexOf("XJ"), -1);
}
}
});
}
use of io.questdb.cairo.sql.RecordCursorFactory in project questdb by bluestreak01.
the class LikeFunctionFactoryTest method testLikeStringPercentageAtEnd.
@Test
public void testLikeStringPercentageAtEnd() throws Exception {
assertMemoryLeak(() -> {
String sql = "create table x as (\n" + "select cast('ABCGE' as string) as name from long_sequence(1)\n" + "union\n" + "select cast('SBDHDJ' as string) as name from long_sequence(1)\n" + "union\n" + "select cast('BDGDGGG' as string) as name from long_sequence(1)\n" + "union\n" + "select cast('AAAAVVV' as string) as name from long_sequence(1)\n" + ")";
compiler.compile(sql, sqlExecutionContext);
try (RecordCursorFactory factory = compiler.compile("select * from x where name like 'ABC%'", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
sink.clear();
printer.print(cursor, factory.getMetadata(), false, sink);
Assert.assertEquals(sink.toString().replace("\n", ""), "ABCGE");
sink.clear();
}
}
});
}
use of io.questdb.cairo.sql.RecordCursorFactory in project questdb by bluestreak01.
the class LikeFunctionFactoryTest method testLikeStringPercentageAtStartAndEnd.
@Test
public void testLikeStringPercentageAtStartAndEnd() throws Exception {
assertMemoryLeak(() -> {
String sql = "create table x as (\n" + "select cast('ABCGE' as string) as name from long_sequence(1)\n" + "union\n" + "select cast('SBDHDJ' as string) as name from long_sequence(1)\n" + "union\n" + "select cast('BDGDGGG' as string) as name from long_sequence(1)\n" + "union\n" + "select cast('AAAAVVV' as string) as name from long_sequence(1)\n" + ")";
compiler.compile(sql, sqlExecutionContext);
try (RecordCursorFactory factory = compiler.compile("select * from x where name like '%BCG%'", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
sink.clear();
printer.print(cursor, factory.getMetadata(), false, sink);
Assert.assertEquals(sink.toString().replace("\n", ""), "ABCGE");
}
}
});
}
use of io.questdb.cairo.sql.RecordCursorFactory in project questdb by bluestreak01.
the class LikeFunctionFactoryTest method testNotLikeCharacterMatch.
@Test
public void testNotLikeCharacterMatch() throws Exception {
assertMemoryLeak(() -> {
compiler.compile("create table x as (select rnd_str() name from long_sequence(2000))", sqlExecutionContext);
try (RecordCursorFactory factory = compiler.compile("select * from x where not name like 'H'", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
sink.clear();
printer.print(cursor, factory.getMetadata(), true, sink);
Assert.assertNotEquals(sink.toString().indexOf('H'), -1);
}
}
});
}
Aggregations