pgsync icon indicating copy to clipboard operation
pgsync copied to clipboard

Does pgsync support postgres window functions, particularly row_number?

Open michaeljmonte opened this issue 2 years ago • 1 comments

PGSync version: 2.2.0 Postgres version: 13 Elasticsearch version: 7.16.1 Redis version: 6.2.4 Python version: 3.9 Problem Description: Is it possible to set up the schema.json so that it generates SQL with a window function, particularly row_number(). Basically what I'm trying to do is the following:

SELECT
	innerq.product_id,
	innerq.product_name,
	innerq.product_isbn,
	innerq.alert_id,
	innerq.alert_message
FROM ( 
			SELECT
				p.id as product_id,
				p.name as product_name,
				p.isbn as product_isbn,
				pa.id as alert_id,
				pa.message as alert_message,
				row_number() OVER (PARTITION BY p.id ORDER BY pa.created_on DESC) AS rownum
			FROM
				product p
				LEFT JOIN product_alerts pa ON pa.product_id = p.id) innerq
WHERE
	innerq.rownum = 1;

The result set would basically be a set of products with their latest product_alert message.(This is only an example that matches my use-case)

Error Message (if any):



michaeljmonte avatar Mar 04 '22 22:03 michaeljmonte

  • Sorry about the delay. window functions are not supported.
  • Can you give me a concrete use case and what you are aiming to do?

toluaina avatar Mar 18 '22 19:03 toluaina