本文整理了Java中org.apache.kylin.metadata.model.TableDesc.mockup()
方法的一些代码示例,展示了TableDesc.mockup()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableDesc.mockup()
方法的具体详情如下:
包路径:org.apache.kylin.metadata.model.TableDesc
类名称:TableDesc
方法名:mockup
[英]create a mockup table for unit test
[中]为单元测试创建一个模型表
代码示例来源:origin: apache/kylin
protected List
List
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;
}
代码示例来源:origin: apache/kylin
private static List
TableDesc t = TableDesc.mockup("table_a");
List
for (int i = 0; i
list.add(c);
}
return list;
}
代码示例来源:origin: apache/kylin
private static List
TableDesc t = TableDesc.mockup("table_a");
List
for (int i = 0; i
list.add(c);
}
return list;
}
}
代码示例来源:origin: apache/kylin
@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
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());
}
代码示例来源:origin: apache/kylin
@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
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());
}
代码示例来源:origin: apache/kylin
@Test
public void testDateAndTimePartition() {
PartitionDesc partitiOnDesc= new PartitionDesc();
TblColRef col1 = TblColRef.mockup(TableDesc.mockup("DEFAULT.TABLE_NAME"), 1, "DATE_COLUMN", "string");
partitionDesc.setPartitionDateColumnRef(col1);
partitionDesc.setPartitionDateColumn(col1.getCanonicalName());
partitionDesc.setPartitionDateFormat("yyyy-MM-dd");
TblColRef col2 = TblColRef.mockup(TableDesc.mockup("DEFAULT.TABLE_NAME"), 2, "HOUR_COLUMN", "string");
partitionDesc.setPartitionTimeColumnRef(col2);
partitionDesc.setPartitionTimeColumn(col2.getCanonicalName());
partitionDesc.setPartitionTimeFormat("H");
TSRange range = new TSRange(DateFormat.stringToMillis("2016-02-22 00:00:00"),
DateFormat.stringToMillis("2016-02-23 01:00:00"));
String cOndition= partitionConditionBuilder.buildDateRangeCondition(partitionDesc, null, range);
Assert.assertEquals(
"((UNKNOWN_ALIAS.DATE_COLUMN = '2016-02-22' AND UNKNOWN_ALIAS.HOUR_COLUMN >= '0') OR (UNKNOWN_ALIAS.DATE_COLUMN > '2016-02-22')) AND ((UNKNOWN_ALIAS.DATE_COLUMN = '2016-02-23' AND UNKNOWN_ALIAS.HOUR_COLUMN <'1') OR (UNKNOWN_ALIAS.DATE_COLUMN <'2016-02-23'))",
condition);
}
代码示例来源:origin: apache/kylin
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");
代码示例来源:origin: apache/kylin
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");
代码示例来源:origin: apache/kylin
@Test
public void testTimePartition() {
PartitionDesc partitiOnDesc= new PartitionDesc();
TblColRef col = TblColRef.mockup(TableDesc.mockup("DEFAULT.TABLE_NAME"), 2, "HOUR_COLUMN", "string");
partitionDesc.setPartitionTimeColumnRef(col);
partitionDesc.setPartitionTimeColumn(col.getCanonicalName());
partitionDesc.setPartitionTimeFormat("HH");
TSRange range = new TSRange(DateFormat.stringToMillis("2016-02-22 00:00:00"),
DateFormat.stringToMillis("2016-02-23 01:00:00"));
String cOndition= partitionConditionBuilder.buildDateRangeCondition(partitionDesc, null, range);
Assert.assertEquals("UNKNOWN_ALIAS.HOUR_COLUMN >= '00' AND UNKNOWN_ALIAS.HOUR_COLUMN <'01'", condition);
}
代码示例来源:origin: apache/kylin
@Test
public void testFindMustEqualColsAndValues() {
TableDesc tbl = TableDesc.mockup("mockup_table");
TblColRef colA = TblColRef.mockup(tbl, 0, "A", "bigint");
TblColRef colB = TblColRef.mockup(tbl, 1, "B", "char(256)");
Set
{
TupleFilter f = compare(colA, FilterOperatorEnum.EQ, "1234");
Assert.assertEquals(map(colA, "1234"), f.findMustEqualColsAndValues(cols));
}
{
TupleFilter f = compare(colA, FilterOperatorEnum.ISNULL);
Assert.assertEquals(map(colA, null), f.findMustEqualColsAndValues(cols));
}
{
TupleFilter f = and(compare(colA, FilterOperatorEnum.ISNULL), compare(colB, FilterOperatorEnum.EQ, "1234"));
Assert.assertEquals(map(colA, null, colB, "1234"), f.findMustEqualColsAndValues(cols));
Assert.assertTrue(not(f).findMustEqualColsAndValues(cols).isEmpty());
}
{
TupleFilter f = compare(colA, FilterOperatorEnum.LT, "1234");
Assert.assertTrue(f.findMustEqualColsAndValues(cols).isEmpty());
}
}
代码示例来源:origin: apache/kylin
@Test
public void basicTest() {
TableDesc t1 = TableDesc.mockup("DEFAULT.TEST_KYLIN_FACT");
TblColRef column = TblColRef.mockup(t1, 2, "CAL_DT", "date");
CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ);
ColumnTupleFilter columnFilter = new ColumnTupleFilter(column);
compareFilter.addChild(columnFilter);
ConstantTupleFilter cOnstantFilter= null;
cOnstantFilter= new ConstantTupleFilter("946684800000");
compareFilter.addChild(constantFilter);
TimeConditionLiteralsReplacer filterDecorator = new TimeConditionLiteralsReplacer(compareFilter);
byte[] bytes = TupleFilterSerializer.serialize(compareFilter, filterDecorator, DictCodeSystem.INSTANCE);
CompareTupleFilter compareTupleFilter = (CompareTupleFilter) TupleFilterSerializer.deserialize(bytes, DictCodeSystem.INSTANCE);
Assert.assertEquals("2000-01-01", compareTupleFilter.getFirstValue());
}
}
代码示例来源:origin: apache/kylin
@Test
public void testDatePartition() {
PartitionDesc partitiOnDesc= new PartitionDesc();
TblColRef col = TblColRef.mockup(TableDesc.mockup("DEFAULT.TABLE_NAME"), 1, "DATE_COLUMN", "string");
partitionDesc.setPartitionDateColumnRef(col);
partitionDesc.setPartitionDateColumn(col.getCanonicalName());
partitionDesc.setPartitionDateFormat("yyyy-MM-dd");
TSRange range = new TSRange(DateFormat.stringToMillis("2016-02-22"), DateFormat.stringToMillis("2016-02-23"));
String cOndition= partitionConditionBuilder.buildDateRangeCondition(partitionDesc, null, range);
Assert.assertEquals("UNKNOWN_ALIAS.DATE_COLUMN >= '2016-02-22' AND UNKNOWN_ALIAS.DATE_COLUMN <'2016-02-23'",
condition);
range = new TSRange(0L, 0L);
cOndition= partitionConditionBuilder.buildDateRangeCondition(partitionDesc, null, range);
Assert.assertEquals("1=0", condition);
}
代码示例来源:origin: apache/kylin
@Test
public void getRewriteFieldType() {
TblColRef mockColOfDoubleType = TblColRef.mockup(TableDesc.mockup("mock_table"), 0, "price", "double", "");
TblColRef mockColOfDecimalType = TblColRef.mockup(TableDesc.mockup("mock_table"), 1, "price", "decimal", "");
FunctionDesc function = FunctionDesc.newInstance("SUM", ParameterDesc.newInstance("1"), "bigint");
assertEquals(DataType.getType("bigint"), function.getRewriteFieldType());
function = FunctionDesc.newInstance("COUNT", ParameterDesc.newInstance("1"), "bigint");
assertEquals(DataType.getType("bigint"), function.getRewriteFieldType());
function = FunctionDesc.newInstance("SUM", ParameterDesc.newInstance(mockColOfDoubleType), "double");
assertEquals(DataType.getType("double"), function.getRewriteFieldType());
function = FunctionDesc.newInstance("MAX", ParameterDesc.newInstance(mockColOfDecimalType), "double");
assertEquals(DataType.getType("decimal"), function.getRewriteFieldType());
function = FunctionDesc.newInstance("MIN", ParameterDesc.newInstance(mockColOfDecimalType), "double");
assertEquals(DataType.getType("decimal"), function.getRewriteFieldType());
function = FunctionDesc.newInstance(FunctionDesc.FUNC_PERCENTILE,
ParameterDesc.newInstance(mockColOfDecimalType), "double");
assertEquals(DataType.ANY, function.getRewriteFieldType());
}