Skip to content

RelationProvider — Relation Providers with Pre-Defined Schema

RelationProvider is an <> of <> of <> (aka schema discovery). In other words, the schema is pre-defined, and a user-specified schema is not allowed.

[[contract]] .RelationProvider Contract [cols="30m,70",options="header",width="100%"] |=== | Method | Description

| createRelation a| [[createRelation]]

[source, scala]

createRelation( sqlContext: SQLContext, parameters: Map[String, String]): BaseRelation


Creates a BaseRelation for loading data from an external data source

Used exclusively when DataSource is requested to resolve a data source for a given data source format

|===

When resolving a data source, DataSource makes sure that a schema is not defined or matches the schema of the data source. DataSource throws an AnalysisException for a user-specified schema that does not match the data source's schema:

[className] does not allow user-specified schemas.

Tip

SchemaRelationProvider is used for data source providers that require a user-defined schema.

NOTE: It is a common pattern while developing a custom data source to use <> with CreatableRelationProvider when requested for a relation (after writing out a structured query).

[[implementations]] .RelationProviders [cols="30,70",options="header",width="100%"] |=== | RelationProvider | Description

| JdbcRelationProvider | [[JdbcRelationProvider]] Data source provider for JDBC data source

| KafkaSourceProvider | [[KafkaSourceProvider]] Data source provider for Kafka data source

|===


Last update: 2020-11-13