Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  *
0009  *    http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 package org.apache.spark.sql.connector.catalog;
0019 
0020 import org.apache.spark.annotation.Evolving;
0021 import org.apache.spark.sql.connector.expressions.Transform;
0022 import org.apache.spark.sql.types.StructType;
0023 
0024 import java.util.Collections;
0025 import java.util.Map;
0026 import java.util.Set;
0027 
0028 /**
0029  * An interface representing a logical structured data set of a data source. For example, the
0030  * implementation can be a directory on the file system, a topic of Kafka, or a table in the
0031  * catalog, etc.
0032  * <p>
0033  * This interface can mixin {@code SupportsRead} and {@code SupportsWrite} to provide data reading
0034  * and writing ability.
0035  * <p>
0036  * The default implementation of {@link #partitioning()} returns an empty array of partitions, and
0037  * the default implementation of {@link #properties()} returns an empty map. These should be
0038  * overridden by implementations that support partitioning and table properties.
0039  *
0040  * @since 3.0.0
0041  */
0042 @Evolving
0043 public interface Table {
0044 
0045   /**
0046    * A name to identify this table. Implementations should provide a meaningful name, like the
0047    * database and table name from catalog, or the location of files for this table.
0048    */
0049   String name();
0050 
0051   /**
0052    * Returns the schema of this table. If the table is not readable and doesn't have a schema, an
0053    * empty schema can be returned here.
0054    */
0055   StructType schema();
0056 
0057   /**
0058    * Returns the physical partitioning of this table.
0059    */
0060   default Transform[] partitioning() {
0061     return new Transform[0];
0062   }
0063 
0064   /**
0065    * Returns the string map of table properties.
0066    */
0067   default Map<String, String> properties() {
0068     return Collections.emptyMap();
0069   }
0070 
0071   /**
0072    * Returns the set of capabilities for this table.
0073    */
0074   Set<TableCapability> capabilities();
0075 }