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

error while using count() function? #120

Closed
tbobin opened this issue Feb 13, 2017 · 2 comments
Closed

error while using count() function? #120

tbobin opened this issue Feb 13, 2017 · 2 comments
Assignees
Labels
Milestone

Comments

@tbobin
Copy link

tbobin commented Feb 13, 2017

I'm getiging an error while trying to use the count() function with the chicago Taxi data set.

If I try

library(RSocrata)

qurl <-  "https://data.cityofchicago.org/resource/wrvz-psew.csv?$select=count(trip_id)&$where=trip_start_timestamp between '2016-04-01T00:00:00' and '2016-04-05T00:00:00'"

df <- read.socrata(url = qurl, app_token = AppToken)

I get the following error message:

getResponse: Error in httr GET: 400  https://data.cityofchicago.org/resource/wrvz-psew.csv?%24select=count%28trip_id%29&%24where=trip_start_timestamp%20between%20%272016-04-01T00%3A00%3A00%27%20and%20%272016-04-05T00%3A00%3A00%27&%24%24app_token=JCVQmBHeUpEHN6j8CJycdJok2&$order=:id
Error in getResponse(validUrl, email, password) : Bad Request (HTTP 400)

if I try following code I get a valid response with status 200:

valid_qurl <- validateUrl(qurl, app_token = AppToken)
httr::GET(valid_qurl)

Any idea?

@PeterAustinMoore
Copy link

PeterAustinMoore commented Feb 13, 2017

It looks like for complex queries the addition of $order=:id code at line 274 of RSocrata.R is causing the error with the query. However, if you add your own $order value it will work, e.g.:

qurl <- "https://data.cityofchicago.org/resource/wrvz-psew.csv?$select=count(trip_id) as count&$where=trip_start_timestamp between '2016-04-01T00:00:00' and '2016-04-05T00:00:00'&$order=count"
df <- read.socrata(url = qurl)

Perhaps just a work around until a better solution can be reached.

@nicklucius
Copy link
Contributor

Thanks @tbobin and @PeterAustinMoore. It looks like this bug is an unintended consequence of fixing #15.

Some queries will cause the :id to be excluded from the result, and in those cases we get this error. I will work on a fix.

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

No branches or pull requests

5 participants