18
18
import com .netflix .metacat .common .server .connectors .exception .TablePreconditionFailedException ;
19
19
import com .netflix .metacat .common .server .connectors .model .TableInfo ;
20
20
import com .netflix .metacat .common .server .properties .Config ;
21
- import com .netflix .metacat .common .server .util .MetacatUtils ;
22
- import com .netflix .metacat .connector .hive .commonview .CommonViewHandler ;
23
21
import com .netflix .metacat .connector .hive .converters .HiveConnectorInfoConverter ;
24
- import com .netflix .metacat .connector .hive .converters .HiveTypeConverter ;
25
22
import com .netflix .metacat .connector .hive .iceberg .IcebergTableHandler ;
26
23
import com .netflix .metacat .connector .hive .iceberg .IcebergTableWrapper ;
27
24
import com .netflix .metacat .connector .hive .sql .DirectSqlTable ;
@@ -54,7 +51,6 @@ public class PolarisConnectorTableService implements ConnectorTableService {
54
51
protected final HiveConnectorInfoConverter connectorConverter ;
55
52
protected final ConnectorContext connectorContext ;
56
53
protected final IcebergTableHandler icebergTableHandler ;
57
- protected final CommonViewHandler commonViewHandler ;
58
54
protected final PolarisTableMapper polarisTableMapper ;
59
55
protected final String catalogName ;
60
56
@@ -66,7 +62,6 @@ public class PolarisConnectorTableService implements ConnectorTableService {
66
62
* @param polarisConnectorDatabaseService connector database service
67
63
* @param connectorConverter converter
68
64
* @param icebergTableHandler iceberg table handler
69
- * @param commonViewHandler common view handler
70
65
* @param polarisTableMapper polaris table polarisTableMapper
71
66
* @param connectorContext the connector context
72
67
*/
@@ -76,7 +71,6 @@ public PolarisConnectorTableService(
76
71
final PolarisConnectorDatabaseService polarisConnectorDatabaseService ,
77
72
final HiveConnectorInfoConverter connectorConverter ,
78
73
final IcebergTableHandler icebergTableHandler ,
79
- final CommonViewHandler commonViewHandler ,
80
74
final PolarisTableMapper polarisTableMapper ,
81
75
final ConnectorContext connectorContext
82
76
) {
@@ -85,7 +79,6 @@ public PolarisConnectorTableService(
85
79
this .connectorConverter = connectorConverter ;
86
80
this .connectorContext = connectorContext ;
87
81
this .icebergTableHandler = icebergTableHandler ;
88
- this .commonViewHandler = commonViewHandler ;
89
82
this .polarisTableMapper = polarisTableMapper ;
90
83
this .catalogName = catalogName ;
91
84
}
@@ -103,13 +96,8 @@ public void create(final ConnectorRequestContext requestContext, final TableInfo
103
96
}
104
97
try {
105
98
final PolarisTableEntity entity = polarisTableMapper .toEntity (tableInfo );
106
- if (HiveTableUtil .isCommonView (tableInfo )) {
107
- polarisStoreService .createTable (entity .getDbName (), entity .getTblName (),
108
- entity .getMetadataLocation (), entity .getParams (), createdBy );
109
- } else {
110
- polarisStoreService .createTable (entity .getDbName (), entity .getTblName (),
99
+ polarisStoreService .createTable (entity .getDbName (), entity .getTblName (),
111
100
entity .getMetadataLocation (), createdBy );
112
- }
113
101
} catch (DataIntegrityViolationException | InvalidMetaException exception ) {
114
102
throw new InvalidMetaException (name , exception );
115
103
} catch (Exception exception ) {
@@ -160,10 +148,8 @@ public TableInfo get(final ConnectorRequestContext requestContext, final Qualifi
160
148
final PolarisTableEntity polarisTableEntity = polarisStoreService
161
149
.getTable (name .getDatabaseName (), name .getTableName ())
162
150
.orElseThrow (() -> new TableNotFoundException (name ));
163
- final boolean isView = MetacatUtils .isCommonView (polarisTableEntity .getParams ());
164
- final TableInfo info = polarisTableMapper .toInfo (polarisTableEntity , isView );
151
+ final TableInfo info = polarisTableMapper .toInfo (polarisTableEntity );
165
152
final String tableLoc = HiveTableUtil .getIcebergTableMetadataLocation (info );
166
-
167
153
// Return the iceberg table with just the metadata location included if requested.
168
154
if (connectorContext .getConfig ().shouldFetchOnlyMetadataLocationEnabled ()
169
155
&& requestContext .isIncludeMetadataLocationOnly ()) {
@@ -172,12 +158,8 @@ public TableInfo get(final ConnectorRequestContext requestContext, final Qualifi
172
158
.fields (Collections .emptyList ())
173
159
.build ();
174
160
}
175
- if (isView ) {
176
- return getCommonView (name , tableLoc , info , connectorContext .getConfig ().isIcebergCacheEnabled ());
177
- } else {
178
- return getIcebergTable (name , tableLoc , info ,
179
- requestContext .isIncludeMetadata (), connectorContext .getConfig ().isIcebergCacheEnabled ());
180
- }
161
+ return getIcebergTable (name , tableLoc , info ,
162
+ requestContext .isIncludeMetadata (), connectorContext .getConfig ().isIcebergCacheEnabled ());
181
163
} catch (TableNotFoundException | IllegalArgumentException exception ) {
182
164
log .error (String .format ("Not found exception for polaris table %s" , name ), exception );
183
165
throw exception ;
@@ -235,19 +217,13 @@ public void update(final ConnectorRequestContext requestContext, final TableInfo
235
217
final QualifiedName name = tableInfo .getName ();
236
218
final Config conf = connectorContext .getConfig ();
237
219
final String lastModifiedBy = PolarisUtils .getUserOrDefault (requestContext );
238
- final boolean isView = HiveTableUtil .isCommonView (tableInfo );
239
- if (isView ) {
240
- commonViewHandler .update (tableInfo );
241
- } else {
242
- icebergTableHandler .update (tableInfo );
243
- }
220
+ icebergTableHandler .update (tableInfo );
244
221
try {
245
222
final Map <String , String > newTableMetadata = tableInfo .getMetadata ();
246
223
if (MapUtils .isEmpty (newTableMetadata )) {
247
224
log .warn ("No parameters defined for iceberg table %s, no data update needed" , name );
248
225
return ;
249
226
}
250
-
251
227
final String prevLoc = newTableMetadata .get (DirectSqlTable .PARAM_PREVIOUS_METADATA_LOCATION );
252
228
final String newLoc = newTableMetadata .get (DirectSqlTable .PARAM_METADATA_LOCATION );
253
229
if (StringUtils .isBlank (prevLoc )) {
@@ -270,25 +246,10 @@ public void update(final ConnectorRequestContext requestContext, final TableInfo
270
246
log .error (message );
271
247
throw new InvalidMetaException (name , message , null );
272
248
}
273
-
274
- boolean updated = false ;
275
- if (isView ) {
276
- final Map <String , String > newTableParams = polarisTableMapper .filterMetadata (newTableMetadata );
277
- final Map <String , String > existingTableParams = polarisStoreService
278
- .getTable (name .getDatabaseName (), name .getTableName ())
279
- .orElseThrow (() -> new TableNotFoundException (name ))
280
- .getParams ();
281
- // optimistically attempt to update metadata location and/or params
282
- updated = polarisStoreService .updateTableMetadataLocationAndParams (
283
- name .getDatabaseName (), name .getTableName (), prevLoc , newLoc ,
284
- existingTableParams , newTableParams , lastModifiedBy );
285
- } else {
286
- // optimistically attempt to update metadata location
287
- updated = polarisStoreService .updateTableMetadataLocation (
288
- name .getDatabaseName (), name .getTableName (), prevLoc , newLoc , lastModifiedBy
289
- );
290
- }
291
-
249
+ // optimistically attempt to update metadata location
250
+ final boolean updated = polarisStoreService .updateTableMetadataLocation (
251
+ name .getDatabaseName (), name .getTableName (),
252
+ prevLoc , newLoc , lastModifiedBy );
292
253
// if succeeded then done, else try to figure out why and throw corresponding exception
293
254
if (updated ) {
294
255
requestContext .setIgnoreErrorsAfterUpdate (true );
@@ -387,10 +348,7 @@ public List<TableInfo> list(
387
348
ConnectorUtils .sort (tbls , sort , Comparator .comparing (t -> t .getTblName ()));
388
349
}
389
350
return ConnectorUtils .paginate (tbls , pageable ).stream ()
390
- .map (
391
- t -> polarisTableMapper .toInfo (t , MetacatUtils .isCommonView (t .getParams ()))
392
- )
393
- .collect (Collectors .toList ());
351
+ .map (t -> polarisTableMapper .toInfo (t )).collect (Collectors .toList ());
394
352
} catch (Exception exception ) {
395
353
final String msg = String .format ("Failed polaris list tables %s using prefix %s" , name , prefix );
396
354
log .error (msg , exception );
@@ -402,7 +360,7 @@ public List<TableInfo> list(
402
360
* Return the table metadata from cache if exists else make the iceberg call and refresh it.
403
361
* @param tableName table name
404
362
* @param tableMetadataLocation table metadata location
405
- * @param info table info stored in Polaris
363
+ * @param info table info stored in hive metastore
406
364
* @param includeInfoDetails if true, will include more details like the manifest file content
407
365
* @param useCache true, if table can be retrieved from cache
408
366
* @return TableInfo
@@ -418,24 +376,6 @@ public TableInfo getIcebergTable(final QualifiedName tableName,
418
376
return connectorConverter .fromIcebergTableToTableInfo (tableName , icebergTable , tableMetadataLocation , info );
419
377
}
420
378
421
- /**
422
- * Return the view metadata from cache if exists else make the iceberg call and refresh it.
423
- * @param tableName table name
424
- * @param tableMetadataLocation table metadata location
425
- * @param info table info stored in Polaris
426
- * @param useCache true, if table can be retrieved from cache
427
- * @return TableInfo
428
- */
429
- @ Cacheable (key = "'iceberg.view.' + #tableMetadataLocation" , condition = "#useCache" )
430
- public TableInfo getCommonView (final QualifiedName tableName ,
431
- final String tableMetadataLocation ,
432
- final TableInfo info ,
433
- final boolean useCache ) {
434
- return commonViewHandler .getCommonViewTableInfo (
435
- tableName , tableMetadataLocation , info , new HiveTypeConverter ()
436
- );
437
- }
438
-
439
379
@ Override
440
380
public List <QualifiedName > getTableNames (
441
381
final ConnectorRequestContext context ,
0 commit comments