Skip to content

Double quote array expansion to prevent splitting#69

Merged
haogang merged 7 commits intounitycatalog:mainfrom
abrassel:double_quote_array_expansion
Jul 24, 2024
Merged

Double quote array expansion to prevent splitting#69
haogang merged 7 commits intounitycatalog:mainfrom
abrassel:double_quote_array_expansion

Conversation

@abrassel
Copy link
Contributor

@abrassel abrassel commented Jun 19, 2024

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

https://github.com/koalaman/shellcheck/wiki/SC2068

Double quotes around $@ (and similarly, ${array[@]}) prevents globbing and word splitting of individual elements, while still expanding to multiple separate arguments.

Testing Changes

bin/uc
Please provide a entity.

Usage: bin/uc <entity> <operation> [options]
Entities: schema, volume, catalog, function, table

By default, the client will connect to UC running locally at http://localhost:8080

To connect to specific UC server, use --server https://<host>

Currently, auth using bearer token is supported. Please specify the token via --auth_token <PAT Token>

For detailed help on entity specific operations, use bin/uc <entity> --help
~/unitycatalog git:[double_quote_array_expansion]
bin/uc schema --help
Please provide a valid sub-command for schema.
Valid sub-commands for schema are: get, create, update, list, delete
For detailed help on schema sub-commands, use bin/uc schema <sub-command> --help
~/unitycatalog git:[double_quote_array_expansion]
bin/uc schema get --help
Usage: bin/uc schema get [options]
Required Params:
  --full_name The full name of the table. The full name is the concatenation of the catalog name, schema name, and table/volume name separated by a dot. For example, catalog_name.schema_name.table_name.
Optional Params:
~/unitycatalog git:[double_quote_array_expansion]
bin/uc schema list
All required parameters are not provided.
Usage: bin/uc schema list [options]
Required Params:
  --catalog The name of the catalog.
Optional Params:
  --max_results The maximum number of results to return.
~/unitycatalog git:[double_quote_array_expansion]
bin/uc catelog list
Invalid entity provided.

Usage: bin/uc <entity> <operation> [options]
Entities: schema, volume, catalog, function, table

By default, the client will connect to UC running locally at http://localhost:8080

To connect to specific UC server, use --server https://<host>

Currently, auth using bearer token is supported. Please specify the token via --auth_token <PAT Token>

For detailed help on entity specific operations, use bin/uc <entity> --help
~/unitycatalog git:[double_quote_array_expansion]
bin/uc catalog list
...
bin/start-uc-server 44
Jul 07, 2024 10:47:24 PM com.fasterxml.jackson.databind.PropertyNamingStrategy$PropertyNamingStrategyBase <init>
WARNING: PropertyNamingStrategy.KebabCaseStrategy is used but it has been deprecated due to risk of deadlock. Consider using PropertyNamingStrategies.KebabCaseStrategy instead. See https://github.com/FasterXML/jackson-databind/issues/2715 for more details.
################################################################### 
#  _    _       _ _            _____      _        _              #
# | |  | |     (_) |          / ____|    | |      | |             #
# | |  | |_ __  _| |_ _   _  | |     __ _| |_ __ _| | ___   __ _  #
# | |  | | '_ \| | __| | | | | |    / _` | __/ _` | |/ _ \ / _` | #
# | |__| | | | | | |_| |_| | | |___| (_| | || (_| | | (_) | (_| | #
#  \____/|_| |_|_|\__|\__, |  \_____\__,_|\__\__,_|_|\___/ \__, | #
#                      __/ |                                __/ | #
#                     |___/              vv0.1.0-SNAPSHOT  |___/  #
###################################################################

#68 

@tdas
Copy link
Contributor

tdas commented Jun 20, 2024

@ravivj-db can you review this since you added this code?

@tdas
Copy link
Contributor

tdas commented Jun 28, 2024

@abrassel @ravivj-db are these changes still needed or relevant?

@abrassel
Copy link
Contributor Author

These are lint fixes. Not super important but intellij will complain about them.

@abrassel abrassel requested review from creechy, ravivj-db and tdas July 8, 2024 05:50
@abrassel
Copy link
Contributor Author

abrassel commented Jul 8, 2024

@creechy - I made the changes. Let me know if you want additional testing!

@abrassel
Copy link
Contributor Author

