Skip to content

Commit

Permalink
Add LIMIT queries to info schema tests
Browse files Browse the repository at this point in the history
The numbers of tables in "test_schema1" and "test_schema2" are reduced
because the added queries have full scans as sub-queries. The original
numbers are too large and may crash workers during product tests.
  • Loading branch information
lxynov authored and kokosing committed Oct 11, 2019
1 parent 20fa9aa commit 219a6d8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ public static class BenchmarkData
private final Map<String, String> queries = ImmutableMap.of(
"FULL_SCAN", "SELECT count(*) FROM information_schema.columns",
"LIKE_PREDICATE", "SELECT count(*) FROM information_schema.columns WHERE table_name LIKE 'table_0' AND table_schema LIKE 'schema_0'",
"MIXED_PREDICATE", "SELECT count(*) FROM information_schema.columns WHERE table_name LIKE 'table_0' AND table_schema = 'schema_0'");
"MIXED_PREDICATE", "SELECT count(*) FROM information_schema.columns WHERE table_name LIKE 'table_0' AND table_schema = 'schema_0'",
"LIMIT_SCAN", "SELECT column_name FROM information_schema.columns LIMIT 100");

@Param({"FULL_SCAN", "LIKE_PREDICATE", "MIXED_PREDICATE"})
@Param({"FULL_SCAN", "LIKE_PREDICATE", "MIXED_PREDICATE", "LIMIT_SCAN"})
private String queryId = "LIKE_PREDICATE";
@Param("200")
private String schemasCount = "200";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ public void testProject()
assertQuery("SELECT column_name, data_type FROM tpch.information_schema.columns ORDER BY 1 DESC, 2 DESC LIMIT 1", "VALUES ('with_hierarchy', 'varchar')");
}


@Test
public void testLimit()
{
assertQuery("SELECT count(*) FROM (SELECT * from tpch.information_schema.columns LIMIT 1)", "VALUES 1");
assertQuery("SELECT count(*) FROM (SELECT * FROM tpch.information_schema.columns LIMIT 100)", "VALUES 100");
assertQuery("SELECT count(*) FROM (SELECT * FROM test_catalog.information_schema.tables LIMIT 10000)", "VALUES 10000");
}

@Test(timeOut = 60_000)
public void testMetadataCalls()
{
Expand All @@ -122,24 +131,24 @@ public void testMetadataCalls()
.withListSchemasCount(1));
assertMetadataCalls(
"SELECT count(*) from test_catalog.information_schema.tables",
"VALUES 300008",
"VALUES 30008",
new MetadataCallsCount()
.withListSchemasCount(1)
.withListTablesCount(2));
assertMetadataCalls(
"SELECT count(*) from test_catalog.information_schema.tables WHERE table_schema = 'test_schema1'",
"VALUES 100000",
"VALUES 10000",
new MetadataCallsCount()
.withListTablesCount(1));
assertMetadataCalls(
"SELECT count(*) from test_catalog.information_schema.tables WHERE table_schema LIKE 'test_sch_ma1'",
"VALUES 100000",
"VALUES 10000",
new MetadataCallsCount()
.withListSchemasCount(1)
.withListTablesCount(1));
assertMetadataCalls(
"SELECT count(*) from test_catalog.information_schema.tables WHERE table_schema LIKE 'test_sch_ma1' AND table_schema IN ('test_schema1', 'test_schema2')",
"VALUES 100000",
"VALUES 10000",
new MetadataCallsCount()
.withListTablesCount(2));
assertMetadataCalls(
Expand Down Expand Up @@ -175,6 +184,20 @@ public void testMetadataCalls()
"VALUES 0",
new MetadataCallsCount()
.withListTablesCount(1));
assertMetadataCalls(
"SELECT count(*) FROM (SELECT * from test_catalog.information_schema.columns LIMIT 1)",
"VALUES 1",
new MetadataCallsCount()
.withListSchemasCount(1)
.withListTablesCount(2)
.withGetColumnsCount(30000));
assertMetadataCalls(
"SELECT count(*) FROM (SELECT * from test_catalog.information_schema.columns LIMIT 10000)",
"VALUES 10000",
new MetadataCallsCount()
.withListSchemasCount(1)
.withListTablesCount(2)
.withGetColumnsCount(30000));
}

private static DistributedQueryRunner createQueryRunner()
Expand All @@ -193,10 +216,10 @@ private static DistributedQueryRunner createQueryRunner()
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
List<SchemaTableName> tablesTestSchema1 = IntStream.range(0, 100000)
List<SchemaTableName> tablesTestSchema1 = IntStream.range(0, 10000)
.mapToObj(i -> new SchemaTableName("test_schema1", "test_table" + i))
.collect(toImmutableList());
List<SchemaTableName> tablesTestSchema2 = IntStream.range(0, 200000)
List<SchemaTableName> tablesTestSchema2 = IntStream.range(0, 20000)
.mapToObj(i -> new SchemaTableName("test_schema2", "test_table" + i))
.collect(toImmutableList());
List<SchemaTableName> tablesInformationSchema = Arrays.stream(InformationSchemaTable.values())
Expand Down

0 comments on commit 219a6d8

Please sign in to comment.