You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Stefano Parmesan (JIRA)" <ji...@apache.org> on 2017/07/06 13:10:00 UTC

[jira] [Created] (SPARK-21330) Bad partitioning does not allow to read a JDBC table with extreme values on the partition column

Stefano Parmesan created SPARK-21330:
----------------------------------------

             Summary: Bad partitioning does not allow to read a JDBC table with extreme values on the partition column
                 Key: SPARK-21330
                 URL: https://issues.apache.org/jira/browse/SPARK-21330
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 2.1.1
            Reporter: Stefano Parmesan


When using "extreme" values in the partition column (like having a randomly generated long number) overflow might happen, leading to the following warning message:

{code}WARN JDBCRelation: The number of partitions is reduced because the specified number of partitions is less than the difference between upper bound and lower bound. Updated number of partitions: -1559072469251914524; Input number of partitions: 20; Lower bound: -7701345953623242445; Upper bound: 9186325650834394647.{code}

When this happens, no data is read from the table.

This happens because of the following check in {{org/apache/spark/sql/execution/datasources/jdbc/JDBCRelation.scala}}:
{code}if ((upperBound - lowerBound) >= partitioning.numPartitions){code}

Funny thing is that we worry about overflows a few lines later:
{code}    // Overflow and silliness can happen if you subtract then divide.
    // Here we get a little roundoff, but that's (hopefully) OK.{code}

A better check would be:
{code}if ((upperBound - partitioning.numPartitions) >= lowerBound){code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org