Documentation
¶
Index ¶
- func ParseDateTime(value interface{}) (*time.Time, error)
- type AlterStatementGenerator
- type BooleanStatistics
- type Column
- type ColumnDifference
- type ColumnStatistics
- type CommonDataType
- type DatabaseDialect
- type DatabaseTypeMapper
- func (m *DatabaseTypeMapper) AddBinaryTypes(types ...string)
- func (m *DatabaseTypeMapper) AddBooleanTypes(types ...string)
- func (m *DatabaseTypeMapper) AddDateTimeTypes(types ...string)
- func (m *DatabaseTypeMapper) AddJSONTypes(types ...string)
- func (m *DatabaseTypeMapper) AddNumericTypes(types ...string)
- func (m *DatabaseTypeMapper) AddStringTypes(types ...string)
- func (m *DatabaseTypeMapper) IsBoolean(databaseType string) bool
- func (m *DatabaseTypeMapper) IsDateTime(databaseType string) bool
- func (m *DatabaseTypeMapper) IsNumeric(databaseType string) bool
- func (m *DatabaseTypeMapper) IsString(databaseType string) bool
- func (m *DatabaseTypeMapper) MapType(databaseType string) CommonDataType
- type DateTimeStatistics
- type JSONStatistics
- type MissingColumn
- type NullabilityDifference
- type NumericalStatistics
- type SchemaComparisonResult
- type StringStatistics
- type Table
- type TableSummarizer
- type TableSummaryResult
- type Type
- type TypeDifference
- type TypeMapping
- type UniquenessDifference
- type UnknownStatistics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseDateTime ¶ added in v0.11.245
ParseDateTime converts various datetime representations to time.Time. This is a shared utility function used across all database implementations.
Types ¶
type AlterStatementGenerator ¶ added in v0.11.359
type AlterStatementGenerator struct {
// contains filtered or unexported fields
}
AlterStatementGenerator generates ALTER TABLE statements based on schema comparison results.
func NewAlterStatementGenerator ¶ added in v0.11.359
func NewAlterStatementGenerator(dialect DatabaseDialect, reverse bool) *AlterStatementGenerator
NewAlterStatementGenerator creates a new ALTER statement generator with the specified dialect.
func (*AlterStatementGenerator) GenerateAlterStatements ¶ added in v0.11.359
func (g *AlterStatementGenerator) GenerateAlterStatements(result *SchemaComparisonResult) []string
GenerateAlterStatements generates ALTER TABLE SQL statements to transform one table to match another. By default (reverse=false), it generates statements to transform Table2 to match Table1. If reverse=true, it generates statements to transform Table1 to match Table2.
type BooleanStatistics ¶
func (*BooleanStatistics) Type ¶
func (bs *BooleanStatistics) Type() string
type Column ¶
type Column struct {
Name string
Type string // Original database-specific type (e.g., "INTEGER", "VARCHAR(255)")
NormalizedType CommonDataType // Normalized common type (e.g., "numeric", "string")
Nullable bool
PrimaryKey bool
Unique bool
Stats ColumnStatistics
}
type ColumnDifference ¶
type ColumnDifference struct {
ColumnName string
TypeDifference *TypeDifference
NullabilityDifference *NullabilityDifference
UniquenessDifference *UniquenessDifference
}
ColumnDifference represents differences for a column that exists in both tables.
type ColumnStatistics ¶
type ColumnStatistics interface {
Type() string
}
ColumnStatistics is an interface for different types of column statistics.
type CommonDataType ¶
type CommonDataType string
CommonDataType represents the normalized data type categories.
const ( CommonTypeNumeric CommonDataType = "numeric" CommonTypeString CommonDataType = "string" CommonTypeBoolean CommonDataType = "boolean" CommonTypeDateTime CommonDataType = "datetime" CommonTypeBinary CommonDataType = "binary" CommonTypeJSON CommonDataType = "json" CommonTypeUnknown CommonDataType = "unknown" )
type DatabaseDialect ¶ added in v0.11.359
type DatabaseDialect string
DatabaseDialect represents the SQL dialect for generating ALTER TABLE statements.
const ( DialectPostgreSQL DatabaseDialect = "postgresql" DialectSnowflake DatabaseDialect = "snowflake" DialectBigQuery DatabaseDialect = "bigquery" DialectDuckDB DatabaseDialect = "duckdb" DialectGeneric DatabaseDialect = "generic" )
func DetectDialectFromConnection ¶ added in v0.11.359
func DetectDialectFromConnection(conn1Type, conn2Type string) DatabaseDialect
DetectDialectFromConnection detects the database dialect from connection type names.
type DatabaseTypeMapper ¶
type DatabaseTypeMapper struct {
// contains filtered or unexported fields
}
DatabaseTypeMapper provides a base implementation for type mapping.
func NewBigQueryTypeMapper ¶
func NewBigQueryTypeMapper() *DatabaseTypeMapper
NewBigQueryTypeMapper provides BigQuery-specific type mapping.
func NewDatabaseTypeMapper ¶
func NewDatabaseTypeMapper() *DatabaseTypeMapper
func NewDuckDBTypeMapper ¶
func NewDuckDBTypeMapper() *DatabaseTypeMapper
NewDuckDBTypeMapper provides DuckDB-specific type mapping.
func NewPostgresTypeMapper ¶ added in v0.11.226
func NewPostgresTypeMapper() *DatabaseTypeMapper
NewPostgresTypeMapper provides PostgreSQL-specific type mapping.
func NewSnowflakeTypeMapper ¶ added in v0.11.226
func NewSnowflakeTypeMapper() *DatabaseTypeMapper
NewSnowflakeTypeMapper provides Snowflake-specific type mapping.
func (*DatabaseTypeMapper) AddBinaryTypes ¶
func (m *DatabaseTypeMapper) AddBinaryTypes(types ...string)
func (*DatabaseTypeMapper) AddBooleanTypes ¶
func (m *DatabaseTypeMapper) AddBooleanTypes(types ...string)
func (*DatabaseTypeMapper) AddDateTimeTypes ¶
func (m *DatabaseTypeMapper) AddDateTimeTypes(types ...string)
func (*DatabaseTypeMapper) AddJSONTypes ¶
func (m *DatabaseTypeMapper) AddJSONTypes(types ...string)
func (*DatabaseTypeMapper) AddNumericTypes ¶
func (m *DatabaseTypeMapper) AddNumericTypes(types ...string)
func (*DatabaseTypeMapper) AddStringTypes ¶
func (m *DatabaseTypeMapper) AddStringTypes(types ...string)
func (*DatabaseTypeMapper) IsBoolean ¶
func (m *DatabaseTypeMapper) IsBoolean(databaseType string) bool
func (*DatabaseTypeMapper) IsDateTime ¶
func (m *DatabaseTypeMapper) IsDateTime(databaseType string) bool
func (*DatabaseTypeMapper) IsNumeric ¶
func (m *DatabaseTypeMapper) IsNumeric(databaseType string) bool
func (*DatabaseTypeMapper) IsString ¶
func (m *DatabaseTypeMapper) IsString(databaseType string) bool
func (*DatabaseTypeMapper) MapType ¶
func (m *DatabaseTypeMapper) MapType(databaseType string) CommonDataType
type DateTimeStatistics ¶
type DateTimeStatistics struct {
EarliestDate *time.Time // Earliest datetime value or nil
LatestDate *time.Time // Latest datetime value or nil
Count int64
NullCount int64
UniqueCount int64
}
func (*DateTimeStatistics) Type ¶
func (dts *DateTimeStatistics) Type() string
type JSONStatistics ¶
func (*JSONStatistics) Type ¶
func (js *JSONStatistics) Type() string
type MissingColumn ¶
type MissingColumn struct {
ColumnName string
Type string
Nullable bool
PrimaryKey bool
Unique bool
TableName string // The table where this column exists
MissingFrom string // The table where this column is missing
}
MissingColumn represents a column that exists in only one table.
type NullabilityDifference ¶
NullabilityDifference represents a difference in nullability between two tables.
type NumericalStatistics ¶
type NumericalStatistics struct {
Min *float64 // pointer to handle NULL values
Max *float64
Avg *float64
Sum *float64
Count int64
NullCount int64
StdDev *float64
}
NumericalStatistics holds statistics for numerical columns.
func (*NumericalStatistics) Type ¶
func (ns *NumericalStatistics) Type() string
type SchemaComparisonResult ¶
type SchemaComparisonResult struct {
Table1 *TableSummaryResult
Table2 *TableSummaryResult
SamePropertiesCount int // Columns with identical properties in both tables
DifferentPropertiesCount int // Columns present in both tables but with different properties
InTable1OnlyCount int // Columns present in table1 but not in table2
InTable2OnlyCount int // Columns present in table2 but not in table1
ColumnDifferences []ColumnDifference // Structured differences for columns present in both tables
MissingColumns []MissingColumn // Columns missing from one of the tables
HasSchemaDifferences bool // True if DifferentPropertiesCount, InTable1OnlyCount, or InTable2OnlyCount > 0
RowCountDiff int64 // Difference in row count between the two tables
HasRowCountDifference bool // True if RowCountDiff != 0
}
SchemaComparisonResult holds the detailed results of a table schema comparison.
func CompareTableSchemas ¶
func CompareTableSchemas(summary1, summary2 *TableSummaryResult, t1Name, t2Name string) SchemaComparisonResult
func (*SchemaComparisonResult) GetSummaryTable ¶
func (c *SchemaComparisonResult) GetSummaryTable() string
type StringStatistics ¶
type StringStatistics struct {
DistinctCount int64
MaxLength int
MinLength int
AvgLength float64
Count int64
NullCount int64
EmptyCount int64
MostCommon map[string]int64 // value -> frequency
TopNDistinct []string // top N most common values
}
StringStatistics holds statistics for string/text columns.
func (*StringStatistics) Type ¶
func (ss *StringStatistics) Type() string
type TableSummarizer ¶
type TableSummarizer interface {
GetTableSummary(ctx context.Context, tableName string, schemaOnly bool) (*TableSummaryResult, error)
}
TableSummarizer defines an interface for connections that can provide a summary of a table.
type TableSummaryResult ¶
type TypeDifference ¶
type TypeDifference struct {
Table1Type string
Table2Type string
Table1NormalizedType CommonDataType
Table2NormalizedType CommonDataType
IsComparable bool // True if normalized types are the same (e.g., both numeric)
}
TypeDifference represents a difference in column types between two tables.
type TypeMapping ¶
type TypeMapping interface {
MapType(databaseType string) CommonDataType
IsNumeric(databaseType string) bool
IsString(databaseType string) bool
IsBoolean(databaseType string) bool
IsDateTime(databaseType string) bool
}
TypeMapping defines the interface for mapping database-specific types to common types.
type UniquenessDifference ¶
UniquenessDifference represents a difference in uniqueness constraints between two tables.
type UnknownStatistics ¶
type UnknownStatistics struct{}
func (*UnknownStatistics) Type ¶
func (us *UnknownStatistics) Type() string