Skip to content

Exporting to Snowflake-Managed Iceberg Tables

RelationalAI supports exporting query results directly to Snowflake-managed Iceberg tables. This feature allows you to persist computed results from your RelationalAI models into Iceberg tables that are fully managed by Snowflake.

To export data to an Iceberg table, you need to:

  1. Create your data model
  2. Define a Table with IcebergConfig
  3. Use select().into() to export the data

The IcebergConfig class is used to configure Iceberg table exports. It accepts the following parameters:

from relationalai.semantics.snowflake import IcebergConfig
# Create a custom configuration
config = IcebergConfig(
external_volume="<user_external_volume>" # Optional external volume for storage
)
# Or use the default configuration
config = IcebergConfig.default
  • external_volume (str | None): Optional external volume for storing Iceberg table data. If not specified, defaults to the external volume for the schema, database, or account.

A predefined instance that uses standard settings suitable for most use cases. This default configuration uses:

  • external_volume=None - Uses Snowflake’s default storage location
# Recommended for most use cases
table = Table(
"MY_DATABASE.MY_SCHEMA.MY_TABLE",
config=IcebergConfig.default # Quick and simple
)
custom_config = IcebergConfig(
external_volume="MY_EXTERNAL_VOLUME"
)
table = Table(
"MY_DATABASE.MY_SCHEMA.MY_TABLE",
cols=["ID", "NAME"],
config=custom_config
)

Here’s a complete example of exporting data to an Iceberg table:

from relationalai.semantics import Model, select, define
from relationalai.semantics.snowflake import Table, IcebergConfig
# Create a model
m = Model("Persons")
Concept, Property = m.Concept, m.Property
# Define a concept
Person = Concept("Person")
Person.id = Property("{Person} has {id:int}")
Person.name = Property("{Person} has {name:str}")
# Create an Iceberg table with default configuration
Persons = Table(
"MY_DATABASE.MY_SCHEMA.PERSONS_TABLE",
cols=["ID", "NAME"],
config=IcebergConfig.default
)
# Define some data
define(
Person.new(id=1, name="Alice"),
Person.new(id=2, name="Bob"),
)
# Export to Iceberg table
select(
Person.id.alias("ID"),
Person.name.alias("NAME"),
).into(Persons, update=False)