cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Machine Learning
Dive into the world of machine learning on the Databricks platform. Explore discussions on algorithms, model training, deployment, and more. Connect with ML enthusiasts and experts.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to drop single feature from feature store table

deep_thought
Contributor

I have a feature store table and I would like to change one of the features from IntegerType to FloatType, I can't merge this change as it violates the schema. Is it possible to drop a single feature from the table and add the revised feature?

Currently I am dropping the whole table to solve this.

1 ACCEPTED SOLUTION

Accepted Solutions

artsheiko
Databricks Employee
Databricks Employee

you can use the feature tables API to update your table in a "overwrite" the existing one :

fs.write_table(
  name='recommender_system.customer_features',
  df = customer_features_df,
  mode = 'overwrite'
)

If this don't work for your use-case, each feature store table is represented by a traditional Delta Table under the hood. So, you can do the next :

df.write.option("mergeSchema", "true")
.format("delta")
.mode(mode="overwrite")
.saveAsTable(delta_table_name)

Finally, you can register an existing Delta table as a feature table :

fs.register_table(
  delta_table='recommender.customer_features',
  primary_keys='customer_id',
  description='Customer features'
)

View solution in original post

3 REPLIES 3

artsheiko
Databricks Employee
Databricks Employee

you can use the feature tables API to update your table in a "overwrite" the existing one :

fs.write_table(
  name='recommender_system.customer_features',
  df = customer_features_df,
  mode = 'overwrite'
)

If this don't work for your use-case, each feature store table is represented by a traditional Delta Table under the hood. So, you can do the next :

df.write.option("mergeSchema", "true")
.format("delta")
.mode(mode="overwrite")
.saveAsTable(delta_table_name)

Finally, you can register an existing Delta table as a feature table :

fs.register_table(
  delta_table='recommender.customer_features',
  primary_keys='customer_id',
  description='Customer features'
)

hi @Artem Sheikoโ€‹ as the schema for the column has changed, mode='overwrite' does not work. When I encounter this problem with delta tables I can pass the overwriteSchema=True param to DataFrameWriter.saveAsTable.

It would be great if fs.write_table could take args for mergeSchema & overwriteSchema

Vidula
Honored Contributor

Hi there @_ _โ€‹ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group