Java Code Examples for org.apache.kylin.metadata.model.TableDesc#mockup()

The following examples show how to use org.apache.kylin.metadata.model.TableDesc#mockup() . 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: DictGridTableTest.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void verifyConvertFilterConstants1() {
    GTInfo info = table.getInfo();

    TableDesc extTable = TableDesc.mockup("ext");
    TblColRef extColA = TblColRef.mockup(extTable, 1, "A", "timestamp");
    TblColRef extColB = TblColRef.mockup(extTable, 2, "B", "integer");

    CompareTupleFilter fComp1 = compare(extColA, FilterOperatorEnum.GT, "2015-01-14");
    CompareTupleFilter fComp2 = compare(extColB, FilterOperatorEnum.EQ, "10");
    LogicalTupleFilter filter = and(fComp1, fComp2);

    List<TblColRef> colMapping = Lists.newArrayList();
    colMapping.add(extColA);
    colMapping.add(extColB);

    TupleFilter newFilter = GTUtil.convertFilterColumnsAndConstants(filter, info, colMapping, null);
    assertEquals(
            "AND [UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.0 GT [\\x00\\x00\\x01J\\xE5\\xBD\\x5C\\x00], UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.1 EQ [\\x00]]",
            newFilter.toString());
}
 
Example 2
Source File: DictGridTableTest.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void verifyConvertFilterConstants4() {
    GTInfo info = table.getInfo();

    TableDesc extTable = TableDesc.mockup("ext");
    TblColRef extColA = TblColRef.mockup(extTable, 1, "A", "timestamp");
    TblColRef extColB = TblColRef.mockup(extTable, 2, "B", "integer");

    CompareTupleFilter fComp1 = compare(extColA, FilterOperatorEnum.GT, "2015-01-14");
    CompareTupleFilter fComp2 = compare(extColB, FilterOperatorEnum.IN, "9", "10", "15");
    LogicalTupleFilter filter = and(fComp1, fComp2);

    List<TblColRef> colMapping = Lists.newArrayList();
    colMapping.add(extColA);
    colMapping.add(extColB);

    // $1 in ("9", "10", "15") has only "10" left
    TupleFilter newFilter = GTUtil.convertFilterColumnsAndConstants(filter, info, colMapping, null);
    assertEquals(
            "AND [UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.0 GT [\\x00\\x00\\x01J\\xE5\\xBD\\x5C\\x00], UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.1 IN [\\x00]]",
            newFilter.toString());
}
 
Example 3
Source File: DictGridTableTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void verifyConvertFilterConstants1() {
    GTInfo info = table.getInfo();

    TableDesc extTable = TableDesc.mockup("ext");
    TblColRef extColA = TblColRef.mockup(extTable, 1, "A", "timestamp");
    TblColRef extColB = TblColRef.mockup(extTable, 2, "B", "integer");

    CompareTupleFilter fComp1 = compare(extColA, FilterOperatorEnum.GT, "2015-01-14");
    CompareTupleFilter fComp2 = compare(extColB, FilterOperatorEnum.EQ, "10");
    LogicalTupleFilter filter = and(fComp1, fComp2);

    List<TblColRef> colMapping = Lists.newArrayList();
    colMapping.add(extColA);
    colMapping.add(extColB);

    TupleFilter newFilter = GTUtil.convertFilterColumnsAndConstants(filter, info, colMapping, null);
    assertEquals(
            "AND [UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.0 GT [\\x00\\x00\\x01J\\xE5\\xBD\\x5C\\x00], UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.1 EQ [\\x00]]",
            newFilter.toString());
}
 
Example 4
Source File: DictGridTableTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void verifyConvertFilterConstants4() {
    GTInfo info = table.getInfo();

    TableDesc extTable = TableDesc.mockup("ext");
    TblColRef extColA = TblColRef.mockup(extTable, 1, "A", "timestamp");
    TblColRef extColB = TblColRef.mockup(extTable, 2, "B", "integer");

    CompareTupleFilter fComp1 = compare(extColA, FilterOperatorEnum.GT, "2015-01-14");
    CompareTupleFilter fComp2 = compare(extColB, FilterOperatorEnum.IN, "9", "10", "15");
    LogicalTupleFilter filter = and(fComp1, fComp2);

    List<TblColRef> colMapping = Lists.newArrayList();
    colMapping.add(extColA);
    colMapping.add(extColB);

    // $1 in ("9", "10", "15") has only "10" left
    TupleFilter newFilter = GTUtil.convertFilterColumnsAndConstants(filter, info, colMapping, null);
    assertEquals(
            "AND [UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.0 GT [\\x00\\x00\\x01J\\xE5\\xBD\\x5C\\x00], UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.1 IN [\\x00]]",
            newFilter.toString());
}
 
Example 5
Source File: TimedJsonStreamParserTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private static List<TblColRef> mockupTblColRefList() {
    TableDesc t = TableDesc.mockup("table_a");
    List<TblColRef> list = new ArrayList<>();
    for (int i = 0; i < userNeedColNames.length; i++) {
        TblColRef c = TblColRef.mockup(t, i, userNeedColNames[i], "string");
        list.add(c);
    }
    return list;
}
 
