Source:
<code>public void subsetComesFirst() { String columnAAlias = "ALIAS_A"; String columnBAlias = "ALIAS_B"; ExpectedValueProvider<WindowNode.Specification> specificationA = specification(ImmutableList.of(columnAAlias), ImmutableList.of(), ImmutableMap.of()); ExpectedValueProvider<WindowNode.Specification> specificationAB = specification(ImmutableList.of(columnAAlias, columnBAlias), ImmutableList.of(), ImmutableMap.of()); Optional<Window> windowAB = Optional.of(new Window(ImmutableList.of(new SymbolReference("a"), new SymbolReference("b")), Optional.empty(), Optional.empty())); Optional<Window> windowA = Optional.of(new Window(ImmutableList.of(new SymbolReference("a")), Optional.empty(), Optional.empty())); tester().assertThat(new GatherAndMergeWindows.SwapAdjacentWindowsBySpecifications(0)) .on(p -> p.window(new WindowNode.Specification( ImmutableList.of(p.symbol("a")), <START> new OrderingScheme( <END> ImmutableList.of(), ImmutableMap.of())), ImmutableMap.of(p.symbol("avg_1", DOUBLE), new WindowNode.Function(new FunctionCall(QualifiedName.of("avg"), windowA, false, ImmutableList.of(new SymbolReference("a"))), signature, frame)), p.window(new WindowNode.Specification( ImmutableList.of(p.symbol("a"), p.symbol("b")), new OrderingScheme( ImmutableList.of(), ImmutableMap.of())), ImmutableMap.of(p.symbol("avg_2", DOUBLE), new WindowNode.Function(new FunctionCall(QualifiedName.of("avg"), windowAB, false, ImmutableList.of(new SymbolReference("b"))), signature, frame)), p.values(p.symbol("a"), p.symbol("b"))))) .matches( window(windowMatcherBuilder -> windowMatcherBuilder .specification(specificationAB) .addFunction(functionCall("avg", Optional.empty(), ImmutableList.of(columnBAlias))), window(windowMatcherBuilder -> windowMatcherBuilder .specification(specificationA) .addFunction(functionCall("avg", Optional.empty(), ImmutableList.of(columnAAlias))), values(ImmutableMap.of(columnAAlias, 0, columnBAlias, 1))))); }</code><technical_language>OrderingScheme.empty()</technical_language>

Target:
public void subsetComesFirst() { String columnAAlias = "ALIAS_A"; String columnBAlias = "ALIAS_B"; ExpectedValueProvider<WindowNode.Specification> specificationA = specification(ImmutableList.of(columnAAlias), ImmutableList.of(), ImmutableMap.of()); ExpectedValueProvider<WindowNode.Specification> specificationAB = specification(ImmutableList.of(columnAAlias, columnBAlias), ImmutableList.of(), ImmutableMap.of()); Optional<Window> windowAB = Optional.of(new Window(ImmutableList.of(new SymbolReference("a"), new SymbolReference("b")), Optional.empty(), Optional.empty())); Optional<Window> windowA = Optional.of(new Window(ImmutableList.of(new SymbolReference("a")), Optional.empty(), Optional.empty())); tester().assertThat(new GatherAndMergeWindows.SwapAdjacentWindowsBySpecifications(0)) .on(p -> p.window(new WindowNode.Specification( ImmutableList.of(p.symbol("a")), Optional.empty()), ImmutableMap.of(p.symbol("avg_1", DOUBLE), new WindowNode.Function(new FunctionCall(QualifiedName.of("avg"), windowA, false, ImmutableList.of(new SymbolReference("a"))), signature, frame)), p.window(new WindowNode.Specification( ImmutableList.of(p.symbol("a"), p.symbol("b")), Optional.empty()), ImmutableMap.of(p.symbol("avg_2", DOUBLE), new WindowNode.Function(new FunctionCall(QualifiedName.of("avg"), windowAB, false, ImmutableList.of(new SymbolReference("b"))), signature, frame)), p.values(p.symbol("a"), p.symbol("b"))))) .matches( window(windowMatcherBuilder -> windowMatcherBuilder .specification(specificationAB) .addFunction(functionCall("avg", Optional.empty(), ImmutableList.of(columnBAlias))), window(windowMatcherBuilder -> windowMatcherBuilder .specification(specificationA) .addFunction(functionCall("avg", Optional.empty(), ImmutableList.of(columnAAlias))), values(ImmutableMap.of(columnAAlias, 0, columnBAlias, 1))))); }