apache / apache/gluten

[CH] Wired type result of decimal plus

Open
#8,990 2 comments 0 reactions 0 assignees View on GitHub
bug triage
Dominant language
Scala
Stars
1.6k
Forks
657
Avg merge
2d 14h
Merged PRs (30d)
80

Description

### Backend

CH (ClickHouse)

### Bug description

`select typeof((p*(1.0-p)/n+z*z/(4.0*n*n))) from (select cast('0E-14' as decimal(38,14)) as p, cast('1.96' as decimal(3,2)) as z, cast(37 as long) as n, id from range(1));`
got:
```
+----------------------------------------------------+
| typeof((((p * (1.0 - p)) / n) + ((z * z) / ((4.0 * n) * n)))) |
+----------------------------------------------------+
| decimal(38,6) |
```

`select typeof( (z*z/(4.0*n*n))) from (select cast('0E-14' as decimal(38,14)) as p, cast('1.96' as decimal(3,2)) as z, cast(37 as long) as n, id from range(1));`
got:
```
+--------------------------------------+
| typeof(((z * z) / ((4.0 * n) * n))) |
+--------------------------------------+
| decimal(38,34) |
```

`select typeof( (p*(1.0-p)/n)) from (select cast('0E-14' as decimal(38,14)) as p, cast('1.96' as decimal(3,2)) as z, cast(37 as long) as n, id from range(1));`
got:
```
+--------------------------------+
| typeof(((p * (1.0 - p)) / n)) |
+--------------------------------+
| decimal(38,6) |
```

### Spark version

Spark-3.3.x

### Spark configurations

_No response_

### System information

_No response_

### Relevant logs

```bash

```

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied Spark 3.3.x query against the ClickHouse backend and compare the reported decimal types with Spark's expected behavior. Trace the decimal type inference used for arithmetic expressions; done means the expression reports the intended precision and scale and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
clickhouse, scala, spark
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.