Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-10245] [SQL] Fix decimal literals with precision < scale #8428

Closed
wants to merge 1 commit into from

Conversation

davies
Copy link
Contributor

@davies davies commented Aug 25, 2015

In BigDecimal or java.math.BigDecimal, the precision could be smaller than scale, for example, BigDecimal("0.001") has precision = 1 and scale = 3. But DecimalType require that the precision should be larger than scale, so we should use the maximum of precision and scale when inferring the schema from decimal literal.

@SparkQA
Copy link

SparkQA commented Aug 25, 2015

Test build #41550 has finished for PR 8428 at commit 6f53bb8.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@yhuai
Copy link
Contributor

yhuai commented Aug 25, 2015

LGTM. Merging to master and branch 1.5.

@yhuai
Copy link
Contributor

yhuai commented Aug 25, 2015

btw, it will be good to add a comment to explain why we do a max.

asfgit pushed a commit that referenced this pull request Aug 25, 2015
In BigDecimal or java.math.BigDecimal, the precision could be smaller than scale, for example, BigDecimal("0.001") has precision = 1 and scale = 3. But DecimalType require that the precision should be larger than scale, so we should use the maximum of precision and scale when inferring the schema from decimal literal.

Author: Davies Liu <davies@databricks.com>

Closes #8428 from davies/smaller_decimal.

(cherry picked from commit ec89bd8)
Signed-off-by: Yin Huai <yhuai@databricks.com>
@asfgit asfgit closed this in ec89bd8 Aug 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants