Search in sources :

Example 6 with EqualToExpression

use of org.apache.carbondata.core.scan.expression.conditional.EqualToExpression in project carbondata by apache.

the class CarbonInputMapperTest method testInputFormatMapperReadAllRowsAndFewColumnsWithFilter.

@Test
public void testInputFormatMapperReadAllRowsAndFewColumnsWithFilter() throws Exception {
    try {
        String outPath = "target/output3";
        CarbonProjection carbonProjection = new CarbonProjection();
        carbonProjection.addColumn("ID");
        carbonProjection.addColumn("country");
        carbonProjection.addColumn("salary");
        Expression expression = new EqualToExpression(new ColumnExpression("country", DataType.STRING), new LiteralExpression("france", DataType.STRING));
        runJob(outPath, carbonProjection, expression);
        Assert.assertEquals("Count lines are not matching", 101, countTheLines(outPath));
        Assert.assertEquals("Column count are not matching", 3, countTheColumns(outPath));
    } catch (Exception e) {
        Assert.assertTrue("failed", false);
    }
}
Also used : CarbonProjection(org.apache.carbondata.hadoop.CarbonProjection) EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) IOException(java.io.IOException) Test(org.junit.Test)

Example 7 with EqualToExpression

use of org.apache.carbondata.core.scan.expression.conditional.EqualToExpression in project carbondata by apache.

the class NoDictionaryTypeVisitor method populateFilterResolvedInfo.

/**
   * Visitor Method will update the filter related details in visitableObj, For no dictionary
   * type columns the filter members will resolved directly, no need to look up in dictionary
   * since it will not be part of dictionary, directly the actual data can be converted as
   * byte[] and can be set. this type of encoding is effective when the particular column
   * is having very high cardinality.
   *
   * @param visitableObj
   * @param metadata
   * @throws FilterUnsupportedException,if exception occurs while evaluating
   * filter models.
   */
public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj, FilterResolverMetadata metadata) throws FilterUnsupportedException {
    DimColumnFilterInfo resolvedFilterObject = null;
    List<String> evaluateResultListFinal = null;
    try {
        // handling for is null case scenarios
        if (metadata.getExpression() instanceof EqualToExpression) {
            EqualToExpression expression = (EqualToExpression) metadata.getExpression();
            if (expression.isNull) {
                evaluateResultListFinal = new ArrayList<>(1);
                evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
            }
        } else {
            evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
        }
        // displaying the report as per hive compatibility.
        if (!metadata.isIncludeFilter() && !evaluateResultListFinal.contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL)) {
            evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
        }
    } catch (FilterIllegalMemberException e) {
        throw new FilterUnsupportedException(e);
    }
    resolvedFilterObject = FilterUtil.getNoDictionaryValKeyMemberForFilter(evaluateResultListFinal, metadata.isIncludeFilter(), metadata.getColumnExpression().getDataType());
    visitableObj.setFilterValues(resolvedFilterObject);
}
Also used : EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) DimColumnFilterInfo(org.apache.carbondata.core.scan.filter.DimColumnFilterInfo) FilterUnsupportedException(org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException) FilterIllegalMemberException(org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)

Example 8 with EqualToExpression

use of org.apache.carbondata.core.scan.expression.conditional.EqualToExpression in project carbondata by apache.

the class CarbonTableInputFormatTest method testInputFormatMapperReadAllRowsAndFewColumnsWithFilter.

@Test
public void testInputFormatMapperReadAllRowsAndFewColumnsWithFilter() throws Exception {
    try {
        String outPath = "target/output3";
        CarbonProjection carbonProjection = new CarbonProjection();
        carbonProjection.addColumn("ID");
        carbonProjection.addColumn("country");
        carbonProjection.addColumn("salary");
        Expression expression = new EqualToExpression(new ColumnExpression("country", DataTypes.STRING), new LiteralExpression("france", DataTypes.STRING));
        runJob(outPath, carbonProjection, expression);
        Assert.assertEquals("Count lines are not matching", 101, countTheLines(outPath));
        Assert.assertEquals("Column count are not matching", 3, countTheColumns(outPath));
    } catch (Exception e) {
        Assert.assertTrue("failed", false);
    } finally {
        StoreCreator.clearDataMaps();
    }
}
Also used : CarbonProjection(org.apache.carbondata.hadoop.CarbonProjection) EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) IOException(java.io.IOException) Test(org.junit.Test)

