Description
"Duplicate variable v already in scope" error thrown when executing a select query. This is because the select query uses 'v' as an alias, when the variable 'v' is already being used in the index.
We can reproduce this error with travel-sample sample bucket, with the following queries:
Create an index on scheduled flight IDs and number of stops using the variable 'v':
CREATE INDEX idx_flight_stops ON `travel-sample` ( stops, DISTINCT ARRAY v.flight FOR v IN schedule END ) WHERE type = "route" ; |
Perform the following select query that finds the list of scheduled 'UA' flights that have one or more stops using the alias 'v':
SELECT * FROM `travel-sample` v
|
WHERE type = "route" |
AND stops >=0 |
AND ANY v IN schedule SATISFIES v.flight LIKE 'UA%' END; |
- The following error is seen on the Query Workbench UI:
The error is seen even if the select query does not use the index. For example:
SELECT * FROM `travel-sample` v WHERE type = "route" |