use of org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation in project carbondata by apache.
the class ThriftWrapperSchemaConverterImpl method fromExtrenalToWrapperParentTableColumnRelations.
private List<ParentColumnTableRelation> fromExtrenalToWrapperParentTableColumnRelations(List<org.apache.carbondata.format.ParentColumnTableRelation> thirftParentColumnRelation) {
List<ParentColumnTableRelation> parentColumnTableRelationList = new ArrayList<>();
for (org.apache.carbondata.format.ParentColumnTableRelation carbonTableRelation : thirftParentColumnRelation) {
RelationIdentifier relationIdentifier = new RelationIdentifier(carbonTableRelation.getRelationIdentifier().getDatabaseName(), carbonTableRelation.getRelationIdentifier().getTableName(), carbonTableRelation.getRelationIdentifier().getTableId());
ParentColumnTableRelation parentColumnTableRelation = new ParentColumnTableRelation(relationIdentifier, carbonTableRelation.getColumnId(), carbonTableRelation.getColumnName());
parentColumnTableRelationList.add(parentColumnTableRelation);
}
return parentColumnTableRelationList;
}
use of org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation in project carbondata by apache.
the class AggregationDataMapSchema method fillParentNameToAggregationMapping.
/**
* Method to prepare mapping of parent to list of aggregation function applied on that column
* @param listOfColumns
* child column schema list
*/
private void fillParentNameToAggregationMapping(List<ColumnSchema> listOfColumns) {
parentColumnToAggregationsMapping = new HashMap<>();
for (ColumnSchema column : listOfColumns) {
if (null != column.getAggFunction() && !column.getAggFunction().isEmpty()) {
List<ParentColumnTableRelation> parentColumnTableRelations = column.getParentColumnTableRelations();
if (null != parentColumnTableRelations && parentColumnTableRelations.size() == 1) {
String columnName = column.getParentColumnTableRelations().get(0).getColumnName();
Set<String> aggFunctions = parentColumnToAggregationsMapping.get(columnName);
if (null == aggFunctions) {
aggFunctions = new HashSet<>();
parentColumnToAggregationsMapping.put(columnName, aggFunctions);
}
aggFunctions.add(column.getAggFunction());
}
}
}
}
use of org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation in project carbondata by apache.
the class CarbonUtil method fromThriftToWrapperParentTableColumnRelations.
static List<ParentColumnTableRelation> fromThriftToWrapperParentTableColumnRelations(List<org.apache.carbondata.format.ParentColumnTableRelation> thirftParentColumnRelation) {
List<ParentColumnTableRelation> parentColumnTableRelationList = new ArrayList<>();
for (org.apache.carbondata.format.ParentColumnTableRelation carbonTableRelation : thirftParentColumnRelation) {
RelationIdentifier relationIdentifier = new RelationIdentifier(carbonTableRelation.getRelationIdentifier().getDatabaseName(), carbonTableRelation.getRelationIdentifier().getTableName(), carbonTableRelation.getRelationIdentifier().getTableId());
ParentColumnTableRelation parentColumnTableRelation = new ParentColumnTableRelation(relationIdentifier, carbonTableRelation.getColumnId(), carbonTableRelation.getColumnName());
parentColumnTableRelationList.add(parentColumnTableRelation);
}
return parentColumnTableRelationList;
}
use of org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation in project carbondata by apache.
the class AbstractDataFileFooterConverter method thriftColumnSchmeaToWrapperColumnSchema.
protected ColumnSchema thriftColumnSchmeaToWrapperColumnSchema(org.apache.carbondata.format.ColumnSchema externalColumnSchema) {
ColumnSchema wrapperColumnSchema = new ColumnSchema();
wrapperColumnSchema.setColumnUniqueId(externalColumnSchema.getColumn_id());
wrapperColumnSchema.setColumnName(externalColumnSchema.getColumn_name());
wrapperColumnSchema.setColumnar(externalColumnSchema.isColumnar());
DataType dataType = thriftDataTyopeToWrapperDataType(externalColumnSchema.data_type);
if (DataTypes.isDecimal(dataType)) {
DecimalType decimalType = (DecimalType) dataType;
decimalType.setPrecision(externalColumnSchema.getPrecision());
decimalType.setScale(externalColumnSchema.getScale());
}
wrapperColumnSchema.setDataType(dataType);
wrapperColumnSchema.setDimensionColumn(externalColumnSchema.isDimension());
List<Encoding> encoders = new ArrayList<Encoding>();
for (org.apache.carbondata.format.Encoding encoder : externalColumnSchema.getEncoders()) {
encoders.add(fromExternalToWrapperEncoding(encoder));
}
wrapperColumnSchema.setEncodingList(encoders);
wrapperColumnSchema.setNumberOfChild(externalColumnSchema.getNum_child());
wrapperColumnSchema.setPrecision(externalColumnSchema.getPrecision());
wrapperColumnSchema.setColumnGroup(externalColumnSchema.getColumn_group_id());
wrapperColumnSchema.setScale(externalColumnSchema.getScale());
wrapperColumnSchema.setDefaultValue(externalColumnSchema.getDefault_value());
Map<String, String> properties = externalColumnSchema.getColumnProperties();
if (properties != null) {
if (properties.get(CarbonCommonConstants.SORT_COLUMNS) != null) {
wrapperColumnSchema.setSortColumn(true);
}
}
wrapperColumnSchema.setFunction(externalColumnSchema.getAggregate_function());
List<org.apache.carbondata.format.ParentColumnTableRelation> parentColumnTableRelation = externalColumnSchema.getParentColumnTableRelations();
if (null != parentColumnTableRelation) {
wrapperColumnSchema.setParentColumnTableRelations(fromThriftToWrapperParentTableColumnRelations(parentColumnTableRelation));
}
return wrapperColumnSchema;
}
use of org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation in project carbondata by apache.
the class ThriftWrapperSchemaConverterImpl method fromWrapperToExternalColumnSchema.
/* (non-Javadoc)
* convert from wrapper to external column schema
*/
@Override
public org.apache.carbondata.format.ColumnSchema fromWrapperToExternalColumnSchema(ColumnSchema wrapperColumnSchema) {
List<org.apache.carbondata.format.Encoding> encoders = new ArrayList<org.apache.carbondata.format.Encoding>();
for (Encoding encoder : wrapperColumnSchema.getEncodingList()) {
encoders.add(fromWrapperToExternalEncoding(encoder));
}
org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(fromWrapperToExternalDataType(wrapperColumnSchema.getDataType()), wrapperColumnSchema.getColumnName(), wrapperColumnSchema.getColumnUniqueId(), wrapperColumnSchema.isColumnar(), encoders, wrapperColumnSchema.isDimensionColumn());
thriftColumnSchema.setColumn_group_id(wrapperColumnSchema.getColumnGroupId());
if (DataTypes.isDecimal(wrapperColumnSchema.getDataType())) {
thriftColumnSchema.setScale(wrapperColumnSchema.getScale());
thriftColumnSchema.setPrecision(wrapperColumnSchema.getPrecision());
} else {
thriftColumnSchema.setScale(-1);
thriftColumnSchema.setPrecision(-1);
}
thriftColumnSchema.setNum_child(wrapperColumnSchema.getNumberOfChild());
thriftColumnSchema.setDefault_value(wrapperColumnSchema.getDefaultValue());
thriftColumnSchema.setColumnProperties(wrapperColumnSchema.getColumnProperties());
thriftColumnSchema.setInvisible(wrapperColumnSchema.isInvisible());
thriftColumnSchema.setColumnReferenceId(wrapperColumnSchema.getColumnReferenceId());
thriftColumnSchema.setSchemaOrdinal(wrapperColumnSchema.getSchemaOrdinal());
if (wrapperColumnSchema.isSortColumn()) {
Map<String, String> properties = wrapperColumnSchema.getColumnProperties();
if (null == properties) {
properties = new HashMap<String, String>();
thriftColumnSchema.setColumnProperties(properties);
}
properties.put(CarbonCommonConstants.SORT_COLUMNS, "true");
}
if (null != wrapperColumnSchema.getAggFunction() && !wrapperColumnSchema.getAggFunction().isEmpty()) {
thriftColumnSchema.setAggregate_function(wrapperColumnSchema.getAggFunction());
} else if (null != wrapperColumnSchema.getTimeSeriesFunction() && !wrapperColumnSchema.getTimeSeriesFunction().isEmpty()) {
thriftColumnSchema.setAggregate_function(wrapperColumnSchema.getTimeSeriesFunction());
} else {
thriftColumnSchema.setAggregate_function("");
}
List<ParentColumnTableRelation> parentColumnTableRelations = wrapperColumnSchema.getParentColumnTableRelations();
if (null != parentColumnTableRelations) {
thriftColumnSchema.setParentColumnTableRelations(wrapperToThriftRelationList(parentColumnTableRelations));
}
return thriftColumnSchema;
}
Aggregations