Github user xuanyuanking commented on a diff in the pull request:
https://github.com/apache/spark/pull/19941#discussion_r156258956
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala
---
@@ -490,20 +489,19 @@ case class DataSource(
}
/**
- * Writes the given [[LogicalPlan]] out to this [[DataSource]] and
returns a [[BaseRelation]] for
- * the following reading.
+ * Returns a [[BaseRelation]] for creating table after `planForWriting`.
Only use
+ * in `CreateDataSourceTableAsSelectCommand` while saving data to
non-existing table.
*/
- def writeAndRead(mode: SaveMode, data: LogicalPlan): BaseRelation = {
+ def getRelation(mode: SaveMode, data: LogicalPlan): BaseRelation = {
if
(data.schema.map(_.dataType).exists(_.isInstanceOf[CalendarIntervalType])) {
throw new AnalysisException("Cannot save interval data type into
external storage.")
}
providingClass.newInstance() match {
- case dataSource: CreatableRelationProvider =>
+ case dataSource: RelationProvider =>
--- End diff --
To the reviewers, current implementation here made datasource should both
inherit `RelationProvider` and `CreatableRelationProvider`([like the
UT](https://github.com/apache/spark/pull/19941/files#diff-d15c669bd62aabde751ae6c54f768d36R28)),
because here just want get the relation by using
`RelationProvider.createRelation` but not save a DF to a destination by using
`CreatableRelationProvider.createRelation`. I need more advise to do better.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]