Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-31070

PIVOT table incorrectly formed

    XMLWordPrintable

Details

    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.

      Attachments

        Activity

          People

            TheLinuxJedi Andrew Hutchings
            Tasso85 Matteo Tassinari
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.