Class HttpInputSourceDefn
- java.lang.Object
-
- org.apache.druid.catalog.model.table.BaseInputSourceDefn
-
- org.apache.druid.catalog.model.table.FormattedInputSourceDefn
-
- org.apache.druid.catalog.model.table.HttpInputSourceDefn
-
- All Implemented Interfaces:
InputSourceDefn
public class HttpInputSourceDefn extends FormattedInputSourceDefn
Definition of an HTTP input source source.Provides a parameterized form where the user defines a value for the
uriTemplatetable property in the table spec, then provides the partial URLs in a table function to use for that one query. The final URIs are created by combining the template and the arguments. Example:uriTemplateproperty): "http://example.com/data/kttm-{}.json"urisfunction argument: "22-Nov-21, 22-Nov-22"When the template is used, the format is optional: it can be provided either with the table spec or at runtime, depending on what the user wants to accomplish. In the above, where the ".json" is encoded in the template, it makes sense to include the format with the spec. If the template was "http://example.com/data/{}", and the data comes in multiple formats, it might make sense to specify the format in the query. In this case, the table spec acts more like a connection.
If the template is not used, then the
urisproperty must be provided in the table spec, along with the corresponding format.The above semantics make a bit more sense when we realize that the spec can also provide a user name and password. When those are provided, then the input source must name a single site: the one for which the credentials are valid. Given this, the only table spec that makes sense is one where the URI is defined: either as a template or explicitly.
When used as an ad-hoc function, the user specifies the uris and optional user name and password: the template is not available (or useful) in the ad-hoc case.
Table function parameters are cleaned up relative to the input source field names to make them a bit easier to use.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.druid.catalog.model.table.BaseInputSourceDefn
BaseInputSourceDefn.AdHocTableFunction, BaseInputSourceDefn.PartialTableFunction
-
-
Field Summary
Fields Modifier and Type Field Description static StringPASSWORD_ENV_VAR_PARAMETERprotected static StringPASSWORD_FIELDstatic StringPASSWORD_PARAMETERstatic StringTYPE_KEYstatic StringURI_TEMPLATE_PROPERTYprotected static StringURIS_FIELDstatic StringURIS_PARAMETERstatic StringUSER_PARAMETERprotected static StringUSERNAME_FIELD-
Fields inherited from class org.apache.druid.catalog.model.table.FormattedInputSourceDefn
FORMAT_PARAMETER
-
-
Constructor Summary
Constructors Constructor Description HttpInputSourceDefn()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<TableFunction.ParameterDefn>adHocTableFnParameters()Overridden by subclasses to provide the list of table function parameters for this specific input format.protected voidauditInputSource(Map<String,Object> jsonMap)Optional step to audit or adjust the input source properties prior to conversion via Jackson.protected voidconvertArgsToSourceMap(Map<String,Object> jsonMap, Map<String,Object> args)Convert SQL arguments to the corresponding "generic JSON" form in the given map.protected ExternalTableSpecconvertCompletedTable(ResolvedExternalTable table, Map<String,Object> args, List<ColumnSpec> columns)Complete a partial table using the table function arguments and columns provided.protected 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.TableFunctionpartialTableFn(ResolvedExternalTable table)Provide a definition for a SQL table function that completes a partial table spec from the catalog.StringtypeValue()Type value for this format: same as the type string used in the serialized JSON for this input source.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 org.apache.druid.catalog.model.table.FormattedInputSourceDefn
addFormatParameters, bind, convertArgsToFormat, convertPartialFormattedTable, convertTableToFormat, defineAdHocTableFunction
-
Methods inherited from class org.apache.druid.catalog.model.table.BaseInputSourceDefn
adHocTableFn, convertArgsToSource, convertArgsToTable, convertSource, convertTable, convertTableToSource, selectPartialTableColumns
-
-
-
-
Field Detail
-
TYPE_KEY
public static final String TYPE_KEY
- See Also:
- Constant Field Values
-
URI_TEMPLATE_PROPERTY
public static final String URI_TEMPLATE_PROPERTY
- See Also:
- Constant Field Values
-
URIS_PARAMETER
public static final String URIS_PARAMETER
- See Also:
- Constant Field Values
-
USER_PARAMETER
public static final String USER_PARAMETER
- See Also:
- Constant Field Values
-
PASSWORD_PARAMETER
public static final String PASSWORD_PARAMETER
- See Also:
- Constant Field Values
-
PASSWORD_ENV_VAR_PARAMETER
public static final String PASSWORD_ENV_VAR_PARAMETER
- See Also:
- Constant Field Values
-
URIS_FIELD
protected static final String URIS_FIELD
- See Also:
- Constant Field Values
-
PASSWORD_FIELD
protected static final String PASSWORD_FIELD
- See Also:
- Constant Field Values
-
USERNAME_FIELD
protected static final String USERNAME_FIELD
- See Also:
- Constant Field Values
-
-
Method Detail
-
typeValue
public String typeValue()
Description copied from interface:InputSourceDefnType value for this format: same as the type string used in the serialized JSON for this input source. Used as the key for this definition within the table registry, and associates the serialized JSON with the corresponding input source definition.
-
inputSourceClass
protected Class<? extends org.apache.druid.data.input.InputSource> inputSourceClass()
Description copied from class:BaseInputSourceDefnOverridden by each subclass to return the input source class to be used for JSON conversions.- Specified by:
inputSourceClassin classBaseInputSourceDefn
-
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- Overrides:
validatein classFormattedInputSourceDefn- Parameters:
table- a catalog table spec with the input source and input format properties parsed into generic Java maps
-
auditInputSource
protected void auditInputSource(Map<String,Object> jsonMap)
Description copied from class:BaseInputSourceDefnOptional step to audit or adjust the input source properties prior to conversion via Jackson. Changes are made directly in thejsonMap.- Overrides:
auditInputSourcein classBaseInputSourceDefn
-
adHocTableFnParameters
protected List<TableFunction.ParameterDefn> adHocTableFnParameters()
Description copied from class:FormattedInputSourceDefnOverridden by subclasses to provide the list of table function parameters for this specific input format. This list is combined with parameters for input formats. The method is called only once per run.- Specified by:
adHocTableFnParametersin classFormattedInputSourceDefn
-
convertArgsToSourceMap
protected void convertArgsToSourceMap(Map<String,Object> jsonMap, Map<String,Object> args)
Description copied from class:BaseInputSourceDefnConvert 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.- Specified by:
convertArgsToSourceMapin classBaseInputSourceDefn
-
partialTableFn
public TableFunction partialTableFn(ResolvedExternalTable table)
Description copied from interface:InputSourceDefnProvide a definition for a SQL table function that completes a partial table spec from the catalog. Used when the spec represents a "partial table" or a "connection". The function provides parameters needed to complete the table (typically the set of input files, objects, etc.) If the catalog table spec does not provide a format, and this input source requires a format, then the parameters also include parameters for all supported input formats, same as forInputSourceDefn.adHocTableFn().- Parameters:
table- a catalog table spec with the input source and input format properties parsed into generic Java maps- Returns:
- a fully-defined external table to be handed off to the Calcite planner.
-
convertCompletedTable
protected ExternalTableSpec convertCompletedTable(ResolvedExternalTable table, Map<String,Object> args, List<ColumnSpec> columns)
Description copied from class:BaseInputSourceDefnComplete 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.- Specified by:
convertCompletedTablein classBaseInputSourceDefn- 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
-
-