Example 9 with EqualToExpression

use of org.apache.carbondata.core.scan.expression.conditional.EqualToExpression in project carbondata by apache.

the class CarbonTableInputFormatTest method testGetFilteredSplits.

@Test
public void testGetFilteredSplits() throws Exception {
    CarbonTableInputFormat carbonInputFormat = new CarbonTableInputFormat();
    JobConf jobConf = new JobConf(new Configuration());
    Job job = Job.getInstance(jobConf);
    job.getConfiguration().set("query.id", UUID.randomUUID().toString());
    String tblPath = StoreCreator.getAbsoluteTableIdentifier().getTablePath();
    FileInputFormat.addInputPath(job, new Path(tblPath));
    CarbonTableInputFormat.setDatabaseName(job.getConfiguration(), StoreCreator.getAbsoluteTableIdentifier().getDatabaseName());
    CarbonTableInputFormat.setTableName(job.getConfiguration(), StoreCreator.getAbsoluteTableIdentifier().getTableName());
    Expression expression = new EqualToExpression(new ColumnExpression("country", DataTypes.STRING), new LiteralExpression("china", DataTypes.STRING));
    CarbonTableInputFormat.setFilterPredicates(job.getConfiguration(), expression);
    List splits = carbonInputFormat.getSplits(job);
    Assert.assertTrue(splits != null);
    Assert.assertTrue(!splits.isEmpty());
}
Also used : Path(org.apache.hadoop.fs.Path) CarbonTablePath(org.apache.carbondata.core.util.path.CarbonTablePath) EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) Configuration(org.apache.hadoop.conf.Configuration) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) CarbonTableInputFormat(org.apache.carbondata.hadoop.api.CarbonTableInputFormat) List(java.util.List) Job(org.apache.hadoop.mapreduce.Job) JobConf(org.apache.hadoop.mapred.JobConf) Test(org.junit.Test)

Example 10 with EqualToExpression

use of org.apache.carbondata.core.scan.expression.conditional.EqualToExpression in project carbondata by apache.

the class ObjectSerializationUtilTest method testConvertObjectToString.

@Test
public void testConvertObjectToString() throws Exception {
    Expression expression = new EqualToExpression(new ColumnExpression("c1", DataTypes.STRING), new LiteralExpression("a", DataTypes.STRING));
    String string = ObjectSerializationUtil.convertObjectToString(expression);
    Assert.assertTrue(string != null);
}
Also used : EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) Expression(org.apache.carbondata.core.scan.expression.Expression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) EqualToExpression(org.apache.carbondata.core.scan.expression.conditional.EqualToExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) ColumnExpression(org.apache.carbondata.core.scan.expression.ColumnExpression) LiteralExpression(org.apache.carbondata.core.scan.expression.LiteralExpression) Test(org.junit.Test)

Aggregations

EqualToExpression (org.apache.carbondata.core.scan.expression.conditional.EqualToExpression)11 ColumnExpression (org.apache.carbondata.core.scan.expression.ColumnExpression)8 LiteralExpression (org.apache.carbondata.core.scan.expression.LiteralExpression)8 Expression (org.apache.carbondata.core.scan.expression.Expression)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 IOException (java.io.IOException)2 GreaterThanEqualToExpression (org.apache.carbondata.core.scan.expression.conditional.GreaterThanEqualToExpression)2 GreaterThanExpression (org.apache.carbondata.core.scan.expression.conditional.GreaterThanExpression)2 InExpression (org.apache.carbondata.core.scan.expression.conditional.InExpression)2 LessThanEqualToExpression (org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression)2 FilterIllegalMemberException (org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException)2 FilterUnsupportedException (org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException)2 ColumnFilterInfo (org.apache.carbondata.core.scan.filter.ColumnFilterInfo)2 CarbonProjection (org.apache.carbondata.hadoop.CarbonProjection)2 ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 Domain (com.facebook.presto.spi.predicate.Domain)1 Range (com.facebook.presto.spi.predicate.Range)1 TupleDomain (com.facebook.presto.spi.predicate.TupleDomain)1