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

com.facebook.presto.testing.MaterializedResult.toTestTypes()方法的使用及代码示例

本文整理了Java中com.facebook.presto.testing.MaterializedResult.toTestTypes()方法的一些代码示例,展示了

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

MaterializedResult.toTestTypes介绍

[英]Converts this MaterializedResult to a new one, representing the data using the same type domain as returned by TestingPrestoClient.
[中]将此MaterializedResult转换为新结果,表示使用TestingPrestoClient返回的相同类型域的数据。

代码示例

代码示例来源:origin: prestodb/presto

protected static void assertQueryReturnsEmptyResult(QueryRunner queryRunner, Session session, @Language("SQL") String sql)
{
try {
MaterializedResult results = queryRunner.execute(session, sql).toTestTypes();
assertNotNull(results);
assertEquals(results.getRowCount(), 0);
}
catch (RuntimeException ex) {
fail("Execution of query failed: " + sql, ex);
}
}

代码示例来源:origin: prestodb/presto

protected MaterializedResult computeActual(Session session, @Language("SQL") String sql)
{
return queryRunner.execute(session, sql).toTestTypes();
}

代码示例来源:origin: prestodb/presto

@Test
public void testDescribeTable()
{
MaterializedResult actualColumns = computeActual("DESC orders").toTestTypes();
assertEquals(actualColumns, getExpectedOrdersTableDescription(isDateTypeSupported(), isParameterizedVarcharSupported()));
}

代码示例来源:origin: prestodb/presto

public void assertFails(@Language("SQL") String sql, @Language("RegExp") String expectedMessageRegExp)
{
try {
runner.execute(runner.getDefaultSession(), sql).toTestTypes();
fail(format("Expected query to fail: %s", sql));
}
catch (RuntimeException exception) {
if (!nullToEmpty(exception.getMessage()).matches(expectedMessageRegExp)) {
fail(format("Expected exception message '%s' to match '%s' for query: %s", exception.getMessage(), expectedMessageRegExp, sql), exception);
}
}
}

代码示例来源:origin: prestodb/presto

MaterializedResultWithPlan resultWithPlan = queryRunner.executeWithPlan(session, sql, WarningCollector.NOOP);
queryPlan = resultWithPlan.getQueryPlan();
results = resultWithPlan.getMaterializedResult().toTestTypes();

代码示例来源:origin: prestodb/presto

@Override
public MaterializedResultWithPlan executeWithPlan(Session session, String sql, WarningCollector warningCollector)
{
ResultWithQueryId resultWithQueryId = executeWithQueryId(session, sql);
return new MaterializedResultWithPlan(resultWithQueryId.getResult().toTestTypes(), getQueryPlan(resultWithQueryId.getQueryId()));
}

代码示例来源:origin: prestodb/presto

@Test
public void testShowTables()
{
MaterializedResult actualTables = computeActual("SHOW TABLES").toTestTypes();
MaterializedResult expectedTables = MaterializedResult.resultBuilder(getQueryRunner().getDefaultSession(), VARCHAR)
.row("orders")
.build();
assertContains(actualTables, expectedTables);
}

代码示例来源:origin: prestodb/presto

@Test
public void testShowSchemas()
{
MaterializedResult actualSchemas = computeActual("SHOW SCHEMAS").toTestTypes();
MaterializedResult.Builder resultBuilder = MaterializedResult.resultBuilder(getQueryRunner().getDefaultSession(), VARCHAR)
.row(getQueryRunner().getDefaultSession().getSchema().orElse("tpch"));
assertContains(actualSchemas, resultBuilder.build());
}

代码示例来源:origin: prestodb/presto

MaterializedResultWithPlan resultWithPlan = actualQueryRunner.executeWithPlan(session, actual, WarningCollector.NOOP);
queryPlan = resultWithPlan.getQueryPlan();
actualResults = resultWithPlan.getMaterializedResult().toTestTypes();
actualResults = actualQueryRunner.execute(session, actual).toTestTypes();

代码示例来源:origin: prestodb/presto

