Skip to content
Merged
Changes from all 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
80 changes: 80 additions & 0 deletions datafusion/sqllogictest/test_files/math.slt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,86 @@ SELECT iszero(1::DECIMAL(10,2)), iszero(0::DECIMAL(10,2)), iszero(NULL::DECIMAL(
----
false true NULL false

# iszero: scalar boundary values at the remaining numeric widths
query BBBBBBBBBB
SELECT
iszero(arrow_cast(-0.0, 'Float16')),
iszero(arrow_cast('NaN', 'Float32')),
iszero(arrow_cast('-128', 'Int8')),
iszero(arrow_cast('-32768', 'Int16')),
iszero(arrow_cast('-9223372036854775808', 'Int64')),
iszero(arrow_cast('65535', 'UInt16')),
iszero(arrow_cast('18446744073709551615', 'UInt64')),
iszero(arrow_cast('0.00', 'Decimal32(7,2)')),
iszero(arrow_cast('-12.34', 'Decimal64(16,2)')),
iszero(arrow_cast('0.00', 'Decimal256(40,2)'))
----
true false false false false false false true false true

# iszero: signed integer arrays, including minimum values and nulls
query IBBBB
SELECT id, iszero(i8), iszero(i16), iszero(i32), iszero(i64)
FROM (VALUES
(1, 0::TINYINT, 0::SMALLINT, 0::INT, 0::BIGINT),
(2, arrow_cast('-128', 'Int8'), arrow_cast('-32768', 'Int16'), arrow_cast('-2147483648', 'Int32'), arrow_cast('-9223372036854775808', 'Int64')),
(3, NULL::TINYINT, NULL::SMALLINT, NULL::INT, NULL::BIGINT)
) AS t(id, i8, i16, i32, i64)
ORDER BY id
----
1 true true true true
2 false false false false
3 NULL NULL NULL NULL

# iszero: unsigned integer arrays
query IBBBB
SELECT id, iszero(u8), iszero(u16), iszero(u32), iszero(u64)
FROM (VALUES
(1, 0::TINYINT UNSIGNED, 0::SMALLINT UNSIGNED, 0::INT UNSIGNED, 0::BIGINT UNSIGNED),
(2, 255::TINYINT UNSIGNED, 65535::SMALLINT UNSIGNED, 4294967295::INT UNSIGNED, 4294967295::BIGINT UNSIGNED),
(3, NULL::TINYINT UNSIGNED, NULL::SMALLINT UNSIGNED, NULL::INT UNSIGNED, NULL::BIGINT UNSIGNED)
) AS t(id, u8, u16, u32, u64)
ORDER BY id
----
1 true true true true
2 false false false false
3 NULL NULL NULL NULL

# iszero: floating-point arrays, including signed zero, NaN, and nulls
query IBBB
SELECT id,
iszero(arrow_cast(v, 'Float16')),
iszero(arrow_cast(v, 'Float32')),
iszero(arrow_cast(v, 'Float64'))
FROM (VALUES (1, 0.0), (2, -0.0), (3, 'NaN'::DOUBLE), (4, -1.5), (5, NULL::DOUBLE)) AS t(id, v)
ORDER BY id
----
1 true true true
2 true true true
3 false false false
4 false false false
5 NULL NULL NULL

# iszero: decimal arrays at every Arrow decimal width
query IBBBB
SELECT id,
iszero(arrow_cast(v, 'Decimal32(7,2)')),
iszero(arrow_cast(v, 'Decimal64(16,2)')),
iszero(arrow_cast(v, 'Decimal128(30,2)')),
iszero(arrow_cast(v, 'Decimal256(40,2)'))
FROM (VALUES (1, '0.00'), (2, '-12.34'), (3, NULL)) AS t(id, v)
ORDER BY id
----
1 true true true true
2 false false false false
3 NULL NULL NULL NULL

# iszero: an untyped all-null array
query B
SELECT iszero(v) FROM (VALUES (NULL), (NULL)) AS t(v)
----
NULL
NULL

# abs: empty argument
statement error
SELECT abs();
Expand Down
Loading