vollt icon indicating copy to clipboard operation
vollt copied to clipboard

Wrong ADQL to SQL translation: alias not unique

Open almicol opened this issue 6 years ago • 1 comments

The following query:

SELECT top 10 a.dec2000, b.dec2000 FROM ph3_mcatalog_fits_V2 a, ph3_mcatalog_fits_V2 b WHERE a.dec2000 between b.dec2000 -0.1 and b.dec2000 + 0.1 and b.ra2000 > a.ra2000 and b.ra2000 < a.ra2000+0.1 AND a.dec2000 < -80.15 AND b.dec2000 < -80.15

Fails with error: Alias 'dec2000' is not unique.

The problem is in the creation of two aliases with the same name (dec2000). Here the full translation to SQL:

<errorSummary type="fatal" hasDetail="true">Unexpected error while executing a SQL query: SQL Anywhere Error -830: Alias 'dec2000' is not unique This is due to wrong aliasing when translating to SQL: SELECT TOP 10 "a"."DEC2000" AS "dec2000" , "b"."DEC2000" AS "dec2000" FROM "safcat"."ph3_mcatalog_fits_V2" AS "a" CROSS JOIN "safcat"."ph3_mcatalog_fits_V2" AS "b" WHERE "a"."DEC2000" BETWEEN "b"."DEC2000"-0.1 AND "b"."DEC2000"+0.1 AND "b"."RA2000" > "a"."RA2000" AND "b"."RA2000" < "a"."RA2000"+0.1 AND "a"."DEC2000" < -80.15 AND "b"."DEC2000" < -80.15

Could you please have a look? Thanks!

almicol avatar May 11 '18 13:05 almicol