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

feat(gcp_storage_object): add prefix filter to storage object list #475

Merged

Conversation

villers
Copy link
Contributor

@villers villers commented Aug 2, 2023

add prefix filter to storage object list

Integration test logs

Logs
select
    name
from
    gcp_storage_object
where
    bucket = 'cdn-signature' and
    prefix = 'prefix'

Example query results

Results
prefix/items1.txt
prefix/items2.txt

@villers villers changed the title feat: add prefix filter to storage object list feat(gcp_storage_object): add prefix filter to storage object list Aug 2, 2023
Hydrate: listStorageObjects,
KeyColumns: []*plugin.KeyColumn{
{Name: "bucket", Require: plugin.Required, CacheMatch: "exact"},
{Name: "prefix", Require: plugin.Optional},

Choose a reason for hiding this comment

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

❓ question : Why you need prefix in key column ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "prefix" in the key columns is added as an optional parameter, meaning it's not required for the function to operate, but if it's provided, it can be used to narrow down the returned results based on the prefix of the object keys in the Google Cloud Storage bucket.

As for the "prefix" field in the table definition, it's a pseudo-column. This means it doesn't actually exist in the Google Cloud Storage Object data, but it is used to provide an additional filter (the prefix in this case) when querying the table. The transform.FromQual("prefix") is used to take the value from the query qualifier and add it to the request. This way, it's possible to write a query like select * from gcp_storage_object where prefix = 'your-prefix', and the results would be only the objects that have keys starting with 'your-prefix'.

@rajlearner17
Copy link

@villers Thanks for this PR. Adding an example for this using a prefix column will be suitable for the user. Thank you!

@villers
Copy link
Contributor Author

villers commented Aug 3, 2023

@villers Thanks for this PR. Adding an example for this using a prefix column will be suitable for the user. Thank you!

it's done

@villers villers force-pushed the feat/add-prefix-to-storage-object-list branch from daa8a2c to 6b70e2c Compare August 3, 2023 08:36
@rajlearner17 rajlearner17 requested review from misraved and removed request for jplanckeel August 3, 2023 11:40
@cbruno10 cbruno10 merged commit c84b76f into turbot:main Aug 3, 2023
1 check passed
@cbruno10
Copy link
Contributor

cbruno10 commented Aug 3, 2023

@villers Thanks so much for the contribution!

@villers villers deleted the feat/add-prefix-to-storage-object-list branch August 3, 2023 18:29
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.

None yet

6 participants