Java Code Examples for org.apache.kylin.metadata.model.DataModelDesc#setMetrics()
The following examples show how to use
org.apache.kylin.metadata.model.DataModelDesc#setMetrics() .
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 |
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: ModelServiceTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Test public void testRevisableModelInCaseOfDeleteMeasure() 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); expectedEx.expect(org.apache.kylin.rest.exception.BadRequestException.class); expectedEx.expectMessage( "Measure: TEST_KYLIN_FACT.ITEM_COUNT can't be removed, It is referred in Cubes: [ci_left_join_cube]"); modelService.updateModelToResourceStore(revisableModel, "default"); }
Example 3
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 4
Source File: ModelCreator.java From kylin with Apache License 2.0 | 6 votes |
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 5
Source File: ModelServiceTest.java From kylin with Apache License 2.0 | 6 votes |
@Test public void testRevisableModelInCaseOfDeleteMeasure() 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); expectedEx.expect(org.apache.kylin.rest.exception.BadRequestException.class); expectedEx.expectMessage( "Measure: TEST_KYLIN_FACT.ITEM_COUNT can't be removed, It is referred in Cubes: [ci_left_join_cube]"); modelService.updateModelToResourceStore(revisableModel, "default"); }
Example 6
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. }