You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Huaxin Gao (Jira)" <ji...@apache.org> on 2021/08/17 05:44:00 UTC

[jira] [Updated] (SPARK-36525) DS V2 Index Support

     [ 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}
  /**
   * Creates an index.
   *
   * @param indexName the name of the index to be created
   * @param indexType the IndexType of the index to be created
   * @param tableName 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 namespace already exists (optional)
   * @throws UnsupportedOperationException If create index is not a supported operation
   */
  void createIndex(String indexName,
                   String indexType,
                   Identifier tableName,
                   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 UnsupportedOperationException {
    throw new UnsupportedOperationException("Delete index is not supported.");
  }

  /**
   * 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 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 {
    throw new UnsupportedOperationException("Restore index is not supported.");
  }

  /**
   * 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 {
    throw new UnsupportedOperationException("Refresh index is not supported.");
  }

  /**
   * 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 {
    throw new UnsupportedOperationException("Alter index is not supported.");
  }

{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}
>   /**
>    * Creates an index.
>    *
>    * @param indexName the name of the index to be created
>    * @param indexType the IndexType of the index to be created
>    * @param tableName 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 namespace already exists (optional)
>    * @throws UnsupportedOperationException If create index is not a supported operation
>    */
>   void createIndex(String indexName,
>                    String indexType,
>                    Identifier tableName,
>                    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 UnsupportedOperationException {
>     throw new UnsupportedOperationException("Delete index is not supported.");
>   }
>   /**
>    * 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 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 {
>     throw new UnsupportedOperationException("Restore index is not supported.");
>   }
>   /**
>    * 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 {
>     throw new UnsupportedOperationException("Refresh index is not supported.");
>   }
>   /**
>    * 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 {
>     throw new UnsupportedOperationException("Alter index is not supported.");
>   }
> {code}



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

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