YAML -> SQL

YAML

    
main:
  select:
  - field: ct.*
  from:
    alias: ct
    fields:
    - name: problem_id
      type: bigint
    - name: info_1
      type: varchar(255)
    - name: info_2
      type: varchar(255)
    - name: info_3
      type: varchar(255)
    crosstab:
    - select:
      - extra_infos.problem_id
      - extra_infos.info_type
      - extra_infos.info_value
      from: extra_infos
    - select:
      - extra_infos.info_type 
      distinct: true
      from: extra_infos

    

SQL

    
SELECT ct.* FROM crosstab('SELECT extra_infos.problem_id, extra_infos.info_type, extra_infos.info_value FROM "extra_infos"', 'SELECT DISTINCT extra_infos.info_type FROM "extra_infos"') AS ct("problem_id" bigint, "info_1" varchar(255), "info_2" varchar(255), "info_3" varchar(255))