I have a tbl I pulled from our hive instance:
library(odbc)
library(tidyverse)
library(dbplyr)
con <- dbConnect(odbc::odbc(), "HiveProd")
prosym <- tbl(con, in_schema("my_schema_name", "pros_year_month"))
The table pros_year_month is in the schema my_schema_name. When I glimpse prosym, all the fields are prepended with my_schema_name e.g. my_schema_name.session_id, my_schema_name.country etc etc.
I'd like to remove my_schema_name from the names of the fields. If I was working with a regular df I would just do this:
corrected_names <- str_replace_all(names(prosym), "my_schema_name.", "")
names(prosym) <- corrected_names
However, prosym shows as a list of 2 with names "src" and "ops" so the above doesn't work.
How can I change the names of prosym?
The reason that I'm trying to do this is that I'm applying several dplyr transformations such as filter and mutate before pulling it all in with collect(). Since I need to reference the data frames features to make these transformations, typing my_schema_name.[fieldname]) all the time is looking unsightly