PHOENIX-5236 Multiple dynamic columns in WHERE clause is not working#2480
PHOENIX-5236 Multiple dynamic columns in WHERE clause is not working#2480xavifeds8 wants to merge 1 commit into
Conversation
|
EARLIER BEHAVIOUR: No rows affected (0.948 seconds) 1 row affected (0.006 seconds) CURRENT BEHAVIOUR : 0: jdbc:phoenix:> DROP TABLE IF EXISTS test_no_workaround CASCADE; No rows affected (0.071 seconds) |
|
@virajjasani / @NihalJain can you please review this ? |
What changes were proposed in this pull request?
Added a ScanUtil.hasDynamicColumns(table) check in WhereCompiler.setScanFilter() so that when the WHERE clause references multiple columns and the table has dynamic columns, Phoenix falls back to MultiCQKeyValueComparisonFilter (HashMap-based, raw byte comparison) instead of MultiEncodedCQKeyValueComparisonFilter (array-based, expects encoded integer qualifiers).
Why are the changes needed?
When a table uses column encoding (the default) and the WHERE clause filters on multiple dynamic columns, Phoenix selects MultiEncodedCQKeyValueComparisonFilter. This filter calls encodingScheme.decode() on each column qualifier, expecting a 2-4 byte encoded integer.
Dynamic columns use the actual column name as the qualifier (e.g., "POPULATION" = 10 bytes), causing InvalidQualifierBytesException: Expected length: 2. Actual: 10.
Single dynamic column in WHERE works fine because SingleCQKeyValueComparisonFilter uses raw byte comparison. The workaround was COLUMN_ENCODED_BYTES=NONE on table creation, which defeats the purpose of encoding.
Does this PR introduce any user-facing change?
Yes. Queries with multiple dynamic columns in the WHERE clause now work correctly on tables with column encoding enabled (the default). Previously these queries threw InvalidQualifierBytesException. No workaround (COLUMN_ENCODED_BYTES=NONE) is needed anymore
How was this patch tested?
5 new unit tests in WhereCompilerTest verifying correct filter selection:
1 new integration test in DynamicColumnIT covering 7 scenarios:
Was this patch authored or co-authored using generative AI tooling?
Yes. This patch was co-authored with Claude Code opus-4.6.