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

OID-related error #32

Open
daniel-perry opened this issue Feb 18, 2016 · 1 comment
Open

OID-related error #32

daniel-perry opened this issue Feb 18, 2016 · 1 comment

Comments

@daniel-perry
Copy link

I have the following database:

https://physionet.org/mimic2/demo/

I can run simple queries fine, when I run a more complicated query like this:

querystr = """select bucket, count(*) from (
select months_between(mimic2v26.admissions.admit_dt::timestamp::date, mimic2v26.d_patients.dob::timestamp::date)/12 from mimic2v26.admissions, mimic2v26.d_patients, 
width_bucket(
months_between(mimic2v26.admissions.admit_dt::timestamp::date,
mimic2v26.d_patients.dob::timestamp::date)/12, 
15, 100, 85) 
as bucket 
where mimic2v26.admissions.subject_id = mimic2v26.d_patients.subject_id 
and 
months_between(mimic2v26.admissions.admit_dt::timestamp::date,
mimic2v26.d_patients.dob::timestamp::date)/12 between 15 and 199
) 
as 
bucket 
group by bucket order by bucket;"""

stmt = prepare(conn, querystr)
result = execute(stmt)

I get the following error:

LoadError: MethodError: `convert` has no method matching convert(::Type{PostgreSQL.PostgresType{Name}}, ::Type{PostgreSQL.OID{2249}})
This may have arisen from a call to the constructor PostgreSQL.PostgresType{Name}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  call{T}(::Type{T}, ::Any)
  convert(::Type{PostgreSQL.PostgresType{Name}}, !Matched::Type{PostgreSQL.OID{16}})
  convert(::Type{PostgreSQL.PostgresType{Name}}, !Matched::Type{Bool})
  ...
while loading In[5], in expression starting on line 17

This query works fine in both psql and via psycopg2.

Digging around it appears OID's are a little used feature of PosgreSQL (http://www.postgresql.org/docs/8.4/interactive/runtime-config-compatible.html#GUC-DEFAULT-WITH-OIDS), which might be why PostgreSQL.jl is having trouble converting a result using OID.
But since psycopg2 supports them, I though it was worth opening the issue.

Julia version: Version 0.4.2 (2015-12-06 21:47 UTC)

@iamed2
Copy link
Contributor

iamed2 commented Feb 18, 2016

OID's are actually used all over PostgreSQL for many things; in this case, OIDs are being used for denoting the type of the data, which is a very common use. Basically I have no type conversion defined for PostgreSQL's RECORD type (which is itself just a placeholder for the type of any record). I'm not sure if I even have a good idea of what to do with record types off the top of my head.

Eventually I do need to address all OIDs so these problems stop happening. I have been unable to work on PostgreSQL due to other projects dominating my time, but this will change March 1 and I'll devote most of my time to PostgreSQL again. In the meantime, I'm open to PRs if you have an idea on how to deal with RECORD types.

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

No branches or pull requests

2 participants