Skip to content

Add control over digits and jsonlite options in uploading data#664

Merged
hadley merged 14 commits intor-dbi:mainfrom
r2evans:fix/320-digits
Feb 25, 2026
Merged

Add control over digits and jsonlite options in uploading data#664
hadley merged 14 commits intor-dbi:mainfrom
r2evans:fix/320-digits

Conversation

@r2evans
Copy link
Copy Markdown
Contributor

@r2evans r2evans commented Jan 9, 2026

Two methods to control digits in uploaded data:

  • options(bigrquery.jsonlite.toJSON=list(digits=NA)) passes that arg (and any others in the named list) to jsonlite::stream_out and ::toJSON; and

  • options(bigrquery.digits=22), a simpler way to pass only digits to the same functions.

Includes NEWS, code, and unit-tests.

@r2evans r2evans changed the title fix #320, add control over digits in uploaded data Add control over digits and jsonlite options in uploading data Jan 10, 2026
@r2evans r2evans mentioned this pull request Jan 11, 2026
Comment thread R/bq-field.R Outdated
@hadley
Copy link
Copy Markdown
Member

hadley commented Feb 16, 2026

I've refocussed this on just data, since I think it's unlikely to affect fields (and if params really are necessary, we should tackle in a different way). Does this still solve your motivating problem?

@r2evans
Copy link
Copy Markdown
Contributor Author

r2evans commented Feb 17, 2026

This is producing an error:

bigrquery::bq_table_upload(ds, data.frame(p=pi), json_digits=NA)
# Error in parent.frame(n + 1) : 
#   promise already under evaluation: recursive default argument reference or earlier problems?

Debugging it shows it is happening in check_digits():

bigrquery:::check_digits(2)
# [1] 2
bigrquery:::check_digits(NULL)
# [1] 22
bigrquery:::check_digits(NA)
# Error in parent.frame(n + 1) : 
#   promise already under evaluation: recursive default argument reference or earlier problems?

I think it's because the formal is check_digits(..., call=caller_env(call)). Looking more at utils.R it looks like many functions define with function(..., call=caller_env()) but both check_quiet and check_digits use caller_env(call), a circular reference. (I can confirm that check_quiet(NULL) also errors in this way.)

@hadley
Copy link
Copy Markdown
Member

hadley commented Feb 17, 2026

Sorry, the default is now NULL (per https://design.tidyverse.org/defaults-short-and-sweet.html), and it looks like you accidentally copied the bad pattern from check_quiet(), which I've now fixed.

@r2evans
Copy link
Copy Markdown
Contributor Author

r2evans commented Feb 17, 2026

Yes, I probably introduced that in my other PR :-(

@hadley
Copy link
Copy Markdown
Member

hadley commented Feb 25, 2026

Just wanted to see if you've had a chance to look at this yet? I'd love to get a bigrquery release out soon.

@r2evans
Copy link
Copy Markdown
Contributor Author

r2evans commented Feb 25, 2026

Just wanted to see if you've had a chance to look at this yet? I'd love to get a bigrquery release out soon.

Yes, I think it's ready afaict. Thanks @hadley !

@hadley hadley merged commit cf62af4 into r-dbi:main Feb 25, 2026
14 checks passed
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.

2 participants