apache/druid · error · UnsupportedOperationException
Please use fetch() instead
Error message
Please use fetch() instead
What it means
SqlEntity implements Druid's Entity/OpenRawFileSupplier interface, but its data comes from a JDBC ResultSet, so there is no InputStream-backed raw representation. openRaw() therefore unconditionally throws UnsupportedOperationException directing callers to fetch(), which materializes the rows into a temporary file.
Solutions
- Call fetch(temporaryDirectory, fetchBuffer) instead of openRaw() to obtain a CleanableFile.
- Check whether the entity supports raw access before calling openRaw() and branch to fetch() for SqlEntity.
- If you control the interface usage, use instanceof SqlEntity to route to the fetch path.
Example fix
// before InputStream in = sqlEntity.openRaw(); // after CleanableFile file = sqlEntity.fetch(tempDir, new byte[DEFAULT_FETCH_BUFFER]);
Defensive patterns
Strategy: type-guard
Validate before calling
if (entity instanceof SqlEntity) {
CleanableFile f = ((SqlEntity) entity).fetch(tempDir, buf);
} else {
InputStream in = entity.openRaw();
} Type guard
boolean supportsRaw(Object e) { return !(e instanceof SqlEntity); } Try / catch
try {
return entity.openRaw();
} catch (UnsupportedOperationException e) {
return entity.fetch(temporaryDirectory, fetchBuffer).getFile();
} Prevention
- Check the Entity implementation before choosing openRaw vs fetch
- Prefer fetch() for SqlEntity always
- Document raw-stream support per Entity type in extension code
When it happens
Trigger: Calling openRaw() on a SqlEntity instance — e.g., generic entity-handling code or input-source plumbing that assumes all entities support raw stream access.
Common situations: Ingestion framework code written for FileEntity/HttpEntity reused against SQL-based input; custom extensions that call openRaw() without first checking whether the entity supports it.
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
- connectURI cannot be null or empty
- 08001
- A local input source accepts only one of
- A local input source requires one property of
- Aggregator[ ] cannot vectorize
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/e0dbae08774056c5.
Report an issue: GitHub.
Appendix: source
Thrown at server/src/main/java/org/apache/druid/metadata/input/SqlEntity.java:89
this.objectMapper = objectMapper;
}
public String getSql()
{
return sql;
}
@Nullable
@Override
public URI getUri()
{
return null;
}
@Override
public InputStream openRaw()
{
throw new UnsupportedOperationException("Please use fetch() instead");
}
@Override
public CleanableFile fetch(File temporaryDirectory, byte[] fetchBuffer) throws IOException
{
final File tempFile = File.createTempFile("druid-sql-entity", ".tmp", temporaryDirectory);
return openCleanableFile(sql, sqlInputSourceDatabaseConnector, objectMapper, foldCase, tempFile);
}
/**
* Executes a SQL query on the specified database and fetches the result into the given file.
* The result file is deleted if the query execution or the file write fails.
*
* @param sql The SQL query to be executed
* @param sqlInputSourceDatabaseConnector The database connector
* @param objectMapper An object mapper, used for deserialization
* @param foldCase A boolean flag used to enable or disabling case sensitivity while handling database column namesView on GitHub (pinned to 9b90983fd2)