From eecb161075720aec0c496576fe6b6ad749c3a726 Mon Sep 17 00:00:00 2001 From: Wenchen Fan Date: Fri, 30 Nov 2018 11:33:26 +0800 Subject: [PATCH] remove default implementation of Table.name --- .../java/org/apache/spark/sql/sources/v2/Table.java | 12 +++--------- .../spark/sql/sources/v2/JavaSimpleBatchTable.java | 5 +++++ .../spark/sql/sources/v2/DataSourceV2Suite.scala | 2 ++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/sql/core/src/main/java/org/apache/spark/sql/sources/v2/Table.java b/sql/core/src/main/java/org/apache/spark/sql/sources/v2/Table.java index d0789818c2ee2..0c65fe0f9e76a 100644 --- a/sql/core/src/main/java/org/apache/spark/sql/sources/v2/Table.java +++ b/sql/core/src/main/java/org/apache/spark/sql/sources/v2/Table.java @@ -37,16 +37,10 @@ public interface Table { /** - * A name to identify this table. - *

- * By default this returns the class name of the implementation. Please override it to provide a - * meaningful name, like the database and table name from catalog, or the location of files for - * this table. - *

+ * A name to identify this table. Implementations should provide a meaningful name, like the + * database and table name from catalog, or the location of files for this table. */ - default String name() { - return this.getClass().toString(); - } + String name(); /** * Returns the schema of this table. diff --git a/sql/core/src/test/java/test/org/apache/spark/sql/sources/v2/JavaSimpleBatchTable.java b/sql/core/src/test/java/test/org/apache/spark/sql/sources/v2/JavaSimpleBatchTable.java index e0c074da103dd..cb5954d5a6211 100644 --- a/sql/core/src/test/java/test/org/apache/spark/sql/sources/v2/JavaSimpleBatchTable.java +++ b/sql/core/src/test/java/test/org/apache/spark/sql/sources/v2/JavaSimpleBatchTable.java @@ -32,6 +32,11 @@ abstract class JavaSimpleBatchTable implements Table, SupportsBatchRead { public StructType schema() { return new StructType().add("i", "int").add("j", "int"); } + + @Override + public String name() { + return this.getClass().toString(); + } } abstract class JavaSimpleScanBuilder implements ScanBuilder, Scan, Batch { diff --git a/sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2Suite.scala b/sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2Suite.scala index 8682e6ea13035..d282193d35d76 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2Suite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2Suite.scala @@ -394,6 +394,8 @@ object SimpleReaderFactory extends PartitionReaderFactory { abstract class SimpleBatchTable extends Table with SupportsBatchRead { override def schema(): StructType = new StructType().add("i", "int").add("j", "int") + + override def name(): String = this.getClass.toString } abstract class SimpleScanBuilder extends ScanBuilder