[
https://issues.apache.org/jira/browse/HBASE-30574?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Wellington Chevreuil updated HBASE-30574:
-----------------------------------------
Resolution: Fixed
Status: Resolved (was: Patch Available)
Merged to master branch. Thanks for reviewing it, [~taklwu] [~meszibalu] !
> Spark 4 connector can return rows that do not satisfy pushed-down filters
> -------------------------------------------------------------------------
>
> Key: HBASE-30574
> URL: https://issues.apache.org/jira/browse/HBASE-30574
> Project: HBase
> Issue Type: Sub-task
> Components: hbase-connectors
> Reporter: Wellington Chevreuil
> Assignee: Wellington Chevreuil
> Priority: Major
> Labels: pull-request-available
>
> In the Spark 4 DataSource V2 read path, HBaseScanBuilder.pushFilters returns
> only the filters it couldn't push to HBase. Spark therefore assumes every
> pushed filter was applied exactly and doesn't check it again after the scan,
> so correctness depends entirely on SparkSQLPushDownFilter running on the
> RegionServer. In some cases that filter and the connector's reader disagree,
> and rows that don't match the query reach the result:
> - Empty cell values. The reader treats a cell with an empty value as NULL
> (HBasePartitionReader.get, getValueLength == 0). SparkSQLPushDownFilter
> treats the same cell as present. A predicate such as col IS NOT NULL passes
> on the RegionServer, and Spark returns a row where col is NULL.
> - Evaluation errors. SparkSQLPushDownFilter.filterRow catches any Throwable
> thrown while evaluating the expression, logs it and returns false, which
> keeps the row. On that path it also doesn't reset columnToCurrentRowValueMap,
> so the failing row's values are carried into the evaluation of the next row.
> - Multiple versions. When the read requests multiple versions
> (hbase.spark.query.maxVersions), the filter evaluates the last version it
> saw, which is the oldest. The reader returns the newest.
> The Spark 3 connector (DS V1 HBaseRelation) doesn't override
> unhandledFilters. Spark always checks every filter again there, so these
> cases never show up in query results.
> Steps to reproduce (string catalog over a table dengue, column family cf):
> val probeKey = "zz-pushdown-probe-empty-gender"
> // put a row whose only cell is an empty cf:gender value
> 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 NOT NULL").show()
> Expected: no rows. Actual: one row, with gender = null. The physical plan has
> no Filter above the scan, because the IsNotNull predicate was treated as
> fully applied by HBase.
> Fix: keep pushing the supported filters to HBase, for row key range pruning
> and server-side filtering, but return all filters from pushFilters so Spark
> checks them again after the scan. This matches the Spark 3 behaviour and
> doesn't depend on the connector jar deployed on the RegionServers.
> pushedFilters() is unchanged. With the fix, the query above returns no rows
> and the plan has a Filter (isnotnull(gender) AND ...) above the scan.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)