title: Spark (Decimal precision 1 exceeds max precision 0)
body: <p>I'm trying to get the count from a JDBC database with the following</p>
  <pre><code>def getCount(url: String, user: String, password : String, driver: String, table: String): BigDecimal={
  
      Context.getSparkSession().read.format(&quot;jdbc&quot;)
      .option(&quot;url&quot;, url)
      .option(&quot;user&quot;, user)
      .option(&quot;password&quot;, password)
      .option(&quot;dtable&quot;, s&quot;(SELECT COUNT(*) FROM $table)&quot;)
      .load()
      .head.getDecimal(0)
  }
  
  </code></pre>
  <p>However, in the code, at the line where I call <code>getDecimal(0)</code>, I get the exception <code>Decimal precision 1 exceeds max precision 0</code>.</p>
  <p>What I've tried to debug this:</p>
  <ol>
  <li><p>I've verified the credentials, URL, and table name, and I'm able to access the database and get the count with these parameters.</p>
  </li>
  <li><p>I've verified it's not a database grant issue by printing the dataframe with</p>
  </li>
  </ol>
  <pre><code>Context.getSparkSession().read.format(&quot;jdbc&quot;)
      .option(&quot;url&quot;, url)
      .option(&quot;user&quot;, user)
      .option(&quot;password&quot;, password)
      .option(&quot;dtable&quot;, s&quot;(SELECT * FROM $table)&quot;)
      .load()
  </code></pre>
  <p>and I'm able to view the entire database table with no issues. I've also tried calling <code>.count()</code> on the dataframe and return the count that way but to no avail.</p>
  <p>Does anybody know what this issue is or has seen something like this before? I'm stumped here. Yes I'm aware there are similar questions here but I've seen no resolutions, and no situations where the max precision is listed as 0, so this is why I'm asking.</p>