Skip to content

Commit

Permalink
TruncateTableCommand Logical Command, V1Table and V2SessionCatalog
Browse files Browse the repository at this point in the history
  • Loading branch information
jaceklaskowski committed Mar 19, 2024
1 parent 22a41d6 commit 9a6185d
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 23 deletions.
4 changes: 4 additions & 0 deletions docs/SessionCatalog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: SessionCatalog
---

# SessionCatalog — Session-Scoped Registry of Relational Entities

`SessionCatalog` is a catalog of relational entities in [SparkSession](SparkSession.md#catalog) (e.g. databases, tables, views, partitions, and functions).
Expand Down
52 changes: 36 additions & 16 deletions docs/V2SessionCatalog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# V2SessionCatalog

`V2SessionCatalog` is the [default session catalog](connector/catalog/CatalogManager.md#defaultSessionCatalog) of [CatalogManager](connector/catalog/CatalogManager.md).
`V2SessionCatalog` is a [TableCatalog](connector/catalog/TableCatalog.md) that makes the good ol' [SessionCatalog](SessionCatalog.md) available in the modern [Catalog Plugin API](connector/catalog/index.md)-based infrastructure.

`V2SessionCatalog` is known under the name of [spark_catalog](#name).

`V2SessionCatalog` is a [TableCatalog](connector/catalog/TableCatalog.md) and a [SupportsNamespaces](connector/catalog/SupportsNamespaces.md).
`V2SessionCatalog` is a [SupportsNamespaces](connector/catalog/SupportsNamespaces.md).

`V2SessionCatalog` is the [default session catalog](connector/catalog/CatalogManager.md#defaultSessionCatalog) of [CatalogManager](connector/catalog/CatalogManager.md).

## Creating Instance

Expand All @@ -11,21 +15,37 @@
* <span id="catalog"> [SessionCatalog](SessionCatalog.md)
* <span id="conf"> [SQLConf](SQLConf.md)

`V2SessionCatalog` is created when `BaseSessionStateBuilder` is requested for [one](BaseSessionStateBuilder.md#v2SessionCatalog).
`V2SessionCatalog` is created when:

## <span id="defaultNamespace"> Default Namespace
* `BaseSessionStateBuilder` is requested for [one](BaseSessionStateBuilder.md#v2SessionCatalog)

```scala
defaultNamespace: Array[String]
```
## capabilities { #capabilities }

??? note "TableCatalog"

```scala
capabilities(): Set[TableCatalogCapability]
```

`capabilities` is part of the [TableCatalog](connector/catalog/TableCatalog.md#capabilities) abstraction.

`capabilities` is [SUPPORT_COLUMN_DEFAULT_VALUE](connector/catalog/TableCatalogCapability.md#SUPPORT_COLUMN_DEFAULT_VALUE).

## Default Namespace { #defaultNamespace }

??? note "CatalogPlugin"

```scala
defaultNamespace: Array[String]
```

The default namespace of `V2SessionCatalog` is **default**.
`defaultNamespace` is part of the [CatalogPlugin](connector/catalog/CatalogPlugin.md#defaultNamespace) abstraction.

`defaultNamespace` is part of the [CatalogPlugin](connector/catalog/CatalogPlugin.md#defaultNamespace) abstraction.
`defaultNamespace` is **default**.

## Name

??? note "Signature"
??? note "CatalogPlugin"

```scala
name: String
Expand All @@ -35,9 +55,9 @@ The default namespace of `V2SessionCatalog` is **default**.

The name of `V2SessionCatalog` is [spark_catalog](connector/catalog/CatalogManager.md#SESSION_CATALOG_NAME).

## <span id="loadTable"> Loading Table
## Loading Table { #loadTable }

??? note "Signature"
??? note "TableCatalog"

```scala
loadTable(
Expand All @@ -48,9 +68,9 @@ The name of `V2SessionCatalog` is [spark_catalog](connector/catalog/CatalogManag

`loadTable` creates a [V1Table](connector/V1Table.md) for a [table metadata](SessionCatalog.md#getTableMetadata) (from the [SessionCatalog](#catalog)).

## <span id="loadFunction"> Loading Function
## Loading Function { #loadFunction }

??? note "Signature"
??? note "FunctionCatalog"

```scala
loadFunction(
Expand All @@ -61,9 +81,9 @@ The name of `V2SessionCatalog` is [spark_catalog](connector/catalog/CatalogManag

`loadFunction`...FIXME

## <span id="createTable"> Creating Table
## Creating Table { #createTable }

??? note "Signature"
??? note "FunctionCatalog"

```scala
createTable(
Expand Down
16 changes: 13 additions & 3 deletions docs/connector/V1Table.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# V1Table

`V1Table` is a [Table](Table.md) that acts as an adapter to expose [v1 table metadata](#v1Table).
`V1Table` is a [Table](Table.md) that acts as an adapter to expose [v1 table metadata](#v1Table) ([CatalogTable](../CatalogTable.md)).

## Creating Instance

`V1Table` takes the following to be created:

* <span id="v1Table"> [CatalogTable](../CatalogTable.md)
* <span id="v1Table"> [v1 Table Metadata](../CatalogTable.md)

`V1Table` is created when `V2SessionCatalog` is requested to [load a table](../V2SessionCatalog.md#loadTable).
`V1Table` is created when:

* `V2SessionCatalog` is requested to [load a table](../V2SessionCatalog.md#loadTable)

## String Representation { #toString }

`toString` is the following string (with the [name](#name)):

```text
V1Table([name])
```
3 changes: 3 additions & 0 deletions docs/connector/catalog/TableCatalogCapability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TableCatalogCapability

`TableCatalogCapability` is...FIXME
14 changes: 10 additions & 4 deletions docs/logical-operators/TruncateTableCommand.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ title: TruncateTableCommand

# TruncateTableCommand Logical Command

`TruncateTableCommand` is a RunnableCommand.md[logical command] that represents spark-sql-SparkSqlAstBuilder.md#visitTruncateTable[TRUNCATE TABLE] SQL statement.
`TruncateTableCommand` is a [leaf logical runnable command](LeafRunnableCommand.md) that represents `TruncateTable` or `TruncatePartition` (over a [V1Table](../connector/V1Table.md) in the [spark_catalog](../connector/catalog/CatalogManager.md#SESSION_CATALOG_NAME) catalog) at execution time.

=== [[creating-instance]] Creating TruncateTableCommand Instance
## Creating Instance

`TruncateTableCommand` takes the following to be created:

* [[tableName]] `TableIdentifier`
* [[partitionSpec]] Optional `TablePartitionSpec`
* <span id="tableName"> `TableIdentifier`
* <span id="partitionSpec"> Optional `TablePartitionSpec`

`TruncateTableCommand` is created when:

* [ResolveSessionCatalog](../logical-analysis-rules/ResolveSessionCatalog.md) logical resolution rule is executed

<!---
=== [[run]] Executing Logical Command -- `run` Method
[source, scala]
Expand Down Expand Up @@ -43,3 +48,4 @@ Operation not allowed: TRUNCATE TABLE ... PARTITION is not supported for tables
```
`run` throws an `AnalysisException` when executed with <<partitionSpec, TablePartitionSpec>> with filesource partition disabled or partition metadata not in a Hive metastore.
-->
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ nav:
- SupportsNamespaces: connector/catalog/SupportsNamespaces.md
- SupportsCatalogOptions: connector/catalog/SupportsCatalogOptions.md
- TableCatalog: connector/catalog/TableCatalog.md
- TableCatalogCapability: connector/catalog/TableCatalogCapability.md
- TableChange: connector/catalog/TableChange.md
- V2TableWithV1Fallback: connector/catalog/V2TableWithV1Fallback.md
- Columnar Execution:
Expand Down

0 comments on commit 9a6185d

Please sign in to comment.