Skip to content

Decimal & UInt Binary operation giving wrong output #16667

Open
@jatin510

Description

@jatin510

Describe the bug

The binary operation between Unsigned Integer and Decimal type produces wrong output.

To Reproduce

Eg queries:

 select arrow_cast(1.23,'Decimal128(3,2)') *  arrow_cast(123, 'UInt64') as multiply;
+----------+
| multiply |
+----------+
| 123      |
+----------+
1 row(s) fetched. 
Elapsed 0.008 seconds.

> 

 select arrow_cast(1.23,'Decimal128(3,2)') *  arrow_cast(123, 'Int64') as multiply;
+----------+
| multiply |
+----------+
| 151.29   |
+----------+
1 row(s) fetched. 

 select arrow_cast(1.23,'Decimal128(3,2)') -  arrow_cast(1, 'UInt64') as subtration;
+----------+
| multiply |
+----------+
| 0        |
+----------+
1 row(s) fetched. 
Elapsed 0.007 seconds.


Expected behavior

select arrow_cast(1.23,'Decimal128(3,2)') *  arrow_cast(123, 'UInt64') as multiply;
+----------+
| multiply |
+----------+
| 151.29     |
+----------+
1 row(s) fetched. 
Elapsed 0.008 seconds.

> 

 select arrow_cast(1.23,'Decimal128(3,2)') *  arrow_cast(123, 'Int64') as multiply;
+----------+
| multiply |
+----------+
| 151.29   |
+----------+
1 row(s) fetched. 

> select arrow_cast(1.23,'Decimal128(3,2)') -  arrow_cast(123, 'Int64') as subtration;
+----------+
| multiply |
+----------+
| -121.77  |
+----------+
1 row(s) fetched. 
Elapsed 0.007 seconds.

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions