Package org.apache.druid.metadata.input
Class SqlEntity
- java.lang.Object
-
- org.apache.druid.metadata.input.SqlEntity
-
- All Implemented Interfaces:
org.apache.druid.data.input.InputEntity
public class SqlEntity extends Object implements org.apache.druid.data.input.InputEntity
Represents a rdbms based input resource and knows how to read query results from the resource using SQL queries.
-
-
Constructor Summary
Constructors Constructor Description SqlEntity(String sql, SQLFirehoseDatabaseConnector sqlFirehoseDatabaseConnector, boolean foldCase, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.druid.data.input.InputEntity.CleanableFilefetch(File temporaryDirectory, byte[] fetchBuffer)StringgetSql()URIgetUri()InputStreamopen()static org.apache.druid.data.input.InputEntity.CleanableFileopenCleanableFile(String sql, SQLFirehoseDatabaseConnector sqlFirehoseDatabaseConnector, 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.
-
-
-
Constructor Detail
-
SqlEntity
public SqlEntity(String sql, SQLFirehoseDatabaseConnector sqlFirehoseDatabaseConnector, boolean foldCase, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Detail
-
getSql
public String getSql()
-
getUri
@Nullable public URI getUri()
- Specified by:
getUriin interfaceorg.apache.druid.data.input.InputEntity
-
open
public InputStream open()
- Specified by:
openin interfaceorg.apache.druid.data.input.InputEntity
-
fetch
public org.apache.druid.data.input.InputEntity.CleanableFile fetch(File temporaryDirectory, byte[] fetchBuffer) throws IOException
- Specified by:
fetchin interfaceorg.apache.druid.data.input.InputEntity- Throws:
IOException
-
openCleanableFile
public static org.apache.druid.data.input.InputEntity.CleanableFile openCleanableFile(String sql, SQLFirehoseDatabaseConnector sqlFirehoseDatabaseConnector, 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 executedsqlFirehoseDatabaseConnector- 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
-
-