Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: Add FixedSizeBinaryTest #6895

Merged
merged 4 commits into from
Jul 14, 2023
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
56 changes: 55 additions & 1 deletion datafusion/core/tests/sqllogictests/test_files/binary.slt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

#############
## Tests for binary data types
## Tests for Binary
#############

# Basic literals encoded as hex
Expand Down Expand Up @@ -73,3 +73,57 @@ GROUP BY column1;
1
1
1

statement ok
drop table t;

#############
## Tests for FixedSizeBinary
#############

# fixed_size_binary
statement ok
CREATE TABLE t_source
AS VALUES
(X'000102', X'000102'),
(X'003102', X'000102'),
(NULL, X'000102'),
(X'FF0102', X'000102'),
(X'000102', X'000102')
;

# Create a table with FixedSizeBinary
statement ok
CREATE TABLE t
AS SELECT
arrow_cast(column1, 'FixedSizeBinary(3)') as "column1",
arrow_cast(column2, 'FixedSizeBinary(3)') as "column2"
FROM t_source;

query ?T
SELECT column1, arrow_typeof(column1) FROM t;
----
000102 FixedSizeBinary(3)
003102 FixedSizeBinary(3)
NULL FixedSizeBinary(3)
ff0102 FixedSizeBinary(3)
000102 FixedSizeBinary(3)

# Comparison
# https://github.com/apache/arrow-rs/pull/4492
query error DataFusion error: Arrow error: Compute error: eq_dyn_binary_scalar only supports Binary or LargeBinary arrays
SELECT
column1,
column2,
column1 = arrow_cast(X'000102', 'FixedSizeBinary(3)'),
column1 = column2
FROM t


# Comparison to different sized field
query error DataFusion error: Error during planning: Cannot infer common argument type for comparison operation FixedSizeBinary\(3\) = FixedSizeBinary\(2\)
SELECT column1, column1 = arrow_cast(X'0102', 'FixedSizeBinary(2)') FROM t

# Comparison to different sized Binary
query error DataFusion error: Error during planning: Cannot infer common argument type for comparison operation FixedSizeBinary\(3\) = Binary
SELECT column1, column1 = X'0102' FROM t