apache / apache/datafusion

Support casting from UTF8 --> FixedSizeBinary, Binary --> FixedSizedBinary

Open
#5,530 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

**Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
A user reported on discord that they were trying to use DataFusion to query FixedSizeBinary fields stored in parquet?

Message link:
https://discord.com/channels/885562378132000778/885562378132000781/1083347011497119775

There is probably a whole project to fully support FixedSizeBinary fields, but initially at least it would be nice to be able to cast them to types that DataFusion has better support for (like Binary)

**Describe the solution you'd like**

@tustvold filed https://github.com/apache/arrow-rs/issues/3826 to track adding conversion between binary <-> fixed size binary

Once that is available, I expect this to work

```
❯ select arrow_cast('002920a3044b3c9f56e797b8'::bytea, 'FixedSizeBinary(12)');
Error during planning: Cannot automatically convert Binary to FixedSizeBinary(12)
```

Once there is direct support to cast between Utf8 and FixedSizeBinary, I would also expect this to work

```
select arrow_cast('002920a3044b3c9f56e797b8', 'FixedSizeBinary(12)');
Error during planning: Cannot automatically convert Utf8 to FixedSizeBinary(12)
```

**Describe alternatives you've considered**

**Additional context**

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the requested binary-to-fixed-size-binary conversion tracked in apache/arrow-rs#3826, then reproduce the two arrow_cast SQL examples from this issue. Done means DataFusion accepts the requested Binary and Utf8 casts to FixedSizeBinary with the expected size validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.