FeatureEngineeringClient and R

athos
New Contributor

Hi! I'm trying to find a way to create a feature table from R and reticulate

Is it possible? Currently I'm not been able to make a pyspark dataframe to be passed from R to the create_table() function.

The code I'm trying to make it work follows:

 

 

 

install.packages("reticulate")
library(reticulate)
os <- import("os")
use_python(os$sys$executable)

library(tidyverse)
library(sparklyr)
# Connect to Spark
spark <- spark_connect(method = "databricks")

fs <- import("databricks.feature_engineering")
fe <- fs$FeatureEngineeringClient()

mtcars_id <- mtcars %>% rownames_to_column("car_id")
mtcars_sdf <- sdf_copy_to(spark, mtcars_id, overwrite = TRUE)
mtcars_sdf <- spark_dataframe(mtcars_sdf)

fe$create_table(
    name="databricks_asn.default.mtcars",
    primary_keys=c("car_id"),
    df=mtcars_sdf,
    description="MTCARS do R"
)