Skip to content

Commit

Permalink
KYLIN-3640 Fix cube with desc broken state can not be deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
nichunen authored and shaofengshi committed Oct 22, 2018
1 parent e9ccd07 commit a0dd4f7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,20 @@ public List<TblColRef> getAllUHCColumns() {
}

public String getProject() {
return getModel().getProject();
DataModelDesc modelDesc = getModel();
if (modelDesc == null) {
// In case the model for cube not exists in metadata
List<ProjectInstance> ownerPrj = ProjectManager.getInstance(config).findProjects(RealizationType.CUBE,
name);

if (ownerPrj.size() == 1) {
return ownerPrj.get(0).getName();
} else {
throw new IllegalStateException("No project found for cube " + name);
}
} else {
return getModel().getProject();
}
}

public static CubeDesc getCopyOf(CubeDesc cubeDesc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.kylin.cube.model.CubeDesc;
import org.apache.kylin.cube.model.DimensionDesc;
import org.apache.kylin.metadata.model.SegmentRange.TSRange;
import org.apache.kylin.metadata.realization.RealizationStatusEnum;
import org.apache.kylin.rest.exception.InternalErrorException;
import org.apache.kylin.rest.exception.NotFoundException;
import org.apache.kylin.rest.request.CubeRequest;
Expand Down Expand Up @@ -228,4 +229,15 @@ public void testGetSql() {
}
}

@Test
public void tesDeleteDescBrokenCube() throws Exception {
final String cubeName = "ci_left_join_cube";
CubeInstance cubeInstance = cubeService.getCubeManager().getCube(cubeName);
CubeDesc cubeDesc = cubeInstance.getDescriptor();
cubeDesc.setModel(null);
cubeInstance.setStatus(RealizationStatusEnum.DESCBROKEN);
cubeController.deleteCube(cubeName);
Assert.assertNull(cubeService.getCubeManager().getCube(cubeName));
}

}

0 comments on commit a0dd4f7

Please sign in to comment.