MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / normalizeColumns

Method normalizeColumns

plugins/destination/duckdb/client/migrate.go:31–54  ·  view source on GitHub ↗
(tables schema.Tables)

Source from the content-addressed store, hash-verified

29}
30
31func (*Client) normalizeColumns(tables schema.Tables) schema.Tables {
32 normalized := make(schema.Tables, 0, len(tables))
33 for _, table := range tables {
34 normalizedTable := *table
35 normalizedTable.Columns = make(schema.ColumnList, len(table.Columns))
36 for i := range table.Columns {
37 normalizedColumn := table.Columns[i]
38 if keyListColumn(normalizedColumn) {
39 normalizedColumn.Type = duckDBToArrow("varchar")
40 }
41 // In DuckDB, a PK column must be NOT NULL, so we need to make sure that the schema we're comparing to has the same
42 // constraint.
43 if normalizedColumn.PrimaryKey {
44 normalizedColumn.NotNull = true
45 }
46 // Since multiple schema types can map to the same duckdb type we need to normalize them to avoid false positives when detecting schema changes
47 normalizedColumn.Type = duckDBToArrow(arrowToDuckDB(normalizedColumn.Type))
48 normalizedTable.Columns[i] = normalizedColumn
49 }
50 normalized = append(normalized, &normalizedTable)
51 }
52
53 return normalized
54}
55
56func (c *Client) nonAutoMigratableTables(tables schema.Tables, duckdbTables schema.Tables) map[string][]schema.TableColumnChange {
57 result := make(map[string][]schema.TableColumnChange)

Callers 1

MigrateTablesMethod · 0.95

Calls 3

keyListColumnFunction · 0.85
duckDBToArrowFunction · 0.85
arrowToDuckDBFunction · 0.85

Tested by

no test coverage detected