Class BaseInputSourceDefn

    • Constructor Detail

      • BaseInputSourceDefn

        public BaseInputSourceDefn()
    • Method Detail

      • inputSourceClass

        protected abstract Class<? extends org.apache.druid.data.input.InputSource> inputSourceClass()
        Overridden by each subclass to return the input source class to be used for JSON conversions.
      • 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 org.apache.druid.data.input.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 org.apache.druid.data.input.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 org.apache.druid.data.input.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 org.apache.druid.data.input.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 org.apache.druid.data.input.InputFormat convertTableToFormat​(ResolvedExternalTable table)
        Convert the format spec, if any, to an input format.