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

only list_tabledata if max_pages*page_size > 0 #184

Closed
wants to merge 1 commit into from

Conversation

@ras44
Copy link
Contributor

commented Aug 25, 2017

In the case users want to create a table via query_exec, but don't want to view any of its contents they might set page_size = 0 or max_pages = 0. If max_pages = 0 an error is thrown during list_tabledata(...). With this PR, list_tabledata is only called if the max_pages*page_size > 0.

@@ -48,15 +48,17 @@ query_exec <- function(query, project,
...
)

list_tabledata(

This comment has been minimized.

Copy link
@byapparov

byapparov Mar 4, 2018

Contributor

I think you should fix the list_tabledata function instead.

e.g. assertion inside the function could be changed from:

assert_that(is.numeric(max_pages), length(max_pages) == 1, max_pages >= 1)

to

assert_that(is.numeric(max_pages), length(max_pages) == 1)
if (max_pages < 1) {
  return(data.frame())
}

Better alternative could be to get table schema with correct column names without getting the data.:

assert_that(is.numeric(max_pages), length(max_pages) == 1)
if (max_pages < 1) {
  table_info <- table_info %||% get_table(project, dataset, table)
  rows <- extract_data(NULL, table_info$schema)
  return(rows)
}
@ras44

This comment has been minimized.

Copy link
Contributor Author

commented Mar 5, 2018

@byapparov I added a new commit on a new branch that implements the second option: return table with fieldnames, but no rows.

@byapparov

This comment has been minimized.

Copy link
Contributor

commented Mar 5, 2018

@ras44 sounds good. I guess you can close this PR and create a new on in this case.

@ras44 ras44 closed this Mar 5, 2018

hadley added a commit that referenced this pull request Apr 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.