Skip to content

SchemaRelationProvider — Relation Providers With Mandatory User-Defined Schema

SchemaRelationProvider is the <> of <> that <>.

The requirement of specifying a user-defined schema is enforced when DataSource is requested for a BaseRelation for a given data source format. If not specified, DataSource throws a AnalysisException:

A schema needs to be specified when using [className].

[[contract]] [source, scala]


package org.apache.spark.sql.sources

trait SchemaRelationProvider { def createRelation( sqlContext: SQLContext, parameters: Map[String, String], schema: StructType): BaseRelation }


.SchemaRelationProvider Contract [cols="1,2",options="header",width="100%"] |=== | Method | Description

| createRelation | [[createRelation]] Creates a BaseRelation for the user-defined schema

Used exclusively when DataSource is requested for a BaseRelation for a given data source format |===

[[implementations]] NOTE: There are no known direct implementation of <> in Spark SQL.

Tip

RelationProvider is used for data source providers with schema inference.

Tip

Use both SchemaRelationProvider and RelationProvider if a data source should support both schema inference and user-defined schemas.


Last update: 2020-11-13