Skip to content

Commit e1537dd

Browse files
CatalogPlugin, TableCatalog and loading a table
1 parent 049d877 commit e1537dd

File tree

4 files changed

+53
-26
lines changed

4 files changed

+53
-26
lines changed

docs/connector/catalog/CatalogPlugin.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# CatalogPlugin
22

3-
`CatalogPlugin` is an [abstraction](#contract) of [table catalogs](#implementations).
3+
`CatalogPlugin` is an [abstraction](#contract) of [catalogs](#implementations) (of assets like [functions](FunctionCatalog.md), [tables](TableCatalog.md) and [views](ViewCatalog.md)).
44

55
!!! note "CatalogHelper"
66
[CatalogHelper](CatalogHelper.md) is a Scala implicit class of `CatalogPlugin` with extensions methods.
77

8+
!!! note "Demo"
9+
Learn more in [Demo: Developing CatalogPlugin](../../demo/developing-catalogplugin.md).
10+
811
## Contract
912

1013
### Default Namespace { #defaultNamespace }
@@ -53,7 +56,3 @@ String name()
5356
* [SupportsNamespaces](SupportsNamespaces.md)
5457
* [TableCatalog](TableCatalog.md)
5558
* [ViewCatalog](ViewCatalog.md)
56-
57-
## Demo
58-
59-
Learn more in [Demo: Developing CatalogPlugin](../../demo/developing-catalogplugin.md).

docs/connector/catalog/CatalogV2Util.md

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# CatalogV2Util
22

3-
## Loading Table { #loadTable }
3+
## Load Table { #loadTable }
44

55
```scala
66
loadTable(
77
catalog: CatalogPlugin,
88
ident: Identifier,
9-
timeTravelSpec: Option[TimeTravelSpec] = None): Option[Table]
9+
timeTravelSpec: Option[TimeTravelSpec] = None,
10+
writePrivilegesString: Option[String] = None): Option[Table]
1011
```
1112

12-
`loadTable` [loads the table](#getTable) (by the given identifier and the optional [TimeTravelSpec](../../time-travel/TimeTravelSpec.md) in the given [CatalogPlugin](CatalogPlugin.md)).
13+
`loadTable` [loads a table](#getTable) (by the given `Identifier` and the optional [TimeTravelSpec](../../time-travel/TimeTravelSpec.md) using the given [CatalogPlugin](CatalogPlugin.md)).
1314

1415
!!! note
15-
`loadTable` is a Scala `Option`-aware wrapper around [CatalogV2Util.getTable](#getTable) that may not only return `null` but also throw an exception.
16+
`loadTable` is a Scala `Option`-aware wrapper around [CatalogV2Util.getTable](#getTable).
1617

1718
---
1819

@@ -22,28 +23,36 @@ loadTable(
2223
* `CatalogV2Util` is requested to [loadRelation](#loadRelation)
2324
* `CatalogImpl` is requested to [load a table](../../CatalogImpl.md#loadTable)
2425

25-
## getTable { #getTable }
26+
## Load Table { #getTable }
2627

2728
```scala
2829
getTable(
2930
catalog: CatalogPlugin,
3031
ident: Identifier,
31-
timeTravelSpec: Option[TimeTravelSpec] = None): Table
32+
timeTravelSpec: Option[TimeTravelSpec] = None,
33+
writePrivilegesString: Option[String] = None): Table
3234
```
3335

36+
`getTable` assumes the given [CatalogPlugin](CatalogPlugin.md) to be a [TableCatalog](CatalogHelper.md#asTableCatalog) to [load a table](TableCatalog.md#loadTable) (by the given `Identifier`).
37+
38+
---
39+
3440
`getTable` requests the given [CatalogPlugin](CatalogPlugin.md) for the [TableCatalog](CatalogHelper.md#asTableCatalog) to [load a table](TableCatalog.md#loadTable) (possibly versioned based on the [TimeTravelSpec](../../time-travel/TimeTravelSpec.md)).
3541

42+
!!! note
43+
It is not allowed for `getTable` to be called with both `timeTravelSpec` and `writePrivilegesString` defined.
44+
3645
!!! note "NoSuchTableException for versioned tables"
3746
[TableCatalog](TableCatalog.md) throws a `NoSuchTableException` exception for versioned tables by default (and leaves other behaviour to custom [TableCatalog](TableCatalog.md#implementations)s, e.g. [Delta Lake]({{ book.delta }}/DeltaCatalog)).
3847

3948
---
4049

4150
`getTable` is used when:
4251

43-
* `CatalogV2Util` is requested to [loadTable](#loadTable)
52+
* `CatalogV2Util` is requested to [load a table](#loadTable)
4453
* `DataSourceV2Utils` is requested to [loadV2Source](../../connectors/DataSourceV2Utils.md#loadV2Source)
4554

46-
## <span id="getTableProviderCatalog"> getTableProviderCatalog
55+
## getTableProviderCatalog { #getTableProviderCatalog }
4756

4857
```scala
4958
getTableProviderCatalog(

docs/connector/catalog/TableCatalog.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ Identifier[] listTables(
6161
String[] namespace)
6262
```
6363

64-
Used when the following commands are executed:
64+
Used when:
6565

66-
* [DropNamespaceExec](../../physical-operators/DropNamespaceExec.md)
67-
* [ShowTablesExec](../../physical-operators/ShowTablesExec.md)
66+
* `DelegatingCatalogExtension` is requested to [listTables](DelegatingCatalogExtension.md#listTables)
67+
* [ShowTablesExec](../../physical-operators/ShowTablesExec.md) is executed
6868

6969
### Load Table { #loadTable }
7070

@@ -74,19 +74,30 @@ Table loadTable(
7474
Table loadTable(
7575
Identifier ident,
7676
long timestamp)
77+
Table loadTable(
78+
Identifier ident,
79+
Set<TableWritePrivilege> writePrivileges) // (1)!
7780
Table loadTable(
7881
Identifier ident,
7982
String version)
8083
```
8184

85+
1. Added in 3.5.3
86+
8287
Used when:
8388

8489
* `CatalogV2Util` is requested to [load a table](CatalogV2Util.md#getTable)
85-
* `DataFrameReader` is requested to [load](../../DataFrameReader.md#load) (for [SupportsCatalogOptions](SupportsCatalogOptions.md) providers)
86-
* `DataFrameWriter` is requested to [save](../../DataFrameWriter.md#save), [insertInto](../../DataFrameWriter.md#insertInto) and [saveAsTable](../../DataFrameWriter.md#saveAsTable)
87-
* `DelegatingCatalogExtension` is requested to [loadTable](DelegatingCatalogExtension.md#loadTable)
88-
* `TableCatalog` is requested to [tableExists](#tableExists)
89-
* `V2SessionCatalog` is requested to [createTable](../../V2SessionCatalog.md#createTable), [alterTable](../../V2SessionCatalog.md#alterTable), [dropTable](../../V2SessionCatalog.md#dropTable), [renameTable](../../V2SessionCatalog.md#renameTable)
90+
* `DataFrameWriter` is requested to [insertInto](../../DataFrameWriter.md#insertInto), [saveInternal](../../DataFrameWriter.md#saveInternal), [saveAsTable](../../DataFrameWriter.md#saveAsTable)
91+
* `AtomicCreateTableAsSelectExec` physical operator is executed
92+
* `AtomicReplaceTableAsSelectExec` physical operator is executed
93+
* [CreateTableAsSelectExec](../../physical-operators/CreateTableAsSelectExec.md) physical operator is executed
94+
* `ReplaceTableAsSelectExec` physical operator is executed
95+
* `DelegatingCatalogExtension` is requested to [load a table](DelegatingCatalogExtension.md#loadTable)
96+
* `RenameTableExec` physical operator is executed
97+
* `AtomicReplaceTableExec` physical operator is executed
98+
* `ReplaceTableExec` physical operator is executed
99+
* `V2SessionCatalog` is requested to [dropTableInternal](../../V2SessionCatalog.md#dropTableInternal), [loadTable](../../V2SessionCatalog.md#loadTable), [dropTable](../../V2SessionCatalog.md#dropTable), [renameTable](../../V2SessionCatalog.md#renameTable)
100+
* `DataStreamWriter` is requested to `toTable`
90101

91102
### Rename Table { #renameTable }
92103

docs/connectors/DataSourceV2Utils.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
---
2+
title: DataSourceV2Utils
3+
---
4+
15
# DataSourceV2Utils Utility
26

37
`DataSourceV2Utils` is an utility to [extractSessionConfigs](#extractSessionConfigs) and [getTableFromProvider](#getTableFromProvider) for batch and streaming reads and writes.
48

5-
## <span id="extractSessionConfigs"> extractSessionConfigs
9+
## extractSessionConfigs { #extractSessionConfigs }
610

711
```scala
812
extractSessionConfigs(
@@ -24,7 +28,7 @@ extractSessionConfigs(
2428
* (Spark Structured Streaming) `DataStreamReader` is requested to load data from a streaming data source
2529
* (Spark Structured Streaming) `DataStreamWriter` is requested to start a streaming query
2630

27-
## <span id="getTableFromProvider"> Creating Table (using TableProvider)
31+
## Creating Table (using TableProvider) { #getTableFromProvider }
2832

2933
```scala
3034
getTableFromProvider(
@@ -44,7 +48,7 @@ getTableFromProvider(
4448
* `DataStreamReader` ([Spark Structured Streaming]({{ book.structured_streaming }}/DataStreamReader)) is requested to load data from a streaming data source
4549
* `DataStreamWriter` ([Spark Structured Streaming]({{ book.structured_streaming }}/DataStreamWriter)) is requested to start a streaming query
4650

47-
## <span id="loadV2Source"> loadV2Source
51+
## Load V2 Source { #loadV2Source }
4852

4953
```scala
5054
loadV2Source(
@@ -56,11 +60,15 @@ loadV2Source(
5660
paths: String*): Option[DataFrame]
5761
```
5862

59-
`loadV2Source` creates a [DataFrame](../DataFrame.md).
63+
`loadV2Source` [extractSessionConfigs](DataSourceV2Utils.md#extractSessionConfigs) and [adds the given paths](#getOptionsWithPaths) if specified.
64+
65+
For the given [TableProvider](../connector/TableProvider.md) being a [SupportsCatalogOptions](../connector/catalog/SupportsCatalogOptions.md), `loadV2Source`...FIXME
66+
67+
In the end, for a [SupportsRead](../connector/SupportsRead.md) table with [BATCH_READ](../connector/TableCapability.md#BATCH_READ) capability, `loadV2Source` creates a `DataFrame` with [DataSourceV2Relation](../logical-operators/DataSourceV2Relation.md#create) logical operator. Otherwise, `loadV2Source` gives no `DataFrame` (`None`).
6068

6169
---
6270

6371
`loadV2Source` is used when:
6472

65-
* `DataFrameReader` is requested to [load data](../DataFrameReader.md#load)
73+
* [DataFrameReader.load](../DataFrameReader.md#load) operator is used
6674
* [CreateTempViewUsing](../logical-operators/CreateTempViewUsing.md) logical operator is executed

0 commit comments

Comments
 (0)