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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classBaseInputSourceDefn.AdHocTableFunctionThe "from-scratch" table function for this input source.classBaseInputSourceDefn.PartialTableFunctionThe "partial" table function that starts with a catalog external table spec, then uses SQL function arguments to "complete" (i.e.
-
Constructor Summary
Constructors Constructor Description BaseInputSourceDefn()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TableFunctionadHocTableFn()Provide 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 org.apache.druid.data.input.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 org.apache.druid.data.input.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 voidconvertArgsToSourceMap(Map<String,Object> jsonMap, Map<String,Object> args)Convert 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 org.apache.druid.data.input.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.ExternalTableSpecconvertTable(ResolvedExternalTable table)Convert a complete (that is, fully-defined) table spec to an external table spec.protected abstract org.apache.druid.data.input.InputFormatconvertTableToFormat(ResolvedExternalTable table)Convert the format spec, if any, to an input format.protected org.apache.druid.data.input.InputSourceconvertTableToSource(ResolvedExternalTable table)Converts the input source given in a table spec.protected abstract BaseInputSourceDefn.AdHocTableFunctiondefineAdHocTableFunction()Overridden by each subclass to define the parameters needed by each input source.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.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, wait
-
Methods inherited from interface org.apache.druid.catalog.model.table.InputSourceDefn
partialTableFn, typeValue
-
-
-
-
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.
-
bind
public void bind(TableDefnRegistry registry)
Description copied from interface:InputSourceDefnGather information about the set of format definitions.- Specified by:
bindin interfaceInputSourceDefn
-
validate
public void validate(ResolvedExternalTable table)
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
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: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 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 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
public ExternalTableSpec convertTable(ResolvedExternalTable table)
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
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 thejsonMap.
-
convertTableToFormat
protected abstract org.apache.druid.data.input.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.
-
-