Search in sources :

Example 26 with IndexFilter

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());
}
Also used : GenericUDFOPNull(org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNull) Configuration(org.apache.hadoop.conf.Configuration) ExprNodeColumnDesc(org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc) ExprNodeGenericFuncDesc(org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc) CarbonFileInputFormat(org.apache.carbondata.hadoop.api.CarbonFileInputFormat) ExprNodeDesc(org.apache.hadoop.hive.ql.plan.ExprNodeDesc) IndexFilter(org.apache.carbondata.core.index.IndexFilter) Job(org.apache.hadoop.mapreduce.Job) JobConf(org.apache.hadoop.mapred.JobConf) InputSplit(org.apache.hadoop.mapreduce.InputSplit) Test(org.junit.Test)

Example 27 with IndexFilter

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);
    }
}
Also used : Expression(org.apache.carbondata.core.scan.expression.Expression) ExprNodeGenericFuncDesc(org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc) IndexFilter(org.apache.carbondata.core.index.IndexFilter) SQLException(java.sql.SQLException) InvalidConfigurationException(org.apache.carbondata.core.exception.InvalidConfigurationException) InvalidPathException(org.apache.hadoop.fs.InvalidPathException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

IndexFilter (org.apache.carbondata.core.index.IndexFilter)27 Configuration (org.apache.hadoop.conf.Configuration)16 InputSplit (org.apache.hadoop.mapreduce.InputSplit)16 JobConf (org.apache.hadoop.mapred.JobConf)15 Job (org.apache.hadoop.mapreduce.Job)15 ExprNodeGenericFuncDesc (org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc)12 Test (org.junit.Test)12 CarbonFileInputFormat (org.apache.carbondata.hadoop.api.CarbonFileInputFormat)11 ExprNodeColumnDesc (org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc)11 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)11 IOException (java.io.IOException)9 ExprNodeConstantDesc (org.apache.hadoop.hive.ql.plan.ExprNodeConstantDesc)9 ArrayList (java.util.ArrayList)8 List (java.util.List)5 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)5 CarbonInputSplit (org.apache.carbondata.hadoop.CarbonInputSplit)5 CarbonTableInputFormat (org.apache.carbondata.hadoop.api.CarbonTableInputFormat)5 HashMap (java.util.HashMap)4 CarbonTablePath (org.apache.carbondata.core.util.path.CarbonTablePath)4 Map (java.util.Map)3