Skip to content

Conversation

anlowee
Copy link

@anlowee anlowee commented Oct 8, 2025

Description

This PR can only be merged after #77 gets merged.

This PR refactored the split filter pushdown unit tests to use ClpQueryRunner.

All unit tests in TestClpFilterToKql have been moved to TestClpComputePushDown, so it can be deleted.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Passed the CI.

Summary by CodeRabbit

  • Tests

    • Added a comprehensive CLP compute-pushdown test suite validating KQL pushdown, remaining filters and metadata SQL across many predicate forms.
    • Introduced test utilities: configurable query-runner overloads, session-context wrapper, temp config file management, and improved test logging/config handling.
    • Removed legacy filter-to-KQL unit tests in favour of the new plan-based test approach.
  • Chores

    • Expanded the test classpath with an additional test-scoped dependency.

@anlowee anlowee force-pushed the xwei/add-splitfilter-runner branch from 914d2b0 to ba3674a Compare October 8, 2025 19:10
Copy link

coderabbitai bot commented Oct 8, 2025

Walkthrough

Added a test-scoped dependency on presto-main. Extended test infrastructure: new overloads and helpers in ClpQueryRunner, support for optional split-filter config, a TestingClpSessionContext, a new end-to-end pushdown test suite TestClpComputePushDown, and removal of the prior TestClpFilterToKql unit-test class.

Changes

Cohort / File(s) Summary of changes
Build: test dependency
presto-clp/pom.xml
Added com.facebook.presto:presto-main as a test-scoped dependency.
Test infra: query runner
presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpQueryRunner.java
Added public createQueryRunner overloads accepting metadata DB params, optional split-filter provider/config, workerCount, and external worker launcher; added createConfigFile and deleteConfigFile helpers; assemble CLP properties into a Map and emit final properties before catalog creation; support optional split-filter config.
Test infra: session context
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestingClpSessionContext.java
Added TestingClpSessionContext implementing SessionContext, delegating to an underlying Session and exposing catalog-scoped properties and session data for tests.
New tests: pushdown e2e
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java
Added TestClpComputePushDown with comprehensive tests that set up a mock metadata DB and split-filter config, run queries, and assert KQL/metadata SQL pushdowns and remaining filter predicates.
Removed tests: legacy pushdown suite
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpFilterToKql.java
Removed the previous unit-test class TestClpFilterToKql.java.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Tester
  participant TestClass as TestClpComputePushDown
  participant QR as ClpQueryRunner
  participant DQR as DistributedQueryRunner
  participant Cat as Catalog
  participant SF as SplitFilterConfig

  Tester->>TestClass: run suite
  TestClass->>QR: createQueryRunner(metadataDb..., splitFilterProvider?, splitFilterConfigPath?, ...)
  alt split-filter config provided
    QR->>SF: createConfigFile / provide config path
  end
  QR->>Cat: assemble clpProperties map (incl. split-provider-type, split-filter-config?)
  Cat-->>QR: catalog created
  QR-->>TestClass: DistributedQueryRunner ready
  TestClass->>DQR: execute queries / request plans
  DQR-->>TestClass: plans (KQL/metadata + remaining filters)
  TestClass->>SF: deleteConfigFile (cleanup)
Loading
sequenceDiagram
  autonumber
  actor Tester
  participant DQR as DistributedQueryRunner
  participant Planner as Planner
  participant CLP as CLP Connector
  participant SFP as SplitFilterProvider

  Tester->>DQR: plan query
  DQR->>Planner: build logical plan
  Planner->>CLP: apply connector pushdown rules
  CLP->>SFP: request split-filter (config/provider)
  SFP-->>CLP: split-filter expression
  CLP-->>Planner: KQL/metadata SQL + remaining filter
  Planner-->>Tester: final plan
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description provides a high-level summary and checklist but omits several required sections from the repository template, including Motivation and Context, Impact, Test Plan, and Release Notes, and it uses inconsistent heading levels compared to the prescribed “##” headings. Please revise the description to match the template by adding the Motivation and Context, Impact, Test Plan, and Release Notes sections, and adjust heading levels to use “##” as specified in the repository’s description_template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the primary change—refactoring the split filter pushdown unit tests—and follows the conventional commit style without extraneous details, making it clear to reviewers what the PR does.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 733f4a2 and ba3674a.

