ibis-project / ibis

the portable Python dataframe library
https://ibis-project.org
Apache License 2.0
5.16k stars 591 forks source link

Cast to float in OmniSci #1682

Closed saulshanabrook closed 5 years ago

saulshanabrook commented 5 years ago

For using floor with omnisci, sometimes we need to cast literals to float in omnisci, see https://github.com/omnisci/mapd-core/issues/305#issuecomment-450295257

However I can figure out how to get ibis to produce SQL like CAST(-124.39000000000038 AS FLOAT).

If I use ibis.literal(x_min, 'float32').cast('float64') I get CAST(-124.39000000000038 AS NUMERIC).

And if I use the opposite ibis.literal(x_min, 'float64').cast('float32') I get CAST(-124.39000000000038 AS REAL).

Is it possible to change how OmniSci does the casting?

saulshanabrook commented 5 years ago

cc @xmnlab

xmnlab commented 5 years ago

the problem probably is related to the mapd dtype map:

dtypes = {
        'BIGINT': dt.int64,
        'BOOLEAN': dt.Boolean,
        'BOOL': dt.Boolean,
        'CHAR': dt.string,
        'DATE': dt.date,
        'DECIMAL': dt.float64,
        'DOUBLE': dt.float64,
        'INT': dt.int32,
        'INTEGER': dt.int32,
        'FLOAT': dt.float32,
        'NULL': dt.Null,
        'NUMERIC': dt.float64,
        'REAL': dt.float32,
        'SMALLINT': dt.int16,
        'STR': dt.string,
        'TEXT': dt.string,
        'TIME': dt.time,
        'TIMESTAMP': dt.timestamp,
        'VARCHAR': dt.string,
    }

I will take a look into that.

thanks for reporting that @saulshanabrook !