Build a Schema
A Kumo Relational Schema combines table metadata with the relationships used to sample predictive context. Build it after preparing the source data and physical column types.
Build a Schema From DataFrames
Build a schema from the prepared customers, orders, and products DataFrames described in Data Requirements:
Schema.from_data() builds the schema and infers table metadata and relationships. Treat this inference as a starting point. The following pages explain how to inspect and correct the inferred metadata and relationships. from_data() reads every table you give it into client memory.
Override Inference at Build Time
Pass known primary keys and time columns to Schema.from_data() to override inference while building the schema:
Pass relationships=[] to build a schema with no relationships and suppress relationship inference. Pass an explicit list of Relationship objects to declare relationships yourself instead of relying on name-matching inference. Refer to Define Relationships.
Schemas Over Tables That Stay in Place
For tables too large to load into memory, or to avoid reading a whole warehouse table for a small prediction, describe them with Schema.from_source() instead. No table is read in full, but from_source() is not lazy. Building the schema already queries the source for column metadata and a preview of up to 1,000 rows per table (used to infer semantic types). Unless you pass check_keys=False, it also runs a key-uniqueness check that scans each table one time. materialize() is the step that samples the rows an actual prediction needs. The following example describes two Databricks tables with from_source() and materializes a query against them:
Schema.from_source() takes a Source (DatabricksSource, SnowflakeSource, PostgresSource, DuckDBSource, or SQLiteSource) built from that backend’s own connection. Refer to the connector pages under Connect Data Sources for each. tables maps the names your query uses to the names in the source. Leave it out to describe every table the source holds. primary_keys, time_columns, and relationships mean what they mean on from_data(). time_columns={"table": None} says a table has no time column, on either builder.
A schema’s tables all come from one source. A schema cannot mix an in-memory table with a sampled one, or combine two different warehouses. Where tables really do live in two systems, join them at the platform level first (for example, a Databricks catalog that federates Snowflake or PostgreSQL) so one source sees all of them.
check_keys=True is the default for from_source(): each declared or inferred key is checked against every row in the source, one aggregate query per table. Pass check_keys=False to skip that scan when the cost matters and the key is already trusted. A key a database itself enforces, such as a PostgreSQL or DuckDB primary key, skips the scan automatically.
Semantic Models (Metric Views and Semantic Views)
A Databricks metric view or Snowflake semantic view already states its tables, joins, and columns. Convert it like any other source:
Only DatabricksSource and SnowflakeSource offer semantic_model(). Its expressions run as SQL under your own credentials, so by default only pure, deterministic built-in functions are allowed. Pass trust_expressions=True to keep an expression that calls something else, when you trust whoever wrote the model. schema.conversion_notes records what the conversion resolved. Read it, but do not depend on its exact wording.
Next Steps
Continue to Configure Table Metadata to inspect and correct the inferred table metadata.