Обсуждение: [PATCH] Add native PIVOT syntax for SQL Server/Oracle compatibility

Поиск
Список
Период
Сортировка

[PATCH] Add native PIVOT syntax for SQL Server/Oracle compatibility

От
Myles Lewis
Дата:
I've developed a patch that adds native PIVOT syntax to PostgreSQL,
enabling SQL Server and Oracle-style pivot queries.

Example:
  SELECT region
  FROM sales
  PIVOT (SUM(revenue) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));

Key features:
- Parser-level transformation to FILTER aggregates
- No executor changes required
- Supports SUM, COUNT, AVG, MIN, MAX
- View creation with pg_get_viewdef() roundtrip
- Comprehensive regression tests (788 lines)

Patch attached.

Myles
Вложения