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

The following examples show how to use org.apache.kylin.metadata.model.TblColRef#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: TupleExpressionSerializerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testSerialization() {
    TblColRef colD = TblColRef.mockup(t, 1, "C1", "decimal");
    TblColRef colM = TblColRef.mockup(t, 2, "C2", "string");
    BigDecimal value = BigDecimal.valueOf(10L);

    ColumnTupleFilter colFilter = new ColumnTupleFilter(colD);
    ConstantTupleFilter constFilter = new ConstantTupleFilter("col");
    CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ);
    compareFilter.addChild(colFilter);
    compareFilter.addChild(constFilter);

    ColumnTupleExpression colTuple = new ColumnTupleExpression(colM);
    NumberTupleExpression constTuple = new NumberTupleExpression(value);

    Pair<TupleFilter, TupleExpression> whenEntry = new Pair<TupleFilter, TupleExpression>(compareFilter, colTuple);
    CaseTupleExpression caseTuple = new CaseTupleExpression(Lists.newArrayList(whenEntry), constTuple);

    byte[] result = TupleExpressionSerializer.serialize(caseTuple, StringCodeSystem.INSTANCE);

    TupleExpression desTuple = TupleExpressionSerializer.deserialize(result, StringCodeSystem.INSTANCE);
    assertEquals(caseTuple, desTuple);
}
 
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 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 3
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 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: 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 6
Source File: TupleExpressionSerializerTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testSerialization() {
    TblColRef colD = TblColRef.mockup(t, 1, "C1", "string");
    TblColRef colM = TblColRef.mockup(t, 2, "C2", "decimal");
    BigDecimal value = BigDecimal.valueOf(10L);

    ColumnTupleFilter colFilter = new ColumnTupleFilter(colD);
    ConstantTupleFilter constFilter = new ConstantTupleFilter("col");
    CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ);
    compareFilter.addChild(colFilter);
    compareFilter.addChild(constFilter);

    ColumnTupleExpression colTuple = new ColumnTupleExpression(colM);
    ConstantTupleExpression constTuple = new ConstantTupleExpression(value);

    Pair<TupleFilter, TupleExpression> whenEntry = new Pair<TupleFilter, TupleExpression>(compareFilter, colTuple);
    CaseTupleExpression caseTuple = new CaseTupleExpression(Lists.newArrayList(whenEntry), constTuple);

    byte[] result = TupleExpressionSerializer.serialize(caseTuple, StringCodeSystem.INSTANCE);

    TupleExpression desTuple = TupleExpressionSerializer.deserialize(result, StringCodeSystem.INSTANCE);
    assertEquals(caseTuple, desTuple);
}
 
Example 7
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;
}
 
Example 8
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 9
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 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: 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 12
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 13
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 14
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 15
Source File: FuzzyValueCombinationTest.java    From kylin with Apache License 2.0 4 votes vote down vote up
private static TblColRef col(int i, TableDesc t) {
    return TblColRef.mockup(t, i, "Col" + i, "string");
}
 
Example 16
Source File: GTUtil.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
static TblColRef tblColRef(int col, String datatype) {
    return TblColRef.mockup(MOCKUP_TABLE, col + 1, "" + col, datatype);
}
 
Example 17
Source File: GTUtil.java    From kylin with Apache License 2.0 4 votes vote down vote up
static TblColRef tblColRef(int col, String datatype) {
    return TblColRef.mockup(MOCKUP_TABLE, col + 1, "" + col, datatype);
}
 
Example 18
Source File: FuzzyValueCombinationTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
private static TblColRef col(int i, TableDesc t) {
    return TblColRef.mockup(t, i, "Col" + i, "string");
}