You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/SparkSession.md
+5-4
Original file line number
Diff line number
Diff line change
@@ -93,22 +93,23 @@ cloneSession(): SparkSession
93
93
*`AdaptiveSparkPlanHelper` is requested to `getOrCloneSessionWithAqeOff`
94
94
*`StreamExecution` (Spark Structured Streaming) is created
95
95
96
-
## <spanid="builder"> Creating SparkSession Using Builder Pattern
96
+
## Creating SparkSession Using Builder Pattern { #builder }
97
97
98
98
```scala
99
99
builder():Builder
100
100
```
101
101
102
-
`builder` is an object method that creates a new [Builder](SparkSession-Builder.md) to build a `SparkSession` using a _fluent API_.
102
+
`builder` is an object method that creates a new [Builder](SparkSession-Builder.md)(that is then used to build a `SparkSession` using a so-called *Fluent API*).
103
103
104
104
```scala
105
105
importorg.apache.spark.sql.SparkSession
106
106
valbuilder=SparkSession.builder
107
107
```
108
108
109
-
TIP: Read about https://en.wikipedia.org/wiki/Fluent_interface[Fluent interface] design pattern in Wikipedia, the free encyclopedia.
109
+
??? note "Fluent interface"
110
+
Read about [Fluent interface](https://en.wikipedia.org/wiki/Fluent_interface) design pattern in Wikipedia, the free encyclopedia.
Only with [spark.sql.defaultColumn.enabled](../configuration-properties.md#spark.sql.defaultColumn.enabled) enabled, `constantFoldCurrentDefaultsToExistDefaults`...FIXME
70
+
71
+
Otherwise, `constantFoldCurrentDefaultsToExistDefaults` does nothing (a _noop_) and returns the given [table schema](../types/StructType.md) intact.
72
+
73
+
---
74
+
75
+
`constantFoldCurrentDefaultsToExistDefaults` is used when:
76
+
77
+
*`CatalogV2Util` is requested to [addField](../connector/catalog/CatalogV2Util.md#addField)
78
+
*[AlterTableAddColumnsCommand](../logical-operators/AlterTableAddColumnsCommand.md) logical command is executed (to [constantFoldCurrentDefaultsToExistDefaults](../logical-operators/AlterTableAddColumnsCommand.md#constantFoldCurrentDefaultsToExistDefaults))
79
+
*[DataSourceAnalysis](../logical-analysis-rules/DataSourceAnalysis.md) logical resolution rule is executed (to resolve a [CreateTable](../logical-operators/CreateTable.md) logical operator with a [DataSource table](../connectors/DDLUtils.md#isDatasourceTable))
80
+
*[DataSourceV2Strategy](../execution-planning-strategies/DataSourceV2Strategy.md) execution planning strategy is executed (to resolve [CreateTable](../logical-operators/CreateTable.md) and `ReplaceTable` logical operators)
*`Analyzer` is requested to [commonNaturalJoinProcessing](../Analyzer.md#commonNaturalJoinProcessing)
45
+
46
+
## markAsAllowAnyAccess { #markAsAllowAnyAccess }
47
+
48
+
```scala
49
+
markAsAllowAnyAccess():Attribute
50
+
```
51
+
52
+
Only with [qualifiedAccessOnly](#qualifiedAccessOnly) enabled, `markAsAllowAnyAccess` removes [__qualified_access_only](index.md#QUALIFIED_ACCESS_ONLY) metadata key from this [Attribute](#attr).
53
+
54
+
Otherwise, `markAsAllowAnyAccess` does nothing (a _noop_) and returns this [Attribute](#attr) intact.
55
+
56
+
---
57
+
58
+
`markAsAllowAnyAccess` is used when:
59
+
60
+
*[AddMetadataColumns](../logical-analysis-rules/AddMetadataColumns.md) logical resolution rule is executed (to [addMetadataCol](../logical-analysis-rules/AddMetadataColumns.md#addMetadataCol))
61
+
*`UnresolvedStar` expression is requested to [expand](../expressions/UnresolvedStar.md#expand)
`MetadataColumn`s are disregarded (_filtered out_) from the [metadataOutput](../logical-operators/LogicalPlan.md#metadataOutput) in [DataSourceV2Relation](../logical-operators/DataSourceV2Relation.md) leaf logical operator when in name-conflict with output columns.
`MetadataBuilder` is used to describe how to [create a Metadata](#build) (using _Fluent API_).
4
+
5
+
??? note "Fluent API"
6
+
Learn more about [Fluent interface](https://en.wikipedia.org/wiki/Fluent_interface) design pattern in Wikipedia, the free encyclopedia.
7
+
8
+
```scala
9
+
importorg.apache.spark.sql.types.MetadataBuilder
10
+
11
+
valnewMetadata=newMetadataBuilder()
12
+
.withMetadata(attr.metadata)
13
+
.putNull("__is_duplicate")
14
+
.build()
15
+
```
16
+
17
+
## Creating Metadata { #build }
18
+
19
+
```scala
20
+
build():Metadata
21
+
```
22
+
23
+
`build` creates a [Metadata](Metadata.md) (for the internal [map](#map)).
24
+
25
+
## withMetadata { #withMetadata }
26
+
27
+
```scala
28
+
withMetadata(
29
+
metadata: Metadata):this.type
30
+
```
31
+
32
+
`withMetadata` adds the [map](Metadata.md#map) of the given [Metadata](Metadata.md) to the internal [map](#map).
33
+
34
+
In the end, `withMetadata` returns this `MetadataBuilder`.
35
+
36
+
---
37
+
38
+
`withMetadata` is used when:
39
+
40
+
*`FileSourceConstantMetadataStructField` is requested for `metadata`
41
+
*`FileSourceGeneratedMetadataStructField` is requested for `metadata`
42
+
*`FileSourceMetadataAttribute` is requested for `metadata` and `removeInternalMetadata`
43
+
*`MetadataColumnHelper` is requested to [markAsAllowAnyAccess](../metadata-columns/MetadataColumnHelper.md#markAsAllowAnyAccess) and [markAsQualifiedAccessOnly](../metadata-columns/MetadataColumnHelper.md#markAsQualifiedAccessOnly)
44
+
*[ResolveDefaultColumns](../logical-analysis-rules/ResolveDefaultColumns.md) logical resolution rule is executed (to [constantFoldCurrentDefaultsToExistDefaults](../logical-analysis-rules/ResolveDefaultColumns.md#constantFoldCurrentDefaultsToExistDefaults))
45
+
*`StructField` is requested to [remove](StructField.md#clearCurrentDefaultValue) or [update the CURRENT_DEFAULT metadata attribute](StructField.md#withCurrentDefaultValue), and [update EXISTS_DEFAULT metadata attribute](StructField.md#withExistenceDefaultValue)
`clearCurrentDefaultValue` removes (_clears_) [CURRENT_DEFAULT](../default-columns/index.md#CURRENT_DEFAULT_COLUMN_METADATA_KEY) column metadata attribute from this [Metadata](#metadata).
88
+
89
+
---
90
+
91
+
`clearCurrentDefaultValue` is used when:
92
+
93
+
*`CatalogV2Util` is requested to [applySchemaChanges](../connector/catalog/CatalogV2Util.md#applySchemaChanges)
94
+
*`AlterTableChangeColumnCommand` logical command is executed
`withCurrentDefaultValue` adds or updates [CURRENT_DEFAULT](../default-columns/index.md#CURRENT_DEFAULT_COLUMN_METADATA_KEY) column metadata attribute (of this [Metadata](#metadata)) to the given `value`.
104
+
105
+
---
106
+
107
+
`withCurrentDefaultValue` is used when:
108
+
109
+
*`CatalogV2Util` is requested to [applySchemaChanges](../connector/catalog/CatalogV2Util.md#applySchemaChanges) and [encodeDefaultValue](../connector/catalog/CatalogV2Util.md#encodeDefaultValue)
110
+
*`AlterTableChangeColumnCommand` logical command is executed (to [addCurrentDefaultValue](#addCurrentDefaultValue))
`withExistenceDefaultValue` adds or updates [EXISTS_DEFAULT](../default-columns/index.md#EXISTS_DEFAULT_COLUMN_METADATA_KEY) column metadata attribute (of this [Metadata](#metadata)) to the given `value`.
120
+
121
+
---
122
+
123
+
`withExistenceDefaultValue` is used when:
124
+
125
+
*`CatalogV2Util` is requested to [encodeDefaultValue](../connector/catalog/CatalogV2Util.md#encodeDefaultValue)
0 commit comments