Search in sources :

Example 1 with QueryProjection

use of org.apache.carbondata.core.scan.model.QueryProjection in project carbondata by apache.

the class CarbonTable method createQueryWithProjection.

/**
 * Create a new QueryModel with specified projection
 */
public QueryModel createQueryWithProjection(String[] projectionColumnNames, DataTypeConverter converter) {
    QueryProjection projection = createProjection(projectionColumnNames);
    QueryModel queryModel = QueryModel.newInstance(this);
    queryModel.setProjection(projection);
    queryModel.setConverter(converter);
    return queryModel;
}
Also used : QueryProjection(org.apache.carbondata.core.scan.model.QueryProjection) QueryModel(org.apache.carbondata.core.scan.model.QueryModel)

Example 2 with QueryProjection

use of org.apache.carbondata.core.scan.model.QueryProjection in project carbondata by apache.

the class CarbonTable method createQueryModelWithProjectAllColumns.

/**
 * Create a new QueryModel with projection all columns in the table.
 */
public QueryModel createQueryModelWithProjectAllColumns(DataTypeConverter converter) {
    QueryProjection projection = new QueryProjection();
    List<CarbonDimension> dimensions = getDimensionByTableName(getTableName());
    for (int i = 0; i < dimensions.size(); i++) {
        projection.addDimension(dimensions.get(i), i);
    }
    List<CarbonMeasure> measures = getMeasureByTableName(getTableName());
    for (int i = 0; i < measures.size(); i++) {
        projection.addMeasure(measures.get(i), i);
    }
    QueryModel model = QueryModel.newInstance(this);
    model.setProjection(projection);
    model.setConverter(converter);
    return model;
}
Also used : QueryProjection(org.apache.carbondata.core.scan.model.QueryProjection) CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) QueryModel(org.apache.carbondata.core.scan.model.QueryModel) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Example 3 with QueryProjection

use of org.apache.carbondata.core.scan.model.QueryProjection in project carbondata by apache.

the class CarbonTable method createProjection.

public QueryProjection createProjection(String[] projectionColumnNames) {
    String factTableName = getTableName();
    QueryProjection projection = new QueryProjection();
    // fill dimensions
    // If columns are null, set all dimensions and measures
    int i = 0;
    if (projectionColumnNames != null) {
        for (String projectionColumnName : projectionColumnNames) {
            CarbonDimension dimension = getDimensionByName(factTableName, projectionColumnName);
            if (dimension != null) {
                projection.addDimension(dimension, i);
                i++;
            } else {
                CarbonMeasure measure = getMeasureByName(factTableName, projectionColumnName);
                if (measure == null) {
                    throw new RuntimeException(projectionColumnName + " column not found in the table " + factTableName);
                }
                projection.addMeasure(measure, i);
                i++;
            }
        }
    }
    return projection;
}
Also used : QueryProjection(org.apache.carbondata.core.scan.model.QueryProjection) CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Aggregations

QueryProjection (org.apache.carbondata.core.scan.model.QueryProjection)3 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)2 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)2 QueryModel (org.apache.carbondata.core.scan.model.QueryModel)2