control encoding of character variables with RMariaDB

Viewed 81

I am performing SQL joins using md5 hashed IDs as keys.

library(dplyr)

# dbt_x already has a field called enc_id that has an md5 hashed id
dbt_x <- 
  dplyr::tbl(db_connection, db_tablename_x) 

dbt_y <- 
  dplyr::tbl(db_connection, db_tablename_y) %>% 
  dplyr::mutate(enc_id = MD5(id)) 

ds_progress <- 
  dplyr::left_join(dbt_x, dbt_y, by = "enc_id", `copy` = TRUE)

My failed join produces the errot message:

Error in result_create(conn@ptr, statement, is_statement) : Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '=' [1267]

Using RMySQL, how can I control the encoding of the dbt_y variable I have created called enc_id?

If this were a dataframe I could just use

dbt_y$enc_id <- enc2utf8(dbt_y$enc_id)

Is there a similar function in RMariaDB?

0 Answers
Related