📒 Files selected for processing (5)
  • presto-clp/pom.xml (1 hunks)
  • presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpQueryRunner.java (3 hunks)
  • presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java (1 hunks)
  • presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpFilterToKql.java (0 hunks)
  • presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestingClpSessionContext.java (1 hunks)
💤 Files with no reviewable changes (1)
  • presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpFilterToKql.java
🧰 Additional context used
🧬 Code graph analysis (3)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestingClpSessionContext.java (1)
presto-main-base/src/main/java/com/facebook/presto/Session.java (1)
  • Session (76-950)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpQueryRunner.java (1)
presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpConfig.java (1)
  • ClpConfig (21-204)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java (5)
presto-main-base/src/main/java/com/facebook/presto/dispatcher/DispatchManager.java (1)
  • DispatchManager (70-472)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/mockdb/ClpMockMetadataDatabase.java (1)
  • ClpMockMetadataDatabase (49-288)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/mockdb/table/ColumnMetadataTableRows.java (1)
  • ColumnMetadataTableRows (30-63)
presto-tests/src/main/java/com/facebook/presto/tests/DistributedQueryRunner.java (1)
  • DistributedQueryRunner (108-1224)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpQueryRunner.java (1)
  • ClpQueryRunner (35-202)
🔇 Additional comments (9)
presto-clp/pom.xml (1)

108-112: LGTM!

The test-scoped dependency on presto-main appropriately supports the new test infrastructure introduced in this PR, including access to DispatchManager, SqlQueryManager, and related query execution components used by TestClpComputePushDown.

presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestingClpSessionContext.java (3)

40-43: LGTM!

The constructor correctly validates the session parameter with a null check.


52-61: LGTM!

Providing default values ("clp" and "default") for catalog and schema when absent from the session ensures consistent behavior in test contexts.


129-137: LGTM!

The conversion from ConnectorId-keyed properties to catalog-name-keyed properties is correctly implemented using Guava's ImmutableMap.builder().

presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java (2)

71-127: LGTM!

The setUp method correctly initializes the mock database, split filter configuration, and query runner. The use of Optional.of(0) for worker count appropriately creates a coordinator-only setup for testing pushdown logic.


437-456: Verify timeout handling and improve diagnostics.

The method waits up to 60 seconds for the query to reach RUNNING state. If this timeout is exceeded, the assertion at line 454 will fail, but the query may remain active and uncancelled, potentially affecting subsequent tests.

Consider these improvements:

  1. Cancel the query if the timeout is exceeded before failing the assertion.
  2. Provide a more descriptive failure message that includes the actual query state and query ID.
 private QueryId createAndPlanQuery(String filter)
             throws ExecutionException, InterruptedException
 {
     QueryId id = queryRunner.getCoordinator().getDispatchManager().createQueryId();
     @Language("SQL") String sql = format("SELECT * FROM clp.default.test_pushdown WHERE %s LIMIT 1", filter);
     dispatchManager.createQuery(
             id,
             "slug",
             0,
             new TestingClpSessionContext(queryRunner.getDefaultSession()),
             sql).get();
     long maxDispatchingAndPlanningTime = 60 * 1000L;    // 1 minute
     long currentWaitingTime = 0L;
     while (dispatchManager.getQueryInfo(id).getState().ordinal() != RUNNING.ordinal() && currentWaitingTime < maxDispatchingAndPlanningTime) {
         Thread.sleep(1000L);
         currentWaitingTime += 1000L;
     }
-    assertTrue(currentWaitingTime < maxDispatchingAndPlanningTime);
+    if (currentWaitingTime >= maxDispatchingAndPlanningTime) {
+        queryManager.cancelQuery(id);
+        fail(format("Query %s did not reach RUNNING state within timeout. Final state: %s", 
+            id, dispatchManager.getQueryInfo(id).getState()));
+    }
     return id;
 }
presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpQueryRunner.java (3)

63-84: LGTM!

The new overload correctly delegates to the session-based variant with default session, maintaining a clean API for callers who don't need custom session configuration.


95-106: LGTM!

The modification maintains backward compatibility by delegating to the comprehensive overload with empty Optional values for split filter parameters.


133-137: LGTM!

