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.
Basic Usage
Section titled “Basic Usage”To export data to an Iceberg table, you need to:
- Create your data model
- Define a
TablewithIcebergConfig - Use
select().into()to export the data
IcebergConfig
Section titled “IcebergConfig”The IcebergConfig class is used to configure Iceberg table exports. It accepts the following parameters:
from relationalai.semantics.snowflake import IcebergConfig
# Create a custom configurationconfig = IcebergConfig( external_volume="<user_external_volume>" # Optional external volume for storage)
# Or use the default configurationconfig = IcebergConfig.defaultParameters
Section titled “Parameters”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.
IcebergConfig.default
Section titled “IcebergConfig.default”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
Using the default configuration
Section titled “Using the default configuration”# Recommended for most use casestable = Table( "MY_DATABASE.MY_SCHEMA.MY_TABLE", config=IcebergConfig.default # Quick and simple)Using a custom configuration
Section titled “Using a custom configuration”custom_config = IcebergConfig( external_volume="MY_EXTERNAL_VOLUME")
table = Table( "MY_DATABASE.MY_SCHEMA.MY_TABLE", cols=["ID", "NAME"], config=custom_config)Example
Section titled “Example”Here’s a complete example of exporting data to an Iceberg table:
from relationalai.semantics import Model, select, definefrom relationalai.semantics.snowflake import Table, IcebergConfig
# Create a modelm = Model("Persons")Concept, Property = m.Concept, m.Property
# Define a conceptPerson = Concept("Person")Person.id = Property("{Person} has {id:int}")Person.name = Property("{Person} has {name:str}")
# Create an Iceberg table with default configurationPersons = Table( "MY_DATABASE.MY_SCHEMA.PERSONS_TABLE", cols=["ID", "NAME"], config=IcebergConfig.default)
# Define some datadefine( Person.new(id=1, name="Alice"), Person.new(id=2, name="Bob"),)
# Export to Iceberg tableselect( Person.id.alias("ID"), Person.name.alias("NAME"),).into(Persons, update=False)