Interface InputFormatDefn

All Known Implementing Classes:
InputFormats.BaseFormatDefn, InputFormats.CsvFormatDefn, InputFormats.DelimitedFormatDefn, InputFormats.FlatTextFormatDefn, InputFormats.JsonFormatDefn

public interface InputFormatDefn
Metadata about a Druid InputFormat. Provides the logic to convert from a table spec or SQL function arguments to a specific form of InputFormat. There is one instance of this interface for each supported InputFormat.
  • Method Summary

    Modifier and Type
    Method
    Description
    convertFromArgs(Map<String,Object> args, List<ColumnSpec> columns, com.fasterxml.jackson.databind.ObjectMapper jsonMapper)
    Create an input format instance from the values provided as arguments that correspond to the defined parameters.
    Create an input format from a resolved catalog table spec.
    Obtain the parameters used to fully define an input format in a SQL function that defines an external table from scratch.
     
    void
    Given a resolved table that has the serialized JSON converted to a Java map, validate the values of that map, typically by converting that map the target input format object (after adjustments and filling in dummy columns.) THe goal is to validate the information the user has provided in the table spec.
  • Method Details

    • typeValue

      String typeValue()
      Returns:
      the string used to identify the input format type in the serialized JSON for the input format. This is also the value used in the format property for SQL functions.
    • validate

      void validate(ResolvedExternalTable table)
      Given a resolved table that has the serialized JSON converted to a Java map, validate the values of that map, typically by converting that map the target input format object (after adjustments and filling in dummy columns.) THe goal is to validate the information the user has provided in the table spec. The final format information is validated elsewhere.
    • parameters

      Obtain the parameters used to fully define an input format in a SQL function that defines an external table from scratch. Note that the final list of table function arguments combines parameters from all the various input sources. It is legal for multiple formats to define the same parameter, as long as both definitions are of the same type.
      Returns:
    • convertFromArgs

      InputFormat convertFromArgs(Map<String,Object> args, List<ColumnSpec> columns, com.fasterxml.jackson.databind.ObjectMapper jsonMapper)
      Create an input format instance from the values provided as arguments that correspond to the defined parameters. The map provided is guaranteed to have a value for each parameter defined as non-optional, and those values will be of the type defined in the parameter. The map will also contain values for the input source: the format should ignore values that don't correspond to parameters it defined.
      Parameters:
      args - the actual arguments for the defined parameters
      columns - the columns provided in SQL, typically via the `EXTEND` clause, but perhaps from an the table spec, if the function is for a partial table
      jsonMapper - the mapper to use to perform conversions
      Returns:
      an input format as defined by the arguments
      Throws:
      IAE - if the arguments are not valid
    • convertFromTable

      InputFormat convertFromTable(ResolvedExternalTable table)
      Create an input format from a resolved catalog table spec. The format is given by the Java map within the given object.
      Parameters:
      table - resolved form of a table spec, with the format JSON parsed into a JSON map
      Returns:
      an input format as defined by the table spec
      Throws:
      IAE - if the spec is not valid