V 25.0.0: When using OR condition, giving error : Detected duplicate prefix in join clauses
- Dominant language
- Java
- Stars
- 14.1k
- Forks
- 3.8k
- Avg merge
- 2d 58m
- Merged PRs (30d)
- 233
Description
**Druid Version 25.0.0**
**Query used:**
```
select SUM(fe.dist_total_revenue),
fe.sales_year,
fe.sales_month,
fe.sales_quarter from denorm_fact_extrapolated_unspsc fe
-- INNER join
where fe.manf_desc = 'BDD' OR fe.manf_desc in (SELECT
manf_desc as top5manf_desc
FROM
denorm_fact_extrapolated_unspsc fes
where
__time BETWEEN TIME_PARSE ('2019-01-31T00:00:00.000Z')
AND TIME_PARSE ('2023-01-31T00:00:00.000Z')
AND fes.manf_desc != 'BDD'
and fes.taxonomy_id in (
SELECT
unspsc_code
FROM
denorm_manf_entitlements
where
email_address= 'a@b.com'
)
group by
manf_desc
order by
SUM(fes.dist_total_revenue) desc
limit
5
)
-- top5manf on manf_desc = top5manf_desc
-- WHERE
AND __time BETWEEN TIME_PARSE ('2019-01-31T00:00:00.000Z')
AND TIME_PARSE ('2023-01-31T00:00:00.000Z')
AND fe.taxonomy_id IN(
SELECT
unspsc_code
FROM
denorm_manf_entitlements
WHERE
email_address= 'a@b.com'
)
group by fe.sales_year,
fe.sales_month,
fe.sales_quarter
```
**Error when running above code:**
> Error: Unknown exception
> Detected duplicate prefix in join clauses: [__j0.]
> org.apache.druid.java.util.common.IAE
**Main Issue**
If i remove below code from the query, it works
```
OR fe.manf_desc in (SELECT
manf_desc as top5manf_desc
FROM
denorm_fact_extrapolated_unspsc fes
where
__time BETWEEN TIME_PARSE ('2019-01-31T00:00:00.000Z')
AND TIME_PARSE ('2023-01-31T00:00:00.000Z')
AND fes.manf_desc != 'BDD'
and fes.taxonomy_id in (
SELECT
unspsc_code
FROM
denorm_manf_entitlements
where
email_address= 'a@b.com'
)
group by
manf_desc
order by
SUM(fes.dist_total_revenue) desc
limit
5
)
```
Contributor guide
Research direction
Start by reproducing the supplied query against Apache Druid 25.0.0 and confirm the “Detected duplicate prefix in join clauses: [__j0.]” error. Compare it with the query after removing the OR subquery; done means the complete query no longer raises the duplicate-prefix exception and regression coverage demonstrates the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100