Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
/**
* An empty mix-in interface for {@link Table}, to indicate this table supports batch scan.
* <p>
* If a {@link Table} implements this interface, its {@link Table#newScanBuilder(DataSourceOptions)}
* must return a {@link ScanBuilder} that builds {@link Scan} with {@link Scan#toBatch()}
* implemented.
* If a {@link Table} implements this interface, the
* {@link SupportsRead#newScanBuilder(DataSourceOptions)} must return a {@link ScanBuilder} that
* builds {@link Scan} with {@link Scan#toBatch()} implemented.
* </p>
*/
@Evolving
public interface SupportsBatchRead extends Table { }
public interface SupportsBatchRead extends SupportsRead { }
Copy link
Member

@dongjoon-hyun dongjoon-hyun Dec 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cloud-fan What about the following?

-public interface SupportsBatchRead extends SupportsRead { }
+public interface SupportsBatchRead extends Table, SupportsRead { }
-interface SupportsRead extends Table {
+interface SupportsRead {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SupportsRead only makes sense under the table context. It also simplifies the code

public interface SupportsBatchRead extends Table, SupportsRead { }
public interface SupportsMicroBatchRead extends Table, SupportsRead { }
public interface SupportsContinuousRead extends Table, SupportsRead { }

to

public interface SupportsBatchRead extends SupportsRead { }
public interface SupportsMicroBatchRead extends SupportsRead { }
public interface SupportsContinuousRead extends SupportsRead { }

BTW SupportsRead is package private.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.sql.sources.v2;

import org.apache.spark.sql.sources.v2.reader.Scan;
import org.apache.spark.sql.sources.v2.reader.ScanBuilder;

/**
* An internal base interface of mix-in interfaces for readable {@link Table}. This adds
* {@link #newScanBuilder(DataSourceOptions)} that is used to create a scan for batch, micro-batch,
* or continuous processing.
*/
interface SupportsRead extends Table {

/**
* Returns a {@link ScanBuilder} which can be used to build a {@link Scan}. Spark will call this
* method to configure each scan.
*/
ScanBuilder newScanBuilder(DataSourceOptions options);
}
15 changes: 2 additions & 13 deletions sql/core/src/main/java/org/apache/spark/sql/sources/v2/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package org.apache.spark.sql.sources.v2;

import org.apache.spark.annotation.Evolving;
import org.apache.spark.sql.sources.v2.reader.Scan;
import org.apache.spark.sql.sources.v2.reader.ScanBuilder;
import org.apache.spark.sql.types.StructType;

/**
Expand All @@ -43,17 +41,8 @@ public interface Table {
String name();

/**
* Returns the schema of this table.
* Returns the schema of this table. If the table is not readable and doesn't have a schema, an
* empty schema can be returned here.
*/
StructType schema();

/**
* Returns a {@link ScanBuilder} which can be used to build a {@link Scan} later. Spark will call
* this method for each data scanning query.
* <p>
* The builder can take some query specific information to do operators pushdown, and keep these
* information in the created {@link Scan}.
* </p>
*/
ScanBuilder newScanBuilder(DataSourceOptions options);
}