热门标签 | 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());
}

推荐阅读
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社区 版权所有