use of org.apache.carbondata.core.scan.expression.conditional.NotInExpression in project carbondata by apache.
the class CarbonReaderTest method testReadWithFilterOfNonTransactionalNotIn.
@Test
public void testReadWithFilterOfNonTransactionalNotIn() throws IOException, InterruptedException {
String path = "./testWriteFiles";
FileUtils.deleteDirectory(new File(path));
IndexStoreManager.getInstance().clearIndexCache(AbsoluteTableIdentifier.from(path), false);
Field[] fields = new Field[3];
fields[0] = new Field("name", DataTypes.STRING);
fields[1] = new Field("age", DataTypes.INT);
fields[2] = new Field("doubleField", DataTypes.DOUBLE);
TestUtil.writeFilesAndVerify(200, new Schema(fields), path);
ColumnExpression columnExpression = new ColumnExpression("doubleField", DataTypes.DOUBLE);
LessThanExpression lessThanExpression = new LessThanExpression(columnExpression, new LiteralExpression("13.5", DataTypes.DOUBLE));
ColumnExpression columnExpression2 = new ColumnExpression("name", DataTypes.STRING);
NotInExpression notInExpression = new NotInExpression(columnExpression2, new LiteralExpression("robot7", DataTypes.STRING));
AndExpression andExpression = new AndExpression(lessThanExpression, notInExpression);
CarbonReader reader = CarbonReader.builder(path, "_temp").projection(new String[] { "name", "age", "doubleField" }).filter(andExpression).build();
int i = 0;
while (reader.hasNext()) {
Object[] row = (Object[]) reader.readNextRow();
assert (!((String) row[0]).contains("robot7"));
assert (7 != ((int) (row[1]) % 10));
assert ((double) row[2] < 13.5);
i++;
}
Assert.assertEquals(i, 25);
reader.close();
FileUtils.deleteDirectory(new File(path));
}
Aggregations