@Test public void testDoesNotFire() { tester().assertThat(new PushLimitThroughMarkDistinct()) .on(p -> p.markDistinct( p.symbol("foo"), ImmutableList.of(p.symbol("bar")), p.limit( 1, p.values()))) .doesNotFire(); } }
@Test public void testKeySymbolNotReferenced() { tester().assertThat(new PruneMarkDistinctColumns()) .on(p -> { Symbol key = p.symbol("key"); Symbol mark = p.symbol("mark"); return p.project( Assignments.identity(mark), p.markDistinct(mark, ImmutableList.of(key), p.values(key))); }) .doesNotFire(); }
@Test public void testAllOutputsReferenced() { tester().assertThat(new PruneMarkDistinctColumns()) .on(p -> { Symbol key = p.symbol("key"); Symbol mark = p.symbol("mark"); return p.project( Assignments.identity(key, mark), p.markDistinct(mark, ImmutableList.of(key), p.values(key))); }) .doesNotFire(); } }
@Test public void test() { tester().assertThat(new PushLimitThroughMarkDistinct()) .on(p -> p.limit( 1, p.markDistinct( p.symbol("foo"), ImmutableList.of(p.symbol("bar")), p.values()))) .matches( node(MarkDistinctNode.class, node(LimitNode.class, node(ValuesNode.class)))); }
@Test public void testMarkerSymbolNotReferenced() { tester().assertThat(new PruneMarkDistinctColumns()) .on(p -> { Symbol key = p.symbol("key"); Symbol key2 = p.symbol("key2"); Symbol mark = p.symbol("mark"); Symbol unused = p.symbol("unused"); return p.project( Assignments.of(key2, key.toSymbolReference()), p.markDistinct(mark, ImmutableList.of(key), p.values(key, unused))); }) .matches( strictProject( ImmutableMap.of("key2", expression("key")), values(ImmutableList.of("key", "unused")))); }
@Test public void testSourceSymbolNotReferenced() { tester().assertThat(new PruneMarkDistinctColumns()) .on(p -> { Symbol key = p.symbol("key"); Symbol mark = p.symbol("mark"); Symbol hash = p.symbol("hash"); Symbol unused = p.symbol("unused"); return p.project( Assignments.identity(mark), p.markDistinct( mark, ImmutableList.of(key), hash, p.values(key, hash, unused))); }) .matches( strictProject( ImmutableMap.of("mark", expression("mark")), markDistinct("mark", ImmutableList.of("key"), "hash", strictProject( ImmutableMap.of( "key", expression("key"), "hash", expression("hash")), values(ImmutableList.of("key", "hash", "unused")))))); }