Skip to content

Conversation

@beliefer
Copy link
Contributor

@beliefer beliefer commented Jun 8, 2022

What changes were proposed in this pull request?

JDBCV2Suite exists some test case which uses sql keywords are not capitalized.
This PR will capitalize sql keywords in JDBCV2Suite.

Why are the changes needed?

Capitalize sql keywords in JDBCV2Suite.

Does this PR introduce any user-facing change?

'No'.
Just update test cases.

How was this patch tested?

N/A.

@beliefer
Copy link
Contributor Author

beliefer commented Jun 8, 2022

ping @huaxingao cc @cloud-fan

@github-actions github-actions bot added the SQL label Jun 8, 2022
@huaxingao huaxingao closed this in 7d44b47 Jun 8, 2022
@huaxingao
Copy link
Contributor

Merged to master. Thanks @beliefer

@beliefer
Copy link
Contributor Author

beliefer commented Jun 9, 2022

@huaxingao @cloud-fan Thanks a lot!

chenzhx pushed a commit to chenzhx/spark that referenced this pull request Jun 13, 2022
### What changes were proposed in this pull request?
`JDBCV2Suite` exists some test case which uses sql keywords are not capitalized.
This PR will capitalize sql keywords in `JDBCV2Suite`.

### Why are the changes needed?
Capitalize sql keywords in `JDBCV2Suite`.

### Does this PR introduce _any_ user-facing change?
'No'.
Just update test cases.

### How was this patch tested?
N/A.

Closes apache#36805 from beliefer/SPARK-39413.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: huaxingao <[email protected]>
chenzhx pushed a commit to chenzhx/spark that referenced this pull request Jun 15, 2022
### What changes were proposed in this pull request?
`JDBCV2Suite` exists some test case which uses sql keywords are not capitalized.
This PR will capitalize sql keywords in `JDBCV2Suite`.

### Why are the changes needed?
Capitalize sql keywords in `JDBCV2Suite`.

### Does this PR introduce _any_ user-facing change?
'No'.
Just update test cases.

### How was this patch tested?
N/A.

