Java Code Examples for org.apache.kylin.metadata.model.DataModelDesc#setPartitionDesc()

The following examples show how to use org.apache.kylin.metadata.model.DataModelDesc#setPartitionDesc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public static DataModelDesc generateKylinModel(String owner, String tableName, List<String> dimensions,
        List<String> measures, PartitionDesc partitionDesc) {
    ModelDimensionDesc modelDimensionDesc = new ModelDimensionDesc();
    modelDimensionDesc.setTable(tableName);
    modelDimensionDesc.setColumns(dimensions.toArray(new String[dimensions.size()]));

    DataModelDesc kylinModel = new DataModelDesc();
    kylinModel.setName(tableName.replace('.', '_'));
    kylinModel.setOwner(owner);
    kylinModel.setDescription("");
    kylinModel.setLastModified(0L);
    kylinModel.setRootFactTableName(tableName);
    kylinModel.setJoinTables(new JoinTableDesc[0]);
    kylinModel.setDimensions(Lists.newArrayList(modelDimensionDesc));
    kylinModel.setMetrics(measures.toArray(new String[measures.size()]));
    kylinModel.setFilterCondition("");
    kylinModel.setPartitionDesc(partitionDesc);
    kylinModel.setCapacity(DataModelDesc.RealizationCapacity.SMALL);
    kylinModel.updateRandomUuid();

    return kylinModel;
}
 
Example 2
Source File: ModelCreator.java    From kylin with Apache License 2.0 6 votes vote down vote up
public static DataModelDesc generateKylinModel(String owner, String tableName, List<String> dimensions,
        List<String> measures, PartitionDesc partitionDesc) {
    ModelDimensionDesc modelDimensionDesc = new ModelDimensionDesc();
    modelDimensionDesc.setTable(tableName);
    modelDimensionDesc.setColumns(dimensions.toArray(new String[dimensions.size()]));

    DataModelDesc kylinModel = new DataModelDesc();
    kylinModel.setName(tableName.replace('.', '_'));
    kylinModel.setOwner(owner);
    kylinModel.setDescription("");
    kylinModel.setLastModified(0L);
    kylinModel.setRootFactTableName(tableName);
    kylinModel.setJoinTables(new JoinTableDesc[0]);
    kylinModel.setDimensions(Lists.newArrayList(modelDimensionDesc));
    kylinModel.setMetrics(measures.toArray(new String[measures.size()]));
    kylinModel.setFilterCondition("");
    kylinModel.setPartitionDesc(partitionDesc);
    kylinModel.setCapacity(DataModelDesc.RealizationCapacity.SMALL);
    kylinModel.updateRandomUuid();

    return kylinModel;
}
 
Example 3
Source File: CubeDescUpgrader.java    From Kylin with Apache License 2.0 5 votes vote down vote up
private void updatePartitionDesc(CubeDesc oldModel, DataModelDesc dm) {

        CubePartitionDesc partition = oldModel.getCubePartitionDesc();
        PartitionDesc newPartition = new PartitionDesc();

        if (partition.getPartitionDateColumn() != null) {
            String partitionCol = partition.getPartitionDateColumn();

            String[] tablecolumn = partitionCol.split("\\.");
            if (tablecolumn != null && tablecolumn.length == 2) {
                // pattern is <tablename>.<colname>
                String tableFullName = getMetadataManager().appendDBName(tablecolumn[0]);
                newPartition.setPartitionDateColumn(tableFullName + "." + tablecolumn[1]);
            } else {

                if (partitionCol.indexOf(".") < 0) {
                    // pattern is <colname>
                    partitionCol = dm.getFactTable() + "." + partitionCol;
                }

                newPartition.setPartitionDateColumn(partitionCol);
            }
        }

        // only append is supported
        newPartition.setCubePartitionType(PartitionDesc.PartitionType.APPEND);

        newPartition.setPartitionDateStart(partition.getPartitionDateStart());

        dm.setPartitionDesc(newPartition);
    }
 
Example 4
Source File: TableSchemaUpdater.java    From kylin with Apache License 2.0 4 votes vote down vote up
public static DataModelDesc dealWithMappingForModel(DataModelDesc other,
        Map<String, TableSchemaUpdateMapping> mappings) {
    // For filter condition, not support
    if (!Strings.isNullOrEmpty(other.getFilterCondition())) {
        throw new UnsupportedOperationException("Cannot deal with filter condition " + other.getFilterCondition());
    }

    DataModelDesc copy = DataModelDesc.getCopyOf(other);
    copy.setLastModified(other.getLastModified());

    // mapping for root fact table identity
    TableSchemaUpdateMapping rootMapping = getTableSchemaUpdateMapping(mappings, other.getRootFactTableName());
    if (rootMapping != null) {
        TableDesc rootFactTable = other.getRootFactTable().getTableDesc();
        copy.setRootFactTableName(
                rootMapping.getTableIdentity(rootFactTable.getDatabase(), rootFactTable.getName()));
    }

    // mapping for joins
    JoinTableDesc[] joinTables = other.getJoinTables();
    JoinTableDesc[] joinTablesCopy = new JoinTableDesc[joinTables.length];
    for (int i = 0; i < joinTables.length; i++) {
        JoinTableDesc joinTable = joinTables[i];
        joinTablesCopy[i] = JoinTableDesc.getCopyOf(joinTable);
        String tableIdentity = joinTable.getTable();
        TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, tableIdentity);
        if (mapping != null && mapping.isTableIdentityChanged()) {
            joinTablesCopy[i].setTable(mapping.getTableIdentity(tableIdentity));
        }
    }
    copy.setJoinTables(joinTablesCopy);

    // mapping for partition columns
    PartitionDesc partDesc = other.getPartitionDesc();
    PartitionDesc partCopy = PartitionDesc.getCopyOf(partDesc);
    if (partDesc.getPartitionDateColumnRef() != null) {
        partCopy.setPartitionDateColumn(
                replacePartitionCol(partDesc.getPartitionDateColumnRef().getCanonicalName(), mappings));
    }
    if (partDesc.getPartitionTimeColumnRef() != null) {
        partCopy.setPartitionTimeColumn(
                replacePartitionCol(partDesc.getPartitionTimeColumnRef().getCanonicalName(), mappings));
    }
    copy.setPartitionDesc(partCopy);

    return copy;
}