abrassel commented Jul 8, 2024

Hm, looks like tests failed. Will investigate

@abrassel
Copy link
Contributor Author

abrassel commented Jul 8, 2024

@creechy heads up - when I run the Tarball Generation Tests on master, I'm also getting a failure.

@creechy
Copy link
Collaborator

creechy commented Jul 9, 2024

@abrassel

@creechy heads up - when I run the Tarball Generation Tests on master, I'm also getting a failure.

yeah I also get the error on main too, I'll take a closer look.

@creechy
Copy link
Collaborator

creechy commented Jul 9, 2024

@abrassel

@creechy heads up - when I run the Tarball Generation Tests on master, I'm also getting a failure.

I think you have discovered a latent bug in the tarball test. Creating a catalog with a space in it, like Test Catalog is forbidden. I think the current test is somehow breaking that into two parameters Test Catalog, and the uc client is silently ignoring the extra parameter. Can you change the test code to create the catalog Test_Catalog (change the space to underscore) and see if that resolves the issue?

@abrassel
Copy link
Contributor Author

abrassel commented Jul 10, 2024

@abrassel

@creechy heads up - when I run the Tarball Generation Tests on master, I'm also getting a failure.

I think you have discovered a latent bug in the tarball test. Creating a catalog with a space in it, like Test Catalog is forbidden. I think the current test is somehow breaking that into two parameters Test Catalog, and the uc client is silently ignoring the extra parameter. Can you change the test code to create the catalog Test_Catalog (change the space to underscore) and see if that resolves the issue?

I'll give this a try.

Update: Gave it a try and it doesn't quite work. We have some command line arguments for which spaces are valid. I.e.

bin/uc table create --full_name unity.default.myTable --columns "col1 int, col2 double" --storage_location /tmp/uc/myTable

In this case "$@" doesn't properly treat the spaces for col1 int, col2 double.

# 5. Run and verify CLI
try:
cli_cmd = [os.path.join(bin_dir, "uc"), "catalog", "create", "--name", "Test Catalog"]
cli_cmd = [os.path.join(bin_dir, "uc"), "catalog", "create", "--name", "Test_Catalog"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should change this test case. Are commands args with spaces not working?

Copy link
Collaborator

@creechy creechy Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UC does not allow objects with spaces in their name, so the test with the space in the name should be failing, and now is failing with @abrassel 's double quote changes, which is why I asked him to change this test. I don't know why this test is currently successful before this PR but I believe it should be failing.

bin/uc Outdated
# echo "Quoted arguments: $quoted_args_str"
# echo "Running command: $CLI_JAVA_COMMAND"
eval $CLI_JAVA_COMMAND $@ || exit
eval "$CLI_JAVA_COMMAND" "$@" || exit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abrassel I took a look at why the tutorial tests are failing, I think it's due to this line. Not sure why the eval was used in the first place but I think if you remove it and make the line $CLI_JAVA_COMMAND "$@" || exit that should fix things. Can you give it a try? There might be a way to make the eval work but this now makes sense why all the args are being wrapped in quotes before being passed here.

Copy link
Collaborator

@vikrantpuppala vikrantpuppala Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to also fix #263

@vikrantpuppala
Copy link
Collaborator

@abrassel could we please make any changes needed to this PR? (please feel free to close if this isn't an issue anymore)

@abrassel
Copy link
Contributor Author

hi @vikrantpuppala , been a bit distracted with some other work lately; I apologize for the delay. Taking a look now

@abrassel abrassel force-pushed the double_quote_array_expansion branch from f29e173 to b35ee87 Compare July 23, 2024 17:50
@abrassel
Copy link
Contributor Author

@vikrantpuppala @creechy i think we are good to go.

Copy link
Collaborator

@creechy creechy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@creechy creechy requested a review from haogang July 23, 2024 20:23
@creechy
Copy link
Collaborator

creechy commented Jul 23, 2024

@haogang this is ready to merge.

@haogang haogang merged commit e4e20da into unitycatalog:main Jul 24, 2024
@abrassel abrassel deleted the double_quote_array_expansion branch July 24, 2024 17:35
dennyglee pushed a commit that referenced this pull request Sep 2, 2024
tdas pushed a commit that referenced this pull request Sep 5, 2024
rtyler pushed a commit to rtyler/unitycatalog that referenced this pull request Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants