Help using REGEXP_EXTRACT function

I have a table that looks like this:

{"timestamp": "2011-01-12T00:00:00.000Z", "tags": "0,0,1"}  #row1
{"timestamp": "2011-01-13T00:00:00.000Z", "tags": "0,0,1"}  #row2
{"timestamp": "2011-01-14T00:00:00.000Z", "tags": "0,1,0"}  #row3
{"timestamp": "2011-01-14T00:00:00.000Z", "tags": "0,1,1"}  #row4

I’m trying to select the rows that have ‘1’ on the last index of dimension ‘tags’.

To do this I’m using the following Druid SQL query:

{“query”:"SELECT count() FROM mytablename where REGEXP_EXTRACT(tags, '^(.{0}+|.),(.{0}+|.),(.{0}+|.)$’,3)=‘1’ "}

Do you see anything wrong with the above query?

That query never completes .

Is there a better way of doing this?

That query never completes .

How many rows are being queried? Does the query complete if you run it on a smaller dataset?

Perhaps you could try LIKE with “%,1”, if tags will always have that format