diff --git a/TabularEditor/UIServices/TableMetadata.cs b/TabularEditor/UIServices/TableMetadata.cs index 09419e89..b75699ac 100644 --- a/TabularEditor/UIServices/TableMetadata.cs +++ b/TabularEditor/UIServices/TableMetadata.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; using TabularEditor.TOMWrapper; using TabularEditor.UI.Dialogs; @@ -116,6 +117,7 @@ public static List CheckPartitionsIdentical(Table table) { return null; } + var ignoredColumns = new HashSet(); var sourceSchema = new Dictionary(StringComparer.InvariantCultureIgnoreCase); foreach (DataRow row in schemaTable.Rows) { @@ -125,8 +127,20 @@ public static List CheckPartitionsIdentical(Table table) row["DataTypeName"].ToString() : (row["DataType"] as Type).Name; var mappedType = DataTypeMap(dataType); + if (sourceSchema.ContainsKey(colName)) + { + ignoredColumns.Add(colName); + } + else + sourceSchema.Add(colName, new DataTypeMapping(dataType, mappedType)); + } - sourceSchema.Add(colName, new DataTypeMapping(dataType, mappedType)); + if(ignoredColumns.Count > 0) + { + var plural = ignoredColumns.Count > 1 ? "s" : ""; + var columns = string.Join("", ignoredColumns.Select(c => "\r\n\t" + c).ToArray()); + var partitionInfo = partition.Table.Partitions.Count > 1 ? $", partition \"{partition.Name}\"" : ""; + MessageBox.Show($"The query on table '{partition.Table.Name}'{partitionInfo} specified the following column{plural} more than once:\r\n{columns}", "Repeated columns", MessageBoxButtons.OK, MessageBoxIcon.Information); } return sourceSchema;