Search in sources :

Example 6 with ParentColumnTableRelation

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;
}
Also used : ArrayList(java.util.ArrayList) ParentColumnTableRelation(org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation) RelationIdentifier(org.apache.carbondata.core.metadata.schema.table.RelationIdentifier)

Example 7 with ParentColumnTableRelation

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());
            }
        }
    }
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) ParentColumnTableRelation(org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation)

Example 8 with ParentColumnTableRelation

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;
}
Also used : ParentColumnTableRelation(org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation) RelationIdentifier(org.apache.carbondata.core.metadata.schema.table.RelationIdentifier)

Example 9 with ParentColumnTableRelation

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;
}
Also used : ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) ParentColumnTableRelation(org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation) DataType(org.apache.carbondata.core.metadata.datatype.DataType) DecimalType(org.apache.carbondata.core.metadata.datatype.DecimalType)

Example 10 with ParentColumnTableRelation

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;
}
Also used : ArrayList(java.util.ArrayList) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) ParentColumnTableRelation(org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation)

Aggregations

ParentColumnTableRelation (org.apache.carbondata.core.metadata.schema.table.column.ParentColumnTableRelation)10 ArrayList (java.util.ArrayList)6 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)6 Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)4 RelationIdentifier (org.apache.carbondata.core.metadata.schema.table.RelationIdentifier)4 DataType (org.apache.carbondata.core.metadata.datatype.DataType)2 DecimalType (org.apache.carbondata.core.metadata.datatype.DecimalType)2 HashSet (java.util.HashSet)1