rstudio / rstudio/pointblank

Arithmetic overflow error converting expression to data type int.

Open
#516 0 comments 0 reactions 1 assignee View on GitHub

@rich-iannone is already working on this.

Since Feb 14, 2024.

Difficulty: [2] Intermediate Effort: [2] Medium Priority: [3] High Type: ☹︎ Bug
Dominant language
R
Stars
1k
Forks
59
Avg merge
25m
Merged PRs (30d)
4

Description

Prework

Description

When using pointblank::scan_data() on a "tbl_Microsoft SQL Server" I receive the following error:
Arithmetic overflow error converting expression to data type int.

Reproducible example

I don't have a reproducible example readily available as I'm using this in a work setting but can attempt to create one later one if needed.

Expected result

The SQL query created is as follows:

SELECT
AVG("X") AS "mean",
MIN("X") AS "min",
MAX("X") AS "max"
FROM (
SELECT "X"
FROM "table_name"
) "q01"'

This is a common issue I see in Microsoft SQL Server and the simple fix is:

SELECT
AVG(CAST("X" as float)) AS "mean",
MIN(CAST("X" as float)) AS "min",
MAX(CAST("X" as float)) AS "max"
FROM (
SELECT "X"
FROM "table_name"
) "q01"'

The way I did this via dbplyr was

table_name %>% select(X) %>% summarize( mean = mean(X%>% as.numeric()) , min = min(X%>% as.numeric()) , max = max(X%>% as.numeric()) ) %>% show_query() %>% collect()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.