1818package org .apache .spark .sql .sources .v2 ;
1919
2020import org .apache .spark .annotation .InterfaceStability ;
21+ import org .apache .spark .sql .sources .DataSourceRegister ;
2122import org .apache .spark .sql .sources .v2 .reader .DataSourceReader ;
2223import 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