@Test public void testExampleSystemTable() { assertQuery("SELECT name FROM sys.example", "SELECT 'test' AS name"); MaterializedResult result = computeActual("SHOW SCHEMAS"); assertTrue(result.getOnlyColumnAsSet().containsAll(ImmutableSet.of("sf100", "tiny", "sys"))); result = computeActual("SHOW TABLES FROM sys"); assertEquals(result.getOnlyColumnAsSet(), ImmutableSet.of("example")); }
@Test public void testGroupingOperationAllBitsSet() { List<Integer> groupingOrdinals = ImmutableList.of(0, 4, 8); List<Set<Integer>> groupingSetOrdinals = ImmutableList.of(ImmutableSet.of(1), ImmutableSet.of(7, 3, 1), ImmutableSet.of(9, 1)); for (Set<Integer> groupingSet : groupingSetOrdinals) { assertEquals(calculateGrouping(groupingSet, groupingOrdinals), 7L); } }
@Test public void testGetDatasourceFullWithInterval() { Map<String, Object> actual = resource.getDatasource(dataSource, "1975/2015", "true"); Map<String, Object> expected = ImmutableMap.of( "2014-02-13T00:00:00.000Z/2014-02-15T00:00:00.000Z", ImmutableMap.of(KEY_DIMENSIONS, ImmutableSet.of("d1"), KEY_METRICS, ImmutableSet.of("m1")), "2014-02-16T00:00:00.000Z/2014-02-17T00:00:00.000Z", ImmutableMap.of(KEY_DIMENSIONS, ImmutableSet.of("d1"), KEY_METRICS, ImmutableSet.of("m1")), "2014-02-17T00:00:00.000Z/2014-02-18T00:00:00.000Z", ImmutableMap.of(KEY_DIMENSIONS, ImmutableSet.of("d2"), KEY_METRICS, ImmutableSet.of("m2")) ); EasyMock.verify(serverInventoryView, timelineServerView); Assert.assertEquals(expected, actual); }
@Test public void testGetAllTiers() { Assert.assertEquals( ImmutableSet.of("tier1", "tier2"), lookupNodeDiscovery.getAllTiers() ); EasyMock.verify(druidNodeDiscoveryProvider, druidNodeDiscovery); } }
@Test public void createUndirected_expectedNodeCount() { MutableNetwork<Integer, String> undirectedGraph = NetworkBuilder.undirected().expectedNodeCount(NODE_COUNT).build(); assertThat(undirectedGraph.addEdge(N1, N2, E12)).isTrue(); assertThat(undirectedGraph.edgesConnecting(N1, N2)).isEqualTo(ImmutableSet.of(E12)); assertThat(undirectedGraph.edgesConnecting(N2, N1)).isEqualTo(ImmutableSet.of(E12)); }
@Test public void testSerdeWithKillAllDataSources() throws Exception ); assertConfig(actual, 1, 1, 1, 1, 1, 1, 2, true, ImmutableSet.of(), true, 1); Assert.assertTrue(e.getCause() instanceof IAE);
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Final aggregation with default value not separated from partial aggregation by remote hash exchange") public void testGloballyDistributedFinalAggregationInTheSameStageAsPartialAggregation() { PlanNode root = builder.aggregation( af -> af.step(FINAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(builder.aggregation(ap -> ap .step(PARTIAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(tableScanNode)))); validatePlan(root, false); }
@Test public void testGetDatasourceWithDefaultInterval() { Map<String, Object> actual = resource.getDatasource(dataSource, null, null); Map<String, Object> expected = ImmutableMap.of(KEY_DIMENSIONS, ImmutableSet.of(), KEY_METRICS, ImmutableSet.of()); Assert.assertEquals(expected, actual); }
@Test public void testGetTableMap() { Assert.assertEquals(ImmutableSet.of("foo", "foo2"), schema.getTableNames()); final Map<String, Table> tableMap = schema.getTableMap(); Assert.assertEquals(ImmutableSet.of("foo", "foo2"), tableMap.keySet()); }
@Test public void createUndirected_expectedEdgeCount() { MutableNetwork<Integer, String> undirectedGraph = NetworkBuilder.undirected().expectedEdgeCount(EDGE_COUNT).build(); assertThat(undirectedGraph.addEdge(N1, N2, E12)).isTrue(); assertThat(undirectedGraph.edgesConnecting(N1, N2)).isEqualTo(ImmutableSet.of(E12)); assertThat(undirectedGraph.edgesConnecting(N2, N1)).isEqualTo(ImmutableSet.of(E12)); }
@Test public void testGroupingOperationSomeBitsSet() { List<Integer> groupingOrdinals = ImmutableList.of(7, 2, 9, 3, 5); List<Set<Integer>> groupingSetOrdinals = ImmutableList.of(ImmutableSet.of(4, 2), ImmutableSet.of(9, 7, 14), ImmutableSet.of(5, 2, 7), ImmutableSet.of(3)); List<Long> expectedResults = ImmutableList.of(23L, 11L, 6L, 29L); for (int groupId = 0; groupId < groupingSetOrdinals.size(); groupId++) { Set<Integer> groupingSet = groupingSetOrdinals.get(groupId); assertEquals(Long.valueOf(calculateGrouping(groupingSet, groupingOrdinals)), expectedResults.get(groupId)); } }
@Test public void testIncompletePartitionDoesNotOvershadow() { testRemove(); add("2011-10-05/2011-10-07", "6", IntegerPartitionChunk.make(null, 10, 0, 60)); Assert.assertTrue("Expected no overshadowed entries", timeline.findOvershadowed().isEmpty()); add("2011-10-05/2011-10-07", "6", IntegerPartitionChunk.make(10, 20, 1, 61)); Assert.assertTrue("Expected no overshadowed entries", timeline.findOvershadowed().isEmpty()); add("2011-10-05/2011-10-07", "6", IntegerPartitionChunk.make(20, null, 2, 62)); assertValues( ImmutableSet.of( createExpected("2011-10-05/2011-10-06", "5", 5) ), timeline.findOvershadowed() ); }
@Test public void testListSchemaNames() { assertEquals(metadata.listSchemaNames(SESSION), ImmutableSet.of("example", "tpch")); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Final aggregation with default value not separated from partial aggregation by local hash exchange") public void testSingleNodeFinalAggregationInTheSameStageAsPartialAggregation() { PlanNode root = builder.aggregation( af -> af.step(FINAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(builder.aggregation(ap -> ap .step(PARTIAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(tableScanNode)))); validatePlan(root, true); }
@Test public void testGetDatasourceNonFullWithInterval() { Map<String, Object> actual = resource.getDatasource(dataSource, "1975/2015", null); Map<String, Object> expected = ImmutableMap.of( KEY_DIMENSIONS, ImmutableSet.of("d1", "d2"), KEY_METRICS, ImmutableSet.of("m1", "m2") ); EasyMock.verify(serverInventoryView); Assert.assertEquals(expected, actual); }
@Test public void testUpdate() { CoordinatorDynamicConfig current = CoordinatorDynamicConfig.builder() .withKillDataSourceWhitelist(ImmutableSet.of("x")) .build(); Assert.assertEquals( current, new CoordinatorDynamicConfig .Builder(null, null, null, null, null, null, null, null, null, null, null, null) .build(current) ); }