Beispiel #1
0
        private void CreateIsolationTable(DiscoveredTable toCreate, TableInfo tableInfo)
        {
            var from = tableInfo.Discover(DataAccessContext.DataLoad);

            //create a RAW table schema called TableName_Isolation
            var cloner = new TableInfoCloneOperation(new HICDatabaseConfiguration(toCreate.Database.Server), tableInfo, LoadBubble.Live, _job ?? (IDataLoadEventListener) new ThrowImmediatelyDataLoadEventListener());

            cloner.CloneTable(from.Database, toCreate.Database, from, toCreate.GetRuntimeName(), true, true, true, tableInfo.PreLoadDiscardedColumns);

            if (!toCreate.Exists())
            {
                throw new Exception($"Table '{toCreate}' did not exist after issuing create command");
            }

            //Add the data load run id
            toCreate.AddColumn(SpecialFieldNames.DataLoadRunID, new DatabaseTypeRequest(typeof(int)), false, 10);
        }
Beispiel #2
0
        private void CreateIsolationTable(DiscoveredTable toCreate, TableInfo tableInfo)
        {
            var from = tableInfo.Discover(DataAccessContext.DataLoad);

            //create a RAW table schema called TableName_Isolation
            var cloner = new TableInfoCloneOperation(null, null, LoadBubble.Live);

            cloner.CloneTable(from.Database, toCreate.Database, from, toCreate.GetRuntimeName(), true, true, true, tableInfo.PreLoadDiscardedColumns);

            if (!toCreate.Exists())
            {
                throw new Exception(string.Format("Table '{0}' did not exist after issuing create command", toCreate));
            }

            //Add the data load run id
            toCreate.AddColumn(SpecialFieldNames.DataLoadRunID, new DatabaseTypeRequest(typeof(int)), false, 10);
        }
        public void CreateRAWTablesInDatabase(DiscoveredDatabase rawDb, IDataLoadJob job)
        {
            var namer = job.Configuration.DatabaseNamer;

            foreach (TableInfo tableInfo in job.RegularTablesToLoad)
            {
                var liveTable = tableInfo.Discover(DataAccessContext.DataLoad);

                var rawTableName = namer.GetName(liveTable.GetRuntimeName(), LoadBubble.Raw);

                var rawTable = rawDb.ExpectTable(rawTableName);

                if (rawTable.Exists())
                {
                    rawTable.Drop();
                }

                var discardedColumns = tableInfo.PreLoadDiscardedColumns.Where(c => c.Destination == DiscardedColumnDestination.Dilute).ToArray();

                var clone = new TableInfoCloneOperation(null, null, LoadBubble.Raw);

                clone.CloneTable(liveTable.Database, rawDb, tableInfo.Discover(DataAccessContext.DataLoad), rawTableName, true, true, true, discardedColumns);

                string[] existingColumns = tableInfo.ColumnInfos.Select(c => c.GetRuntimeName(LoadStage.AdjustRaw)).ToArray();

                foreach (PreLoadDiscardedColumn preLoadDiscardedColumn in tableInfo.PreLoadDiscardedColumns)
                {
                    //this column does not get dropped so will be in live TableInfo
                    if (preLoadDiscardedColumn.Destination == DiscardedColumnDestination.Dilute)
                    {
                        continue;
                    }

                    if (existingColumns.Any(e => e.Equals(preLoadDiscardedColumn.GetRuntimeName(LoadStage.AdjustRaw))))
                    {
                        throw new Exception("There is a column called " + preLoadDiscardedColumn.GetRuntimeName(LoadStage.AdjustRaw) + " as both a PreLoadDiscardedColumn and in the TableInfo (live table), you should either drop the column from the live table or remove it as a PreLoadDiscarded column");
                    }

                    //add all the preload discarded columns because they could be routed to ANO store or sent to oblivion
                    AddColumnToTable(rawTable, preLoadDiscardedColumn.RuntimeColumnName, preLoadDiscardedColumn.SqlDataType, job);
                }

                _rawTables.Add(rawTable);
            }
        }
Beispiel #4
0
        public void Test_CloneTable()
        {
            var dt = new DataTable();

            dt.Columns.Add("FF");

            var db  = GetCleanedServer(FAnsi.DatabaseType.MicrosoftSQLServer);
            var tbl = db.CreateTable("MyTable", dt);

            Import(tbl, out var ti, out _);

            var config = new HICDatabaseConfiguration(tbl.Database.Server);

            //create a RAW table schema called TableName_Isolation
            var cloner = new TableInfoCloneOperation(config, (TableInfo)ti, LoadBubble.Live, new ThrowImmediatelyDataLoadEventListener());

            cloner.CloneTable(tbl.Database, tbl.Database, tbl, tbl.GetRuntimeName() + "_copy", true, true, true, ti.PreLoadDiscardedColumns);

            var tbl2 = tbl.Database.ExpectTable(tbl.GetRuntimeName() + "_copy");

            Assert.IsTrue(tbl2.Exists());
        }