ParameterPushdown implements PushDownType { @Override public ListenableFuture<Boolean> activate( DataServiceExecutor executor, PushDownOptimizationMeta meta ) { Map<String, String> parameterValues = captureParameterValues( executor.getSql() ); executor.getParameters().putAll( parameterValues ); return Futures.immediateFuture( !parameterValues.isEmpty() ); }  List<Definition> getDefinitions(); Definition createDefinition(); @Override void init( TransMeta transMeta, DataServiceMeta dataService, PushDownOptimizationMeta optMeta ); @Override ListenableFuture<Boolean> activate( DataServiceExecutor executor, PushDownOptimizationMeta meta ); @Override OptimizationImpactInfo preview( DataServiceExecutor executor, PushDownOptimizationMeta meta ); static final String DEFINITIONS_LIST_ATTRIBUTE; static final String PARAMETER_ATTRIBUTE; static final String FIELD_NAME_ATTRIBUTE; static final String FORMAT_ATTRIBUTE; static final String DEFAULT_FORMAT; static final String PARAMETER_PREFIX; }
@Test public void testActivate() throws Exception { query( "WHERE ALBUM IN ('Thick as a Brick', 'Aqualung')" ); assertThat( parameterPushdown.activate( executor, optimizationMeta ).get( 5, TimeUnit.SECONDS ), is( false ) ); verifyActivate( Collections.<String, String>emptyMap() ); query( "WHERE ( ARTIST = 'The Doors' AND ALBUM = 'Morrison Hotel' ) OR " + "( ARTIST = 'The Kinks' AND ALBUM = 'Lola Versus Powerman and the Money-Go-Round, Pt. 1' )" ); verifyActivate( Collections.<String, String>emptyMap() ); query( "WHERE ARTIST = 'Queen' OR ALBUM LIKE '% at the %' " ); verifyActivate( Collections.<String, String>emptyMap() ); query( "WHERE ALBUM = ARTIST" ); verifyActivate( Collections.<String, String>emptyMap() ); query( "WHERE ARTIST = 'The Who' AND ( ALBUM IN ( 'Tommy', 'Quadrophenia' ) OR LIVE = true )" ); verifyActivate( ImmutableMap.of( "ARTIST_FIELD", "artist: \"The Who\"," ) ); query( "WHERE ARTIST = 'Pink Floyd' AND ALBUM = 'Atom Heart Mother' AND LIVE = true" ); verifyActivate( ImmutableMap.of( "ARTIST_FIELD", "artist: \"Pink Floyd\",", "ALBUM_FIELD", "album: \"Atom Heart Mother\",", "LIVE_FIELD", "true" ) ); query( "WHERE ARTIST IN ('Led Zeppelin', 'Deep Purple') AND LIVE = true" ); verifyActivate( ImmutableMap.of( "LIVE_FIELD", "true" ) ); }