Skip to content

Commit 6cac2b5

Browse files
committed
address comments
1 parent 19808d5 commit 6cac2b5

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

sql/core/src/main/java/org/apache/spark/sql/sources/v2/ReadSupport.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.spark.sql.sources.v2;
1919

2020
import org.apache.spark.annotation.InterfaceStability;
21+
import org.apache.spark.sql.sources.DataSourceRegister;
2122
import org.apache.spark.sql.sources.v2.reader.DataSourceReader;
2223
import org.apache.spark.sql.types.StructType;
2324

@@ -34,16 +35,21 @@ public interface ReadSupport extends DataSourceV2 {
3435
* If this method fails (by throwing an exception), the action will fail and no Spark job will be
3536
* submitted.
3637
*
37-
* @param schema the user provided schema.
38+
* @param schema the user specified schema.
3839
* @param options the options for the returned data source reader, which is an immutable
3940
* case-insensitive string-to-string map.
4041
*
41-
* By default this method ignores the user provided schema and just calls
42-
* {@link #createReader(DataSourceOptions)}, implementations should override this method to
43-
* handle user provided schema.
42+
* By default this method throws {@link UnsupportedOperationException}, implementations should
43+
* override this method to handle user specified schema.
4444
*/
4545
default DataSourceReader createReader(StructType schema, DataSourceOptions options) {
46-
return createReader(options);
46+
String name;
47+
if (this instanceof DataSourceRegister) {
48+
name = ((DataSourceRegister) this).shortName();
49+
} else {
50+
name = this.getClass().getName();
51+
}
52+
throw new UnsupportedOperationException(name + " does not support user specified schema");
4753
}
4854

4955
/**

0 commit comments

Comments
 (0)