[BUG] Alias cannot be referred in Compiler with union subqueries
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 468
- Avg merge
- 29m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
There seems to be an issue with the compiler where aliases in union subqueries cannot be referenced correctly. Below is an example that illustrates the problem:
```
gremlin> g.V().limit(1).union(out(), out().out()).as('a').select('a').count()
ErrorCode: TAG_NOT_FOUND
Message: {alias=a} not found; expected aliases are: [_]
```
Workaround Solution:
By rewriting the query, we can achieve the expected results:
```
gremlin> g.V().limit(1).union(out().as('a'), out().out().as('a')).select('a').count()
==>30033
```
To reproduce, compiler configuration is as follows:
```
graph.planner.is.on=true
graph.planner.opt=RBO
graph.planner.rules=FilterIntoJoinRule, FilterMatchRule, ExtendIntersectRule, ExpandGetVFusionRule
graph.physical.opt=proto
gremlin.script.language.name=antlr_gremlin_calcite
```
Contributor guide
Research direction
Start by running the reported Gremlin query with the listed compiler configuration, then compare it with the workaround that places the alias inside each union branch. Trace how the compiler handles aliases across union subqueries; done means the original query resolves alias a and produces the expected count without the workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100