Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow referencing grandparent fields #15981

Open
hlcianfagna opened this issue May 10, 2024 · 0 comments
Open

Allow referencing grandparent fields #15981

hlcianfagna opened this issue May 10, 2024 · 0 comments

Comments

@hlcianfagna
Copy link
Contributor

hlcianfagna commented May 10, 2024

Problem Statement

When writing certain analytical queries it is useful to be able to refer to "grandparent" fields, for instance:

WITH myvalues
AS (
	SELECT 1 AS a
	)
SELECT (
		SELECT subquery1.a
		FROM (
			SELECT a.b as a
			FROM generate_series(1, 2) a(b)
			WHERE a.b = myvalues.a
			) subquery1
		)
FROM myvalues;

This currently fails with:

UnsupportedFeatureException[Cannot use relation "myvalues" in this context. Can only access columns of an immediate parent, not a grandparent]

However in PostgreSQL it is accepted:

 a 
---
 1
(1 row

Possible Solutions

Resolve field names like in PostgreSQL

Considered Alternatives

Depends on the situation, in some queries it is for instance possible to bring filtering one level up, into a CTE, using arrays, and then process them with array expressions at a single-row level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants