ropensci / rdflib

:package: High level wrapper around the redland package for common rdf applications
https://docs.ropensci.org/rdflib
Other
57 stars 9 forks source link

rdf_query should have quiet console option #42

Closed James-G-Hill closed 2 years ago

James-G-Hill commented 2 years ago

When calling rdf_query there is a call to readr::read_csv. Each time this is called there is a redundant output to the console showing the data types of the data in the loaded file (always property, value, source).

There should be an option to turn this off when running rdf_query by passing through a boolean value to the readr::read_csv parameter: show_col_types.

cboettig commented 2 years ago

Thanks and agreed! Arguably col_types should be set explicitly rather than allowing readr to guess? At the time of writing that argument to suppress those messages didn't exist in readr. A PR would be much appreciated!

Note that meanwhile, the user can simply toggle this behavior off as described in readr documentation by setting

options(readr.show_col_types = FALSE)
James-G-Hill commented 2 years ago

Yeah, I'll be happy to submit a PR when I get time; it's not urgent of course. If col_types should be set, you are suggesting the user should be able to pass the readr col_types parameter through to rdf_query and then through to readr?

cboettig commented 2 years ago

Thanks. Yeah, right, ideally the user would need to be able to pass the desired col_types to rdf_query, since of course the return types may depend on the query. So ideally a PR would a col_types argument to rdf_query for that purpose. Also, if col_types is not given by the user, (i.e. the default), then it should either suppress the warning while allowing readr to guess (as in the current behavior), but I think it would be better just to default to character type, since it is possible for queries to result in 'mixed type' responses and string encoding is probably the safest choice to avoid accidental coercion to NAs.

James-G-Hill commented 2 years ago

I think the solution provided is good enough; not sure the col_types is necessary; better to just remove it then add in later if somebody needs it.