-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-25454][SQL] add a new config for picking minimum precision for integral literals #22494
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1345,6 +1345,16 @@ object SQLConf { | |
| .booleanConf | ||
| .createWithDefault(true) | ||
|
|
||
| val LITERAL_PRECISE_PRECISION = | ||
| buildConf("spark.sql.literal.precisePrecision") | ||
| .internal() | ||
| .doc("When integral literals are used with decimals in binary operators, Spark will " + | ||
| "pick a precise precision for the literals to calculate the precision and scale " + | ||
|
||
| "of the result decimal, when this config is true. By picking a precise precision, we " + | ||
| "can avoid wasting precision, to reduce the possibility of overflow.") | ||
|
||
| .booleanConf | ||
| .createWithDefault(true) | ||
|
|
||
| val SQL_OPTIONS_REDACTION_PATTERN = | ||
| buildConf("spark.sql.redaction.options.regex") | ||
| .doc("Regex to decide which keys in a Spark SQL command's options map contain sensitive " + | ||
|
|
@@ -1939,6 +1949,8 @@ class SQLConf extends Serializable with Logging { | |
|
|
||
| def decimalOperationsAllowPrecisionLoss: Boolean = getConf(DECIMAL_OPERATIONS_ALLOW_PREC_LOSS) | ||
|
|
||
| def literalPrecisePrecision: Boolean = getConf(LITERAL_PRECISE_PRECISION) | ||
|
|
||
| def continuousStreamingExecutorQueueSize: Int = getConf(CONTINUOUS_STREAMING_EXECUTOR_QUEUE_SIZE) | ||
|
|
||
| def continuousStreamingExecutorPollIntervalMs: Long = | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2858,6 +2858,13 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext { | |
| val result = ds.flatMap(_.bar).distinct | ||
| result.rdd.isEmpty | ||
| } | ||
|
|
||
| test("SPARK-25454: decimal division with negative scale") { | ||
| // TODO: completely fix this issue even LITERAL_PRECISE_PRECISION is true. | ||
|
||
| withSQLConf(SQLConf.LITERAL_PRECISE_PRECISION.key -> "false") { | ||
| checkAnswer(sql("select 26393499451 / (1e6 * 1000)"), Row(BigDecimal("26.3934994510000"))) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| case class Foo(bar: Option[String]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmh... PRECISE_PRECISION sounds weird... can we look for a better one? I don't have a suggestion right now, but I'll think about it.