Package org.apache.druid.metadata.input
Class SqlEntity
java.lang.Object
org.apache.druid.metadata.input.SqlEntity
- All Implemented Interfaces:
InputEntity
Represents a rdbms based input resource and knows how to read query results from the resource using SQL queries.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.druid.data.input.InputEntity
InputEntity.CleanableFile -
Field Summary
Fields inherited from interface org.apache.druid.data.input.InputEntity
DEFAULT_FETCH_BUFFER_SIZE, DEFAULT_MAX_NUM_FETCH_TRIES -
Constructor Summary
ConstructorsConstructorDescriptionSqlEntity(String sql, SQLInputSourceDatabaseConnector sqlInputSourceDatabaseConnector, boolean foldCase, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptiongetSql()getUri()open()static InputEntity.CleanableFileopenCleanableFile(String sql, SQLInputSourceDatabaseConnector sqlInputSourceDatabaseConnector, com.fasterxml.jackson.databind.ObjectMapper objectMapper, boolean foldCase, File tempFile) Executes a SQL query on the specified database and fetches the result into the given file.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.data.input.InputEntity
getRetryCondition
-
Constructor Details
-
SqlEntity
public SqlEntity(String sql, SQLInputSourceDatabaseConnector sqlInputSourceDatabaseConnector, boolean foldCase, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
getSql
-
getUri
- Specified by:
getUriin interfaceInputEntity
-
open
- Specified by:
openin interfaceInputEntity
-
fetch
public InputEntity.CleanableFile fetch(File temporaryDirectory, byte[] fetchBuffer) throws IOException - Specified by:
fetchin interfaceInputEntity- Throws:
IOException
-
openCleanableFile
public static InputEntity.CleanableFile openCleanableFile(String sql, SQLInputSourceDatabaseConnector sqlInputSourceDatabaseConnector, com.fasterxml.jackson.databind.ObjectMapper objectMapper, boolean foldCase, File tempFile) throws IOException 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.- Parameters:
sql- The SQL query to be executedsqlInputSourceDatabaseConnector- The database connectorobjectMapper- An object mapper, used for deserializationfoldCase- A boolean flag used to enable or disabling case sensitivity while handling database column names- Returns:
- A
InputEntity.CleanableFileobject that wraps the file containing the SQL results - Throws:
IOException
-