You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "mini666 (via GitHub)" <gi...@apache.org> on 2026/03/27 03:30:00 UTC

[PR] HBASE-30033 Scan.setFilter() should validate against existing batch setting [hbase]

mini666 opened a new pull request, #7988:
URL: https://github.com/apache/hbase/pull/7988

   ## Summary
   
    `Scan.setBatch()` validates that the scan does not have a filter with `hasFilterRow()=true`, throwing `IncompatibleFilterException` if it does. However, `Scan.setFilter()` does not perform the reverse check against an existing batch setting.
   
    This allows creating an invalid Scan by calling `setBatch()` before `setFilter()`, bypassing the validation:
   
    ```java
    // This correctly throws IncompatibleFilterException
    Scan scan = new Scan();
    scan.setFilter(new PageFilter(10));
    scan.setBatch(5); // throws
   
    // This silently creates the same invalid combination
    Scan scan = new Scan();
    scan.setBatch(5);
    scan.setFilter(new PageFilter(10)); // no validation
   ```
   
    Fix
   
    Added validation in Scan.setFilter() to throw IncompatibleFilterException when a filter with hasFilterRow()=true is set on a scan that already has batch configured.
   
    Jira
   
    https://issues.apache.org/jira/browse/HBASE-30033


-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] HBASE-30033 Scan.setFilter() should validate against existing batch setting [hbase]

Posted by "liuxiaocs7 (via GitHub)" <gi...@apache.org>.
liuxiaocs7 commented on code in PR #7988:
URL: https://github.com/apache/hbase/pull/7988#discussion_r2999166210


##########
hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestScan.java:
##########
@@ -254,6 +256,36 @@ public void testScanCopyConstructor() throws Exception {
       "Make sure copy constructor adds all the fields in the copied object");
   }
 
+  @Test(expected = IncompatibleFilterException.class)

Review Comment:
   We need to use `assertThrows` here?



-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] HBASE-30033 Scan.setFilter() should validate against existing batch setting [hbase]

Posted by "liuxiaocs7 (via GitHub)" <gi...@apache.org>.
liuxiaocs7 commented on PR #7988:
URL: https://github.com/apache/hbase/pull/7988#issuecomment-4140055766

   Hi, @mini666, please rebase master and retry?
   
   Thanks!


-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] HBASE-30033 Scan.setFilter() should validate against existing batch setting [hbase]

Posted by "junegunn (via GitHub)" <gi...@apache.org>.
junegunn commented on PR #7988:
URL: https://github.com/apache/hbase/pull/7988#issuecomment-4162517411

   1. Please run `mvn spotless:apply`.
   2. `TestOperation.testScanOperationToJSON` seems related. Please have a look. Thanks.


-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] HBASE-30033 Scan.setFilter() should validate against existing batch setting [hbase]

Posted by "vaijosh (via GitHub)" <gi...@apache.org>.
vaijosh commented on code in PR #7988:
URL: https://github.com/apache/hbase/pull/7988#discussion_r2999090128


##########
hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestScan.java:
##########
@@ -254,6 +256,28 @@ public void testScanCopyConstructor() throws Exception {
       "Make sure copy constructor adds all the fields in the copied object");
   }
 
+  @Test(expected = IncompatibleFilterException.class)
+  public void testSetFilterWithBatchThrows() {
+    Scan scan = new Scan();
+    scan.setBatch(5);
+    scan.setFilter(new PageFilter(10));
+  }
+
+  @Test
+  public void testSetFilterWithoutBatchDoesNotThrow() {
+    Scan scan = new Scan();
+    scan.setFilter(new PageFilter(10));
+    // no exception expected
+  }
+
+  @Test
+  public void testSetFilterWithBatchAndNonFilterRowFilter() {
+    Scan scan = new Scan();
+    scan.setBatch(5);
+    scan.setFilter(new FilterList());
+    // FilterList.hasFilterRow() returns false, so no exception expected
+  }
+

Review Comment:
   @mini666 
   nit: Consider adding a test case to cover the scenario where filter == null, ensuring that no exception is thrown.



-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] HBASE-30033 Scan.setFilter() should validate against existing batch setting [hbase]

Posted by "vaijosh (via GitHub)" <gi...@apache.org>.
vaijosh commented on code in PR #7988:
URL: https://github.com/apache/hbase/pull/7988#discussion_r2999124752


##########
hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestScan.java:
##########
@@ -254,6 +256,36 @@ public void testScanCopyConstructor() throws Exception {
       "Make sure copy constructor adds all the fields in the copied object");
   }
 
+  @Test(expected = IncompatibleFilterException.class)
+  public void testSetFilterWithBatchThrows() {
+    Scan scan = new Scan();
+    scan.setBatch(5);
+    scan.setFilter(new PageFilter(10));
+  }
+
+  @Test
+  public void testSetFilterWithoutBatchDoesNotThrow() {
+    Scan scan = new Scan();
+    scan.setFilter(new PageFilter(10));
+    // no exception expected
+  }
+
+  @Test
+  public void testSetFilterWithBatchAndNonFilterRowFilter() {
+    Scan scan = new Scan();
+    scan.setBatch(5);
+    scan.setFilter(new FilterList());
+    // FilterList.hasFilterRow() returns false, so no exception expected
+  }
+
+  @Test
+  public void testSetFilterWithBatchAndNullFilter() {
+    Scan scan = new Scan();
+    scan.setBatch(5);
+    scan.setFilter(null);
+    // null filter should not throw

Review Comment:
   @mini666,
   I'd add test to cover "filter == null" path.
   
   @Test
   public void testSetFilterNullWithBatchDoesNotThrow() {
     Scan scan = new Scan();
     scan.setBatch(5);
     scan.setFilter(null); // should not throw
   }



-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] HBASE-30033 Scan.setFilter() should validate against existing batch setting [hbase]

Posted by "Apache9 (via GitHub)" <gi...@apache.org>.
Apache9 commented on PR #7988:
URL: https://github.com/apache/hbase/pull/7988#issuecomment-4140476726

   We have already migrated to junit5 so we can not use expected any more. Please use assertThrows instead.
   
   Thanks.


-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] HBASE-30033 Scan.setFilter() should validate against existing batch setting [hbase]

Posted by "junegunn (via GitHub)" <gi...@apache.org>.
junegunn commented on PR #7988:
URL: https://github.com/apache/hbase/pull/7988#issuecomment-4189930392

   Can I ask any PMC member to add him as a contributor so we can assign the issue to him?


-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] HBASE-30033 Scan.setFilter() should validate against existing batch setting [hbase]

Posted by "junegunn (via GitHub)" <gi...@apache.org>.
junegunn merged PR #7988:
URL: https://github.com/apache/hbase/pull/7988


-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org