Skip to main content
RafaelDiaz
Silver ⭐️
November 11, 2021
Solved

SET Location in dbwrite table in r

I am using Rstudio and I need to save some tables in my sandbox, however I cannot specify the location, because by default we send the tables to the path: hdfs: //haprod/warehouse/tablespace/managed/hive/cld_ml_bi_eng.db/iris How can I specify the location when writing the table is in the LOCATION '/sandbox/CLD_ML_BI_ENG/iris'

 

library(DBI)
library(odbc)
con_Hive <- dbConnect(odbc::odbc(), "Hive_produccion", database = "cld_ml_bi_eng", encoding = "latin1")
colnames(iris) <- gsub(pattern = "\\.", replacement = "_", x = colnames(iris))
dbWriteTable(conn = con_Hive, name = Id(schema = "cld_ml_bi_eng", table = "iris"), value = iris)

LOCATION '/sandbox/CLD_ML_BI_ENG/iris'

 

asish
asishAnswer
Gold ⭐️⭐️⭐️
November 12, 2021

AFAIK the table location should be set at the time of Creation.

 

You can set files in a different location.

 

You can use ALTER TABLE jsont1 SET LOCATION "hdfs://mycluster:8020/jsam/j1"; to change the location and need to move the files manually from old location to new location.

1 reply

asish
Gold ⭐️⭐️⭐️
asishAnswer
Gold ⭐️⭐️⭐️
November 12, 2021

AFAIK the table location should be set at the time of Creation.

 

You can set files in a different location.

 

You can use ALTER TABLE jsont1 SET LOCATION "hdfs://mycluster:8020/jsam/j1"; to change the location and need to move the files manually from old location to new location.

Translate