Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions datafusion/sqllogictest/test_files/operator.slt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,42 @@ from numeric_types;
----
Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64 Float32 Float64 Decimal128(6, 2)

# Plus with literal integer
query TTTTTTTTTTT
select
arrow_typeof(int8 + 2),
arrow_typeof(int16 + 2),
arrow_typeof(int32 + 2),
arrow_typeof(int64 + 2),
arrow_typeof(uint8 + 2),
arrow_typeof(uint16 + 2),
arrow_typeof(uint32 + 2),
arrow_typeof(uint64 + 2),
arrow_typeof(float32 + 2),
arrow_typeof(float64 + 2),
arrow_typeof(decimal + 2)
from numeric_types;
----
Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Float32 Float64 Decimal128(23, 2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shows that adding a literal integer (2) does not upcast to Decimal for integer types (which would be terrible for performance)


# Plus with literal decimal
query TTTTTTTTTTT
select
arrow_typeof(int8 + 2.0),
arrow_typeof(int16 + 2.0),
arrow_typeof(int32 + 2.0),
arrow_typeof(int64 + 2.0),
arrow_typeof(uint8 + 2.0),
arrow_typeof(uint16 + 2.0),
arrow_typeof(uint32 + 2.0),
arrow_typeof(uint64 + 2.0),
arrow_typeof(float32 + 2.0),
arrow_typeof(float64 + 2.0),
arrow_typeof(decimal + 2.0)
from numeric_types;
----
Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64


# Minus with the same operand type, expect the same output type
# except for decimal which is promoted to the highest precision
Expand All @@ -72,6 +108,43 @@ from numeric_types;
----
Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64 Float32 Float64 Decimal128(6, 2)

# Minus with literal integer
query TTTTTTTTTTT
select
arrow_typeof(int8 - 2),
arrow_typeof(int16 - 2),
arrow_typeof(int32 - 2),
arrow_typeof(int64 - 2),
arrow_typeof(uint8 - 2),
arrow_typeof(uint16 - 2),
arrow_typeof(uint32 - 2),
arrow_typeof(uint64 - 2),
arrow_typeof(float32 - 2),
arrow_typeof(float64 - 2),
arrow_typeof(decimal - 2)
from numeric_types;
----
Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Float32 Float64 Decimal128(23, 2)

# Minus with literal decimal
query TTTTTTTTTTT
select
arrow_typeof(int8 - 2.0),
arrow_typeof(int16 - 2.0),
arrow_typeof(int32 - 2.0),
arrow_typeof(int64 - 2.0),
arrow_typeof(uint8 - 2.0),
arrow_typeof(uint16 - 2.0),
arrow_typeof(uint32 - 2.0),
arrow_typeof(uint64 - 2.0),
arrow_typeof(float32 - 2.0),
arrow_typeof(float64 - 2.0),
arrow_typeof(decimal - 2.0)
from numeric_types;
----
Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64


# Multiply with the same operand type, expect the same output type
# except for decimal which is promoted to the highest precision
query TTTTTTTTTTT
Expand All @@ -91,6 +164,43 @@ from numeric_types;
----
Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64 Float32 Float64 Decimal128(11, 4)

# Multiply with literal integer
query TTTTTTTTTTT
select
arrow_typeof(int8 * 2),
arrow_typeof(int16 * 2),
arrow_typeof(int32 * 2),
arrow_typeof(int64 * 2),
arrow_typeof(uint8 * 2),
arrow_typeof(uint16 * 2),
arrow_typeof(uint32 * 2),
arrow_typeof(uint64 * 2),
arrow_typeof(float32 * 2),
arrow_typeof(float64 * 2),
arrow_typeof(decimal * 2)
from numeric_types;
----
Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Float32 Float64 Decimal128(26, 2)

# Multiply with literal decimal
query TTTTTTTTTTT
select
arrow_typeof(int8 * 2.0),
arrow_typeof(int16 * 2.0),
arrow_typeof(int32 * 2.0),
arrow_typeof(int64 * 2.0),
arrow_typeof(uint8 * 2.0),
arrow_typeof(uint16 * 2.0),
arrow_typeof(uint32 * 2.0),
arrow_typeof(uint64 * 2.0),
arrow_typeof(float32 * 2.0),
arrow_typeof(float64 * 2.0),
arrow_typeof(decimal * 2.0)
from numeric_types;
----
Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64


# Divide with the same operand type, expect the same output type
# except for decimal which is promoted to the highest precision
query TTTTTTTTTTT
Expand All @@ -110,5 +220,42 @@ from numeric_types;
----
Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64 Float32 Float64 Decimal128(11, 6)

# Divide with literal integer
query TTTTTTTTTTT
select
arrow_typeof(int8 / 2),
arrow_typeof(int16 / 2),
arrow_typeof(int32 / 2),
arrow_typeof(int64 / 2),
arrow_typeof(uint8 / 2),
arrow_typeof(uint16 / 2),
arrow_typeof(uint32 / 2),
arrow_typeof(uint64 / 2),
arrow_typeof(float32 / 2),
arrow_typeof(float64 / 2),
arrow_typeof(decimal / 2)
from numeric_types;
----
Int64 Int64 Int64 Int64 Int64 Int64 Int64 Int64 Float32 Float64 Decimal128(9, 6)

# Divide with literal decimal
query TTTTTTTTTTT
select
arrow_typeof(int8 / 2.0),
arrow_typeof(int16 / 2.0),
arrow_typeof(int32 / 2.0),
arrow_typeof(int64 / 2.0),
arrow_typeof(uint8 / 2.0),
arrow_typeof(uint16 / 2.0),
arrow_typeof(uint32 / 2.0),
arrow_typeof(uint64 / 2.0),
arrow_typeof(float32 / 2.0),
arrow_typeof(float64 / 2.0),
arrow_typeof(decimal / 2.0)
from numeric_types;
----
Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64


statement ok
drop table numeric_types