private void assertOneNotNullResult(String query)
{
MaterializedResult results = getQueryRunner().execute(getSession(), query).toTestTypes();
assertEquals(results.getRowCount(), 1);
assertEquals(results.getMaterializedRows().get(0).getFieldCount(), 1);
assertNotNull(results.getMaterializedRows().get(0).getField(0));
}
}

代码示例来源:origin: prestodb/presto

@Override
public void testDescribeTable()
{
// Override base class because table descriptions for Accumulo connector include comments
MaterializedResult actual = computeActual("DESC ORDERS").toTestTypes();
assertEquals(actual.getMaterializedRows().get(0).getField(0), "orderkey");
assertEquals(actual.getMaterializedRows().get(0).getField(1), "bigint");
assertEquals(actual.getMaterializedRows().get(1).getField(0), "custkey");
assertEquals(actual.getMaterializedRows().get(1).getField(1), "bigint");
assertEquals(actual.getMaterializedRows().get(2).getField(0), "orderstatus");
assertEquals(actual.getMaterializedRows().get(2).getField(1), "varchar(1)");
assertEquals(actual.getMaterializedRows().get(3).getField(0), "totalprice");
assertEquals(actual.getMaterializedRows().get(3).getField(1), "double");
assertEquals(actual.getMaterializedRows().get(4).getField(0), "orderdate");
assertEquals(actual.getMaterializedRows().get(4).getField(1), "date");
assertEquals(actual.getMaterializedRows().get(5).getField(0), "orderpriority");
assertEquals(actual.getMaterializedRows().get(5).getField(1), "varchar(15)");
assertEquals(actual.getMaterializedRows().get(6).getField(0), "clerk");
assertEquals(actual.getMaterializedRows().get(6).getField(1), "varchar(15)");
assertEquals(actual.getMaterializedRows().get(7).getField(0), "shippriority");
assertEquals(actual.getMaterializedRows().get(7).getField(1), "integer");
assertEquals(actual.getMaterializedRows().get(8).getField(0), "comment");
assertEquals(actual.getMaterializedRows().get(8).getField(1), "varchar(79)");
}
}

代码示例来源:origin: prestodb/presto

public void assertQuery(@Language("SQL") String actual, @Language("SQL") String expected, boolean ensureOrdering)
{
MaterializedResult actualResults = null;
try {
actualResults = runner.execute(runner.getDefaultSession(), actual).toTestTypes();
}
catch (RuntimeException ex) {
fail("Execution of 'actual' query failed: " + actual, ex);
}
MaterializedResult expectedResults = null;
try {
expectedResults = runner.execute(runner.getDefaultSession(), expected).toTestTypes();
}
catch (RuntimeException ex) {
fail("Execution of 'expected' query failed: " + expected, ex);
}
assertEquals(actualResults.getTypes(), expectedResults.getTypes(), "Types mismatch for query: \n " + actual + "\n:");
List actualRows = actualResults.getMaterializedRows();
List expectedRows = expectedResults.getMaterializedRows();
if (ensureOrdering) {
if (!actualRows.equals(expectedRows)) {
assertEquals(actualRows, expectedRows, "For query: \n " + actual + "\n:");
}
}
else {
assertEqualsIgnoreOrder(actualRows, expectedRows, "For query: \n " + actual);
}
}

代码示例来源:origin: prestodb/presto

private void assertOneNotNullResult(@Language("SQL") String query)
{
MaterializedResult results = getQueryRunner().execute(getSession(), query).toTestTypes();
assertEquals(results.getRowCount(), 1);
assertEquals(results.getMaterializedRows().get(0).getFieldCount(), 1);
assertNotNull(results.getMaterializedRows().get(0).getField(0));
}

代码示例来源:origin: prestodb/presto

@Override
@Test
public void testShowSchemas()
{
MaterializedResult actualSchemas = computeActual("SHOW SCHEMAS").toTestTypes();
MaterializedResult.Builder resultBuilder = MaterializedResult.resultBuilder(getQueryRunner().getDefaultSession(), VARCHAR)
.row("tiny")
.row("sf1");
assertContains(actualSchemas, resultBuilder.build());
}
}

