dynamobi/dynamobi — Issue #642: [FRG-230] validator can't deal with duplicate column aliases in nested selects
Author: dynamobi-build
Created: 2011-12-30 03:40:02+00:00
State: open
Labels: FRG, SQL Validator

[reporter="jvs", created="Wed, 1 Nov 2006 00:17:47 -0500 (GMT-05:00)"]
This case is mostly of academic interest (only managed to hit it because of a sampling SQL generator which sticks unnecessary select * on top of things).

select * from (select empno as x, deptno as x from sales.emps);

Both columns come back with the same results, which is incorrect. But

select empno as x, deptno as x from sales.emps;

does fine. The problem is that when SqlValidator expands the select *, it needs to make up SqlIdentifiers to reference the inner columns, but there's no way to do that unambiguously. However, there is no ambiguity at the SQL level (and SQL:2003 allows for duplicate column aliases as long as there is no ambiguity from the point of view of outer queries).

Rewrite the inner column aliases to make them unique, and fix up references? Yuck.