Select to view content in your preferred language

Raise exception when correlated subquery used in FGDB SQL (not supported)

386
1
02-03-2023 07:58 AM
Status: Open
Labels (1)
Bud
by
Esteemed Contributor

A correlated subquery is a subquery that depends on a value or table name from the main query that surrounds it. Source: Practical SQL by Anthony Debarros.

Example:

NOT EXISTS (
        SELECT *
        FROM road_insp r2
        WHERE r2.asset_id = road_insp.asset_id AND r2.date_ > road_insp.date_
       )
--Demo: https://dbfiddle.uk/gSGjLTCW

If we use a correlated subquery in file geodatabase SQL, such as in an FGDB view or SQL expression, then ArcGIS Pro will execute the SQL without throwing an error, but the result will be incorrect. Despite the presence of the subquery in the WHERE clause, either all rows or no rows will be returned, which is not the correct result.

The incorrect results are misleading and can cause serious problems in our GIS analysis if not caught.

In a community post, an Esri staff member mentioned, "File Geodatabase does not support correlated subqueries." But you'd never know it when writing SQL in ArcGIS Pro.

Idea:

Could ArcGIS Pro be enhanced so that it raises an exception when a correlated subquery is used in FGDB SQL?

Related:

Thanks.

1 Comment
Bud
by

BUG-000156143 - An SQL query containing the EXISTS predicate validates successfully but returns incorrect results from a file geodatabase.

ENH-000156158 - Raise exception when using unsupported SQL expressions in file geodatabases.

Esri Canada Case 03264937 - Exception not raised when unsupported FGDB SQL used (correlated subquery)