代码示例来源:origin: prestodb/presto

@Test
@Override
public void testDescribeTable()
{
MaterializedResult actualColumns = computeActual("DESC orders").toTestTypes();
MaterializedResult.Builder builder = resultBuilder(getQueryRunner().getDefaultSession(), VARCHAR, VARCHAR, VARCHAR, VARCHAR);
for (MaterializedRow row : actualColumns.getMaterializedRows()) {
builder.row(row.getField(0), row.getField(1), "", "");
}
MaterializedResult actualResult = builder.build();
builder = resultBuilder(getQueryRunner().getDefaultSession(), VARCHAR, VARCHAR, VARCHAR, VARCHAR);
MaterializedResult expectedColumns = builder
.row("orderkey", "bigint", "", "")
.row("custkey", "bigint", "", "")
.row("orderstatus", "varchar", "", "")
.row("totalprice", "double", "", "")
.row("orderdate", "varchar", "", "")
.row("orderpriority", "varchar", "", "")
.row("clerk", "varchar", "", "")
.row("shippriority", "bigint", "", "")
.row("comment", "varchar", "", "").build();
assertEquals(actualResult, expectedColumns, format("%s != %s", actualResult, expectedColumns));
}
}

代码示例来源:origin: prestodb/presto

/**
* Overrides original implementation because of usage of 'extra' column.
*/
@Test
@Override
public void testDescribeTable()
{
MaterializedResult actualColumns = this.computeActual("DESC orders").toTestTypes();
MaterializedResult.Builder builder = MaterializedResult.resultBuilder(this.getQueryRunner().getDefaultSession(), VarcharType.VARCHAR, VarcharType.VARCHAR, VarcharType.VARCHAR, VarcharType.VARCHAR);
for (MaterializedRow row : actualColumns.getMaterializedRows()) {
builder.row(row.getField(0), row.getField(1), "", "");
}
MaterializedResult filteredActual = builder.build();
builder = MaterializedResult.resultBuilder(this.getQueryRunner().getDefaultSession(), VarcharType.VARCHAR, VarcharType.VARCHAR, VarcharType.VARCHAR, VarcharType.VARCHAR);
MaterializedResult expectedColumns = builder
.row("orderkey", "bigint", "", "")
.row("custkey", "bigint", "", "")
.row("orderstatus", "varchar", "", "")
.row("totalprice", "double", "", "")
.row("orderdate", "varchar", "", "")
.row("orderpriority", "varchar", "", "")
.row("clerk", "varchar", "", "")
.row("shippriority", "integer", "", "")
.row("comment", "varchar", "", "").build();
assertEquals(filteredActual, expectedColumns, String.format("%s != %s", filteredActual, expectedColumns));
}

代码示例来源:origin: prestodb/presto

@Override
public void testDescribeTable()
{
// we need specific implementation of this tests due to specific Presto<->Mysql varchar length mapping.
MaterializedResult actualColumns = computeActual("DESC ORDERS").toTestTypes();
MaterializedResult expectedColumns = MaterializedResult.resultBuilder(getQueryRunner().getDefaultSession(), VARCHAR, VARCHAR, VARCHAR, VARCHAR)
.row("orderkey", "bigint", "", "")
.row("custkey", "bigint", "", "")
.row("orderstatus", "varchar(255)", "", "")
.row("totalprice", "double", "", "")
.row("orderdate", "date", "", "")
.row("orderpriority", "varchar(255)", "", "")
.row("clerk", "varchar(255)", "", "")
.row("shippriority", "integer", "", "")
.row("comment", "varchar(255)", "", "")
.build();
assertEquals(actualColumns, expectedColumns);
}

代码示例来源:origin: com.facebook.presto/presto-tests

@Test
public void testDescribeTable()
{
MaterializedResult actualColumns = computeActual("DESC orders").toTestTypes();
assertEquals(actualColumns, getExpectedOrdersTableDescription(isDateTypeSupported(), isParameterizedVarcharSupported()));
}

