Class SqlEntity

java.lang.Object
org.apache.druid.metadata.input.SqlEntity
All Implemented Interfaces:
InputEntity

public class SqlEntity extends Object implements InputEntity
Represents a rdbms based input resource and knows how to read query results from the resource using SQL queries.
  • Constructor Details

    • SqlEntity

      public SqlEntity(String sql, SQLInputSourceDatabaseConnector sqlInputSourceDatabaseConnector, boolean foldCase, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • getSql

      public String getSql()
    • getUri

      @Nullable public URI getUri()
      Specified by:
      getUri in interface InputEntity
    • open

      public InputStream open()
      Specified by:
      open in interface InputEntity
    • fetch

      public InputEntity.CleanableFile fetch(File temporaryDirectory, byte[] fetchBuffer) throws IOException
      Specified by:
      fetch in interface InputEntity
      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 executed
      sqlInputSourceDatabaseConnector - The database connector
      objectMapper - An object mapper, used for deserialization
      foldCase - A boolean flag used to enable or disabling case sensitivity while handling database column names
      Returns:
      A InputEntity.CleanableFile object that wraps the file containing the SQL results
      Throws:
      IOException