Copilot commented on code in PR #2666:
URL: https://github.com/apache/phoenix/pull/2666#discussion_r4516930404
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/UncoveredGlobalIndexRegionScannerIT.java:
##########
@@ -919,6 +919,41 @@ public void testPointLookup() throws Exception {
}
}
+ /**
+ * A row that gives NULL for the conditions on uncovered columns does not
change the result of the
+ * next rows in the same region scan.
+ */
+ @Test
+ public void testUncoveredConditionsAfterNullRow() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexTableName = generateUniqueName();
+ try (Connection conn = DriverManager.getConnection(getUrl());
+ Statement stmt = conn.createStatement()) {
+ stmt.execute("create table " + dataTableName
+ + " (id varchar(10) not null primary key, val1 varchar(10), val2
varchar(10),"
+ + " val3 varchar(10))" + (salted ? " SALT_BUCKETS=4" : ""));
+ // The first row in index order has a NULL val2. The other rows match
all conditions.
+ stmt.execute("upsert into " + dataTableName + " values ('a', 'x', null,
'z')");
+ for (char id = 'b'; id <= 'h'; id++) {
+ stmt.execute("upsert into " + dataTableName + " values ('" + id + "',
'x', 'y', 'z')");
+ }
Review Comment:
This test assumes the NULL row (`id='a'`) is encountered before the
qualifying rows within the same scan. When `salted` is true, salting can
distribute rows across different salt buckets/scan ranges, so the NULL row may
not be scanned before (or even alongside) the qualifying rows that should be
affected by the leaked expression state. That can make the test pass even on a
regressed build (false negative). Consider making the salted variant
deterministic by generating IDs until both the NULL row and several qualifying
rows map to the same salt bucket, or (if the goal is specifically to cover the
expression reset logic) disabling salting for this test case so scan
order/bucket locality is guaranteed.
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/index/UncoveredGlobalIndexRegionScannerIT.java:
##########
@@ -919,6 +919,41 @@ public void testPointLookup() throws Exception {
}
}
+ /**
+ * A row that gives NULL for the conditions on uncovered columns does not
change the result of the
+ * next rows in the same region scan.
+ */
+ @Test
+ public void testUncoveredConditionsAfterNullRow() throws Exception {
+ String dataTableName = generateUniqueName();
+ String indexTableName = generateUniqueName();
+ try (Connection conn = DriverManager.getConnection(getUrl());
+ Statement stmt = conn.createStatement()) {
+ stmt.execute("create table " + dataTableName
+ + " (id varchar(10) not null primary key, val1 varchar(10), val2
varchar(10),"
+ + " val3 varchar(10))" + (salted ? " SALT_BUCKETS=4" : ""));
+ // The first row in index order has a NULL val2. The other rows match
all conditions.
+ stmt.execute("upsert into " + dataTableName + " values ('a', 'x', null,
'z')");
+ for (char id = 'b'; id <= 'h'; id++) {
+ stmt.execute("upsert into " + dataTableName + " values ('" + id + "',
'x', 'y', 'z')");
+ }
+ conn.commit();
+ stmt.execute("CREATE " + (uncovered ? "UNCOVERED " : "") + "INDEX " +
indexTableName + " on "
+ + dataTableName + " (val1)");
+ String sql = "SELECT /*+ INDEX(" + dataTableName + " " + indexTableName
+ ")*/ id from "
+ + dataTableName + " WHERE val1 = 'x' AND val2 = 'y' AND val3 = 'z'";
+ assertTrue(TestUtil.getExplainPlan(conn, sql).contains(indexTableName));
+ int rows = 0;
+ try (ResultSet rs = stmt.executeQuery(sql)) {
Review Comment:
The query runs immediately after `CREATE INDEX`. If index population/build
is asynchronous in some test configurations, this can be flaky (e.g., explain
still references the index due to the hint, but the index may not be
usable/fully populated yet). To make the IT robust, wait for the index to reach
ACTIVE and be populated (using the existing Phoenix test utilities used
elsewhere in the suite) before executing the SELECT.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]