Metin Hatipogullari created ORC-2237:
----------------------------------------
Summary: SARG evaluation compares STRING literals in UTF-16 order
against UTF-8-ordered statistics
Key: ORC-2237
URL: https://issues.apache.org/jira/browse/ORC-2237
Project: ORC
Issue Type: Bug
Components: Java, Reader
Affects Versions: 2.3.0
Reporter: Metin Hatipogullari
StringStatisticsImpl keeps min/max in UTF-8 byte order (Text.compareTo).
RecordReaderImpl.getBaseObjectForComparison turns the predicate literal into a
java.lang.String, and the range check then uses String.compareTo (UTF-16 code
units). The orders disagree for supplementary characters vs U+E000..U+FFFF: in
UTF-8, U+1F600 sorts after U+E000; in UTF-16 its high surrogate 0xD83D sorts
before it. Row groups are skipped for predicates they satisfy.
Through Spark 4.2.1 (ORC 2.3.0), one file per row:
{code:python}
for k, s in [(1, "\U0001F600"), (2, ""), (3, "�"), (4, "\U00010000"), (5, "z")]:
spark.createDataFrame([(k, s)], "k INT, s
STRING").coalesce(1).write.mode("append").orc("/tmp/astral")
spark.read.orc("/tmp/astral").where("s > ''").select("k").show() # 3 only,
expected 1, 3, 4
{code}
Correct with spark.sql.orc.filterPushdown=false. Files written by the C++
writer are pruned the same way, so it is the reader side. Comparing STRING
literals and bounds as UTF-8 bytes (e.g. as Text) would fix it.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)