Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Jul 11, 2022

Which issue does this PR close?

Closes #2873

Rationale for this change

Fixes a bug introduced in #2819

See #2873 (a query that used to work does not anymore). The underlying issue is described in #2874

What changes are included in this PR?

Hack around #2874

Are there any user-facing changes?

Sone queries on dictionaries work again

cc @viirya

@github-actions github-actions bot added core Core DataFusion crate physical-expr Changes to the physical-expr crates labels Jul 11, 2022
@alamb alamb changed the title Alamb/fix cast dicts Fix casts of ScalarValue::Utf8 toDictionaryArray Jul 11, 2022
&array,
&self.cast_type,
)?)),
ColumnarValue::Scalar(scalar)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual code change -- the rest of the PR is tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this prevent this from using the scalar comparison kernels, effectively reversing #2808

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 that is a good point -- perhaps I'll have a go at a proper fix for #2874

// $VALUE_FN is an expression (like `result.value`) that extracts the value at index `i`
macro_rules! generic_test_cast {
($A_ARRAY:ident, $A_TYPE:expr, $A_VEC:expr, $TYPEARRAY:ident, $TYPE:expr, $VEC:expr) => {{
($A_ARRAY:ident, $A_TYPE:expr, $A_VEC:expr, $TYPEARRAY:ident, $TYPE:expr, $VEC:expr, $VALUE_FN:expr) => {{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed to add a way to extract the value of the result at element i because it is different for a DictionaryArray

@alamb alamb marked this pull request as ready for review July 11, 2022 18:56
@alamb alamb changed the title Fix casts of ScalarValue::Utf8 toDictionaryArray Fix casts of ScalarValue::Utf8 to DictionaryArray Jul 11, 2022
@alamb alamb force-pushed the alamb/fix_cast_dicts branch from 3b4c110 to 24df39e Compare July 12, 2022 13:54
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a massive fan of this, as I think it will basically prevent evaluating scalar predicates directly against dictionaries, but I'm approving as it is blocking upgrades.

I personally would prefer we carry the data type on ColumnarValue::Scalar or something...

@alamb alamb marked this pull request as draft July 12, 2022 17:08
@alamb
Copy link
Contributor Author

alamb commented Jul 12, 2022

Will convert to draft as I attempt to "do it properly" as in #2874

@alamb
Copy link
Contributor Author

alamb commented Jul 12, 2022

Update: Doing it properly in #2891 is showing good promise

@alamb
Copy link
Contributor Author

alamb commented Jul 14, 2022

Closing in favor of #2891

@alamb alamb closed this Jul 14, 2022
@alamb alamb deleted the alamb/fix_cast_dicts branch August 8, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error with CASE and DictionaryArrays: ArrowError(InvalidArgumentError("arguments need to have the same data type"))

2 participants