DyfanJones / noctua

Connect R to Athena using paws SDK (DBI Interface)
https://dyfanjones.github.io/noctua/
Other
45 stars 5 forks source link

Float/real type cannot be read #133

Closed OssiLehtinen closed 3 years ago

OssiLehtinen commented 3 years ago

Hi Dyfan,

it appears that noctua doesn't know how to interpret a query result with the type 'real'.

For example:

res <- DBI::dbSendStatement(cona, "create table temp.realexample as (select cast(1 as real) as realcol)")
# Wait until table is created
dplyr::tbl(cona, dbplyr::in_schema("temp", "realexample"))

produces the error: "Error: Unknown shortcut: real"

Should AthenaToRDataType-function have mapping for 'real' included (instead of 'float')?

https://github.com/DyfanJones/noctua/blob/3b9d5d5494e425b8ff4673a2f18f0efdc1d6b484/R/DataTypes.R#L23 https://github.com/DyfanJones/noctua/blob/3b9d5d5494e425b8ff4673a2f18f0efdc1d6b484/R/DataTypes.R#L47

DyfanJones commented 3 years ago

Hi @OssiLehtinen,

You are quiet right, this is an oversight. As I didn't realise that Athena only uses float in DDL but real in SQL functions like select cast (https://docs.aws.amazon.com/athena/latest/ug/data-types.html).

DyfanJones commented 3 years ago

When float has been create in the tables ddl what does that column data type return as: float or real?

I could always just add real to the switch function to make sure noctua covers all bases :)

DyfanJones commented 3 years ago

@OssiLehtinen is there any other Data types that are missing? I am not a 100% sure if binary, map, array and struct can be simply added without some extra thinking it through.

Potentially cast them as strings for the file readrs and then parse them using jsonlite 🤔

OssiLehtinen commented 3 years ago

When float has been create in the tables ddl what does that column data type return as: float or real?

I could always just add real to the switch function to make sure noctua covers all bases :)

I'm afk atm but I think it returns real. Will have to check, but probably only tomorrow.

OssiLehtinen commented 3 years ago

@OssiLehtinen is there any other Data types that are missing? I am not a 100% sure if binary, map, array and struct can be simply added without some extra thinking it through.

Potentially cast them as strings for the file readrs and then parse them using jsonlite 🤔

Didn't bump into issues with other baisc types.

Arrays etc definitely don't work so I have been avoiding them. An interesting idea to read them in as strings and parse afterwards!

DyfanJones commented 3 years ago

I will raise another ticket around the array data type, as I might not be able to get it working :P