private List <Col> GetColumns(string sourceDB, string sourceTableName, string schema, string originalTableName) { //get actual field list on the source table var includeColumns = new List <string>() { "SYS_CHANGE_VERSION", "SYS_CHANGE_OPERATION" }; var columns = sourceDataUtils.GetFieldList(sourceDB, sourceTableName, schema, originalTableName, includeColumns); //get the table config object var table = Config.TableByName(originalTableName); var cols = new List <Col>(); bool isPrimaryKey; foreach (TColumn col in columns) { isPrimaryKey = false; if (table.columns.Count > 0) { // NOTE: it is important that table.columns is populated. Problem occurs if not. // Because Vertica needs Primary Key information for the columns try { isPrimaryKey = table.columns.Where(c => (c.name != "SYS_CHANGE_VERSION" && c.name != "SYS_CHANGE_OPERATION")).First(c => c.name == col.name).isPk; } catch (Exception e) { logger.Log("Cannot determine whether column [" + col.name + "] is PK", LogLevel.Warn); isPrimaryKey = false; } } ColumnModifier mod = table.getColumnModifier(col.name); string verticaTypeName = destDataUtils.MapColumnTypeName(SqlFlavor.MSSQL, col.dataType, mod); cols.Add(new Col(VerticaDataUtils.MapReservedWord(col.name), verticaTypeName, col.dataType, isPrimaryKey)); } return(cols); }
public MSSQLToVerticaDataCopy(MSSQLDataUtils sourceDataUtils, VerticaDataUtils destDataUtils, Logger logger) { this.sourceDataUtils = sourceDataUtils; this.destDataUtils = destDataUtils; this.logger = logger; }