forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-26811][SQL] Add capabilities to v2.Table
This adds a new method, `capabilities` to `v2.Table` that returns a set of `TableCapability`. Capabilities are used to fail queries during analysis checks, `V2WriteSupportCheck`, when the table does not support operations, like truncation. Existing tests for regressions, added new analysis suite, `V2WriteSupportCheckSuite`, for new capability checks. Closes apache#24012 from rdblue/SPARK-26811-add-capabilities. Authored-by: Ryan Blue <blue@apache.org> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
- Loading branch information
Showing
32 changed files
with
417 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
sql/core/src/main/java/org/apache/spark/sql/sources/v2/SupportsBatchRead.java
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
sql/core/src/main/java/org/apache/spark/sql/sources/v2/SupportsBatchWrite.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
sql/core/src/main/java/org/apache/spark/sql/sources/v2/TableCapability.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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.annotation.Experimental; | ||
|
||
/** | ||
* Capabilities that can be provided by a {@link Table} implementation. | ||
* <p> | ||
* Tables use {@link Table#capabilities()} to return a set of capabilities. Each capability signals | ||
* to Spark that the table supports a feature identified by the capability. For example, returning | ||
* {@code BATCH_READ} allows Spark to read from the table using a batch scan. | ||
*/ | ||
@Experimental | ||
public enum TableCapability { | ||
/** | ||
* Signals that the table supports reads in batch execution mode. | ||
*/ | ||
BATCH_READ, | ||
|
||
/** | ||
* Signals that the table supports append writes in batch execution mode. | ||
* <p> | ||
* Tables that return this capability must support appending data and may also support additional | ||
* write modes, like {@link #TRUNCATE}, {@link #OVERWRITE_BY_FILTER}, and | ||
* {@link #OVERWRITE_DYNAMIC}. | ||
*/ | ||
BATCH_WRITE, | ||
|
||
/** | ||
* Signals that the table can be truncated in a write operation. | ||
* <p> | ||
* Truncating a table removes all existing rows. | ||
* <p> | ||
* See {@link org.apache.spark.sql.sources.v2.writer.SupportsTruncate}. | ||
*/ | ||
TRUNCATE, | ||
|
||
/** | ||
* Signals that the table can replace existing data that matches a filter with appended data in | ||
* a write operation. | ||
* <p> | ||
* See {@link org.apache.spark.sql.sources.v2.writer.SupportsOverwrite}. | ||
*/ | ||
OVERWRITE_BY_FILTER, | ||
|
||
/** | ||
* Signals that the table can dynamically replace existing data partitions with appended data in | ||
* a write operation. | ||
* <p> | ||
* See {@link org.apache.spark.sql.sources.v2.writer.SupportsDynamicOverwrite}. | ||
*/ | ||
OVERWRITE_DYNAMIC | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.