Documentation
¶
Overview ¶
Package schema computes schema diffs between two sources and decides which columns are comparable for the row diff.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Comparable ¶
Comparable reports whether two logical types can be meaningfully compared value-by-value. Identical types always can; int64 and float64 are compared numerically; date and timestamp are not conflated.
Types ¶
type Diff ¶
type Diff struct {
AddedColumns []string `json:"added_columns"` // in right only
RemovedColumns []string `json:"removed_columns"` // in left only
TypeChanges []TypeChange `json:"type_changes"`
Nullability []NullabilityChange `json:"nullability_changes"`
// Renames lists the right-side columns compared under a left-side name
// (--rename). They are Common columns, not an added/removed pair, and
// deliberately do not make the schemas differ, since the caller declared
// them equivalent, but they are always reported.
Renames []Rename `json:"renames,omitempty"`
// Common lists columns present in both schemas whose values can be
// compared (identical or numerically coercible logical types), in
// left-schema order.
Common []string `json:"-"`
}
Diff is the full schema comparison result.
type NullabilityChange ¶
type NullabilityChange struct {
Column string `json:"column"`
LeftNullable bool `json:"left_nullable"`
RightNullable bool `json:"right_nullable"`
}
NullabilityChange describes a column whose nullability differs.
type Rename ¶
type Rename struct {
Left string `json:"left"` // the name the column is compared under
Right string `json:"right"` // the right input's own name for it
}
Rename records a right-side column that was compared under a left-side name (--rename). Renamed pairs are ordinary Common columns, so they are not reported as an added/removed pair. Either way they are reported.
func ApplyRenames ¶
ApplyRenames returns a copy of right with columns renamed to their left-side names, plus the renames actually applied. m is keyed by the right-side name; a rename to a name the left does not have, or that collides with another right-side column, is an error rather than a silently unmatched column.
type TypeChange ¶
type TypeChange struct {
Column string `json:"column"`
LeftType source.Type `json:"-"`
RightType source.Type `json:"-"`
Left string `json:"left"` // logical (physical) rendering
Right string `json:"right"` // logical (physical) rendering
Comparable bool `json:"comparable"`
}
TypeChange describes one column present in both schemas with different logical types.