RussellSpitzer commented on code in PR #199:
URL: https://github.com/apache/polaris/pull/199#discussion_r1733953732


##########
regtests/run_spark_sql.sh:
##########
@@ -36,37 +44,65 @@ fi
 
 
SPARK_BEARER_TOKEN="${REGTEST_ROOT_BEARER_TOKEN:-principal:root;realm:default-realm}"
 
-# Use local filesystem by default
-curl -X POST -H "Authorization: Bearer ${SPARK_BEARER_TOKEN}" -H 'Accept: 
application/json' -H 'Content-Type: application/json' \
-  http://${POLARIS_HOST:-localhost}:8181/api/management/v1/catalogs \
-  -d '{
-        "catalog": {
-          "name": "manual_spark",
-          "type": "INTERNAL",
-          "readOnly": false,
-          "properties": {
-            "default-base-location": "file:///tmp/polaris/"
-          },
-          "storageConfigInfo": {
-            "storageType": "FILE",
-            "allowedLocations": [
-              "file:///tmp"
-            ]
-          }
-        }
-      }'
+# use local filesystem if no arguments are provided
+if [ -z "$1" ]; then
+  # create a catalog backed by the local filesystem
+  curl -X POST -H "Authorization: Bearer ${SPARK_BEARER_TOKEN}" \
+       -H 'Accept: application/json' \
+       -H 'Content-Type: application/json' \
+       http://${POLARIS_HOST:-localhost}:8181/api/management/v1/catalogs \
+       -d '{
+             "catalog": {
+               "name": "manual_spark",
+               "type": "INTERNAL",
+               "readOnly": false,
+               "properties": {
+                 "default-base-location": "file:///tmp/polaris/"
+               },
+               "storageConfigInfo": {
+                 "storageType": "FILE",
+                 "allowedLocations": [
+                   "file:///tmp"
+                 ]
+               }
+             }
+           }'
+else
+  AWS_BASE_LOCATION=$1
+  AWS_ROLE_ARN=$2
+  # Check if AWS variables are set
+  if [ -z "${AWS_BASE_LOCATION}" ] || [ -z "${AWS_ROLE_ARN}" ]; then
+    echo "AWS_BASE_LOCATION or/and AWS_ROLE_ARN not set. Please set them to 
create a catalog backed by S3."

Review Comment:
   This is still a bit confusing because these things are not "set" they are 
passed through. So I think it would better if we just check the number of args 
passed to the command. Then you can just say expected 2 or 0 args and got 1 or 
3 or whatever. 
   
   ```sh
   if [ $# -eq 2 ]; then
       echo "run_spark_sql.sh only accepts 0 or 2 arguments"
       echo $USAGE
       exit 1
   fi
   ```
   
   Feel free to ignore copying the USAGE through if you like but that would be 
another nice feature.



-- 
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