apache / apache/datafusion

Coercion from `Dictionary(UInt32, Boolean)` to `Boolean`

Open
#12,511 3 comments 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

I'm trying to run a query like

```sql
select count(*) from records where json_data_colum ? 'foo' and true
```

With datafusion and getting an error:

```
type_coercion caused by Error during planning: Cannot infer common argument type for logical boolean operation Dictionary(UInt32, Boolean) AND Boolean
```

(note in our case `json_data_colum` is a dictionary column containing JSON strings, so `json_data_colum ? 'foo'` returns a `Dictionary(UInt32, Boolean)`)

This is related to https://github.com/apache/datafusion/pull/12382 where @adriangb fixed the case of filtering on a dictionary column.

I'll fix this specific case in https://github.com/datafusion-contrib/datafusion-functions-json, but I guess this should work.

Contributor guide

Open the contributing guide

Research direction

Reproduce the SQL query and inspect the type-coercion path for logical AND expressions involving Dictionary(UInt32, Boolean). Read the behavior and discussion in DataFusion PR 12382, then verify that the dictionary-backed predicate plans successfully; done means the query no longer fails with the common-argument-type error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.