Arithmetic overflow error converting expression to data type int.
@rich-iannone is already working on this.
Since Feb 14, 2024.
- Dominant language
- R
- Stars
- 1k
- Forks
- 59
- Avg merge
- 25m
- Merged PRs (30d)
- 4
Description
Prework
- [ X] Read and agree to the code of conduct and contributing guidelines.
- [ X] If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.