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

Cannot authorize view in same project but different dataset #21

Open
pathatcher opened this issue Jul 14, 2021 · 4 comments
Open

Cannot authorize view in same project but different dataset #21

pathatcher opened this issue Jul 14, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@pathatcher
Copy link

Name: bigquery-view-analyzer
Version: 20.4.1

Good afternoon. We cannot seem to authorize views that reside in the same project and different datasets. Our users have access to a dataset containing views but do not have direct access to the dataset with the tables. If the dataset is in a different project we are able to authorize without issue.
Thank you

examples

[doesn't work]
bqva tree --view "mtech-daas-transact-pdata-uat:rfnd_sls_v.ebr_ros_arsfmstr_xxpezt_nc_xros115_extract_v"

displays

◉ = Project ◉ = Table
◉ = Dataset ◉ = View

mtech-daas-transact-pdata-uat:rfnd_sls_v.ebr_ros_arsfmstr_xxpezt_nc_xros115_extract_v

[works]

bqva tree --view "mtech-daas-appdata:cubpmvp.date_dim_v"
◉ = Project ◉ = Table
◉ = Dataset ◉ = View

mtech-daas-appdata:cubpmvp.date_dim_v
└── mtech-daas-appdata:ewpmvp.date_dim_v
└── mtech-daas-reference-pdata:trst_ref.DATE_DIM

@pathatcher
Copy link
Author

Figured out the actual issue. BQ queries no longer requires the ticks around the project.dataset.table when creating views. The current code is looking for the ticks as a valid table and when it is not found the view is not authorized.

--works
create or replace view project.dataset.viewName as
select * from project.dataset.tableName;

bqva authorize --view project.dataset.viewName

--does not works
create or replace view project.dataset.viewName_noTick as
select * from project.dataset.tableName;

bqva authorize --view project.dataset.viewName_noTick

The issue is in the STANDARD_SQL_TABLE_PATTERN:

STANDARD_SQL_TABLE_PATTERN = \ r"(?:(?:FROM|JOIN)\s+?)?(?P[-\w]+?)?\.?(?P[\w]+?)?\.?(?P

[\w]+)?(?!\()\b"

STANDARD_SQL_TABLE_PATTERN_NOTICK = \ r"(?:(?:FROM|JOIN)\s+?)?(?P<project>[-\w]+?)?.?(?P<dataset>[\w]+?)?.?(?P<table>[\w]+)?(?!\()\b"

christippett added a commit that referenced this issue Aug 2, 2021
fix: Update table regex (fixes #20 #21)
@christippett christippett added the enhancement New feature or request label Aug 5, 2021
@christippett
Copy link
Contributor

Hi @pathatcher, thanks for raising this. I've updated the regex pattern used when parsing objects from a view definition to account for the latest BigQuery syntax. I've released a new version on PyPI, if and when you get a chance please give it a try and let me know if it resolves the issue you were having.

@christippett
Copy link
Contributor

@TWinsnes + @polleyg

@pathatcher
Copy link
Author

Hi @pathatcher, thanks for raising this. I've updated the regex pattern used when parsing objects from a view definition to account for the latest BigQuery syntax. I've released a new version on PyPI, if and when you get a chance please give it a try and let me know if it resolves the issue you were having.

Shoot! So sorry for the super late response. It worked. Again sorry about my slow response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants