Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into sync-a-fork-5
Browse files Browse the repository at this point in the history
  • Loading branch information
youngyjd committed Feb 14, 2025
2 parents b534195 + 74435c9 commit fc2bca9
Show file tree
Hide file tree
Showing 259 changed files with 4,595 additions and 2,818 deletions.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ allprojects {
param.environment("NEED_CREATE_DOCKER_NETWORK", "true")
}

val icebergVersion: String = libs.versions.iceberg.get()
param.systemProperty("ICEBERG_VERSION", icebergVersion)

// Change poll image pause time from 30s to 60s
param.environment("TESTCONTAINERS_PULL_PAUSE_TIMEOUT", "60")
val jdbcDatabase = project.properties["jdbcBackend"] as? String ?: "h2"
Expand Down
6 changes: 6 additions & 0 deletions catalogs/catalog-hadoop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ dependencies {
exclude("org.eclipse.jetty", "*")
exclude("io.netty")
exclude("org.fusesource.leveldbjni")
// Exclude `protobuf-java` 2.5.0 to avoid conflict with a higher version of `protobuf-java`
// in the authorization module. The reason is that the class loader of `catalog-hadoop` is the
// parent of the class loader of the authorization module, so the class loader of `catalog-hadoop`
// will load the class `protobuf-java` 2.5.0 first, which will cause the authorization module to
// fail to load the class `protobuf-java` 3.15.8.
exclude("com.google.protobuf", "protobuf-java")
}
implementation(libs.slf4j.api)
implementation(libs.awaitility)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,38 @@ public class CatalogCommandHandler extends CommandHandler {
private final GravitinoCommandLine gravitinoCommandLine;
private final CommandLine line;
private final String command;
private final boolean ignore;
private final String url;
private final CommandContext context;
private final FullName name;
private final String metalake;
private String catalog;
private final String outputFormat;

/**
* Constructs a {@link CatalogCommandHandler} instance.
*
* @param gravitinoCommandLine The Gravitino command line instance.
* @param line The command line arguments.
* @param command The command to execute.
* @param ignore Ignore server version mismatch.
* @param context The command context.
*/
public CatalogCommandHandler(
GravitinoCommandLine gravitinoCommandLine, CommandLine line, String command, boolean ignore) {
GravitinoCommandLine gravitinoCommandLine,
CommandLine line,
String command,
CommandContext context) {
this.gravitinoCommandLine = gravitinoCommandLine;
this.line = line;
this.command = command;
this.ignore = ignore;
this.context = context;

this.url = getUrl(line);
this.name = new FullName(line);
this.metalake = name.getMetalakeName();
this.outputFormat = line.getOptionValue(GravitinoOptions.OUTPUT);
}

/** Handles the command execution logic based on the provided command. */
@Override
protected void handle() {
String userName = line.getOptionValue(GravitinoOptions.LOGIN);
Command.setAuthenticationMode(getAuth(line), userName);
Command.setAuthenticationMode(context.auth(), userName);
List<String> missingEntities = Lists.newArrayList();

if (CommandActions.LIST.equals(command)) {
Expand Down Expand Up @@ -126,12 +125,9 @@ private boolean executeCommand() {
/** Handles the "DETAILS" command. */
private void handleDetailsCommand() {
if (line.hasOption(GravitinoOptions.AUDIT)) {
gravitinoCommandLine.newCatalogAudit(url, ignore, metalake, catalog).validate().handle();
gravitinoCommandLine.newCatalogAudit(context, metalake, catalog).validate().handle();
} else {
gravitinoCommandLine
.newCatalogDetails(url, ignore, outputFormat, metalake, catalog)
.validate()
.handle();
gravitinoCommandLine.newCatalogDetails(context, metalake, catalog).validate().handle();
}
}

Expand All @@ -143,26 +139,22 @@ private void handleCreateCommand() {

Map<String, String> propertyMap = new Properties().parse(properties);
gravitinoCommandLine
.newCreateCatalog(url, ignore, metalake, catalog, provider, comment, propertyMap)
.newCreateCatalog(context, metalake, catalog, provider, comment, propertyMap)
.validate()
.handle();
}

/** Handles the "DELETE" command. */
private void handleDeleteCommand() {
boolean force = line.hasOption(GravitinoOptions.FORCE);
gravitinoCommandLine
.newDeleteCatalog(url, ignore, force, metalake, catalog)
.validate()
.handle();
gravitinoCommandLine.newDeleteCatalog(context, metalake, catalog).validate().handle();
}

/** Handles the "SET" command. */
private void handleSetCommand() {
String property = line.getOptionValue(GravitinoOptions.PROPERTY);
String value = line.getOptionValue(GravitinoOptions.VALUE);
gravitinoCommandLine
.newSetCatalogProperty(url, ignore, metalake, catalog, property, value)
.newSetCatalogProperty(context, metalake, catalog, property, value)
.validate()
.handle();
}
Expand All @@ -171,17 +163,14 @@ private void handleSetCommand() {
private void handleRemoveCommand() {
String property = line.getOptionValue(GravitinoOptions.PROPERTY);
gravitinoCommandLine
.newRemoveCatalogProperty(url, ignore, metalake, catalog, property)
.newRemoveCatalogProperty(context, metalake, catalog, property)
.validate()
.handle();
}

/** Handles the "PROPERTIES" command. */
private void handlePropertiesCommand() {
gravitinoCommandLine
.newListCatalogProperties(url, ignore, metalake, catalog)
.validate()
.handle();
gravitinoCommandLine.newListCatalogProperties(context, metalake, catalog).validate().handle();
}

/** Handles the "UPDATE" command. */
Expand All @@ -193,32 +182,32 @@ private void handleUpdateCommand() {
if (line.hasOption(GravitinoOptions.ENABLE)) {
boolean enableMetalake = line.hasOption(GravitinoOptions.ALL);
gravitinoCommandLine
.newCatalogEnable(url, ignore, metalake, catalog, enableMetalake)
.newCatalogEnable(context, metalake, catalog, enableMetalake)
.validate()
.handle();
}
if (line.hasOption(GravitinoOptions.DISABLE)) {
gravitinoCommandLine.newCatalogDisable(url, ignore, metalake, catalog).validate().handle();
gravitinoCommandLine.newCatalogDisable(context, metalake, catalog).validate().handle();
}

if (line.hasOption(GravitinoOptions.COMMENT)) {
String updateComment = line.getOptionValue(GravitinoOptions.COMMENT);
gravitinoCommandLine
.newUpdateCatalogComment(url, ignore, metalake, catalog, updateComment)
.newUpdateCatalogComment(context, metalake, catalog, updateComment)
.validate()
.handle();
}
if (line.hasOption(GravitinoOptions.RENAME)) {
String newName = line.getOptionValue(GravitinoOptions.RENAME);
gravitinoCommandLine
.newUpdateCatalogName(url, ignore, metalake, catalog, newName)
.newUpdateCatalogName(context, metalake, catalog, newName)
.validate()
.handle();
}
}

/** Handles the "LIST" command. */
private void handleListCommand() {
gravitinoCommandLine.newListCatalogs(url, ignore, outputFormat, metalake).validate().handle();
gravitinoCommandLine.newListCatalogs(context, metalake).validate().handle();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public class ColumnCommandHandler extends CommandHandler {
private final GravitinoCommandLine gravitinoCommandLine;
private final CommandLine line;
private final String command;
private final boolean ignore;
private final String url;
private final CommandContext context;
private final FullName name;
private final String metalake;
private final String catalog;
Expand All @@ -44,16 +43,18 @@ public class ColumnCommandHandler extends CommandHandler {
* @param gravitinoCommandLine The Gravitino command line instance.
* @param line The command line arguments.
* @param command The command to execute.
* @param ignore Ignore server version mismatch.
* @param context The command context.
*/
public ColumnCommandHandler(
GravitinoCommandLine gravitinoCommandLine, CommandLine line, String command, boolean ignore) {
GravitinoCommandLine gravitinoCommandLine,
CommandLine line,
String command,
CommandContext context) {
this.gravitinoCommandLine = gravitinoCommandLine;
this.line = line;
this.command = command;
this.ignore = ignore;
this.context = context;

this.url = getUrl(line);
this.name = new FullName(line);
this.metalake = name.getMetalakeName();
this.catalog = name.getCatalogName();
Expand All @@ -65,7 +66,7 @@ public ColumnCommandHandler(
@Override
protected void handle() {
String userName = line.getOptionValue(GravitinoOptions.LOGIN);
Command.setAuthenticationMode(getAuth(line), userName);
Command.setAuthenticationMode(context.auth(), userName);

List<String> missingEntities = Lists.newArrayList();
if (catalog == null) missingEntities.add(CommandEntities.CATALOG);
Expand Down Expand Up @@ -120,7 +121,7 @@ private boolean executeCommand() {
private void handleDetailsCommand() {
if (line.hasOption(GravitinoOptions.AUDIT)) {
gravitinoCommandLine
.newColumnAudit(url, ignore, metalake, catalog, schema, table, column)
.newColumnAudit(context, metalake, catalog, schema, table, column)
.validate()
.handle();
} else {
Expand All @@ -144,8 +145,7 @@ private void handleCreateCommand() {

gravitinoCommandLine
.newAddColumn(
url,
ignore,
context,
metalake,
catalog,
schema,
Expand All @@ -164,7 +164,7 @@ private void handleCreateCommand() {
/** Handles the "DELETE" command. */
private void handleDeleteCommand() {
gravitinoCommandLine
.newDeleteColumn(url, ignore, metalake, catalog, schema, table, column)
.newDeleteColumn(context, metalake, catalog, schema, table, column)
.validate()
.handle();
}
Expand All @@ -174,44 +174,43 @@ private void handleUpdateCommand() {
if (line.hasOption(GravitinoOptions.COMMENT)) {
String comment = line.getOptionValue(GravitinoOptions.COMMENT);
gravitinoCommandLine
.newUpdateColumnComment(url, ignore, metalake, catalog, schema, table, column, comment)
.newUpdateColumnComment(context, metalake, catalog, schema, table, column, comment)
.validate()
.handle();
}
if (line.hasOption(GravitinoOptions.RENAME)) {
String newName = line.getOptionValue(GravitinoOptions.RENAME);
gravitinoCommandLine
.newUpdateColumnName(url, ignore, metalake, catalog, schema, table, column, newName)
.newUpdateColumnName(context, metalake, catalog, schema, table, column, newName)
.validate()
.handle();
}
if (line.hasOption(GravitinoOptions.DATATYPE) && !line.hasOption(GravitinoOptions.DEFAULT)) {
String datatype = line.getOptionValue(GravitinoOptions.DATATYPE);
gravitinoCommandLine
.newUpdateColumnDatatype(url, ignore, metalake, catalog, schema, table, column, datatype)
.newUpdateColumnDatatype(context, metalake, catalog, schema, table, column, datatype)
.validate()
.handle();
}
if (line.hasOption(GravitinoOptions.POSITION)) {
String position = line.getOptionValue(GravitinoOptions.POSITION);
gravitinoCommandLine
.newUpdateColumnPosition(url, ignore, metalake, catalog, schema, table, column, position)
.newUpdateColumnPosition(context, metalake, catalog, schema, table, column, position)
.validate()
.handle();
}
if (line.hasOption(GravitinoOptions.NULL)) {
boolean nullable = line.getOptionValue(GravitinoOptions.NULL).equals("true");
gravitinoCommandLine
.newUpdateColumnNullability(
url, ignore, metalake, catalog, schema, table, column, nullable)
.newUpdateColumnNullability(context, metalake, catalog, schema, table, column, nullable)
.validate()
.handle();
}
if (line.hasOption(GravitinoOptions.AUTO)) {
boolean autoIncrement = line.getOptionValue(GravitinoOptions.AUTO).equals("true");
gravitinoCommandLine
.newUpdateColumnAutoIncrement(
url, ignore, metalake, catalog, schema, table, column, autoIncrement)
context, metalake, catalog, schema, table, column, autoIncrement)
.validate()
.handle();
}
Expand All @@ -220,7 +219,7 @@ private void handleUpdateCommand() {
String dataType = line.getOptionValue(GravitinoOptions.DATATYPE);
gravitinoCommandLine
.newUpdateColumnDefault(
url, ignore, metalake, catalog, schema, table, column, defaultValue, dataType)
context, metalake, catalog, schema, table, column, defaultValue, dataType)
.validate()
.handle();
}
Expand All @@ -229,7 +228,7 @@ private void handleUpdateCommand() {
/** Handles the "LIST" command. */
private void handleListCommand() {
gravitinoCommandLine
.newListColumns(url, ignore, metalake, catalog, schema, table)
.newListColumns(context, metalake, catalog, schema, table)
.validate()
.handle();
}
Expand Down
Loading

0 comments on commit fc2bca9

Please sign in to comment.