Wellington Chevreuil created HBASE-30575:
--------------------------------------------

             Summary: SparkSQLPushDownFilter drops rows that Spark SQL 
semantics would return (IS NULL on empty cells, multi-version reads)
                 Key: HBASE-30575
                 URL: https://issues.apache.org/jira/browse/HBASE-30575
             Project: HBase
          Issue Type: Bug
          Components: hbase-connectors
    Affects Versions: 1.0.0
            Reporter: Wellington Chevreuil


This issue currently affects both hbase-spark (Spark 3) and hbase-spark4 
modules.

1. IS NULL on an empty cell. Both connectors read a cell with an empty value as 
NULL (HBasePartitionReader.get in Spark 4, DefaultSource in Spark 3). On the 
RegionServer, IsNullLogicExpression decides null-ness by whether the cell 
exists, so an empty cell counts as non-null. col IS NULL therefore drops a row 
that Spark would return.
2. Multi-version reads. With hbase.spark.query.maxVersions > 1, 
SparkSQLPushDownFilter.filterCell overwrites its per-column value for each 
version it sees, so filterRow ends up testing the oldest version. The connector 
returns the newest. If the oldest version fails the predicate and the newest 
passes, the row is dropped.

Reproduction (string catalog over table dengue, cf:gender):



 
{code:java}
val probeKey = "zz-pushdown-probe-empty-gender"
table.put(new Put(Bytes.toBytes(probeKey))
  .addColumn(Bytes.toBytes("cf"), Bytes.toBytes("gender"), Array.empty[Byte]))
spark.sql(s"SELECT rowkey, gender FROM dengue WHERE rowkey = '$probeKey' AND 
gender IS NULL")
// expected: 1 row (probeKey, null); actual: 0 rows
{code}
 

 

For the multi-version case: put cf:gender='Female', then cf:gender='Male' on 
the same row in a CF with VERSIONS ≥ 2. Read with 
hbase.spark.query.maxVersions=2 and WHERE gender = 'Male'. You get 0 rows; 1 is 
expected.

Possible fixes:
- Server side: make IsNullLogicExpression treat a zero-length value as null, 
and have filterCell keep only the newest version per column. This fixes both 
connectors, but RegionServers need the redeployed hbase-spark-pushdown jar. 
Mixed-version clusters keep the old behaviour.
- Client side: don't push IsNull anywhere in a filter tree 
(PredicatePushdownSupport.isSupported). Also don't push column filters when 
maxVersions > 1. This works with any RegionServer jar, but gives up some 
server-side filtering.
- Doing both is probably best: the client-side guard now, the server-side fix 
for when the jar gets upgraded.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to