schemacompare

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TableKey

func TableKey(schema, table string) string

TableKey is the "schema.table" key used in the per-side schema maps.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the OneLake Table API (Unity Catalog / Delta protocol).

func NewClient

func NewClient(token string) *Client

func NewClientWithBase

func NewClientWithBase(token, baseURL string) *Client

func (*Client) GetTable

func (c *Client) GetTable(wsID, lhID, schema, table string) ([]ColumnSchema, error)

func (*Client) ListSchemas

func (c *Client) ListSchemas(wsID, lhID string) ([]string, error)

func (*Client) ListTables

func (c *Client) ListTables(wsID, lhID, schema string) ([]string, error)

type ColumnChange

type ColumnChange struct {
	Name    string
	Kind    ColumnChangeKind
	OldType string // target side
	NewType string // source side
}

type ColumnChangeKind

type ColumnChangeKind int
const (
	ColAdded ColumnChangeKind = iota
	ColRemoved
	ColTypeChanged
)

type ColumnSchema

type ColumnSchema struct {
	Name     string
	Type     string
	Nullable bool
	Position int
}

ColumnSchema is one column's name, formatted type, nullability and ordinal.

type Fetcher

type Fetcher struct {
	// contains filtered or unexported fields
}

Fetcher loads table/column schemas from the OneLake Table API. A single Fetcher carries ONE shared concurrency budget, so concurrent Fetch calls (e.g. the source and target lakehouse sides running at once) stay within one total in-flight limit rather than each opening its own pool and stacking the load on OneLake. Within a Fetch, ListTables runs concurrently across schemas and GetTable runs concurrently across tables — both drawing from that budget.

func NewFetcher

func NewFetcher(api OneLakeTableAPI, concurrency int) *Fetcher

NewFetcher returns a Fetcher whose total in-flight API calls are capped at concurrency (minimum 1).

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(wsID, lhID string, schemas []string) (map[string]TableSchema, error)

Fetch returns every table's column schema for the given schemas of one lakehouse, keyed by TableKey. Returns the first error encountered.

type LakehouseDiff

type LakehouseDiff struct {
	Lakehouse string
	Schemas   []string
	Tables    []TableDiff
	Matching  int
}

LakehouseDiff is one lakehouse's full comparison result. The caller fills Lakehouse and Schemas; Compare produces Tables and Matching.

type OneLakeTableAPI

type OneLakeTableAPI interface {
	ListSchemas(wsID, lhID string) ([]string, error)
	ListTables(wsID, lhID, schema string) ([]string, error)
	GetTable(wsID, lhID, schema, table string) ([]ColumnSchema, error)
}

OneLakeTableAPI is the read-only metadata surface schemacompare needs.

type TableChangeKind

type TableChangeKind int
const (
	TableNew     TableChangeKind = iota // only in source
	TableRemoved                        // only in target
	TableChanged                        // exists both, columns differ
)

type TableDiff

type TableDiff struct {
	Schema  string
	Table   string
	Kind    TableChangeKind
	Columns []ColumnChange // populated when Kind == TableChanged
}

func Compare

func Compare(source, target map[string]TableSchema) (tables []TableDiff, matching int)

Compare diffs two side maps keyed by TableKey. source is the promotion origin (+), target the destination (-). Returns differing tables (sorted by key) and the count of fully-matching tables.

type TableSchema

type TableSchema struct {
	Schema  string
	Table   string
	Columns map[string]ColumnSchema
}

TableSchema is one table's columns keyed by column name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL