org.apache.kylin.cube.model.validation.IValidatorRule Java Examples

The following examples show how to use org.apache.kylin.cube.model.validation.IValidatorRule. 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: AggregationGroupRuleTest.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testCombinationIntOverflow() throws IOException {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        if (f.getName().endsWith("bad")) {
            String path = f.getPath();
            f.renameTo(new File(path.substring(0, path.length() - 4)));
        }
    }

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/ut_cube_desc_combination_int_overflow.json"), CubeDesc.class);

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    try {
        desc.init(getTestConfig());
    } catch (Exception ex) {
        // as it's a failure case, it should throw exception
    }
    rule.validate(desc, vContext);
    assertEquals(1, vContext.getResults().length);
}
 
Example #2
Source File: AggregationGroupRuleTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testCombinationIntOverflow() throws IOException {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
        if (f.getName().endsWith("bad")) {
            String path = f.getPath();
            f.renameTo(new File(path.substring(0, path.length() - 4)));
        }
    }

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/ut_cube_desc_combination_int_overflow.json"), CubeDesc.class);

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    try {
        desc.init(getTestConfig());
    } catch (Exception ex) {
        // as it's a failure case, it should throw exception
    }
    rule.validate(desc, vContext);
    assertEquals(1, vContext.getResults().length);
}
 
Example #3
Source File: AggregationGroupSizeRuleTest.java    From Kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testOneMandatoryColumn() {
    IValidatorRule<CubeDesc> rule = new AggregationGroupSizeRule() {
        /*
         * (non-Javadoc)
         * 
         * @see
         * org.apache.kylin.metadata.validation.rule.AggregationGroupSizeRule
         * #getMaxAgrGroupSize()
         */
        @Override
        protected int getMaxAgrGroupSize() {
            return 3;
        }
    };
    rule.validate(cube, vContext);
    vContext.print(System.out);
    assertEquals("Failed to validate aggragation group error", vContext.getResults().length, 2);
    assertTrue("Failed to validate aggragation group error", vContext.getResults()[0].getMessage().startsWith("Length of the number"));
    assertTrue("Failed to validate aggragation group error", vContext.getResults()[1].getMessage().startsWith("Length of the number"));
    // assertTrue("Failed to validate aggragation group error",
    // vContext.getResults()[2].getMessage()
    // .startsWith("Hierachy column"));
}
 
Example #4
Source File: AggregationGroupRuleTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testGoodDesc2() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    desc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { //
            new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "CATEG_LVL2_NAME" } };

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(1, vContext.getResults().length);
}
 
Example #5
Source File: AggregationGroupRuleTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testBadDesc1() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    String[] temp = Arrays.asList(desc.getAggregationGroups().get(0).getIncludes()).subList(0, 3).toArray(new String[3]);

    desc.getAggregationGroups().get(0).setIncludes(temp);
    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(1, vContext.getResults().length);
    assertEquals("Aggregation group 1 'includes' dimensions not include all the dimensions:[seller_id, META_CATEG_NAME, lstg_format_name, lstg_site_id, slr_segment_cd]", (vContext.getResults()[0].getMessage()));
}
 
Example #6
Source File: AggregationGroupRuleTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testBadDesc2() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    desc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { //
            new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "META_CATEG_NAME", "CATEG_LVL2_NAME" } };

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(2, vContext.getResults().length);
    assertEquals("Aggregation group 1 joint dimensions has overlap with more than 1 dimensions in same hierarchy: [CATEG_LVL2_NAME, META_CATEG_NAME]", (vContext.getResults()[0].getMessage()));
}
 
Example #7
Source File: RowKeyAttrRuleTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testGoodDesc() throws IOException {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/").listFiles()) {
        CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
        ValidateContext vContext = new ValidateContext();
        IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
        rule.validate(desc, vContext);
        vContext.print(System.out);
        assertTrue(vContext.getResults().length == 0);
    }
}
 
Example #8
Source File: RowKeyAttrRuleTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testBadDesc() throws IOException {
    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    desc.getRowkey().getRowKeyColumns()[2].setColumn("");
    IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
    rule.validate(desc, vContext);
    vContext.print(System.out);
    assertTrue(vContext.getResults().length == 1);
    assertTrue("Rowkey column empty".equalsIgnoreCase(vContext.getResults()[0].getMessage()));
}
 
Example #9
Source File: AggregationGroupRuleTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testGoodDesc2() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    desc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { //
            new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "CATEG_LVL2_NAME" } };

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(1, vContext.getResults().length);
}
 
Example #10
Source File: AggregationGroupRuleTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testBadDesc1() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    String[] temp = Arrays.asList(desc.getAggregationGroups().get(0).getIncludes()).subList(0, 3).toArray(new String[3]);

    desc.getAggregationGroups().get(0).setIncludes(temp);
    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(1, vContext.getResults().length);
    assertEquals("Aggregation group 1 'includes' dimensions not include all the dimensions:[seller_id, META_CATEG_NAME, lstg_format_name, lstg_site_id, slr_segment_cd]", (vContext.getResults()[0].getMessage()));
}
 
Example #11
Source File: AggregationGroupRuleTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testBadDesc2() throws IOException {

    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    desc.getAggregationGroups().get(0).getSelectRule().jointDims = new String[][] { //
            new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "META_CATEG_NAME", "CATEG_LVL2_NAME" } };

    IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
    rule.validate(desc, vContext);
    //vContext.print(System.out);
    assertEquals(2, vContext.getResults().length);
    assertEquals("Aggregation group 1 joint dimensions has overlap with more than 1 dimensions in same hierarchy: [CATEG_LVL2_NAME, META_CATEG_NAME]", (vContext.getResults()[0].getMessage()));
}
 
Example #12
Source File: RowKeyAttrRuleTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testGoodDesc() throws IOException {
    for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/").listFiles()) {
        CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
        ValidateContext vContext = new ValidateContext();
        IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
        rule.validate(desc, vContext);
        vContext.print(System.out);
        assertTrue(vContext.getResults().length == 0);
    }
}
 
Example #13
Source File: RowKeyAttrRuleTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testBadDesc() throws IOException {
    ValidateContext vContext = new ValidateContext();
    CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
    desc.getRowkey().getRowKeyColumns()[2].setColumn("");
    IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
    rule.validate(desc, vContext);
    vContext.print(System.out);
    assertTrue(vContext.getResults().length == 1);
    assertTrue("Rowkey column empty".equalsIgnoreCase(vContext.getResults()[0].getMessage()));
}
 
Example #14
Source File: RowKeyAttrRuleTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testOneMandatoryColumn() {
    IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
    rule.validate(cube, vContext);
    vContext.print(System.out);
    assertTrue("Failed to validate rowkey", vContext.getResults().length == 1);
    assertTrue("Failed to validate mandatory error", vContext.getResults()[0].getMessage().startsWith("Rowkey column"));
}
 
Example #15
Source File: MandatoryColumnRuleTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testOneMandatoryColumn() {
    IValidatorRule<CubeDesc> rule = new MandatoryColumnRule();
    rule.validate(cube, vContext);
    assertTrue("Failed to validate mandatory error", vContext.getResults().length == 1);
    assertTrue("Failed to validate mandatory error", vContext.getResults()[0].getMessage().startsWith("mandatory column"));
}