热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.kylin.metadata.model.TableDesc.mockup()方法的使用及代码示例

本文整理了Java中org.apache.kylin.metadata.model.TableDesc.mockup()方法的一些代码示例,展示了Table

本文整理了Java中org.apache.kylin.metadata.model.TableDesc.mockup()方法的一些代码示例,展示了TableDesc.mockup()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableDesc.mockup()方法的具体详情如下:
包路径:org.apache.kylin.metadata.model.TableDesc
类名称:TableDesc
方法名:mockup

TableDesc.mockup介绍

[英]create a mockup table for unit test
[中]为单元测试创建一个模型表

代码示例

代码示例来源:origin: apache/kylin

protected List buildGroups() {
List groups = new ArrayList();
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 mockupTblColRefList() {
TableDesc t = TableDesc.mockup("table_a");
List list = new ArrayList<>();
for (int i = 0; i TblColRef c = TblColRef.mockup(t, i, userNeedColNames[i], "string");
list.add(c);
}
return list;
}

代码示例来源:origin: apache/kylin

private static List mockupTblColRefListWithComment(String[] comments) {
TableDesc t = TableDesc.mockup("table_a");
List list = new ArrayList<>();
for (int i = 0; i TblColRef c = TblColRef.mockup(t, i, userNeedColNames[i], "string", comments[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 = 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());
}

代码示例来源: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 = 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());
}

代码示例来源: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 cols = Sets.newHashSet(colA, colB);

{
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());
}

推荐阅读
  • Gradle 是 Android Studio 中默认的构建工具,了解其基本配置对于开发效率的提升至关重要。本文将详细介绍如何在 Gradle 中定义和使用共享变量,以确保项目的一致性和可维护性。 ... [详细]
  • Java连接MySQL数据库的方法及测试示例
    本文详细介绍了如何安装MySQL数据库,并通过Java编程语言实现与MySQL数据库的连接,包括环境搭建、数据库创建以及简单的查询操作。 ... [详细]
  • 本文详细介绍了 `org.apache.tinkerpop.gremlin.structure.VertexProperty` 类中的 `key()` 方法,并提供了多个实际应用的代码示例。通过这些示例,读者可以更好地理解该方法在图数据库操作中的具体用途。 ... [详细]
  • spring boot使用jetty无法启动 ... [详细]
  • Android与JUnit集成测试实践
    本文探讨了如何在Android项目中集成JUnit进行单元测试,并详细介绍了修改AndroidManifest.xml文件以支持测试的方法。 ... [详细]
  • 本文探讨了如何选择一个合适的序列化版本ID(serialVersionUID),包括使用生成器还是简单的整数,以及在不同情况下应如何处理序列化版本ID。 ... [详细]
  • C/C++ 应用程序的安装与卸载解决方案
    本文介绍了如何使用Inno Setup来创建C/C++应用程序的安装程序,包括自动检测并安装所需的运行库,确保应用能够顺利安装和卸载。 ... [详细]
  • Spring Security基础配置详解
    本文详细介绍了Spring Security的基础配置方法,包括如何搭建Maven多模块工程以及具体的安全配置步骤,帮助开发者更好地理解和应用这一强大的安全框架。 ... [详细]
  • 尽管在WPF中工作了一段时间,但在菜单控件的样式设置上遇到了一些基础问题,特别是关于如何正确配置前景色和背景色。 ... [详细]
  • 本文探讨了如何在 Spring MVC 框架下,通过自定义注解和拦截器机制来实现细粒度的权限管理功能。 ... [详细]
  • Maven + Spring + MyBatis + MySQL 环境搭建与实例解析
    本文详细介绍如何使用MySQL数据库进行环境搭建,包括创建数据库表并插入示例数据。随后,逐步指导如何配置Maven项目,整合Spring框架与MyBatis,实现高效的数据访问。 ... [详细]
  • 长期从事ABAP开发工作的专业人士,在面对行业新趋势时,往往需要重新审视自己的发展方向。本文探讨了几位资深专家对ABAP未来走向的看法,以及开发者应如何调整技能以适应新的技术环境。 ... [详细]
  • 本文详细介绍了 Java 中 org.apache.jena.atlas.lib.ByteBufferLib 类下的 acopyArray 方法,并提供了多个实际应用中的代码示例,帮助开发者更好地理解和使用该方法。 ... [详细]
  • 问题场景用Java进行web开发过程当中,当遇到很多很多个字段的实体时,最苦恼的莫过于编辑字段的查看和修改界面,发现2个页面存在很多重复信息,能不能写一遍?有没有轮子用都不如自己造。解决方式笔者根据自 ... [详细]
  • 解决JavaScript中法语字符排序问题
    在开发一个使用JavaScript、HTML和CSS的Web应用时,遇到从SQLite数据库中提取的法语词汇排序不正确的问题,特别是带重音符号的字母未按预期排序。 ... [详细]
author-avatar
水果jia
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有