[ 
https://issues.apache.org/jira/browse/SPARK-36525?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Huaxin Gao updated SPARK-36525:
-------------------------------
    Description: 
Many data sources support index to improvement query performance. In order to 
take advantage of the index support in data source, the following APIs will be 
added for working with indexes:

{code:java}
 public interface SupportsIndex extends Table {

  /**
   * Creates an index.
   *
   * @param indexName the name of the index to be created
   * @param indexType the type of the index to be created. If this is not 
specified, Spark
   *                  will use empty String.
   * @param columns the columns on which index to be created
   * @param columnsProperties the properties of the columns on which index to 
be created
   * @param properties the properties of the index to be created
   * @throws IndexAlreadyExistsException If the index already exists.
   */
  void createIndex(String indexName,
      String indexType,
      NamedReference[] columns,
      Map<NamedReference, Map<String, String>> columnsProperties,
      Map<String, String> properties)
      throws IndexAlreadyExistsException;

  /**
   * Drops the index with the given name.
   *
   * @param indexName the name of the index to be dropped.
   * @throws NoSuchIndexException If the index does not exist.
   */
  void dropIndex(String indexName) throws NoSuchIndexException;

  /**
   * Checks whether an index exists in this table.
   *
   * @param indexName the name of the index
   * @return true if the index exists, false otherwise
   */
  boolean indexExists(String indexName);

  /**
   * Lists all the indexes in this table.
   */
  TableIndex[] listIndexes();
}

{code}



  was:
Many data sources support index to improvement query performance. In order to 
take advantage of the index support in data source, the following APIs will be 
added for working with indexes:

{code:java}
  /**
   * Creates an index.
   *
   * @param indexName the name of the index to be created
   * @param indexType the IndexType of the index to be created
   * @param table the table on which index to be created
   * @param columns the columns on which index to be created
   * @param properties the properties of the index to be created
   * @throws IndexAlreadyExistsException If the index already exists (optional)
   * @throws UnsupportedOperationException If create index is not a supported 
operation
   */
  void createIndex(String indexName,
      String indexType,
      Identifier table,
      FieldReference[] columns,
      Map<String, String> properties)
      throws IndexAlreadyExistsException, UnsupportedOperationException;

  /**
   * Soft deletes the index with the given name.
   * Deleted index can be restored by calling restoreIndex.
   *
   * @param indexName the name of the index to be deleted
   * @return true if the index is deleted
   * @throws NoSuchIndexException If the index does not exist (optional)
   * @throws UnsupportedOperationException If delete index is not a supported 
operation
   */
  default boolean deleteIndex(String indexName)
      throws NoSuchIndexException, UnsupportedOperationException

  /**
   * Checks whether an index exists.
   *
   * @param indexName the name of the index
   * @return true if the index exists, false otherwise
   */
  boolean indexExists(String indexName);

  /**
   * Lists all the indexes in a table.
   *
   * @param table the table to be checked on for indexes
   * @throws NoSuchTableException
   */
  Index[] listIndexes(Identifier table) throws NoSuchTableException;

  /**
   * Hard deletes the index with the given name.
   * The Index can't be restored once dropped.
   *
   * @param indexName the name of the index to be dropped.
   * @return true if the index is dropped
   * @throws NoSuchIndexException If the index does not exist (optional)
   * @throws UnsupportedOperationException If drop index is not a supported 
operation
   */
  boolean dropIndex(String indexName) throws NoSuchIndexException, 
UnsupportedOperationException;

  /**
   * Restores the index with the given name.
   * Deleted index can be restored by calling restoreIndex, but dropped index 
can't be restored.
   *
   * @param indexName the name of the index to be restored
   * @return true if the index is restored
   * @throws NoSuchIndexException If the index does not exist (optional)
   * @throws UnsupportedOperationException
   */
  default boolean restoreIndex(String indexName)
      throws NoSuchIndexException, UnsupportedOperationException

  /**
   * Refreshes index using the latest data. This causes the index to be rebuilt.
   *
   * @param indexName the name of the index to be rebuilt
   * @return true if the index is rebuilt
   * @throws NoSuchIndexException If the index does not exist (optional)
   * @throws UnsupportedOperationException
   */
  default boolean refreshIndex(String indexName)
      throws NoSuchIndexException, UnsupportedOperationException

  /**
   * Alter Index using the new property. This causes the index to be rebuilt.
   *
   * @param indexName the name of the index to be altered
   * @return true if the index is altered
   * @throws NoSuchIndexException If the index does not exist (optional)
   * @throws UnsupportedOperationException
   */
  default boolean alterIndex(String indexName, Properties properties)
      throws NoSuchIndexException, UnsupportedOperationException
{code}




> DS V2 Index Support
> -------------------
>
>                 Key: SPARK-36525
>                 URL: https://issues.apache.org/jira/browse/SPARK-36525
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.3.0
>            Reporter: Huaxin Gao
>            Priority: Major
>
> Many data sources support index to improvement query performance. In order to 
> take advantage of the index support in data source, the following APIs will 
> be added for working with indexes:
> {code:java}
>  public interface SupportsIndex extends Table {
>   /**
>    * Creates an index.
>    *
>    * @param indexName the name of the index to be created
>    * @param indexType the type of the index to be created. If this is not 
> specified, Spark
>    *                  will use empty String.
>    * @param columns the columns on which index to be created
>    * @param columnsProperties the properties of the columns on which index to 
> be created
>    * @param properties the properties of the index to be created
>    * @throws IndexAlreadyExistsException If the index already exists.
>    */
>   void createIndex(String indexName,
>       String indexType,
>       NamedReference[] columns,
>       Map<NamedReference, Map<String, String>> columnsProperties,
>       Map<String, String> properties)
>       throws IndexAlreadyExistsException;
>   /**
>    * Drops the index with the given name.
>    *
>    * @param indexName the name of the index to be dropped.
>    * @throws NoSuchIndexException If the index does not exist.
>    */
>   void dropIndex(String indexName) throws NoSuchIndexException;
>   /**
>    * Checks whether an index exists in this table.
>    *
>    * @param indexName the name of the index
>    * @return true if the index exists, false otherwise
>    */
>   boolean indexExists(String indexName);
>   /**
>    * Lists all the indexes in this table.
>    */
>   TableIndex[] listIndexes();
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to