@Test public void testPickLayoutAnyPreference() throws Exception { Comparator<ActualProperties> preference = streamingExecutionPreference(PreferredProperties.any()); List<ActualProperties> input = ImmutableList.<ActualProperties>builder() .add(builder().global(streamPartitionedOn(ALL_COLUMNS)).build()) .add(builder().global(singleStreamPartition()).build()) .add( builder() .global(arbitraryPartition()) .local(ImmutableList.of(grouped("a", "b"))) .build()) .add(builder().global(arbitraryPartition()).build()) .add(builder().global(hashDistributedOn("a")).build()) .add( builder() .global(singleStream()) .local(ImmutableList.of(constant("a"), sorted("b", ASC_NULLS_FIRST))) .build()) .add( builder() .global(singleStreamPartition()) .local(ImmutableList.of(sorted("a", ASC_NULLS_FIRST))) .build()) .build(); // Given no preferences, the original input order should be maintained Assert.assertEquals(stableSort(input, preference), input); }
@Test public void testPickLayoutPartitionedWithGroup() throws Exception { Comparator<ActualProperties> preference = streamingExecutionPreference( PreferredProperties.partitionedWithLocal( ImmutableSet.of(symbol("a")), ImmutableList.of(grouped("a")))); List<ActualProperties> input = ImmutableList.<ActualProperties>builder() .add(builder().global(streamPartitionedOn("a")).build()) .add(builder().global(singleStreamPartition()).build()) .add( builder() .global(arbitraryPartition()) .local(ImmutableList.of(grouped("a", "b"))) .build()) .add(builder().global(arbitraryPartition()).build()) .add(builder().global(hashDistributedOn("a")).build()) .add( builder() .global(singleStream()) .local(ImmutableList.of(constant("a"), sorted("b", ASC_NULLS_FIRST))) .build()) .add( builder() .global(singleStreamPartition()) .local(ImmutableList.of(sorted("a", ASC_NULLS_FIRST))) .build()) .add(builder().global(hashDistributedOn("a")).build()) .build(); List<ActualProperties> expected = ImmutableList.<ActualProperties>builder() .add( builder() .global(singleStream()) .local(ImmutableList.of(constant("a"), sorted("b", ASC_NULLS_FIRST))) .build()) .add( builder() .global(singleStreamPartition()) .local(ImmutableList.of(sorted("a", ASC_NULLS_FIRST))) .build()) .add(builder().global(streamPartitionedOn("a")).build()) .add(builder().global(singleStreamPartition()).build()) .add(builder().global(hashDistributedOn("a")).build()) .add(builder().global(hashDistributedOn("a")).build()) .add( builder() .global(arbitraryPartition()) .local(ImmutableList.of(grouped("a", "b"))) .build()) .add(builder().global(arbitraryPartition()).build()) .build(); Assert.assertEquals(stableSort(input, preference), expected); }