use of org.apache.carbondata.core.index.IndexFilter in project carbondata by apache.
the class Hive2CarbonExpressionTest method testNullHiveFilter.
@Test
public void testNullHiveFilter() throws IOException {
ExprNodeDesc column1 = new ExprNodeColumnDesc(TypeInfoFactory.booleanTypeInfo, "name", null, false);
List<ExprNodeDesc> children1 = Lists.newArrayList();
children1.add(column1);
ExprNodeGenericFuncDesc node1 = new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo, new GenericUDFOPNull(), children1);
Configuration configuration = new Configuration();
CarbonInputFormat.setFilterPredicates(configuration, new IndexFilter(table, Hive2CarbonExpression.convertExprHive2Carbon(node1)));
final Job job = new Job(new JobConf(configuration));
final CarbonFileInputFormat format = new CarbonFileInputFormat();
format.setTableInfo(job.getConfiguration(), table.getTableInfo());
format.setTablePath(job.getConfiguration(), table.getTablePath());
format.setTableName(job.getConfiguration(), table.getTableName());
format.setDatabaseName(job.getConfiguration(), table.getDatabaseName());
List<InputSplit> list = format.getSplits(job);
Assert.assertEquals(0, list.size());
}
use of org.apache.carbondata.core.index.IndexFilter in project carbondata by apache.
the class MapredCarbonInputFormat method setFilterPredicates.
protected void setFilterPredicates(Configuration configuration, CarbonTable carbonTable) {
try {
String expr = configuration.get(TableScanDesc.FILTER_EXPR_CONF_STR);
if (expr == null) {
return;
}
ExprNodeGenericFuncDesc exprNodeGenericFuncDesc = SerializationUtilities.deserializeObject(expr, ExprNodeGenericFuncDesc.class);
LOGGER.debug("hive expression:" + exprNodeGenericFuncDesc.getGenericUDF());
LOGGER.debug("hive expression string:" + exprNodeGenericFuncDesc.getExprString());
Expression expression = Hive2CarbonExpression.convertExprHive2Carbon(exprNodeGenericFuncDesc);
if (expression == null) {
return;
}
LOGGER.debug("carbon expression:" + expression.getString());
IndexFilter filter = new IndexFilter(carbonTable, expression, true);
CarbonInputFormat.setFilterPredicates(configuration, filter);
} catch (Exception e) {
throw new RuntimeException("Error while reading filter expression", e);
}
}
Aggregations