cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

FeatureEngineeringClient and Databricks Connect

antonioferegrin
Visitor
Hello everyone, I want to use Databricks Connect to connect externally to my clusters and run code, and while Databricks connect works without any issue, like this:

 

```
from databricks.sdk.core import Config

 

config = Config(cluster_id="XXXX")
spark = SparkSession.builder.sdkConfig(config).getOrCreate()

 

catalog = "my_test_catalog"
schema = "my_schema"
table = "my_table"

 

spark.sql(f"CREATE CATALOG IF NOT EXISTS {catalog}")
spark.sql(f"USE CATALOG {catalog}")
spark.sql(f"CREATE SCHEMA IF NOT EXISTS {schema}")
spark.sql(f"USE SCHEMA {schema}")
 
```
 
However, I try to use the `FeatureEngineeringClient` to create a table like this:
```
from databricks.feature_engineering import FeatureEngineeringClient
from pyspark.sql.types import StringType, StructField, StructType, TimestampType

 

log_message_schema = StructType(
[
StructField("message", StringType(), True),
StructField("application", StringType(), True),
StructField("request_id", StringType(), False),
StructField("timestamp", TimestampType(), False),
StructField("levelname", StringType(), True),
StructField("data", StringType(), True),
StructField("run_id", StringType(), True),
StructField("model_name", StringType(), True),
]
)

 

feature_engineering_client = FeatureEngineeringClient()

 

feature_engineering_client.create_table(
name=f"{catalog}.{schema}.{table}_offline",
primary_keys=["request_id", "timestamp"],
timestamp_keys=["timestamp"],
schema=log_message_schema,
)
```

 

I get an authentication error:

 

```
Exception: {'error_code': '401', 'message': 'Unauthorized'}
```

 

Do you know why this could be happening?
2 REPLIES 2

VZLA
Databricks Employee
Databricks Employee

TL;DR Sounds like a limitation.

I believe the doc's paragraph (https://docs.databricks.com/en/machine-learning/feature-store/python-api.html#limitations), "implicitly" but not very clearly, implies that a SparkSession with Access to UC and databricks resources is required; in case of DatabricksConnect it seems like it is not passed to the FEClient during initialization, otherwise it should avoid such Authorization errors.

I assume with this exception, you're also also finding a full stacktrace; you can confirm if the above is indeed the problem by inspecting it, and then identify which code line is raising the exception.

saurabh18cs
Contributor II

do you have modify rights on this schema to create a table?

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