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;
}
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;
}
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;
}
Aggregations