[MDEV-31070] PIVOT table incorrectly formed Created: 2023-04-18  Updated: 2023-05-22

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - Connect
Affects Version/s: 10.6.12
Fix Version/s: 10.6

Type: Bug Priority: Major
Reporter: Matteo Tassinari Assignee: Andrew Hutchings
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Ubuntu 22.04


Attachments: Microsoft Word pivot_error.xlsx    

 Description   

Given a sort of EAV table with the attached data, I tried defining a PIVOT table to transform the `campo` in actual columns, where the value would be `valore`, and the remaning `id_*` fields would be the remaning key fields as

CREATE OR REPLACE TABLE my_pivot_table
ENGINE=CONNECT
TABLE_TYPE=PIVOT
TABNAME=my_source_table
OPTION_LIST='user=connect,PivotCol=campo,FncCol=valore,GroupBy=1';

However this produces the wrong structure, as seen in the second sheet of attached data.

Here you see the `id_*` fields are repeated for each field determined by `campo`, and each rows populates only one field, leaving the others empty, while I would have expected a single row with all the fields populated.

I think the table definition is incorrect, hence this appears to be a problem in the connect engine itself.



 Comments   
Comment by Matteo Tassinari [ 2023-04-18 ]

I attached the original and pivoted data as Excel file as I was not able to properly format the table directly in the bug description, sorry for that.

Generated at Thu Feb 08 10:21:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.