18
18
19
19
package org .apache .hudi .table .catalog ;
20
20
21
+ import org .apache .hudi .adapter .HiveCatalogConstants .AlterHiveDatabaseOp ;
21
22
import org .apache .hudi .avro .AvroSchemaUtils ;
22
23
import org .apache .hudi .client .HoodieFlinkWriteClient ;
23
24
import org .apache .hudi .common .fs .FSUtils ;
47
48
import org .apache .flink .annotation .VisibleForTesting ;
48
49
import org .apache .flink .configuration .ConfigOption ;
49
50
import org .apache .flink .configuration .Configuration ;
50
- import org .apache .flink .sql .parser .hive .ddl .SqlAlterHiveDatabase ;
51
- import org .apache .flink .sql .parser .hive .ddl .SqlAlterHiveDatabaseOwner ;
52
- import org .apache .flink .sql .parser .hive .ddl .SqlCreateHiveDatabase ;
53
51
import org .apache .flink .table .catalog .AbstractCatalog ;
54
52
import org .apache .flink .table .catalog .CatalogBaseTable ;
55
53
import org .apache .flink .table .catalog .CatalogDatabase ;
107
105
import java .util .List ;
108
106
import java .util .Map ;
109
107
110
- import static org .apache .flink .sql .parser .hive .ddl .SqlAlterHiveDatabase .ALTER_DATABASE_OP ;
111
- import static org .apache .flink .sql .parser .hive .ddl .SqlAlterHiveDatabaseOwner .DATABASE_OWNER_NAME ;
112
- import static org .apache .flink .sql .parser .hive .ddl .SqlAlterHiveDatabaseOwner .DATABASE_OWNER_TYPE ;
113
- import static org .apache .flink .table .factories .FactoryUtil .CONNECTOR ;
114
- import static org .apache .flink .util .Preconditions .checkArgument ;
115
- import static org .apache .flink .util .Preconditions .checkNotNull ;
116
- import static org .apache .flink .util .StringUtils .isNullOrWhitespaceOnly ;
108
+ import static org .apache .hudi .adapter .HiveCatalogConstants .ALTER_DATABASE_OP ;
109
+ import static org .apache .hudi .adapter .HiveCatalogConstants .DATABASE_LOCATION_URI ;
110
+ import static org .apache .hudi .adapter .HiveCatalogConstants .DATABASE_OWNER_NAME ;
111
+ import static org .apache .hudi .adapter .HiveCatalogConstants .DATABASE_OWNER_TYPE ;
112
+ import static org .apache .hudi .adapter .HiveCatalogConstants .ROLE_OWNER ;
113
+ import static org .apache .hudi .adapter .HiveCatalogConstants .USER_OWNER ;
117
114
import static org .apache .hudi .configuration .FlinkOptions .PATH ;
118
115
import static org .apache .hudi .table .catalog .TableOptionProperties .COMMENT ;
119
116
import static org .apache .hudi .table .catalog .TableOptionProperties .PK_CONSTRAINT_NAME ;
120
117
import static org .apache .hudi .table .catalog .TableOptionProperties .SPARK_SOURCE_PROVIDER ;
118
+ import static org .apache .flink .table .factories .FactoryUtil .CONNECTOR ;
119
+ import static org .apache .flink .util .Preconditions .checkArgument ;
120
+ import static org .apache .flink .util .Preconditions .checkNotNull ;
121
+ import static org .apache .flink .util .StringUtils .isNullOrWhitespaceOnly ;
121
122
122
123
/**
123
124
* A catalog implementation for Hoodie based on MetaStore.
@@ -219,7 +220,7 @@ public CatalogDatabase getDatabase(String databaseName)
219
220
220
221
Map <String , String > properties = new HashMap <>(hiveDatabase .getParameters ());
221
222
222
- properties .put (SqlCreateHiveDatabase . DATABASE_LOCATION_URI , hiveDatabase .getLocationUri ());
223
+ properties .put (DATABASE_LOCATION_URI , hiveDatabase .getLocationUri ());
223
224
224
225
return new CatalogDatabaseImpl (properties , hiveDatabase .getDescription ());
225
226
}
@@ -248,7 +249,7 @@ public void createDatabase(
248
249
249
250
Map <String , String > properties = database .getProperties ();
250
251
251
- String dbLocationUri = properties .remove (SqlCreateHiveDatabase . DATABASE_LOCATION_URI );
252
+ String dbLocationUri = properties .remove (DATABASE_LOCATION_URI );
252
253
if (dbLocationUri == null && this .catalogPath != null ) {
253
254
// infer default location uri
254
255
dbLocationUri = new Path (this .catalogPath , databaseName ).toString ();
@@ -318,11 +319,10 @@ private static Database alterDatabase(Database hiveDB, CatalogDatabase newDataba
318
319
String opStr = newParams .remove (ALTER_DATABASE_OP );
319
320
if (opStr == null ) {
320
321
// by default is to alter db properties
321
- opStr = SqlAlterHiveDatabase . AlterHiveDatabaseOp .CHANGE_PROPS .name ();
322
+ opStr = AlterHiveDatabaseOp .CHANGE_PROPS .name ();
322
323
}
323
- String newLocation = newParams .remove (SqlCreateHiveDatabase .DATABASE_LOCATION_URI );
324
- SqlAlterHiveDatabase .AlterHiveDatabaseOp op =
325
- SqlAlterHiveDatabase .AlterHiveDatabaseOp .valueOf (opStr );
324
+ String newLocation = newParams .remove (DATABASE_LOCATION_URI );
325
+ AlterHiveDatabaseOp op = AlterHiveDatabaseOp .valueOf (opStr );
326
326
switch (op ) {
327
327
case CHANGE_PROPS :
328
328
hiveDB .setParameters (newParams );
@@ -335,10 +335,10 @@ private static Database alterDatabase(Database hiveDB, CatalogDatabase newDataba
335
335
String ownerType = newParams .remove (DATABASE_OWNER_TYPE );
336
336
hiveDB .setOwnerName (ownerName );
337
337
switch (ownerType ) {
338
- case SqlAlterHiveDatabaseOwner . ROLE_OWNER :
338
+ case ROLE_OWNER :
339
339
hiveDB .setOwnerType (PrincipalType .ROLE );
340
340
break ;
341
- case SqlAlterHiveDatabaseOwner . USER_OWNER :
341
+ case USER_OWNER :
342
342
hiveDB .setOwnerType (PrincipalType .USER );
343
343
break ;
344
344
default :
0 commit comments