prestodb / RPresto

DBI-based adapter for Presto for the statistical programming language R.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`is.infinite()` in R is incorrectly translated to `IS_FINITE()` in SQL

jarodmeng opened this issue · comments

I encountered this bug just now and it took me a while to hunt it down to something incredibly simple (yet somehow escaping all the unit tests).

The is.infinite() function in R is translated to IS_FINITE() in Presto and basically creates a completely opposite result (see the minimum reprex below).

library(RPresto)
library(dbplyr)
conn <- DBI::dbConnect(
  RPresto::Presto(),
  schema='test',
  catalog='catalog',
  host='http://localhost',
  port=8000,
  source='RPresto Test',
  user=Sys.getenv('USER')
)
dbplyr::translate_sql(is.infinite(x), con = conn)
#> <SQL> IS_FINITE("x")

Created on 2021-08-12 by the reprex package (v2.0.1)

The bug is actually hardcoded here whereby both is.finite() and is.infinite() are translated to IS_FINITE(). My guess is there was some copy-and-paste mistake.

It should be super easy to fix and I will add unit tests to enhance testing coverage.