Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Coercion of logical to double #204

Description

@tslumley

In the MonetDBLite backend to dbplyr, both automatic and explicit coercion of logical to double fails. For example, with

library(tidyverse)
library(MonetDBLite)
ms<-src_monetdblite("/tmp")
iris<-copy_to(ms, iris)

The following both fail with an error message Server says 'ParseException:SQLparser:types boolean(1,0) and decimal(18,3) are not equal'

iris %>% mutate(is_setosa=Species=="setosa") %>% summarise(mean(is_setosa)) %>% collect()
iris %>% mutate(is_setosa=as.numeric(Species=="setosa")) %>% summarise(mean(is_setosa)) %>% collect()

Based on https://www.monetdb.org/pipermail/users-list/2013-May/006344.html I tried

iris %>% mutate(is_setosa=as.numeric(as.integer(Species=="setosa"))) %>% summarise(mean(is_setosa)) %>% collect()

which did work. Is it possible to get this work-around into the SQL translator? It doesn't look trivial because you don't want to use as.numeric(as.integer()) on something that's already double precision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions