Learn R Programming

RPresto (version 1.2.1)

dbDataType,PrestoDriver-method: Return the corresponding presto data type for the given R object

Description

Return the corresponding presto data type for the given R object

Usage

# S4 method for PrestoDriver
dbDataType(dbObj, obj, ...)

Arguments

dbObj

A '>PrestoDriver object

obj

Any R object

...

Extra optional parameters, not currently used

Value

A character value corresponding to the Presto type for obj

Details

The default value for unknown classes is ‘VARCHAR’.

‘ARRAY’s and ‘MAP’s are supported with some caveats. Unnamed lists will be treated as ‘ARRAY’s and named lists will be a ‘MAP’. All items are expected to be of the same corresponding Presto type, otherwise the default ‘VARCHAR’ value is returned. The key type for ‘MAP’s is always ‘VARCHAR’. The ‘value’ type for empty lists is always a ‘VARCHAR’.

Examples

Run this code
# NOT RUN {
drv <- RPresto::Presto()
dbDataType(drv, list())
dbDataType(drv, 1)
dbDataType(drv, NULL)
dbDataType(drv, list(list(list(a=Sys.Date()))))
dbDataType(drv, as.POSIXct('2015-03-01 00:00:00', tz='UTC'))
dbDataType(drv, Sys.time())
# Data types for ARRAY or MAP values can be tricky
all.equal('VARCHAR', dbDataType(drv, list(1, 2, 3L)))
# }

Run the code above in your browser using DataLab