dimas-b commented on code in PR #2762:
URL: https://github.com/apache/polaris/pull/2762#discussion_r2407897414


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/bootstrap/SchemaOptions.java:
##########
@@ -33,7 +34,8 @@ public interface SchemaOptions {
 
   @Value.Check
   default void validate() {
-    if (schemaVersion() != null && schemaFile() != null) {
+    if (schemaVersion() != null
+        && (schemaFile() != null && 
!Objects.requireNonNull(schemaFile()).isEmpty())) {

Review Comment:
   Why bother with empty `schemaFile()` here at all? Why not validate it 
separately and require that it be non-empty if set (if non-null)?



##########
runtime/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java:
##########
@@ -35,20 +35,28 @@
     description = "Bootstraps realms and root principal credentials.")
 public class BootstrapCommand extends BaseCommand {
 
-  @CommandLine.ArgGroup(multiplicity = "1")
-  InputOptions inputOptions;
+  @CommandLine.Mixin InputOptions inputOptions;
 
   static class InputOptions {
 
-    @CommandLine.ArgGroup(multiplicity = "1", exclusive = false)
-    StandardInputOptions stdinOptions;
-
+    // This ArgGroup enforces the mandatory, exclusive choice.
     @CommandLine.ArgGroup(multiplicity = "1")
-    FileInputOptions fileOptions;
+    ExclusiveOptions exclusiveOptions;
 
-    @CommandLine.ArgGroup(multiplicity = "1")
-    SchemaInputOptions schemaInputOptions;
+    // This @Mixin provides independent, optional schema flags.
+    @CommandLine.Mixin SchemaInputOptions schemaInputOptions = new 
SchemaInputOptions();
+
+    // This static inner class encapsulates the mutually exclusive choices.
+    static class ExclusiveOptions {
+
+      @CommandLine.ArgGroup(exclusive = false, heading = "Standard Input 
Options:%n")
+      StandardInputOptions stdinOptions;
 
+      @CommandLine.ArgGroup(exclusive = false, heading = "File Input 
Options:%n")
+      FileInputOptions fileOptions;

Review Comment:
   I'm still not sure we end up with the right delineation of options.
   
   I think `--print-credentials` is conceptually applicable to all cases that 
involve root credentials (regardless of the source of credentials).
   
   Also `--realm` is applicable to all cases. A use may want a sub-set of 
realms from a file or from `--credential` (which may come from a large env. 
var, etc.).
   
   Rather than treating `--credential` and `--credentials-file` as mutually 
exclusive, I'd prefer the tool to merge `RootCredentialsSet` from all sources. 
   
   In the end all options are applicable and we default `--realm` to all realms 
within the merged `RootCredentialsSet`.
   
   I think that would be nicer from the end user POV. WDYT?



##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/bootstrap/SchemaOptions.java:
##########
@@ -33,7 +34,8 @@ public interface SchemaOptions {
 
   @Value.Check
   default void validate() {
-    if (schemaVersion() != null && schemaFile() != null) {
+    if (schemaVersion() != null
+        && (schemaFile() != null && 
!Objects.requireNonNull(schemaFile()).isEmpty())) {

Review Comment:
   TBH, I'd personally convert these properties to `OptionalInt` and 
`Optional<String>`... WDYT? (this is optional 😉 )



##########
runtime/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java:
##########
@@ -35,20 +35,28 @@
     description = "Bootstraps realms and root principal credentials.")
 public class BootstrapCommand extends BaseCommand {
 
-  @CommandLine.ArgGroup(multiplicity = "1")
-  InputOptions inputOptions;
+  @CommandLine.Mixin InputOptions inputOptions;
 
   static class InputOptions {
 
-    @CommandLine.ArgGroup(multiplicity = "1", exclusive = false)
-    StandardInputOptions stdinOptions;
-
+    // This ArgGroup enforces the mandatory, exclusive choice.
     @CommandLine.ArgGroup(multiplicity = "1")
-    FileInputOptions fileOptions;
+    ExclusiveOptions exclusiveOptions;
 
-    @CommandLine.ArgGroup(multiplicity = "1")
-    SchemaInputOptions schemaInputOptions;
+    // This @Mixin provides independent, optional schema flags.
+    @CommandLine.Mixin SchemaInputOptions schemaInputOptions = new 
SchemaInputOptions();
+
+    // This static inner class encapsulates the mutually exclusive choices.
+    static class ExclusiveOptions {

Review Comment:
   Suggestion: `RootCredentialOptions`



##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/DatabaseType.java:
##########
@@ -53,9 +54,10 @@ public static DatabaseType fromDisplayName(String 
displayName) {
    * caller.
    */
   public InputStream openInitScriptResource(@Nonnull SchemaOptions 
schemaOptions) {
-    if (schemaOptions.schemaFile() != null) {
+    if (schemaOptions.schemaFile() != null
+        && !Objects.requireNonNull(schemaOptions.schemaFile()).isEmpty()) {

Review Comment:
   why `requireNonNull` when we know it's not `null` by the previous condition?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to