You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error with partitioned dataset: Cannot infer common argument type for comparison operation Binary != Utf8 #7039
When running the following query (from ClickBench) on the partitioned dataset (100 parquet files)
SELECT"MobilePhoneModel", COUNT(DISTINCT "UserID") AS u FROM hits_partitioned WHERE"MobilePhoneModel"<>''GROUP BY"MobilePhoneModel"ORDER BY u DESCLIMIT10;
I get the following error:
Error during planning: Cannot infer common argument type for comparison operation Binary != Utf8
To Reproduce
Get the data using bench.sh (after #7005 is merged)
bench.sh data clickbench_1
bench.sh data clickbench_multi
CREATE EXTERNAL TABLE hits_partitioned
STORED AS PARQUET
LOCATION 'hits_partitioned';
SELECT"MobilePhoneModel", COUNT(DISTINCT "UserID") AS u FROM hits_partitioned WHERE"MobilePhoneModel"<>''GROUP BY"MobilePhoneModel"ORDER BY u DESCLIMIT10;
Expected behavior
The query works fine with the single file dataset. I expect the same error
-- Single file parquet
CREATE EXTERNAL TABLE hits_single
STORED AS PARQUET
LOCATION 'hits.parquet';
-- Single file works great
SELECT "MobilePhoneModel", COUNT(DISTINCT "UserID") AS u FROM hits_single WHERE "MobilePhoneModel" <> '' GROUP BY "MobilePhoneModel" ORDER BY u DESC LIMIT 10;
changed the title [-]ClickBench error with partitioned dataset: Cannot infer common argument type for comparison operation Binary != Utf8[/-][+]Error with partitioned dataset: Cannot infer common argument type for comparison operation Binary != Utf8[/+]on Jul 24, 2023
Thank you for the investigation @jonahgao -- think coercion for binary --> UTF8 would make sense. I will try and find some time to work on this if no one beats me to it.
🤔 Or maybe I will file a ticket and see if someone else wants to work on it.
It would be better if we could manually specify the data type of the columns, which is not currently supported for Parquet.
I think that we can do this safely when we are certain that the binary data is valid UTF-8.
I think that we can do this safely when we are certain that the binary data is valid UTF-8.
I agree -- I think it would be good to cast the column into UTF8 (erroring if it contains non UTF8 data)
For this particular query we could add an explicit cast like ::varchar perhaps like the following
SELECT"MobilePhoneModel"::varchar,
COUNT(DISTINCT "UserID") AS u
FROM hits_partitioned
WHERE"MobilePhoneModel"<>''GROUP BY"MobilePhoneModel"ORDER BY u DESCLIMIT10;
Activity
[-]ClickBench error with partitioned dataset: Cannot infer common argument type for comparison operation Binary != Utf8[/-][+]Error with partitioned dataset: Cannot infer common argument type for comparison operation Binary != Utf8[/+]jonahgao commentedon Jul 24, 2023
The schemas of these two datasets in Parquet format are different.
The single file dataset has specified the logical type as
Stringfor MobilePhoneModel, but the partitioned one does not have that specification.In the partitioned dataset, the type inference for the MobilePhoneModel is
Binary.I think we may need to support type coercion from
Utf8toBinaryhere.alamb commentedon Jul 24, 2023
Thank you for the investigation @jonahgao -- think coercion for binary --> UTF8 would make sense. I will try and find some time to work on this if no one beats me to it.
🤔 Or maybe I will file a ticket and see if someone else wants to work on it.
jonahgao commentedon Jul 25, 2023
#7080 should make the query execution successful.
But the MobilePhoneModel displayed in binary format.
It would be better if we could manually specify the data type of the columns, which is not currently supported for Parquet.
I think that we can do this safely when we are certain that the binary data is valid UTF-8.
create external table hits_partitioned( "UserID" bigint, "MobilePhoneModel" text ) STORED AS PARQUET LOCATION 'hits_partitioned';https://github.com/apache/arrow-datafusion/blob/1a0542acbc01e5243471ae0fc3586c2f1f40013b/datafusion/sql/src/statement.rs#L636-L640
alamb commentedon Jul 25, 2023
I agree -- I think it would be good to cast the column into
UTF8(erroring if it contains non UTF8 data)For this particular query we could add an explicit cast like
::varcharperhaps like the followingjonahgao commentedon Jul 25, 2023
This must be the best way 👍 .