You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now executing pivot_wider gives an error on the bit column.
values_from<- setdiff(colnames(dbf), c("uid", "idx"))
pivot_wider(dbf, id_cols="uid", names_from="idx", values_from=all_of(values_from))
#R> Error in `collect()`:#R> ! Failed to collect lazy table.#R> Caused by error in `<fn>`:#R> ! ODBC failed with error 42000 from [Microsoft][ODBC SQL Server Driver][SQL Server].#R> ✖ Operand data type bit is invalid for max operator.#R> • Statement(s) could not be prepared.#R> • <SQL> 'SELECT TOP 11#R> • "uid",#R> • MAX(IIF("idx" = 1, "num", NULL)) AS "num_1",#R> • MAX(IIF("idx" = 2, "num", NULL)) AS "num_2",#R> • MAX(IIF("idx" = 3, "num", NULL)) AS "num_3",#R> • MAX(IIF("idx" = 1, "bit", NULL)) AS "bit_1",#R> • MAX(IIF("idx" = 2, "bit", NULL)) AS "bit_2",#R> • MAX(IIF("idx" = 3, "bit", NULL)) AS "bit_3"#R> • FROM "temp_test_wide"#R> • GROUP BY "uid"'#R> ℹ From nanodbc/nanodbc.cpp:1783.#R> Run `rlang::last_trace()` to see where the error occurred.
Using show_query shows the source of the problem, the SQL generated looks like
Using
pivot_wider
on atbl
connected to a MSSQL database gives an error, sinceMAX
is not allowed on BIT.Versions
R version 4.4.1
dbplyr_2.5.0
dplyr_1.1.4
DBI_1.2.3
tidyverse_2.0.0
Microsoft SQL Server 2014 (SP3-CU4-GDR) (KB5029185) - 12.0.6449.1 (X64)
Example
so far everything works as expected. We connect to the server and the
tbl
Now executing
pivot_wider
gives an error on the bit column.Using
show_query
shows the source of the problem, the SQL generated looks likebut should be
Looking at you code in
backend-mssql.R
I see you have amssql_bit_int_bit
function forMAX
.However for
pivot_wider
it seams to be missed.Changing the argument
values_fn
toresolves the problem.
Hope this helps.
The text was updated successfully, but these errors were encountered: