Skip to content

Apache DataFusion SQL Query Engine

Minor: Add FixedSizeBinaryTest (#6895)

Andrew Lambd316702722e6
diff --git a/datafusion/core/tests/sqllogictests/test_files/binary.slt b/datafusion/core/tests/sqllogictests/test_files/binary.slt
index 5738153a41..ca55ff56cb 100644
--- a/datafusion/core/tests/sqllogictests/test_files/binary.slt
+++ b/datafusion/core/tests/sqllogictests/test_files/binary.slt
@@ -16,7 +16,7 @@
# under the License.
#############
-## Tests for binary data types
+## Tests for Binary
#############
# Basic literals encoded as hex
@@ -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