34
34
35
35
/**
36
36
* An optional mix-in for implementations of {@link TableCatalog} that support staging creation of
37
- * the a table before committing the table's metadata along with its contents in CREATE TABLE AS
37
+ * a table before committing the table's metadata along with its contents in CREATE TABLE AS
38
38
* SELECT or REPLACE TABLE AS SELECT operations.
39
39
* <p>
40
40
* It is highly recommended to implement this trait whenever possible so that CREATE TABLE AS
41
41
* SELECT and REPLACE TABLE AS SELECT operations are atomic. For example, when one runs a REPLACE
42
42
* TABLE AS SELECT operation, if the catalog does not implement this trait, the planner will first
43
43
* drop the table via {@link TableCatalog#dropTable(Identifier)}, then create the table via
44
- * {@link TableCatalog#createTable(Identifier, Column[], Transform[], Map )}, and then perform
44
+ * {@link TableCatalog#createTable(Identifier, TableInfo )}, and then perform
45
45
* the write via {@link SupportsWrite#newWriteBuilder(LogicalWriteInfo)}.
46
46
* However, if the write operation fails, the catalog will have already dropped the table, and the
47
47
* planner cannot roll back the dropping of the table.
@@ -72,6 +72,21 @@ default StagedTable stageCreate(
72
72
throw QueryCompilationErrors .mustOverrideOneMethodError ("stageCreate" );
73
73
}
74
74
75
+ /**
76
+ * Stage the creation of a table, preparing it to be committed into the metastore.
77
+ * <p>
78
+ * @deprecated This is deprecated. Please override
79
+ * {@link #stageCreate(Identifier, TableInfo)} instead.
80
+ */
81
+ @ Deprecated (since = "4.1.0" )
82
+ default StagedTable stageCreate (
83
+ Identifier ident ,
84
+ Column [] columns ,
85
+ Transform [] partitions ,
86
+ Map <String , String > properties ) throws TableAlreadyExistsException , NoSuchNamespaceException {
87
+ return stageCreate (ident , CatalogV2Util .v2ColumnsToStructType (columns ), partitions , properties );
88
+ }
89
+
75
90
/**
76
91
* Stage the creation of a table, preparing it to be committed into the metastore.
77
92
* <p>
@@ -82,21 +97,16 @@ default StagedTable stageCreate(
82
97
* committed, an exception should be thrown by {@link StagedTable#commitStagedChanges()}.
83
98
*
84
99
* @param ident a table identifier
85
- * @param columns the column of the new table
86
- * @param partitions transforms to use for partitioning data in the table
87
- * @param properties a string map of table properties
100
+ * @param tableInfo information about the table
88
101
* @return metadata for the new table. This can be null if the catalog does not support atomic
89
102
* creation for this table. Spark will call {@link #loadTable(Identifier)} later.
90
103
* @throws TableAlreadyExistsException If a table or view already exists for the identifier
91
104
* @throws UnsupportedOperationException If a requested partition transform is not supported
92
105
* @throws NoSuchNamespaceException If the identifier namespace does not exist (optional)
93
106
*/
94
- default StagedTable stageCreate (
95
- Identifier ident ,
96
- Column [] columns ,
97
- Transform [] partitions ,
98
- Map <String , String > properties ) throws TableAlreadyExistsException , NoSuchNamespaceException {
99
- return stageCreate (ident , CatalogV2Util .v2ColumnsToStructType (columns ), partitions , properties );
107
+ default StagedTable stageCreate (Identifier ident , TableInfo tableInfo )
108
+ throws TableAlreadyExistsException , NoSuchNamespaceException {
109
+ return stageCreate (ident , tableInfo .columns (), tableInfo .partitions (), tableInfo .properties ());
100
110
}
101
111
102
112
/**
@@ -115,6 +125,23 @@ default StagedTable stageReplace(
115
125
throw QueryCompilationErrors .mustOverrideOneMethodError ("stageReplace" );
116
126
}
117
127
128
+ /**
129
+ * Stage the replacement of a table, preparing it to be committed into the metastore when the
130
+ * returned table's {@link StagedTable#commitStagedChanges()} is called.
131
+ * <p>
132
+ * This is deprecated, please override
133
+ * {@link #stageReplace(Identifier, TableInfo)} instead.
134
+ */
135
+ @ Deprecated (since = "4.1.0" )
136
+ default StagedTable stageReplace (
137
+ Identifier ident ,
138
+ Column [] columns ,
139
+ Transform [] partitions ,
140
+ Map <String , String > properties ) throws NoSuchNamespaceException , NoSuchTableException {
141
+ return stageReplace (
142
+ ident , CatalogV2Util .v2ColumnsToStructType (columns ), partitions , properties );
143
+ }
144
+
118
145
/**
119
146
* Stage the replacement of a table, preparing it to be committed into the metastore when the
120
147
* returned table's {@link StagedTable#commitStagedChanges()} is called.
@@ -134,22 +161,16 @@ default StagedTable stageReplace(
134
161
* operation.
135
162
*
136
163
* @param ident a table identifier
137
- * @param columns the columns of the new table
138
- * @param partitions transforms to use for partitioning data in the table
139
- * @param properties a string map of table properties
164
+ * @param tableInfo information about the table
140
165
* @return metadata for the new table. This can be null if the catalog does not support atomic
141
166
* creation for this table. Spark will call {@link #loadTable(Identifier)} later.
142
167
* @throws UnsupportedOperationException If a requested partition transform is not supported
143
168
* @throws NoSuchNamespaceException If the identifier namespace does not exist (optional)
144
169
* @throws NoSuchTableException If the table does not exist
145
170
*/
146
- default StagedTable stageReplace (
147
- Identifier ident ,
148
- Column [] columns ,
149
- Transform [] partitions ,
150
- Map <String , String > properties ) throws NoSuchNamespaceException , NoSuchTableException {
151
- return stageReplace (
152
- ident , CatalogV2Util .v2ColumnsToStructType (columns ), partitions , properties );
171
+ default StagedTable stageReplace (Identifier ident , TableInfo tableInfo )
172
+ throws NoSuchNamespaceException , NoSuchTableException {
173
+ return stageReplace (ident , tableInfo .columns (), tableInfo .partitions (), tableInfo .properties ());
153
174
}
154
175
155
176
/**
@@ -168,6 +189,23 @@ default StagedTable stageCreateOrReplace(
168
189
throw QueryCompilationErrors .mustOverrideOneMethodError ("stageCreateOrReplace" );
169
190
}
170
191
192
+ /**
193
+ * Stage the creation or replacement of a table, preparing it to be committed into the metastore
194
+ * when the returned table's {@link StagedTable#commitStagedChanges()} is called.
195
+ * <p>
196
+ * This is deprecated, please override
197
+ * {@link #stageCreateOrReplace(Identifier, TableInfo)} instead.
198
+ */
199
+ @ Deprecated (since = "4.1.0" )
200
+ default StagedTable stageCreateOrReplace (
201
+ Identifier ident ,
202
+ Column [] columns ,
203
+ Transform [] partitions ,
204
+ Map <String , String > properties ) throws NoSuchNamespaceException {
205
+ return stageCreateOrReplace (
206
+ ident , CatalogV2Util .v2ColumnsToStructType (columns ), partitions , properties );
207
+ }
208
+
171
209
/**
172
210
* Stage the creation or replacement of a table, preparing it to be committed into the metastore
173
211
* when the returned table's {@link StagedTable#commitStagedChanges()} is called.
@@ -186,21 +224,18 @@ default StagedTable stageCreateOrReplace(
186
224
* the staged changes are committed but the table doesn't exist at commit time.
187
225
*
188
226
* @param ident a table identifier
189
- * @param columns the columns of the new table
190
- * @param partitions transforms to use for partitioning data in the table
191
- * @param properties a string map of table properties
227
+ * @param tableInfo information about the table
192
228
* @return metadata for the new table. This can be null if the catalog does not support atomic
193
229
* creation for this table. Spark will call {@link #loadTable(Identifier)} later.
194
230
* @throws UnsupportedOperationException If a requested partition transform is not supported
195
231
* @throws NoSuchNamespaceException If the identifier namespace does not exist (optional)
196
232
*/
197
- default StagedTable stageCreateOrReplace (
198
- Identifier ident ,
199
- Column [] columns ,
200
- Transform [] partitions ,
201
- Map <String , String > properties ) throws NoSuchNamespaceException {
202
- return stageCreateOrReplace (
203
- ident , CatalogV2Util .v2ColumnsToStructType (columns ), partitions , properties );
233
+ default StagedTable stageCreateOrReplace (Identifier ident , TableInfo tableInfo )
234
+ throws NoSuchNamespaceException {
235
+ return stageCreateOrReplace (ident ,
236
+ tableInfo .columns (),
237
+ tableInfo .partitions (),
238
+ tableInfo .properties ());
204
239
}
205
240
206
241
/**
0 commit comments