dolt icon indicating copy to clipboard operation
dolt copied to clipboard

Diff table duplicate column names

Open max-hoffman opened this issue 2 years ago • 0 comments

The diff table generates commit and date columns with to_ and from_ prefixes, for example to_commit and from_commit. Those generated columns ids are important for filters and project expressions. A table with data commit and date columns (distinct from the diff meta data columns) will produce diff schema columns with the same name, to_commit, from_commit, ...

We need a way for users to differentiate between these unique columns with otherwise identical column names.

Dolt's enginetests have a scripts that observes this behavior:

	{
		Name: "table with commit column should maintain its data in diff",
		SetUpScript: []string{
			"CREATE TABLE t (pk int PRIMARY KEY, commit varchar(20));",
			"CALL DOLT_ADD('.')",
			"CALL dolt_commit('-am', 'creating table t');",
			"INSERT INTO t VALUES (1, 'hi');",
			"CALL dolt_commit('-am', 'insert data');",
		},
		Assertions: []queries.ScriptTestAssertion{
			{
				Query:    "SELECT to_pk, char_length(to_commit), from_pk, char_length(from_commit), diff_type from dolt_diff_t;",
				Expected: []sql.Row{{1, 32, nil, 32, "added"}},
			},
		},
	},

For example, we could use more specific namespace prefixes, a dummy table, or variable injections to differentiate the meta data columns. Non-qualified/namespaced columns would ideally default to the underlying table schema.

max-hoffman avatar Oct 20 '22 21:10 max-hoffman