Error in query

29 views
Skip to first unread message

aparna bala

unread,
Jan 31, 2023, 4:52:35 AM1/31/23
to Druid User
Hi, when i  run this query , it shows an error
SELECT
      (SELECT COUNT(*)  FROM "test1" i WHERE o.id >= i.id) "rowNum" 
    , __time
FROM "test1" o


error: SQL requires a join with 'GREATER_THAN_OR_EQUAL' condition that is not supported.

Steve Halladay

unread,
Jan 31, 2023, 5:18:35 PM1/31/23
to Druid User
I noticed your question and I happened to have been reading about JOINs in Druid SQL. You may find this doc helpful https://druid.apache.org/docs/latest/querying/datasource.html#join.
I'm not sure I understand what you are trying to do with the query, but it appears that Druid sometimes treats subqueries as JOINs (in the native language query), and Druid can only perform JOINs with equality conditions.
Feel free to let us know if this helps.

Ben Krug

unread,
Feb 1, 2023, 7:03:23 PM2/1/23
to druid...@googlegroups.com
I agree, there's an implicit join in use.  What is the query trying to do exactly?  Seems like it's trying to find a pseudo rowNum, but I don't get the logic behind it.

--
You received this message because you are subscribed to the Google Groups "Druid User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to druid-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/druid-user/446b126c-1aca-490a-ac33-ec030683f64dn%40googlegroups.com.

John Kowtko

unread,
Feb 2, 2023, 10:54:13 AM2/2/23
to Druid User
I thought that Druid only recognizes equality join conditions ... so that WHERE condition should be recognized as a regular filter condition, not a join condition.

For generating Rank/Rownum like this, you may have to do a CROSS JOIN between the two tables and then apply the inequality WHERE condition:

-- John
Reply all
Reply to author
Forward
0 new messages