Example 6
Source File: SnapshotManagerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private TableDesc genTableDesc(String tableName) {
    TableDesc table = TableDesc.mockup(tableName);
    ColumnDesc desc1 = new ColumnDesc("1", "id", "string", null, null, null, null);
    desc1.setId("1");
    desc1.setDatatype("long");
    ColumnDesc desc2 = new ColumnDesc("2", "country", "string", null, null, null, null);
    desc2.setId("2");
    desc2.setDatatype("string");
    ColumnDesc[] columns = { desc1, desc2 };
    table.setColumns(columns);
    table.init(kylinConfig, "default");
    return table;
}
 
Example 7
Source File: FilterBaseTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
protected List<TblColRef> buildGroups() {
    List<TblColRef> groups = new ArrayList<TblColRef>();

    TableDesc t1 = TableDesc.mockup("DEFAULT.TEST_KYLIN_FACT");
    TblColRef c1 = TblColRef.mockup(t1, 2, "CAL_DT", "string");
    groups.add(c1);

    TableDesc t2 = TableDesc.mockup("DEFAULT.TEST_CATEGORY_GROUPINGS");
    TblColRef c2 = TblColRef.mockup(t2, 14, "META_CATEG_NAME", "string");
    groups.add(c2);

    return groups;
}
 
Example 8
Source File: TimedJsonStreamParserTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private static List<TblColRef> mockupTblColRefList() {
    TableDesc t = TableDesc.mockup("table_a");
    List<TblColRef> list = new ArrayList<>();
    for (int i = 0; i < userNeedColNames.length; i++) {
        TblColRef c = TblColRef.mockup(t, i, userNeedColNames[i], "string");
        list.add(c);
    }
    return list;
}
 
Example 9
Source File: TimedJsonStreamParserTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private static List<TblColRef> mockupTblColRefListWithComment(String[] comments) {
    TableDesc t = TableDesc.mockup("table_a");
    List<TblColRef> list = new ArrayList<>();
    for (int i = 0; i < userNeedColNames.length; i++) {
        TblColRef c = TblColRef.mockup(t, i, userNeedColNames[i], "string", comments[i]);
        list.add(c);
    }
    return list;
}
 
Example 10
Source File: TimedJsonStreamParserTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
private static List<TblColRef> mockupTblColRefList() {
    TableDesc t = TableDesc.mockup("table_a");
    List<TblColRef> list = new ArrayList<>();
    for (int i = 0; i < userNeedColNames.length; i++) {
        TblColRef c = TblColRef.mockup(t, i, userNeedColNames[i], "string");
        list.add(c);
    }
    return list;
}
 
Example 11
Source File: SnapshotManagerTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
private TableDesc genTableDesc(String tableName) {
    TableDesc table = TableDesc.mockup(tableName);
    ColumnDesc desc1 = new ColumnDesc("1", "id", "string", null, null, null, null);
    desc1.setId("1");
    desc1.setDatatype("long");
    ColumnDesc desc2 = new ColumnDesc("2", "country", "string", null, null, null, null);
    desc2.setId("2");
    desc2.setDatatype("string");
    ColumnDesc[] columns = { desc1, desc2 };
    table.setColumns(columns);
    table.init(kylinConfig, "default");
    return table;
}
 
Example 12
Source File: FilterBaseTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
protected List<TblColRef> buildGroups() {
    List<TblColRef> groups = new ArrayList<TblColRef>();

    TableDesc t1 = TableDesc.mockup("DEFAULT.TEST_KYLIN_FACT");
    TblColRef c1 = TblColRef.mockup(t1, 2, "CAL_DT", "string");
    groups.add(c1);

    TableDesc t2 = TableDesc.mockup("DEFAULT.TEST_CATEGORY_GROUPINGS");
    TblColRef c2 = TblColRef.mockup(t2, 14, "META_CATEG_NAME", "string");
    groups.add(c2);

    return groups;
}
 
Example 13
Source File: TimedJsonStreamParserTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
private static List<TblColRef> mockupTblColRefList() {
    TableDesc t = TableDesc.mockup("table_a");
    List<TblColRef> list = new ArrayList<>();
    for (int i = 0; i < userNeedColNames.length; i++) {
        TblColRef c = TblColRef.mockup(t, i, userNeedColNames[i], "string");
        list.add(c);
    }
    return list;
}
 
Example 14
Source File: TimedJsonStreamParserTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
private static List<TblColRef> mockupTblColRefListWithComment(String[] comments) {
    TableDesc t = TableDesc.mockup("table_a");
    List<TblColRef> list = new ArrayList<>();
    for (int i = 0; i < userNeedColNames.length; i++) {
        TblColRef c = TblColRef.mockup(t, i, userNeedColNames[i], "string", comments[i]);
        list.add(c);
    }
    return list;
}