22
22
import org .apache .spark .sql .catalyst .analysis .NoSuchFunctionException ;
23
23
import org .apache .spark .sql .catalyst .analysis .NoSuchNamespaceException ;
24
24
import org .apache .spark .sql .catalyst .analysis .NoSuchTableException ;
25
+ import org .apache .spark .sql .catalyst .analysis .NoSuchViewException ;
25
26
import org .apache .spark .sql .catalyst .analysis .NonEmptyNamespaceException ;
26
27
import org .apache .spark .sql .catalyst .analysis .TableAlreadyExistsException ;
28
+ import org .apache .spark .sql .catalyst .analysis .ViewAlreadyExistsException ;
27
29
import org .apache .spark .sql .connector .catalog .CatalogExtension ;
28
30
import org .apache .spark .sql .connector .catalog .CatalogPlugin ;
29
31
import org .apache .spark .sql .connector .catalog .FunctionCatalog ;
33
35
import org .apache .spark .sql .connector .catalog .Table ;
34
36
import org .apache .spark .sql .connector .catalog .TableCatalog ;
35
37
import org .apache .spark .sql .connector .catalog .TableChange ;
38
+ import org .apache .spark .sql .connector .catalog .View ;
39
+ import org .apache .spark .sql .connector .catalog .ViewCatalog ;
40
+ import org .apache .spark .sql .connector .catalog .ViewChange ;
36
41
import org .apache .spark .sql .connector .catalog .functions .UnboundFunction ;
37
42
import org .apache .spark .sql .connector .expressions .Transform ;
38
43
import org .apache .spark .sql .internal .SQLConf ;
41
46
import org .slf4j .Logger ;
42
47
import org .slf4j .LoggerFactory ;
43
48
44
- public class BigQueryCatalogExtension implements CatalogExtension {
49
+ public class BigQueryCatalogExtension implements CatalogExtension , ViewCatalog {
45
50
46
51
private static final Logger logger = LoggerFactory .getLogger (BigQueryCatalogExtension .class );
47
52
private static final String [] DEFAULT_NAMESPACE = new String [] {"default" };
@@ -166,6 +171,68 @@ public boolean dropTable(Identifier ident) {
166
171
public void renameTable (Identifier oldIdent , Identifier newIdent )
167
172
throws NoSuchTableException , TableAlreadyExistsException {}
168
173
174
+ @ Override
175
+ public Identifier [] listViews (String ... namespace ) throws NoSuchNamespaceException {
176
+ return delegateAsViewCatalog ().listViews (namespace );
177
+ }
178
+
179
+ @ Override
180
+ public View loadView (Identifier ident ) throws NoSuchViewException {
181
+ return delegateAsViewCatalog ().loadView (ident );
182
+ }
183
+
184
+ @ Override
185
+ public void invalidateView (Identifier ident ) {
186
+ delegateAsViewCatalog ().invalidateView (ident );
187
+ }
188
+
189
+ @ Override
190
+ public boolean viewExists (Identifier ident ) {
191
+ return delegateAsViewCatalog ().viewExists (ident );
192
+ }
193
+
194
+ @ Override
195
+ public View createView (
196
+ Identifier ident ,
197
+ String sql ,
198
+ String currentCatalog ,
199
+ String [] currentNamespace ,
200
+ StructType schema ,
201
+ String [] queryColumnNames ,
202
+ String [] columnAliases ,
203
+ String [] columnComments ,
204
+ Map <String , String > properties )
205
+ throws ViewAlreadyExistsException , NoSuchNamespaceException {
206
+ return delegateAsViewCatalog ()
207
+ .createView (
208
+ ident ,
209
+ sql ,
210
+ currentCatalog ,
211
+ currentNamespace ,
212
+ schema ,
213
+ queryColumnNames ,
214
+ columnAliases ,
215
+ columnComments ,
216
+ properties );
217
+ }
218
+
219
+ @ Override
220
+ public View alterView (Identifier ident , ViewChange ... changes )
221
+ throws NoSuchViewException , IllegalArgumentException {
222
+ return delegateAsViewCatalog ().alterView (ident , changes );
223
+ }
224
+
225
+ @ Override
226
+ public boolean dropView (Identifier ident ) {
227
+ return delegateAsViewCatalog ().dropView (ident );
228
+ }
229
+
230
+ @ Override
231
+ public void renameView (Identifier oldIdent , Identifier newIdent )
232
+ throws NoSuchViewException , ViewAlreadyExistsException {
233
+ delegateAsViewCatalog ().renameView (oldIdent , newIdent );
234
+ }
235
+
169
236
private TableCatalog delegateAsTableCatalog () {
170
237
return (TableCatalog ) sessionCatalog ;
171
238
}
@@ -177,4 +244,8 @@ private FunctionCatalog delegateAsFunctionCatalog() {
177
244
private SupportsNamespaces delegateAsSupportsNamespaces () {
178
245
return (SupportsNamespaces ) sessionCatalog ;
179
246
}
247
+
248
+ private ViewCatalog delegateAsViewCatalog () {
249
+ return (ViewCatalog ) sessionCatalog ;
250
+ }
180
251
}
0 commit comments