Metin Hatipogullari created SPARK-61741:
-------------------------------------------

             Summary: CBO: FilterEstimation.evaluateBinaryForNumeric throws 
NumberFormatException when distinctCount is 0
                 Key: SPARK-61741
                 URL: https://issues.apache.org/jira/browse/SPARK-61741
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.5.9, 4.0.5, 4.1.4, 4.2.1, 5.0.0
            Reporter: Metin Hatipogullari


{code:sql}
CREATE TABLE p (b INT, c INT, a INT) USING parquet PARTITIONED BY (a);
INSERT INTO p VALUES (1, 1, 1), (-1, 3, -3);
CREATE TABLE t (k INT, v INT) USING parquet;   -- empty
ANALYZE TABLE p COMPUTE STATISTICS FOR ALL COLUMNS;
ANALYZE TABLE t COMPUTE STATISTICS FOR ALL COLUMNS;
SET spark.sql.cbo.enabled=true;
SELECT p.a FROM p JOIN t ON p.a = t.k WHERE p.a < 1 AND t.k > 0;
-- java.lang.NumberFormatException: Character N is neither a decimal digit 
number ...
--   at ...FilterEstimation.evaluateBinaryForNumeric(FilterEstimation.scala:562)
{code}

p.a < 1 plus the inferred p.a > 0 leaves a column stat with distinctCount 0 but 
min/max set. At the boundary case, percent = 1.0 - 1.0 / ndv is -Infinity, 
ceil(0 * -Infinity) is NaN, and the BigDecimal conversion throws. SPARK-23799 
fixed the same division in evaluateInSet; evaluateBinaryForNumeric needs the 
same ndv == 0 guard. 3.5.9 through master; I have a patch with a test.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to