Closes apache#36805 from beliefer/SPARK-39413.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: huaxingao <[email protected]>
chenzhx added a commit to Kyligence/spark that referenced this pull request Jun 15, 2022
…mal binary arithmetic (#481)

* [SPARK-39270][SQL] JDBC dialect supports registering dialect specific functions

### What changes were proposed in this pull request?
The build-in functions in Spark is not the same as JDBC database.
We can provide the chance users could register dialect specific functions.

### Why are the changes needed?
JDBC dialect supports registering dialect specific functions

### Does this PR introduce _any_ user-facing change?
'No'.
New feature.

### How was this patch tested?
New tests.

Closes apache#36649 from beliefer/SPARK-39270.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* [SPARK-39413][SQL] Capitalize sql keywords in JDBCV2Suite

### What changes were proposed in this pull request?
`JDBCV2Suite` exists some test case which uses sql keywords are not capitalized.
This PR will capitalize sql keywords in `JDBCV2Suite`.

### Why are the changes needed?
Capitalize sql keywords in `JDBCV2Suite`.

### Does this PR introduce _any_ user-facing change?
'No'.
Just update test cases.

### How was this patch tested?
N/A.

Closes apache#36805 from beliefer/SPARK-39413.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: huaxingao <[email protected]>

* [SPARK-38997][SPARK-39037][SQL][FOLLOWUP] PushableColumnWithoutNestedColumn` need be translated to predicate too

### What changes were proposed in this pull request?
apache#35768 assume the expression in `And`, `Or` and `Not` must be predicate.
apache#36370 and apache#36325 supported push down expressions in `GROUP BY` and `ORDER BY`. But the children of `And`, `Or` and `Not` can be `FieldReference.column(name)`.
`FieldReference.column(name)` is not a predicate, so the assert may fail.

### Why are the changes needed?
This PR fix the bug for `PushableColumnWithoutNestedColumn`.

### Does this PR introduce _any_ user-facing change?
'Yes'.
Let the push-down framework more correctly.

### How was this patch tested?
New tests

Closes apache#36776 from beliefer/SPARK-38997_SPARK-39037_followup.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* [SPARK-39316][SQL] Merge PromotePrecision and CheckOverflow into decimal binary arithmetic

### What changes were proposed in this pull request?

The main change:
- Add a new method `resultDecimalType` in `BinaryArithmetic`
- Add a new expression `DecimalAddNoOverflowCheck` for the internal decimal add, e.g. `Sum`/`Average`, the different with `Add` is:
  - `DecimalAddNoOverflowCheck` does not check overflow
  - `DecimalAddNoOverflowCheck` make `dataType` as its input parameter
- Merge the decimal precision code of `DecimalPrecision` into each arithmetic data type, so every arithmetic should report the accurate decimal type. And we can remove the unused expression `PromotePrecision` and related code
- Merge `CheckOverflow` iinto arithmetic eval and code-gen code path, so every arithmetic can handle the overflow case during runtime

Merge `PromotePrecision` into `dataType`, for example, `Add`:
```scala
override def resultDecimalType(p1: Int, s1: Int, p2: Int, s2: Int): DecimalType = {
  val resultScale = max(s1, s2)
  if (allowPrecisionLoss) {
    DecimalType.adjustPrecisionScale(max(p1 - s1, p2 - s2) + resultScale + 1,
      resultScale)
  } else {
    DecimalType.bounded(max(p1 - s1, p2 - s2) + resultScale + 1, resultScale)
  }
}
```

Merge `CheckOverflow`, for example, `Add` eval:
```scala
dataType match {
  case decimalType: DecimalType =>
    val value = numeric.plus(input1, input2)
    checkOverflow(value.asInstanceOf[Decimal], decimalType)
  ...
}
```

Note that, `CheckOverflow` is still useful after this pr, e.g. `RowEncoder`. We can do further in a separate pr.

### Why are the changes needed?

Fix the bug of `TypeCoercion`, for example:
```sql
SELECT CAST(1 AS DECIMAL(28, 2))
UNION ALL
SELECT CAST(1 AS DECIMAL(18, 2)) / CAST(1 AS DECIMAL(18, 2));
```

Relax the decimal precision at runtime, so we do not need redundant Cast

### Does this PR introduce _any_ user-facing change?

yes, bug fix

### How was this patch tested?

Pass exists test and add some bug fix test in `decimalArithmeticOperations.sql`

Closes apache#36698 from ulysses-you/decimal.

Lead-authored-by: ulysses-you <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* fix ut

Co-authored-by: Jiaan Geng <[email protected]>
Co-authored-by: ulysses-you <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
yabola pushed a commit to Kyligence/spark that referenced this pull request Jun 21, 2022
…mal binary arithmetic (#481)

* [SPARK-39270][SQL] JDBC dialect supports registering dialect specific functions

### What changes were proposed in this pull request?
The build-in functions in Spark is not the same as JDBC database.
We can provide the chance users could register dialect specific functions.

### Why are the changes needed?
JDBC dialect supports registering dialect specific functions

### Does this PR introduce _any_ user-facing change?
'No'.
New feature.

### How was this patch tested?
New tests.

Closes apache#36649 from beliefer/SPARK-39270.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* [SPARK-39413][SQL] Capitalize sql keywords in JDBCV2Suite

### What changes were proposed in this pull request?
`JDBCV2Suite` exists some test case which uses sql keywords are not capitalized.
This PR will capitalize sql keywords in `JDBCV2Suite`.

### Why are the changes needed?
Capitalize sql keywords in `JDBCV2Suite`.

### Does this PR introduce _any_ user-facing change?
'No'.
Just update test cases.

### How was this patch tested?
N/A.

Closes apache#36805 from beliefer/SPARK-39413.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: huaxingao <[email protected]>

* [SPARK-38997][SPARK-39037][SQL][FOLLOWUP] PushableColumnWithoutNestedColumn` need be translated to predicate too

### What changes were proposed in this pull request?
apache#35768 assume the expression in `And`, `Or` and `Not` must be predicate.
apache#36370 and apache#36325 supported push down expressions in `GROUP BY` and `ORDER BY`. But the children of `And`, `Or` and `Not` can be `FieldReference.column(name)`.
`FieldReference.column(name)` is not a predicate, so the assert may fail.

### Why are the changes needed?
This PR fix the bug for `PushableColumnWithoutNestedColumn`.

### Does this PR introduce _any_ user-facing change?
'Yes'.
Let the push-down framework more correctly.

### How was this patch tested?
New tests

Closes apache#36776 from beliefer/SPARK-38997_SPARK-39037_followup.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* [SPARK-39316][SQL] Merge PromotePrecision and CheckOverflow into decimal binary arithmetic

### What changes were proposed in this pull request?

The main change:
- Add a new method `resultDecimalType` in `BinaryArithmetic`
- Add a new expression `DecimalAddNoOverflowCheck` for the internal decimal add, e.g. `Sum`/`Average`, the different with `Add` is:
  - `DecimalAddNoOverflowCheck` does not check overflow
  - `DecimalAddNoOverflowCheck` make `dataType` as its input parameter
- Merge the decimal precision code of `DecimalPrecision` into each arithmetic data type, so every arithmetic should report the accurate decimal type. And we can remove the unused expression `PromotePrecision` and related code
- Merge `CheckOverflow` iinto arithmetic eval and code-gen code path, so every arithmetic can handle the overflow case during runtime

Merge `PromotePrecision` into `dataType`, for example, `Add`:
```scala
override def resultDecimalType(p1: Int, s1: Int, p2: Int, s2: Int): DecimalType = {
  val resultScale = max(s1, s2)
  if (allowPrecisionLoss) {
    DecimalType.adjustPrecisionScale(max(p1 - s1, p2 - s2) + resultScale + 1,
      resultScale)
  } else {
    DecimalType.bounded(max(p1 - s1, p2 - s2) + resultScale + 1, resultScale)
  }
}
```

Merge `CheckOverflow`, for example, `Add` eval:
```scala
dataType match {
  case decimalType: DecimalType =>
    val value = numeric.plus(input1, input2)
    checkOverflow(value.asInstanceOf[Decimal], decimalType)
  ...
}
```

Note that, `CheckOverflow` is still useful after this pr, e.g. `RowEncoder`. We can do further in a separate pr.

### Why are the changes needed?

Fix the bug of `TypeCoercion`, for example:
```sql
SELECT CAST(1 AS DECIMAL(28, 2))
UNION ALL
SELECT CAST(1 AS DECIMAL(18, 2)) / CAST(1 AS DECIMAL(18, 2));
```

Relax the decimal precision at runtime, so we do not need redundant Cast

### Does this PR introduce _any_ user-facing change?

yes, bug fix

### How was this patch tested?

Pass exists test and add some bug fix test in `decimalArithmeticOperations.sql`

Closes apache#36698 from ulysses-you/decimal.

Lead-authored-by: ulysses-you <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* fix ut

Co-authored-by: Jiaan Geng <[email protected]>
Co-authored-by: ulysses-you <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
leejaywei pushed a commit to Kyligence/spark that referenced this pull request Jul 14, 2022
…mal binary arithmetic (#481)

* [SPARK-39270][SQL] JDBC dialect supports registering dialect specific functions

The build-in functions in Spark is not the same as JDBC database.
We can provide the chance users could register dialect specific functions.

JDBC dialect supports registering dialect specific functions

'No'.
New feature.

New tests.

Closes apache#36649 from beliefer/SPARK-39270.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* [SPARK-39413][SQL] Capitalize sql keywords in JDBCV2Suite

`JDBCV2Suite` exists some test case which uses sql keywords are not capitalized.
This PR will capitalize sql keywords in `JDBCV2Suite`.

Capitalize sql keywords in `JDBCV2Suite`.

'No'.
Just update test cases.

N/A.

Closes apache#36805 from beliefer/SPARK-39413.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: huaxingao <[email protected]>

* [SPARK-38997][SPARK-39037][SQL][FOLLOWUP] PushableColumnWithoutNestedColumn` need be translated to predicate too

apache#35768 assume the expression in `And`, `Or` and `Not` must be predicate.
apache#36370 and apache#36325 supported push down expressions in `GROUP BY` and `ORDER BY`. But the children of `And`, `Or` and `Not` can be `FieldReference.column(name)`.
`FieldReference.column(name)` is not a predicate, so the assert may fail.

This PR fix the bug for `PushableColumnWithoutNestedColumn`.

'Yes'.
Let the push-down framework more correctly.

New tests

Closes apache#36776 from beliefer/SPARK-38997_SPARK-39037_followup.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* [SPARK-39316][SQL] Merge PromotePrecision and CheckOverflow into decimal binary arithmetic

The main change:
- Add a new method `resultDecimalType` in `BinaryArithmetic`
- Add a new expression `DecimalAddNoOverflowCheck` for the internal decimal add, e.g. `Sum`/`Average`, the different with `Add` is:
  - `DecimalAddNoOverflowCheck` does not check overflow
  - `DecimalAddNoOverflowCheck` make `dataType` as its input parameter
- Merge the decimal precision code of `DecimalPrecision` into each arithmetic data type, so every arithmetic should report the accurate decimal type. And we can remove the unused expression `PromotePrecision` and related code
- Merge `CheckOverflow` iinto arithmetic eval and code-gen code path, so every arithmetic can handle the overflow case during runtime

Merge `PromotePrecision` into `dataType`, for example, `Add`:
```scala
override def resultDecimalType(p1: Int, s1: Int, p2: Int, s2: Int): DecimalType = {
  val resultScale = max(s1, s2)
  if (allowPrecisionLoss) {
    DecimalType.adjustPrecisionScale(max(p1 - s1, p2 - s2) + resultScale + 1,
      resultScale)
  } else {
    DecimalType.bounded(max(p1 - s1, p2 - s2) + resultScale + 1, resultScale)
  }
}
```

Merge `CheckOverflow`, for example, `Add` eval:
```scala
dataType match {
  case decimalType: DecimalType =>
    val value = numeric.plus(input1, input2)
    checkOverflow(value.asInstanceOf[Decimal], decimalType)
  ...
}
```

Note that, `CheckOverflow` is still useful after this pr, e.g. `RowEncoder`. We can do further in a separate pr.

Fix the bug of `TypeCoercion`, for example:
```sql
SELECT CAST(1 AS DECIMAL(28, 2))
UNION ALL
SELECT CAST(1 AS DECIMAL(18, 2)) / CAST(1 AS DECIMAL(18, 2));
```

Relax the decimal precision at runtime, so we do not need redundant Cast

yes, bug fix

Pass exists test and add some bug fix test in `decimalArithmeticOperations.sql`

Closes apache#36698 from ulysses-you/decimal.

Lead-authored-by: ulysses-you <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* fix ut

Co-authored-by: Jiaan Geng <[email protected]>
Co-authored-by: ulysses-you <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
zheniantoushipashi pushed a commit to Kyligence/spark that referenced this pull request Aug 8, 2022
…mal binary arithmetic (#481)

* [SPARK-39270][SQL] JDBC dialect supports registering dialect specific functions

### What changes were proposed in this pull request?
The build-in functions in Spark is not the same as JDBC database.
We can provide the chance users could register dialect specific functions.

### Why are the changes needed?
JDBC dialect supports registering dialect specific functions

### Does this PR introduce _any_ user-facing change?
'No'.
New feature.

### How was this patch tested?
New tests.

Closes apache#36649 from beliefer/SPARK-39270.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* [SPARK-39413][SQL] Capitalize sql keywords in JDBCV2Suite

### What changes were proposed in this pull request?
`JDBCV2Suite` exists some test case which uses sql keywords are not capitalized.
This PR will capitalize sql keywords in `JDBCV2Suite`.

### Why are the changes needed?
Capitalize sql keywords in `JDBCV2Suite`.

### Does this PR introduce _any_ user-facing change?
'No'.
Just update test cases.

### How was this patch tested?
N/A.

Closes apache#36805 from beliefer/SPARK-39413.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: huaxingao <[email protected]>

* [SPARK-38997][SPARK-39037][SQL][FOLLOWUP] PushableColumnWithoutNestedColumn` need be translated to predicate too

### What changes were proposed in this pull request?
apache#35768 assume the expression in `And`, `Or` and `Not` must be predicate.
apache#36370 and apache#36325 supported push down expressions in `GROUP BY` and `ORDER BY`. But the children of `And`, `Or` and `Not` can be `FieldReference.column(name)`.
`FieldReference.column(name)` is not a predicate, so the assert may fail.

### Why are the changes needed?
This PR fix the bug for `PushableColumnWithoutNestedColumn`.

### Does this PR introduce _any_ user-facing change?
'Yes'.
Let the push-down framework more correctly.

### How was this patch tested?
New tests

Closes apache#36776 from beliefer/SPARK-38997_SPARK-39037_followup.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* [SPARK-39316][SQL] Merge PromotePrecision and CheckOverflow into decimal binary arithmetic

### What changes were proposed in this pull request?

The main change:
- Add a new method `resultDecimalType` in `BinaryArithmetic`
- Add a new expression `DecimalAddNoOverflowCheck` for the internal decimal add, e.g. `Sum`/`Average`, the different with `Add` is:
  - `DecimalAddNoOverflowCheck` does not check overflow
  - `DecimalAddNoOverflowCheck` make `dataType` as its input parameter
- Merge the decimal precision code of `DecimalPrecision` into each arithmetic data type, so every arithmetic should report the accurate decimal type. And we can remove the unused expression `PromotePrecision` and related code
- Merge `CheckOverflow` iinto arithmetic eval and code-gen code path, so every arithmetic can handle the overflow case during runtime

Merge `PromotePrecision` into `dataType`, for example, `Add`:
```scala
override def resultDecimalType(p1: Int, s1: Int, p2: Int, s2: Int): DecimalType = {
  val resultScale = max(s1, s2)
  if (allowPrecisionLoss) {
    DecimalType.adjustPrecisionScale(max(p1 - s1, p2 - s2) + resultScale + 1,
      resultScale)
  } else {
    DecimalType.bounded(max(p1 - s1, p2 - s2) + resultScale + 1, resultScale)
  }
}
```

Merge `CheckOverflow`, for example, `Add` eval:
```scala
dataType match {
  case decimalType: DecimalType =>
    val value = numeric.plus(input1, input2)
    checkOverflow(value.asInstanceOf[Decimal], decimalType)
  ...
}
```

Note that, `CheckOverflow` is still useful after this pr, e.g. `RowEncoder`. We can do further in a separate pr.

### Why are the changes needed?

Fix the bug of `TypeCoercion`, for example:
```sql
SELECT CAST(1 AS DECIMAL(28, 2))
UNION ALL
SELECT CAST(1 AS DECIMAL(18, 2)) / CAST(1 AS DECIMAL(18, 2));
```

Relax the decimal precision at runtime, so we do not need redundant Cast

### Does this PR introduce _any_ user-facing change?

yes, bug fix

### How was this patch tested?

Pass exists test and add some bug fix test in `decimalArithmeticOperations.sql`

Closes apache#36698 from ulysses-you/decimal.

Lead-authored-by: ulysses-you <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* fix ut

Co-authored-by: Jiaan Geng <[email protected]>
Co-authored-by: ulysses-you <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
RolatZhang pushed a commit to Kyligence/spark that referenced this pull request Aug 29, 2023
…mal binary arithmetic (#481)

* [SPARK-39270][SQL] JDBC dialect supports registering dialect specific functions

The build-in functions in Spark is not the same as JDBC database.
We can provide the chance users could register dialect specific functions.

JDBC dialect supports registering dialect specific functions

'No'.
New feature.

New tests.

Closes apache#36649 from beliefer/SPARK-39270.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* [SPARK-39413][SQL] Capitalize sql keywords in JDBCV2Suite

`JDBCV2Suite` exists some test case which uses sql keywords are not capitalized.
This PR will capitalize sql keywords in `JDBCV2Suite`.

Capitalize sql keywords in `JDBCV2Suite`.

'No'.
Just update test cases.

N/A.

Closes apache#36805 from beliefer/SPARK-39413.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: huaxingao <[email protected]>

* [SPARK-38997][SPARK-39037][SQL][FOLLOWUP] PushableColumnWithoutNestedColumn` need be translated to predicate too

apache#35768 assume the expression in `And`, `Or` and `Not` must be predicate.
apache#36370 and apache#36325 supported push down expressions in `GROUP BY` and `ORDER BY`. But the children of `And`, `Or` and `Not` can be `FieldReference.column(name)`.
`FieldReference.column(name)` is not a predicate, so the assert may fail.

This PR fix the bug for `PushableColumnWithoutNestedColumn`.

'Yes'.
Let the push-down framework more correctly.

New tests

Closes apache#36776 from beliefer/SPARK-38997_SPARK-39037_followup.

Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* [SPARK-39316][SQL] Merge PromotePrecision and CheckOverflow into decimal binary arithmetic

The main change:
- Add a new method `resultDecimalType` in `BinaryArithmetic`
- Add a new expression `DecimalAddNoOverflowCheck` for the internal decimal add, e.g. `Sum`/`Average`, the different with `Add` is:
  - `DecimalAddNoOverflowCheck` does not check overflow
  - `DecimalAddNoOverflowCheck` make `dataType` as its input parameter
- Merge the decimal precision code of `DecimalPrecision` into each arithmetic data type, so every arithmetic should report the accurate decimal type. And we can remove the unused expression `PromotePrecision` and related code
- Merge `CheckOverflow` iinto arithmetic eval and code-gen code path, so every arithmetic can handle the overflow case during runtime

Merge `PromotePrecision` into `dataType`, for example, `Add`:
```scala
override def resultDecimalType(p1: Int, s1: Int, p2: Int, s2: Int): DecimalType = {
  val resultScale = max(s1, s2)
  if (allowPrecisionLoss) {
    DecimalType.adjustPrecisionScale(max(p1 - s1, p2 - s2) + resultScale + 1,
      resultScale)
  } else {
    DecimalType.bounded(max(p1 - s1, p2 - s2) + resultScale + 1, resultScale)
  }
}
```

Merge `CheckOverflow`, for example, `Add` eval:
```scala
dataType match {
  case decimalType: DecimalType =>
    val value = numeric.plus(input1, input2)
    checkOverflow(value.asInstanceOf[Decimal], decimalType)
  ...
}
```

Note that, `CheckOverflow` is still useful after this pr, e.g. `RowEncoder`. We can do further in a separate pr.

Fix the bug of `TypeCoercion`, for example:
```sql
SELECT CAST(1 AS DECIMAL(28, 2))
UNION ALL
SELECT CAST(1 AS DECIMAL(18, 2)) / CAST(1 AS DECIMAL(18, 2));
```

Relax the decimal precision at runtime, so we do not need redundant Cast

yes, bug fix

Pass exists test and add some bug fix test in `decimalArithmeticOperations.sql`

Closes apache#36698 from ulysses-you/decimal.

Lead-authored-by: ulysses-you <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>

* fix ut

Co-authored-by: Jiaan Geng <[email protected]>
Co-authored-by: ulysses-you <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Co-authored-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants