How to add table name argument to Time range variable while running join tables query

The query I have written for a join table query in a grafana dashboard panel to be pulled from druid

SELECT
"stream2:table.“coulmn1”,
“stream1:table”.“column1”
FROM “stream1:table”
INNER JOIN “stream2:table” ON “stream1:table”.“common_key” = "stream2:table.“common_key”
WHERE “stream1:table”.“condition” = ‘xxx’

The query grafana is running along with time range for the dashboard.

SELECT
"stream2:table.“coulmn1”,
“stream1:table”.“column1”
FROM “stream1:table”
INNER JOIN “stream2:table” ON “stream1:table”.“common_key” = "stream2:table.“common_key”
WHERE “stream1:table”.“condition” = ‘xxx’
AND __time >= TIME_PARSE(‘2021-12-31T18:30:00.000Z’) AND __time <= TIME_PARSE(‘2022-12-31T18:29:59.999Z’)

The Error I’m seeing

POST https://druid-dev.interactivedatastore.xxx/druid/v2/sql giving up after 1 attempt(s): failed to query Druid: {Error:Plan validation failed ErrorMessage:org.apache.calcite.runtime.CalciteContextException: From line 6, column 64 to line 6, column 69: Column ‘__time’ is ambiguous ErrorClass:org.apache.calcite.tools.ValidationException Host:}

This happens due to __time column being available in both tables.

How can I add changes to the panel so that query for time range looks like this.

AND “stream1:table”.__time >= TIME_PARSE(‘2021-12-31T18:30:00.000Z’) AND “stream1:table”.__time <= TIME_PARSE(‘2022-12-31T18:29:59.999Z’)

This might work:
SELECT Col1, Col2 FROM ( SELECT "stream2:table.“coulmn1” AS Col1, “stream1:table”.“column1” AS Col2, “stream1:table”.__time AS Time FROM “stream1:table” INNER JOIN “stream2:table” ON “stream1:table”.“common_key” = "stream2:table.“common_key” WHERE “stream1:table”.“condition” = ‘xxx’ ) AS Output WHERE Time >= TIME_PARSE(‘2021-12-31T18:30:00.000Z’) AND Time <= TIME_PARSE(‘2022-12-31T18:29:59.999Z’)

Hope this helps.