The logging enhancement provides useful visibility into the finalized CLP properties before catalog creation, which aids in debugging test configurations.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpQueryRunner.java (1)

181-187: TestNG coupling remains (previously flagged).

The deleteConfigFile method still uses assertTrue from TestNG, coupling this utility to the test framework. This was previously flagged as a nitpick-level concern in past reviews but has not been addressed.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba3674a and a230472.

📒 Files selected for processing (1)
  • presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpQueryRunner.java (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpQueryRunner.java (2)
presto-clp/src/main/java/com/facebook/presto/plugin/clp/ClpConfig.java (1)
  • ClpConfig (21-204)
presto-tests/src/main/java/com/facebook/presto/tests/DistributedQueryRunner.java (1)
  • DistributedQueryRunner (108-1224)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: test (17.0.13, :presto-main-base)
  • GitHub Check: test (17.0.13, :presto-tests -P ci-only-tpch-distributed-queries)
  • GitHub Check: test (17.0.13, :presto-tests -P ci-only-local-queries)
  • GitHub Check: test (17.0.13, :presto-tests -P presto-tests-execution-memory)
  • GitHub Check: test (17.0.13, :presto-tests -P ci-only-plan-determinism)
  • GitHub Check: test (17.0.13, :presto-tests -P ci-only-aggregation-queries)
  • GitHub Check: test (17.0.13, :presto-tests -P ci-only-distributed-non-hash-gen)
  • GitHub Check: test (17.0.13, :presto-tests -P presto-tests-general)
  • GitHub Check: test (8.0.442, :presto-main-base)
  • GitHub Check: test (8.0.442, :presto-tests -P ci-only-plan-determinism)
  • GitHub Check: test (8.0.442, :presto-tests -P ci-only-local-queries)
  • GitHub Check: test (8.0.442, :presto-tests -P presto-tests-general)
  • GitHub Check: test (8.0.442, :presto-tests -P ci-only-tpch-distributed-queries)
  • GitHub Check: test (8.0.442, :presto-tests -P ci-only-distributed-non-hash-gen)
  • GitHub Check: test (8.0.442, :presto-tests -P presto-tests-execution-memory)
  • GitHub Check: maven-checks (17.0.13)
  • GitHub Check: maven-checks (8.0.442)
  • GitHub Check: prestissimo-worker-images-build
🔇 Additional comments (2)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpQueryRunner.java (2)

21-36: Imports support new config file functionality.

The imports are appropriate for the new config file handling methods. The UTF_8 charset import indicates the charset issue from previous reviews has been addressed.

Note: TestNG assertion imports (assertTrue, fail) remain, which couples this utility to the test framework. This was previously flagged as a nitpick-level concern.


65-108: Overload design provides good backward compatibility.

The new overloads that accept splitFilterProvider and splitFilterConfigPath parameters are well-designed. The existing method now forwards Optional.empty() for these parameters, maintaining backward compatibility while enabling split-filter configuration for new test cases.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java (1)

433-434: Complete the exception handling improvement.

The previous review's suggestion to improve exception context has been partially addressed (QueryId declarations moved, finally block added). However, fail(e.getMessage()) still loses the stack trace and filter context.

Apply this diff to preserve full exception context:

-        catch (Exception e) {
-            fail(e.getMessage());
-        }
+        catch (Exception e) {
+            fail(format("Test failed for filter '%s': %s", filter, e.getMessage()), e);
+        }

Based on past review comments.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a230472 and 0b14e83.

📒 Files selected for processing (1)
  • presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java (4)
presto-main-base/src/main/java/com/facebook/presto/dispatcher/DispatchManager.java (1)
  • DispatchManager (70-472)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/mockdb/ClpMockMetadataDatabase.java (1)
  • ClpMockMetadataDatabase (49-288)
presto-tests/src/main/java/com/facebook/presto/tests/DistributedQueryRunner.java (1)
  • DistributedQueryRunner (108-1224)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/ClpQueryRunner.java (1)
  • ClpQueryRunner (37-205)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: maven-checks (17.0.13)
  • GitHub Check: maven-checks (8.0.442)
  • GitHub Check: prestissimo-worker-images-build
🔇 Additional comments (3)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java (3)

129-144: Previous feedback addressed.

The cancelAllQueries() call has been added before the wait loop, improving cleanup robustness as suggested in the previous review.


146-374: Comprehensive test coverage.

The test methods provide thorough coverage of predicate pushdown scenarios across string matching, numeric comparisons, logical operators, and special functions. The test structure is clear and maintainable.


467-496: Helper methods are well-designed.

equalsIgnoreBase correctly normalizes memory addresses for stable comparisons, and the layout handle extraction helpers safely handle type checks. The logic is sound.

Comment on lines +134 to +135
long maxCleanUpTime = 5 * 1000L; // 5 seconds
long currentCleanUpTime = 0L;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Extract timeout constants for maintainability.

The timeout values and polling intervals are hardcoded at multiple locations (5 seconds, 60 seconds, 1-second intervals). Extracting these to named constants improves clarity and makes timeout adjustments easier.

Add constants at the class level:

 @Test(singleThreaded = true)
 public class TestClpComputePushDown
 {
     private static final String TABLE_NAME = "test_pushdown";
     private static final Pattern BASE_PTR =
             Pattern.compile("(?<=base=)\\[B@[0-9a-fA-F]+");
+    private static final long QUERY_CLEANUP_TIMEOUT_MS = 5_000L;
+    private static final long QUERY_PLANNING_TIMEOUT_MS = 60_000L;
+    private static final long POLL_INTERVAL_MS = 1_000L;

Then reference these constants at lines 134-135 and 457-461.

Also applies to: 457-461

🤖 Prompt for AI Agents
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java
around lines 134-135 and 457-461: extract the hardcoded timeout and polling
values into descriptive class-level constants (e.g., CLEANUP_TIMEOUT_MS =
5_000L, GLOBAL_TIMEOUT_MS = 60_000L, POLL_INTERVAL_MS = 1_000L) and replace the
inline literals at the referenced lines with these constants; ensure constants
are static final and used everywhere the 5s, 60s, and 1s values appear in this
test class so future adjustments are centralized.

Comment on lines +446 to +465
private QueryId createAndPlanQuery(String filter)
throws ExecutionException, InterruptedException
{
QueryId id = queryRunner.getCoordinator().getDispatchManager().createQueryId();
@Language("SQL") String sql = format("SELECT * FROM clp.default.test_pushdown WHERE %s LIMIT 1", filter);
dispatchManager.createQuery(
id,
"slug",
0,
new TestingClpSessionContext(queryRunner.getDefaultSession()),
sql).get();
long maxDispatchingAndPlanningTime = 60 * 1000L; // 1 minute
long currentWaitingTime = 0L;
while (dispatchManager.getQueryInfo(id).getState().ordinal() != RUNNING.ordinal() && currentWaitingTime < maxDispatchingAndPlanningTime) {
Thread.sleep(1000L);
currentWaitingTime += 1000L;
}
assertTrue(currentWaitingTime < maxDispatchingAndPlanningTime);
return id;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Address potential query leak if planning fails.

If createQuery().get() throws an exception at line 456, or the assertion fails at line 463, the QueryId is created but not returned. The caller's finally block cannot cancel it. While tearDown() eventually calls cancelAllQueries(), the query remains active until then, potentially interfering with subsequent tests.

Apply this diff to ensure cleanup:

 private QueryId createAndPlanQuery(String filter)
             throws ExecutionException, InterruptedException
 {
     QueryId id = queryRunner.getCoordinator().getDispatchManager().createQueryId();
     @Language("SQL") String sql = format("SELECT * FROM clp.default.test_pushdown WHERE %s LIMIT 1", filter);
-    dispatchManager.createQuery(
-            id,
-            "slug",
-            0,
-            new TestingClpSessionContext(queryRunner.getDefaultSession()),
-            sql).get();
-    long maxDispatchingAndPlanningTime = 60 * 1000L;    // 1 minute
-    long currentWaitingTime = 0L;
-    while (dispatchManager.getQueryInfo(id).getState().ordinal() != RUNNING.ordinal() && currentWaitingTime < maxDispatchingAndPlanningTime) {
-        Thread.sleep(1000L);
-        currentWaitingTime += 1000L;
+    try {
+        dispatchManager.createQuery(
+                id,
+                "slug",
+                0,
+                new TestingClpSessionContext(queryRunner.getDefaultSession()),
+                sql).get();
+        long maxDispatchingAndPlanningTime = 60 * 1000L;    // 1 minute
+        long currentWaitingTime = 0L;
+        while (dispatchManager.getQueryInfo(id).getState().ordinal() != RUNNING.ordinal() && currentWaitingTime < maxDispatchingAndPlanningTime) {
+            Thread.sleep(1000L);
+            currentWaitingTime += 1000L;
+        }
+        assertTrue(currentWaitingTime < maxDispatchingAndPlanningTime);
+        return id;
+    }
+    catch (Exception e) {
+        queryManager.cancelQuery(id);
+        throw e;
     }
-    assertTrue(currentWaitingTime < maxDispatchingAndPlanningTime);
-    return id;
 }

@anlowee anlowee requested a review from wraymo October 10, 2025 14:14
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (2)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java (2)

436-438: Improve exception handling to preserve context.

The current exception handling at lines 436-438 loses the stack trace. While the finally block ensures query cleanup, propagating the full exception with context would aid debugging.

Consider this approach:

-        catch (Exception e) {
-            fail(e.getMessage());
-        }
+        catch (Exception e) {
+            fail(format("Test failed for filter '%s': %s", filter, e.getMessage()), e);
+        }

449-468: Add try-catch to prevent query leaks during planning failures.

If createQuery().get() throws an exception or the assertion fails, the query has been created but may not be properly cancelled immediately. While the caller's finally block will eventually cancel it, adding a try-catch here ensures immediate cleanup.

Apply this diff:

 private QueryId createAndPlanQuery(String filter)
             throws ExecutionException, InterruptedException
 {
     QueryId id = queryRunner.getCoordinator().getDispatchManager().createQueryId();
     @Language("SQL") String sql = format("SELECT * FROM clp.default.test_pushdown WHERE %s LIMIT 1", filter);
+    try {
         dispatchManager.createQuery(
                 id,
                 "slug",
                 0,
                 new TestingClpSessionContext(queryRunner.getDefaultSession()),
                 sql).get();
         long maxDispatchingAndPlanningTime = 60 * 1000L;    // 1 minute
         long currentWaitingTime = 0L;
         while (dispatchManager.getQueryInfo(id).getState().ordinal() != RUNNING.ordinal() && currentWaitingTime < maxDispatchingAndPlanningTime) {
             Thread.sleep(1000L);
             currentWaitingTime += 1000L;
         }
         assertTrue(currentWaitingTime < maxDispatchingAndPlanningTime);
         return id;
+    }
+    catch (Exception e) {
+        queryManager.cancelQuery(id);
+        throw e;
+    }
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b14e83 and 7ffb13a.

📒 Files selected for processing (1)
  • presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java (1 hunks)
🔇 Additional comments (4)
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java (4)

58-64: LGTM: Well-structured test class with proper isolation.

The @Test(singleThreaded = true) annotation ensures test isolation, and the BASE_PTR pattern provides a clever way to normalize object references in assertions.


71-127: LGTM: Comprehensive test setup.

The setup method properly initializes the mock metadata database with diverse column types, configures split filtering, and establishes the necessary query infrastructure for end-to-end pushdown testing.


146-374: LGTM: Comprehensive test coverage.

The test methods systematically cover all major pushdown scenarios including string matching, numeric comparisons, boolean logic, special predicates (BETWEEN, IN, IS NULL), and CLP-specific functionality. The test organization by predicate type enhances readability.


481-499: LGTM: Clean helper methods for plan inspection.

The helper methods for extracting ClpTableLayoutHandle from plan nodes are straightforward, type-safe, and correctly handle the case where the expected node types are not found.

Comment on lines +129 to +144
@AfterClass
public void tearDown()
throws InterruptedException
{
queryRunner.cancelAllQueries();
long maxCleanUpTime = 5 * 1000L; // 5 seconds
long currentCleanUpTime = 0L;
while (!queryManager.getQueries().isEmpty() && currentCleanUpTime < maxCleanUpTime) {
Thread.sleep(1000L);
currentCleanUpTime += 1000L;
}
if (null != mockMetadataDatabase) {
mockMetadataDatabase.teardown();
}
deleteConfigFile(splitFilterConfigFilePath);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Teardown is adequate, but consider extracting timeout constants.

The teardown properly cancels all queries and waits for cleanup. However, the hardcoded timeout values (5 seconds, 1-second polling) would benefit from being extracted to class-level constants for maintainability.

Also applies to: 460-464

🤖 Prompt for AI Agents
In
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java
around lines 129-144 (and similarly at lines 460-464), the teardown method uses
hardcoded timeout/polling values (5 * 1000L and 1000L); extract these magic
numbers into descriptive private static final class-level constants (e.g.,
CLEANUP_MAX_WAIT_MS and CLEANUP_POLL_INTERVAL_MS), replace the literals in the
loop with those constants, and update any other occurrences at lines 460-464 to
use the same constants for consistency and maintainability.

Thread.sleep(1000L);
currentWaitingTime += 1000L;
}
assertTrue(currentWaitingTime < maxDispatchingAndPlanningTime);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider a more descriptive timeout assertion message.

The assertion provides a generic failure message. A descriptive message would help diagnose whether query planning is legitimately slow or the timeout needs adjustment.

-        assertTrue(currentWaitingTime < maxDispatchingAndPlanningTime);
+        assertTrue(currentWaitingTime < maxDispatchingAndPlanningTime,
+                   format("Query planning timed out after %d ms (filter: %s)", currentWaitingTime, filter));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
assertTrue(currentWaitingTime < maxDispatchingAndPlanningTime);
private QueryId createAndPlanQuery(String filter)
throws ExecutionException, InterruptedException
{
QueryId id = queryRunner.getCoordinator().getDispatchManager().createQueryId();
@Language("SQL") String sql = format("SELECT * FROM clp.default.test_pushdown WHERE %s LIMIT 1", filter);
dispatchManager.createQuery(
id,
"slug",
0,
new TestingClpSessionContext(queryRunner.getDefaultSession()),
sql).get();
long maxDispatchingAndPlanningTime = 60 * 1000L; // 1 minute
long currentWaitingTime = 0L;
while (dispatchManager.getQueryInfo(id).getState().ordinal() != RUNNING.ordinal()
&& currentWaitingTime < maxDispatchingAndPlanningTime) {
Thread.sleep(1000L);
currentWaitingTime += 1000L;
}
assertTrue(currentWaitingTime < maxDispatchingAndPlanningTime,
format("Query planning timed out after %d ms (filter: %s)", currentWaitingTime, filter));
return id;
}
🤖 Prompt for AI Agents
In
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java
around line 466, the assertion assertTrue(currentWaitingTime <
maxDispatchingAndPlanningTime) lacks a descriptive failure message; replace it
with an assertion that includes a clear message and the actual timing values
(for example use assertTrue(condition, "Query planning exceeded timeout: waited
" + currentWaitingTime + " ms, allowed " + maxDispatchingAndPlanningTime + "
ms") or an equivalent assertion helper) so test failures show whether planning
was slow or the timeout needs adjustment.

Comment on lines +470 to +479
private void equalsIgnoreBase(RowExpression actualExpression, RowExpression expectedExpression)
{
if (actualExpression == null) {
assertNull(expectedExpression);
return;
}
String normalizedActualExpressionText = BASE_PTR.matcher(actualExpression.toString()).replaceAll("[B@IGNORED");
String normalizedExpectedExpressionText = BASE_PTR.matcher(expectedExpression.toString()).replaceAll("[B@IGNORED");
assertEquals(normalizedActualExpressionText, normalizedExpectedExpressionText);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

LGTM: Clever normalization approach.

The equalsIgnoreBase method correctly normalizes base pointer references in RowExpression strings for consistent assertions. Consider adding a brief comment explaining why base pointer normalization is necessary for test reliability.

🤖 Prompt for AI Agents
In
presto-clp/src/test/java/com/facebook/presto/plugin/clp/TestClpComputePushDown.java
around lines 470 to 479, add a short inline comment above the equalsIgnoreBase
method explaining that base pointer normalization is necessary because
RowExpression.toString includes non-deterministic object base pointers (e.g.,
memory addresses) which would make string comparisons flaky in tests, so the
method replaces those patterns with a constant token to ensure stable
assertions; keep the comment concise (one or two sentences) and place it
directly above the method signature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant