Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#5379] Add property commands for filesets in Gravitio CLI #5382

Open
wants to merge 96 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
b5e08c0
Added firest part of CLI code.
justinmclean Oct 2, 2024
655d133
update CLI option with output
justinmclean Oct 2, 2024
4a29c8b
Add missing license header
justinmclean Oct 2, 2024
1b12eff
Add default
justinmclean Oct 2, 2024
75de71e
Spotless on Java 11
justinmclean Oct 2, 2024
5172afa
Ignore warnings in test with Java 11
justinmclean Oct 2, 2024
0dc8856
Disable two tests on JAVA 17
justinmclean Oct 2, 2024
24dee9e
disabling two tests for now
justinmclean Oct 2, 2024
0ddbb7d
fix disabled tests
justinmclean Oct 2, 2024
4b95dd3
Still having issues on Java 17
justinmclean Oct 2, 2024
f76fa16
remove two tests as Java 17 is still giving issues
justinmclean Oct 2, 2024
8cbc605
No need to copy CLI for IT tests
justinmclean Oct 2, 2024
0ec7ecb
create catalogs and other entities
justinmclean Oct 9, 2024
fa2cdaf
remove unneeded call
justinmclean Oct 9, 2024
1e05853
Merge branch 'CLI' into CLI_II
justinmclean Oct 10, 2024
3df9f11
add more tests
justinmclean Oct 11, 2024
5e611be
add more tests
justinmclean Oct 11, 2024
68f7fa2
change version command into client and server version commands
justinmclean Oct 11, 2024
e2ebb7a
list entities and commands
justinmclean Oct 11, 2024
0e82c8f
Cache the metalake environment variable
justinmclean Oct 11, 2024
7b97750
use libs
justinmclean Oct 11, 2024
a562ed7
Merge branch 'main' into CLI
justinmclean Oct 11, 2024
47364fd
Merge branch 'CLI' into CLI_II
justinmclean Oct 12, 2024
d678b99
Trino Connector uses old deprecated CLI
justinmclean Oct 12, 2024
c201ef5
Merge branch 'CLI' into CLI_II
justinmclean Oct 12, 2024
253a2b4
fix test
justinmclean Oct 12, 2024
0ef4695
add basic user and group commands
justinmclean Oct 14, 2024
9320324
basic CLI for tags
justinmclean Oct 14, 2024
b3f081a
complete tag CLI
justinmclean Oct 15, 2024
29c9222
update docs
justinmclean Oct 15, 2024
f90a086
fix spelling error
justinmclean Oct 16, 2024
3c87c3d
add examples not using metalake
justinmclean Oct 16, 2024
10af3d2
remove duplication and clarify
justinmclean Oct 16, 2024
f955db2
use client shadow jar
justinmclean Oct 16, 2024
80aef91
wrong file
justinmclean Oct 16, 2024
6d897c0
new -> 19
justinmclean Oct 17, 2024
76aa1fe
fix example command
justinmclean Oct 17, 2024
affd6ad
revert as the suggested name is not value
justinmclean Oct 17, 2024
abc2da8
simplify command options
justinmclean Oct 17, 2024
a7c2a88
Merge branch 'CLI' into CLI_II
justinmclean Oct 17, 2024
055678b
fix merge issue and tests
justinmclean Oct 17, 2024
9808022
update command options
justinmclean Oct 17, 2024
464a74b
fix imports
justinmclean Oct 17, 2024
05bc9ed
update command options
justinmclean Oct 17, 2024
d27c59a
Merge branch 'CLI_II' into CLI_III
justinmclean Oct 17, 2024
423219c
Merge branch 'main' into CLI
justinmclean Oct 17, 2024
a405bfd
Merge branch 'CLI_IV' of https://github.com/justinmclean/gravitino in…
justinmclean Oct 17, 2024
954b351
Make executable and runnable from bin directory. update command format.
justinmclean Oct 22, 2024
808fffc
revert back to using two args and fix command format
justinmclean Oct 22, 2024
848a381
remove meatlake form name and add back metalake option
justinmclean Oct 22, 2024
2fe9a80
add Gravitino URL as an environment variable
justinmclean Oct 22, 2024
526d305
update README to mention environment variables
justinmclean Oct 22, 2024
d2ded4c
improved description of met lake name and add to options docs
justinmclean Oct 22, 2024
cb5a5d7
remove version number from alias
justinmclean Oct 22, 2024
71107fd
order in alphabetical order
justinmclean Oct 22, 2024
a6aeb42
add final where needed
justinmclean Oct 22, 2024
ce3ddc1
made private
justinmclean Oct 22, 2024
70aaaf9
use Joiner instead of StringBuilder
justinmclean Oct 22, 2024
22ca191
update commands
justinmclean Oct 23, 2024
ab52cf2
improve command line error handling
justinmclean Oct 23, 2024
bd57944
add executable shell script
justinmclean Oct 23, 2024
445cd41
put back README and make it developer focused
justinmclean Oct 23, 2024
7ea7125
support ignore option to ignore client/server version mismatch
justinmclean Oct 23, 2024
0a8844e
move list commands up one entity
justinmclean Oct 23, 2024
c342d7e
add comment
justinmclean Oct 23, 2024
d2b28af
no need for class
justinmclean Oct 23, 2024
038e1f6
fix command error handling and unwanted output
justinmclean Oct 23, 2024
ce5fa18
remove example scripts
justinmclean Oct 23, 2024
069f425
add CLI documentation
justinmclean Oct 23, 2024
5ed49fa
Merge branch 'CLI' into CLI_II
justinmclean Oct 23, 2024
4d68055
update tests
justinmclean Oct 23, 2024
f8c1f9b
update commands to use ignore parameter
justinmclean Oct 23, 2024
33efd6e
made variables final
justinmclean Oct 23, 2024
82ba035
remove user-facing content
justinmclean Oct 23, 2024
a4ac180
add URL to config file
justinmclean Oct 24, 2024
1ea9e12
list commands need to run first or warning in output occurs
justinmclean Oct 24, 2024
c3fc55c
add javadocs
justinmclean Oct 24, 2024
451a92f
Merge branch 'CLI_II' into CLI_III
justinmclean Oct 24, 2024
50edda6
add ignore to commands
justinmclean Oct 24, 2024
cb31019
make fields final
justinmclean Oct 24, 2024
dd97d26
simplify output
justinmclean Oct 24, 2024
b47ac45
Merge branch 'CLI_III' into CLI_IV
justinmclean Oct 24, 2024
43546f8
add final
justinmclean Oct 24, 2024
2d268a6
missed one
justinmclean Oct 24, 2024
6ad0af5
simplify output
justinmclean Oct 24, 2024
4b60ea4
Merge branch 'main' into CLI_II
justinmclean Oct 24, 2024
20e550f
reset files
justinmclean Oct 24, 2024
eeefccc
restore test files
justinmclean Oct 24, 2024
9f073ac
add ignore to the config file
justinmclean Oct 24, 2024
64f18ef
update documentation
justinmclean Oct 24, 2024
74452c9
minor English updates
justinmclean Oct 25, 2024
c79c6e3
Merge branch 'CLI_II' into CLI_III
justinmclean Oct 25, 2024
d521410
Merge branch 'CLI_III' into CLI_IV
justinmclean Oct 25, 2024
5b5453d
add basic fileset commands
justinmclean Oct 30, 2024
19cc513
add update commands for fileset
justinmclean Oct 30, 2024
55efdb6
add fileset property commands
justinmclean Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class CommandActions {
public static final String UPDATE = "update";
public static final String CREATE = "create";
public static final String DELETE = "delete";
public static final String SET = "set";
public static final String REMOVE = "remove";
public static final String PROPERTIES = "properties";

private static final HashSet<String> VALID_COMMANDS = new HashSet<>();

Expand All @@ -40,6 +43,9 @@ public class CommandActions {
VALID_COMMANDS.add(UPDATE);
VALID_COMMANDS.add(CREATE);
VALID_COMMANDS.add(DELETE);
VALID_COMMANDS.add(SET);
VALID_COMMANDS.add(REMOVE);
VALID_COMMANDS.add(PROPERTIES);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class CommandEntities {
public static final String SCHEMA = "schema";
public static final String TABLE = "table";
public static final String COLUMN = "column";
public static final String USER = "user";
public static final String GROUP = "group";
public static final String TAG = "tag";
public static final String FILESET = "fileset";

private static final HashSet<String> VALID_ENTITIES = new HashSet<>();

Expand All @@ -40,6 +44,10 @@ public class CommandEntities {
VALID_ENTITIES.add(SCHEMA);
VALID_ENTITIES.add(TABLE);
VALID_ENTITIES.add(COLUMN);
VALID_ENTITIES.add(USER);
VALID_ENTITIES.add(GROUP);
VALID_ENTITIES.add(TAG);
VALID_ENTITIES.add(FILESET);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,22 @@
public class ErrorMessages {
public static final String UNSUPPORTED_COMMAND = "Unsupported or unknown command.";
public static final String UNKNOWN_ENTITY = "Unknown entity.";
public static final String TOO_MANY_ARGUMENTS = "Too many arguments.";
public static final String UNKNOWN_METALAKE = "Unknown metalake name.";
public static final String UNKNOWN_CATALOG = "Unknown catalog name.";
public static final String UNKNOWN_SCHEMA = "Unknown schema name.";
public static final String UNKNOWN_TABLE = "Unknown table name.";
public static final String MALFORMED_NAME = "Malformed entity name.";
public static final String MISSING_NAME = "Missing name.";
public static final String METALAKE_EXISTS = "Metalake already exists.";
public static final String CATALOG_EXISTS = "Catalog already exists.";
public static final String SCHEMA_EXISTS = "Schema already exists.";
public static final String UNKNOWN_USER = "Unknown user.";
public static final String USER_EXISTS = "User already exists.";
public static final String UNKNOWN_GROUP = "Unknown group.";
public static final String GROUP_EXISTS = "Group already exists.";
public static final String UNKNOWN_TAG = "Unknown tag.";
public static final String TAG_EXISTS = "Tag already exists.";
public static final String UNKNOWN_FILESET = "Unknown fileset.";
public static final String FILESET_EXISTS = "Fileset already exists.";
}
71 changes: 70 additions & 1 deletion clients/cli/src/main/java/org/apache/gravitino/cli/FullName.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ public FullName(CommandLine line) {

/**
* Retrieves the metalake name from the command line options, the GRAVITINO_METALAKE environment
* variable.
* variable or the Gravitino config file.
*
* @return The metalake name, or null if not found.
*/
public String getMetalakeName() {
GravitinoConfig config = new GravitinoConfig(null);

// If specified on the command line use that
if (line.hasOption(GravitinoOptions.METALAKE)) {
return line.getOptionValue(GravitinoOptions.METALAKE);
Expand All @@ -60,6 +62,18 @@ public String getMetalakeName() {
// Check if the metalake name is set as an environment variable
if (metalakeEnv != null) {
return metalakeEnv;
// Check if the metalake name is specified in the configuration file
} else if (config.fileExists()) {
config.read();
String configName = config.getMetalakeName();
if (configName != null) {
return configName;
}
}

// Extract the metalake name from the full name option
if (line.hasOption(GravitinoOptions.NAME)) {
return line.getOptionValue(GravitinoOptions.NAME).split("\\.")[0];
}

return null;
Expand Down Expand Up @@ -115,4 +129,59 @@ public String getNamePart(int position) {
System.err.println(ErrorMessages.MISSING_NAME);
return null;
}

/**
* Helper method to determine a specific part of the full name exits.
*
* @param partNo The part of the name to obtain.
* @return True if the part exitsts.
*/
public boolean hasNamePart(int partNo) {
/* Extract the name part from the full name if available. */
if (line.hasOption(GravitinoOptions.NAME)) {
String[] names = line.getOptionValue(GravitinoOptions.NAME).split("\\.");
int length = names.length;
int position = partNo;

return position <= length;
}

return false;
}

/**
* Does the metalake name exist?
*
* @return True if the catalog name exists, or false if it does not.
*/
public boolean hasMetalakeName() {
return hasNamePart(1);
}

/**
* Does the catalog name exist?
*
* @return True if the catalog name exists, or false if it does not.
*/
public boolean hasCatalogName() {
return hasNamePart(2);
}

/**
* Does the schema name exist?
*
* @return True if the schema name exists, or false if it does not.
*/
public boolean hasSchemaName() {
return hasNamePart(3);
}

/**
* Does the table name exist?
*
* @return True if the table name exists, or false if it does not.
*/
public boolean hasTableName() {
return hasNamePart(4);
}
}
Loading
Loading