代码示例来源:origin: com.facebook.presto/presto-tests

@Test
public void testShowTables()
{
MaterializedResult actualTables = computeActual("SHOW TABLES").toTestTypes();
MaterializedResult expectedTables = MaterializedResult.resultBuilder(getQueryRunner().getDefaultSession(), VARCHAR)
.row("orders")
.build();
assertContains(actualTables, expectedTables);
}

代码示例来源:origin: com.facebook.presto/presto-tests

@Test
public void testShowSchemas()
{
MaterializedResult actualSchemas = computeActual("SHOW SCHEMAS").toTestTypes();
MaterializedResult.Builder resultBuilder = MaterializedResult.resultBuilder(getQueryRunner().getDefaultSession(), VARCHAR)
.row(getQueryRunner().getDefaultSession().getSchema().orElse("tpch"));
assertContains(actualSchemas, resultBuilder.build());
}

推荐阅读
  • 本文详细介绍了Java中org.neo4j.helpers.collection.Iterators.single()方法的功能、使用场景及代码示例,帮助开发者更好地理解和应用该方法。 ... [详细]
  • 优化ListView性能
    本文深入探讨了如何通过多种技术手段优化ListView的性能,包括视图复用、ViewHolder模式、分批加载数据、图片优化及内存管理等。这些方法能够显著提升应用的响应速度和用户体验。 ... [详细]
  • 本文详细介绍了Java中org.eclipse.ui.forms.widgets.ExpandableComposite类的addExpansionListener()方法,并提供了多个实际代码示例,帮助开发者更好地理解和使用该方法。这些示例来源于多个知名开源项目,具有很高的参考价值。 ... [详细]
  • 本文详细介绍了Java编程语言中的核心概念和常见面试问题,包括集合类、数据结构、线程处理、Java虚拟机(JVM)、HTTP协议以及Git操作等方面的内容。通过深入分析每个主题,帮助读者更好地理解Java的关键特性和最佳实践。 ... [详细]
  • 扫描线三巨头 hdu1928hdu 1255  hdu 1542 [POJ 1151]
    学习链接:http:blog.csdn.netlwt36articledetails48908031学习扫描线主要学习的是一种扫描的思想,后期可以求解很 ... [详细]
  • 本文详细介绍了 GWT 中 PopupPanel 类的 onKeyDownPreview 方法,提供了多个代码示例及应用场景,帮助开发者更好地理解和使用该方法。 ... [详细]
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • Java 中 Writer flush()方法,示例 ... [详细]
  • 主要用了2个类来实现的,话不多说,直接看运行结果,然后在奉上源代码1.Index.javaimportjava.awt.Color;im ... [详细]
  • 本文介绍了如何使用JQuery实现省市二级联动和表单验证。首先,通过change事件监听用户选择的省份,并动态加载对应的城市列表。其次,详细讲解了使用Validation插件进行表单验证的方法,包括内置规则、自定义规则及实时验证功能。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 在金融和会计领域,准确无误地填写票据和结算凭证至关重要。这些文件不仅是支付结算和现金收付的重要依据,还直接关系到交易的安全性和准确性。本文介绍了一种使用C语言实现小写金额转换为大写金额的方法,确保数据的标准化和规范化。 ... [详细]
  • Android LED 数字字体的应用与实现
    本文介绍了一种适用于 Android 应用的 LED 数字字体(digital font),并详细描述了其在 UI 设计中的应用场景及其实现方法。这种字体常用于视频、广告倒计时等场景,能够增强视觉效果。 ... [详细]
  • 本文详细介绍了Java中org.w3c.dom.Text类的splitText()方法,通过多个代码示例展示了其实际应用。该方法用于将文本节点在指定位置拆分为两个节点,并保持在文档树中。 ... [详细]
  • 本文详细介绍了 Apache Jena 库中的 Txn.executeWrite 方法,通过多个实际代码示例展示了其在不同场景下的应用,帮助开发者更好地理解和使用该方法。 ... [详细]
author-avatar
Aqingking_577
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有