Java Code Examples for org.apache.kylin.metadata.model.DataModelDesc#getDimensions()
The following examples show how to use
org.apache.kylin.metadata.model.DataModelDesc#getDimensions() .
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: ModelServiceTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Test public void testRevisableModelInCaseOfDeleteDims() throws IOException { List<DataModelDesc> dataModelDescs = modelService.listAllModels("ci_left_join_model", "default", true); Assert.assertTrue(dataModelDescs.size() == 1); DataModelDesc revisableModel = dataModelDescs.get(0); List<ModelDimensionDesc> originDims = revisableModel.getDimensions(); String[] reviseDims = cutItems(originDims.get(0).getColumns(), 1); originDims.get(0).setColumns(reviseDims); revisableModel.setDimensions(originDims); // actually the TEST_COUNT_DISTINCT_BITMAP was defined in dimension (not measure) expectedEx.expect(org.apache.kylin.rest.exception.BadRequestException.class); expectedEx.expectMessage( "Measure: TEST_KYLIN_FACT.TEST_COUNT_DISTINCT_BITMAP can't be removed, It is referred in Cubes: [ci_left_join_cube]"); modelService.updateModelToResourceStore(revisableModel, "default"); }
Example 2
Source File: ModelServiceTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Test public void testRevisableModelInCaseOfMoveMeasureToDim() throws IOException { List<DataModelDesc> dataModelDescs = modelService.listAllModels("ci_left_join_model", "default", true); Assert.assertTrue(dataModelDescs.size() == 1); DataModelDesc revisableModel = dataModelDescs.get(0); String[] originM = revisableModel.getMetrics(); String[] reviseM = cutItems(originM, 1); revisableModel.setMetrics(reviseM); String col = originM[originM.length - 1]; col = col.substring(col.indexOf('.') + 1); List<ModelDimensionDesc> originDims = revisableModel.getDimensions(); String[] reviseDims = addItems(originDims.get(0).getColumns(), col); originDims.get(0).setColumns(reviseDims); revisableModel.setDimensions(originDims); modelService.updateModelToResourceStore(revisableModel, "default"); //It should pass without any exceptions. }
Example 3
Source File: TableSchemaUpdateChecker.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private Set<ColumnDesc> findUsedColumnsInFactTable(DataModelDesc usedModel, TableDesc factTable) { Set<ColumnDesc> usedColumns = Sets.newHashSet(); // column in dimension for (ModelDimensionDesc dim : usedModel.getDimensions()) { if (dim.getTable().equalsIgnoreCase(factTable.getName())) { for (String col : dim.getColumns()) { usedColumns.add(mustGetColumnDesc(factTable, col)); } } } // column in measure for (String columnInMeasure : usedModel.getMetrics()) { if (factTable.getName().equalsIgnoreCase(getTableName(columnInMeasure))) { usedColumns.add(mustGetColumnDesc(factTable, columnInMeasure)); } } return usedColumns; }
Example 4
Source File: ModelServiceTest.java From kylin with Apache License 2.0 | 6 votes |
@Test public void testRevisableModelInCaseOfDeleteDims() throws IOException { List<DataModelDesc> dataModelDescs = modelService.listAllModels("ci_left_join_model", "default", true); Assert.assertTrue(dataModelDescs.size() == 1); DataModelDesc revisableModel = dataModelDescs.get(0); List<ModelDimensionDesc> originDims = revisableModel.getDimensions(); String[] reviseDims = cutItems(originDims.get(0).getColumns(), 1); originDims.get(0).setColumns(reviseDims); revisableModel.setDimensions(originDims); // actually the TEST_COUNT_DISTINCT_BITMAP was defined in dimension (not measure) expectedEx.expect(org.apache.kylin.rest.exception.BadRequestException.class); expectedEx.expectMessage( "Measure: TEST_KYLIN_FACT.TEST_COUNT_DISTINCT_BITMAP can't be removed, It is referred in Cubes: [ci_left_join_cube]"); modelService.updateModelToResourceStore(revisableModel, "default"); }
Example 5
Source File: ModelServiceTest.java From kylin with Apache License 2.0 | 6 votes |
@Test public void testRevisableModelInCaseOfMoveMeasureToDim() throws IOException { List<DataModelDesc> dataModelDescs = modelService.listAllModels("ci_left_join_model", "default", true); Assert.assertTrue(dataModelDescs.size() == 1); DataModelDesc revisableModel = dataModelDescs.get(0); String[] originM = revisableModel.getMetrics(); String[] reviseM = cutItems(originM, 1); revisableModel.setMetrics(reviseM); String col = originM[originM.length - 1]; col = col.substring(col.indexOf('.') + 1); List<ModelDimensionDesc> originDims = revisableModel.getDimensions(); String[] reviseDims = addItems(originDims.get(0).getColumns(), col); originDims.get(0).setColumns(reviseDims); revisableModel.setDimensions(originDims); modelService.updateModelToResourceStore(revisableModel, "default"); //It should pass without any exceptions. }
Example 6
Source File: TableSchemaUpdateChecker.java From kylin with Apache License 2.0 | 6 votes |
private List<String> checkAllColumnsInLookupTable(DataModelDesc usedModel, TableDesc newTableDesc) { List<String> violateColumns = Lists.newArrayList(); Set<String> newColumns = Sets.newHashSet(newTableDesc.getColumns()).stream() .map(c -> c.getName().toUpperCase(Locale.ROOT)).collect(Collectors.toSet()); for (ModelDimensionDesc dim : usedModel.getDimensions()) { if (dim.getTable().equalsIgnoreCase(newTableDesc.getIdentity())) { Set<String> oldColumns = Sets.newHashSet(dim.getColumns()).stream().map(c -> c.toUpperCase(Locale.ROOT)) .collect(Collectors.toSet()); oldColumns.removeAll(newColumns); violateColumns.addAll(oldColumns); } } return violateColumns; }
Example 7
Source File: TableSchemaUpdateChecker.java From kylin with Apache License 2.0 | 6 votes |
private Set<ColumnDesc> findUsedColumnsInFactTable(DataModelDesc usedModel, TableDesc factTable) { Set<ColumnDesc> usedColumns = Sets.newHashSet(); // column in dimension for (ModelDimensionDesc dim : usedModel.getDimensions()) { if (dim.getTable().equalsIgnoreCase(factTable.getName())) { for (String col : dim.getColumns()) { usedColumns.add(mustGetColumnDesc(factTable, col)); } } } // column in measure for (String columnInMeasure : usedModel.getMetrics()) { if (factTable.getName().equalsIgnoreCase(getTableName(columnInMeasure))) { usedColumns.add(mustGetColumnDesc(factTable, columnInMeasure)); } } return usedColumns; }
Example 8
Source File: ModelService.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private List<String> getModelCols(DataModelDesc model) { List<String> dimCols = new ArrayList<String>(); List<ModelDimensionDesc> dimensions = model.getDimensions(); for (ModelDimensionDesc dim : dimensions) { String table = dim.getTable(); for (String c : dim.getColumns()) { dimCols.add(table + "." + c); } } return dimCols; }
Example 9
Source File: ModelService.java From kylin with Apache License 2.0 | 5 votes |
private List<String> getModelCols(DataModelDesc model) { List<String> dimCols = new ArrayList<String>(); List<ModelDimensionDesc> dimensions = model.getDimensions(); for (ModelDimensionDesc dim : dimensions) { String table = dim.getTable(); for (String c : dim.getColumns()) { dimCols.add(table + "." + c); } } return dimCols; }