Explore the SDK using Google Colab or check all templates.
How to use Nekt SDK
- Generate a token with access to the appropriate resources (tables, volumes, secrets). This is the safest way to secure your resources outside Nekt environment.
- Install the SDK (already included in our templates):
- Using the SDK
Nekt SDK methods
Find all functions available listed here:Initialize the SDK (required)
Initialize the SDK (required)
Load table
Load table
Load a table from your lakehouse as a Spark DataFrame using the Returns: Spark DataFrameExample:We recommend using type hinting to make this explicit:
.load_table() method.Parameters:layer_name(str): The name of the layer where the table is locatedtable_name(str): The name of the table you want to load
Layer and table names must use the same capitalization as you use on your Catalog.
Save table
Save table
Save a Spark DataFrame as a table in your lakehouse using the Returns: bool (success status)Example:Example without folder:
.save_table() method.Parameters:df(DataFrame): The Spark DataFrame to savelayer_name(str): The name of the layer where the table will be savedtable_name(str): The name of the table to createfolder_name(str, optional): The folder name within the layer. If not provided, the table will be saved in the root of the layer
Layer, table and folder names must use the same capitalization as you use on your Catalog.
.save_table() currently only supports overwrite mode, so your table will always have only data written by the last call of this method.Get Spark session
Get Spark session
Access the shared Spark session instance using the
.get_spark_session() method. This is useful when you need direct access to Spark operations, like creating a new dataframe with custom schema or data.Returns: SparkSession objectExample:Load volume
Load volume
Load a volume from your lakehouse using the Returns: List[Dict[str, str]] containing file paths in the volumeExample:
.load_volume() method. Volumes allow you to store and access unstructured data files.Parameters:layer_name(str): The name of the layer where the volume is locatedvolume_name(str): The name of the volume you want to load
Layer and volume names must use the same capitalization as you use on your Catalog.
Load secret
Load secret
Load a secret value from your organization’s secrets vault using the Returns: str (the secret value)Example:
.load_secret() method. Secrets are useful for storing sensitive information like API keys and credentials.Parameters:key(str): The secret key to retrieve
Key name must use the same capitalization as you use on your Catalog.
Make sure your token has permission to access the secret you’re trying to load.
Load Delta table (advanced)
Load Delta table (advanced)
Load a Delta table from your lakehouse using the Returns: DeltaTable objectExample:
.load_delta_table() method.All data stored on your lakehouse is saved on delta format, and you can leverage it if needed (delta tables provide ACID transactions and time travel capabilities).Parameters:layer_name(str): The name of the layer where the Delta table is locatedtable_name(str): The name of the Delta table you want to load
Layer and table names must use the same capitalization as you use on your Catalog.