Class BaseInputSourceDefn
java.lang.Object
org.apache.druid.catalog.model.table.BaseInputSourceDefn
- All Implemented Interfaces:
InputSourceDefn
- Direct Known Subclasses:
FormattedInputSourceDefn
Base class for input source definitions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassThe "from-scratch" table function for this input source.classThe "partial" table function that starts with a catalog external table spec, then uses SQL function arguments to "complete" (i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionProvide a definition for a SQL table function that defines an ad-hoc external table "from scratch" for this input source.protected voidauditInputSource(Map<String, Object> jsonMap) Optional step to audit or adjust the input source properties prior to conversion via Jackson.voidbind(TableDefnRegistry registry) Gather information about the set of format definitions.protected InputFormatconvertArgsToFormat(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.protected InputSourceconvertArgsToSource(Map<String, Object> args, com.fasterxml.jackson.databind.ObjectMapper jsonMapper) Convert the input source using arguments to a "from scratch" table function.protected abstract voidConvert SQL arguments to the corresponding "generic JSON" form in the given map.protected ExternalTableSpecconvertArgsToTable(Map<String, Object> args, List<ColumnSpec> columns, com.fasterxml.jackson.databind.ObjectMapper jsonMapper) Define a table "from scratch" using SQL function arguments.protected abstract ExternalTableSpecconvertCompletedTable(ResolvedExternalTable table, Map<String, Object> args, List<ColumnSpec> columns) Complete a partial table using the table function arguments and columns provided.protected InputSourceconvertSource(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.Convert a complete (that is, fully-defined) table spec to an external table spec.protected abstract InputFormatConvert the format spec, if any, to an input format.protected InputSourceConverts the input source given in a table spec.protected abstract BaseInputSourceDefn.AdHocTableFunctionOverridden by each subclass to define the parameters needed by each input source.protected abstract Class<? extends InputSource>Overridden by each subclass to return the input source class to be used for JSON conversions.protected List<ColumnSpec>selectPartialTableColumns(ResolvedExternalTable table, List<ColumnSpec> columns) Choose table or SQL-provided columns: table takes precedence.voidvalidate(ResolvedExternalTable table) 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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.catalog.model.table.InputSourceDefn
partialTableFn, typeValue
-
Constructor Details
-
BaseInputSourceDefn
public BaseInputSourceDefn()
-
-
Method Details
-
inputSourceClass
Overridden by each subclass to return the input source class to be used for JSON conversions. -
bind
Description copied from interface:InputSourceDefnGather information about the set of format definitions.- Specified by:
bindin interfaceInputSourceDefn
-
validate
Description copied from interface:InputSourceDefnGiven 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:
validatein interfaceInputSourceDefn- Parameters:
table- a catalog table spec with the input source and input format properties parsed into generic Java maps
-
defineAdHocTableFunction
Overridden by each subclass to define the parameters needed by each input source. -
adHocTableFn
Description copied from interface:InputSourceDefnProvide 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:
adHocTableFnin interfaceInputSourceDefn- 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
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 anEXTENDSclause: 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 mapargs- 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 SQLEXTENDclause- Returns:
- an external table spec which Calcite can consume
-
convertTable
Description copied from interface:InputSourceDefnConvert a complete (that is, fully-defined) table spec to an external table spec. Used when SQL references the catalog table directly by name in theFROMclause without using a table function.- Specified by:
convertTablein interfaceInputSourceDefn- Returns:
- a fully-defined external table to be handed off to the Calcite planner.
-
convertTableToSource
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
Optional step to audit or adjust the input source properties prior to conversion via Jackson. Changes are made directly in thejsonMap. -
convertTableToFormat
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.
-