apache/druid · error · UnsupportedOperationException
Cannot filter datasource
Error message
Cannot filter datasource [%s] using [%s]
What it means
When a Druid 'table' (or similar) datasource is used with MSQ, the query's segment spec must cover all of time (eternity). checkQuerySegmentSpecIsEternity throws this UnsupportedOperationException when the intervals filter is anything other than [MIN-MAX]/eternity, i.e. the user tried to restrict the datasource with an intervals() filter that MSQ cannot push down here.
Solutions
- Replace the intervals filter with a WHERE __time >= ... AND __time < ... predicate on the time column.
- Remove the interval restriction and query the full datasource, filtering results in SQL.
- Rewrite as a native query (not MSQ) if interval-based segment pruning is essential.
- Upgrade Druid if a newer version supports interval pushdown for this datasource type.
Example fix
// before
SELECT * FROM TABLE(intervals('2023-01-01/2023-02-01')) AS t
// after
SELECT * FROM myds t WHERE __time >= TIMESTAMP '2023-01-01 00:00:00' AND __time < TIMESTAMP '2023-02-01 00:00:00' Defensive patterns
Strategy: validation
Validate before calling
// Ensure any intervals spec on the datasource is eternity before submitting to MSQ
if (spec.intervals && !(spec.intervals.length === 1 && spec.intervals[0] === '-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z')) {
throw new Error('MSQ datasource intervals must be eternity; use WHERE __time filters instead');
} Prevention
- Use WHERE __time predicates for time restriction in MSQ/SQL.
- Avoid TABLE(intervals(...)) datasource functions in MSQ queries.
- Translate native intervals() filters into SQL time predicates when migrating.
When it happens
Trigger: Issuing an MSQ/dsql query against a datasource with a non-eternity intervals segment spec (e.g. intervals() filter or a table Function datasource restricted to specific intervals), such as SELECT ... FROM TABLE(...WHERE intervals filter) rather than a WHERE __time filter.
Common situations: Migrating native queries that use intervals() filters to SQL/MSQ; tooling that generates TableFunction datasources with interval restrictions; users expecting interval pruning like the native engine provides.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot handle constant condition
- Cannot handle equality condition involving left-hand…
- Cannot handle non-equijoin condition
- Failed to handle query
- Failed to handle query
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/4087ef827e714182.
Report an issue: GitHub.
Appendix: source
Thrown at multi-stage-query/src/main/java/org/apache/druid/msq/querykit/datasource/DataSourcePlannerUtils.java:79
}
/**
* Verify that the provided {@link QuerySegmentSpec} is a {@link MultipleIntervalSegmentSpec} with
* interval {@link Intervals#ETERNITY}. If not, throw an {@link UnsupportedOperationException}.
* <p>
* See {@link org.apache.druid.sql.calcite.rel.DruidQuery#canUseIntervalFiltering(DataSource)}.
*/
public static void checkQuerySegmentSpecIsEternity(
final DataSource dataSource,
final QuerySegmentSpec querySegmentSpec
)
{
final boolean querySegmentSpecIsEternity =
querySegmentSpec instanceof MultipleIntervalSegmentSpec
&& querySegmentSpec.getIntervals().equals(Intervals.ONLY_ETERNITY);
if (!querySegmentSpecIsEternity) {
throw new UOE(
"Cannot filter datasource [%s] using [%s]",
dataSource.getClass().getName(),
ColumnHolder.TIME_COLUMN_NAME
);
}
}
}
View on GitHub (pinned to 9b90983fd2)