3939import io .trino .spi .connector .ConnectorTransactionHandle ;
4040import io .trino .spi .connector .Constraint ;
4141import io .trino .spi .connector .DynamicFilter ;
42+ import io .trino .spi .connector .DynamicFilterSnapshot ;
4243import io .trino .spi .connector .EmptyPageSource ;
4344import io .trino .spi .predicate .Domain ;
4445import io .trino .spi .predicate .Range ;
6263import java .util .Set ;
6364import java .util .concurrent .CompletableFuture ;
6465import java .util .concurrent .atomic .AtomicBoolean ;
66+ import java .util .concurrent .atomic .AtomicReference ;
6567import java .util .function .Consumer ;
6668import java .util .stream .LongStream ;
6769
@@ -106,7 +108,7 @@ public abstract class AbstractTestCoordinatorDynamicFiltering
106108 public void setup ()
107109 {
108110 // create lineitem table in test connector
109- getQueryRunner ().installPlugin (new TestingPlugin (getRetryPolicy () == RetryPolicy . TASK ));
111+ getQueryRunner ().installPlugin (new TestingPlugin ());
110112 getQueryRunner ().installPlugin (new TpchPlugin ());
111113 getQueryRunner ().installPlugin (new TpcdsPlugin ());
112114 getQueryRunner ().installPlugin (new MemoryPlugin ());
@@ -474,12 +476,7 @@ protected void assertQueryDynamicFilters(
474476 private class TestingPlugin
475477 implements Plugin
476478 {
477- private final boolean isTaskRetryMode ;
478-
479- public TestingPlugin (boolean isTaskRetryMode )
480- {
481- this .isTaskRetryMode = isTaskRetryMode ;
482- }
479+ public TestingPlugin () {}
483480
484481 @ Override
485482 public Iterable <ConnectorFactory > getConnectorFactories ()
@@ -497,7 +494,7 @@ public String getName()
497494 @ Override
498495 public Connector create (String catalogName , Map <String , String > config , ConnectorContext context )
499496 {
500- return new TestConnector (metadata , isTaskRetryMode );
497+ return new TestConnector (metadata );
501498 }
502499 });
503500 }
@@ -507,12 +504,10 @@ private class TestConnector
507504 implements Connector
508505 {
509506 private final ConnectorMetadata metadata ;
510- private final boolean isTaskRetryMode ;
511507
512- private TestConnector (ConnectorMetadata metadata , boolean isTaskRetryMode )
508+ private TestConnector (ConnectorMetadata metadata )
513509 {
514510 this .metadata = requireNonNull (metadata , "metadata is null" );
515- this .isTaskRetryMode = isTaskRetryMode ;
516511 }
517512
518513 @ Override
@@ -537,37 +532,32 @@ public ConnectorSplitSource getSplits(
537532 ConnectorTransactionHandle transaction ,
538533 ConnectorSession session ,
539534 ConnectorTableHandle table ,
540- DynamicFilter dynamicFilter ,
535+ Set < ColumnHandle > dynamicFilterColumns ,
541536 Constraint constraint )
542537 {
543- if (!isTaskRetryMode ) {
544- // In task retry mode, dynamic filter collection is done outside the join stage,
545- // so it's not necessary that dynamicFilter will be blocked initially.
546- assertThat (dynamicFilter .isBlocked ().isDone ())
547- .describedAs ("Dynamic filter should be initially blocked" )
548- .isFalse ();
549- }
550- assertThat (dynamicFilter .getColumnsCovered ())
538+ assertThat (dynamicFilterColumns )
551539 .describedAs ("columns covered" )
552540 .isEqualTo (expectedDynamicFilterColumnsCovered );
553541
554542 AtomicBoolean splitProduced = new AtomicBoolean ();
543+ AtomicReference <TupleDomain <ColumnHandle >> capturedPredicate = new AtomicReference <>();
555544 return new ConnectorSplitSource ()
556545 {
557546 @ Override
558- public CompletableFuture < ConnectorSplitBatch > getNextBatch ( int maxSize )
547+ public long getRequestedDynamicFilterWaitTimeoutMillis ( )
559548 {
560- CompletableFuture <?> blocked = dynamicFilter .isBlocked ();
549+ return Long .MAX_VALUE ;
550+ }
561551
562- if (blocked .isDone ()) {
563- splitProduced .set (true );
564- return completedFuture (new ConnectorSplitBatch (ImmutableList .of (createRemoteSplit ()), isFinished ()));
552+ @ Override
553+ public CompletableFuture <List <ConnectorSplit >> getNextBatch (int maxSize , DynamicFilterSnapshot dynamicFilterSnapshot )
554+ {
555+ if (!dynamicFilterSnapshot .isComplete ()) {
556+ return completedFuture (ImmutableList .of ());
565557 }
566-
567- return blocked .thenApply (_ -> {
568- // yield until dynamic filter is fully loaded
569- return new ConnectorSplitBatch (ImmutableList .of (), false );
570- });
558+ capturedPredicate .set (dynamicFilterSnapshot .currentPredicate ());
559+ splitProduced .set (true );
560+ return completedFuture (ImmutableList .of (createRemoteSplit ()));
571561 }
572562
573563 @ Override
@@ -576,17 +566,15 @@ public void close() {}
576566 @ Override
577567 public boolean isFinished ()
578568 {
579- assertThat (dynamicFilter . getColumnsCovered () )
569+ assertThat (dynamicFilterColumns )
580570 .describedAs ("columns covered" )
581571 .isEqualTo (expectedDynamicFilterColumnsCovered );
582572
583- if (!dynamicFilter . isComplete () || ! splitProduced .get ()) {
573+ if (!splitProduced .get ()) {
584574 return false ;
585575 }
586576
587- assertThat (dynamicFilter .isBlocked ().isDone ()).isTrue ();
588- expectedCoordinatorDynamicFilterAssertion .accept (dynamicFilter .getCurrentPredicate ());
589-
577+ expectedCoordinatorDynamicFilterAssertion .accept (capturedPredicate .get ());
590578 return true ;
591579 }
592580 };
0 commit comments