Class BaseInputSourceDefn

java.lang.Object
org.apache.druid.catalog.model.table.BaseInputSourceDefn
All Implemented Interfaces:
InputSourceDefn
Direct Known Subclasses:
FormattedInputSourceDefn

public abstract class BaseInputSourceDefn extends Object implements InputSourceDefn
Base class for input source definitions.
  • Constructor Details

    • BaseInputSourceDefn

      public BaseInputSourceDefn()
  • Method Details

    • inputSourceClass

      protected abstract Class<? extends InputSource> inputSourceClass()
      Overridden by each subclass to return the input source class to be used for JSON conversions.
    • bind

      public void bind(TableDefnRegistry registry)
      Description copied from interface: InputSourceDefn
      Gather information about the set of format definitions.
      Specified by:
      bind in interface InputSourceDefn
    • validate

      public void validate(ResolvedExternalTable table)
      Description copied from interface: InputSourceDefn
      Given a external table catalog spec, with the JSON input source and format properties parsed to generic Java maps, validate that the properties are valid prior to saving the spec into the catalog.
      Specified by:
      validate in interface InputSourceDefn
      Parameters:
      table - a catalog table spec with the input source and input format properties parsed into generic Java maps
    • defineAdHocTableFunction

      protected abstract BaseInputSourceDefn.AdHocTableFunction defineAdHocTableFunction()
      Overridden by each subclass to define the parameters needed by each input source.
    • adHocTableFn

      public TableFunction adHocTableFn()
      Description copied from interface: InputSourceDefn
      Provide a definition for a SQL table function that defines an ad-hoc external table "from scratch" for this input source. Typically defines parameters for the input source and all allowed input formats.
      Specified by:
      adHocTableFn in interface InputSourceDefn
      Returns:
      a fully-defined external table to be handed off to the Calcite planner.
    • convertArgsToTable

      protected ExternalTableSpec convertArgsToTable(Map<String,Object> args, List<ColumnSpec> columns, com.fasterxml.jackson.databind.ObjectMapper jsonMapper)
      Define a table "from scratch" using SQL function arguments.
    • convertArgsToSource

      protected InputSource convertArgsToSource(Map<String,Object> args, com.fasterxml.jackson.databind.ObjectMapper jsonMapper)
      Convert the input source using arguments to a "from scratch" table function.
    • convertArgsToSourceMap

      protected abstract void convertArgsToSourceMap(Map<String,Object> jsonMap, Map<String,Object> args)
      Convert SQL arguments to the corresponding "generic JSON" form in the given map. The map will then be adjusted and converted to the actual input source.
    • convertArgsToFormat

      protected InputFormat convertArgsToFormat(Map<String,Object> args, List<ColumnSpec> columns, com.fasterxml.jackson.databind.ObjectMapper jsonMapper)
      Convert SQL arguments, and the column schema, to an input format, if required.
    • convertCompletedTable

      protected abstract ExternalTableSpec convertCompletedTable(ResolvedExternalTable table, Map<String,Object> args, List<ColumnSpec> columns)
      Complete a partial table using the table function arguments and columns provided. The arguments match the set of parameters used for the function. The columns are provided if the SQL included an EXTENDS clause: the implementation should decide if columns are required (or allowed) depending on whether the partial spec already defines columns.
      Parameters:
      table - the partial table spec, with input source and format parsed into a generic Java map
      args - the argument values provided in the SQL table function call. The arguments use the Java types defined in the parameter definitions.
      columns - the set of columns (if any) from the SQL EXTEND clause
      Returns:
      an external table spec which Calcite can consume
    • convertTable

      public ExternalTableSpec convertTable(ResolvedExternalTable table)
      Description copied from interface: InputSourceDefn
      Convert a complete (that is, fully-defined) table spec to an external table spec. Used when SQL references the catalog table directly by name in the FROM clause without using a table function.
      Specified by:
      convertTable in interface InputSourceDefn
      Returns:
      a fully-defined external table to be handed off to the Calcite planner.
    • convertTableToSource

      protected InputSource convertTableToSource(ResolvedExternalTable table)
      Converts the input source given in a table spec. Since Druid input sources were not designed for the use by the catalog or SQL, some cleanup is done to simplify the parameters which the user provides.
      Parameters:
      table - the resolved external table spec
      Returns:
      the input source converted from the spec
    • convertSource

      protected InputSource convertSource(Map<String,Object> jsonMap, com.fasterxml.jackson.databind.ObjectMapper jsonMapper)
      Convert from a generic Java map to the target input source using the object mapper provided. Translates Jackson errors into a generic unchecked error.
    • auditInputSource

      protected void auditInputSource(Map<String,Object> jsonMap)
      Optional step to audit or adjust the input source properties prior to conversion via Jackson. Changes are made directly in the jsonMap.
    • convertTableToFormat

      protected abstract InputFormat convertTableToFormat(ResolvedExternalTable table)
      Convert the format spec, if any, to an input format.
    • selectPartialTableColumns

      protected List<ColumnSpec> selectPartialTableColumns(ResolvedExternalTable table, List<ColumnSpec> columns)
      Choose table or SQL-provided columns: table takes precedence.