Ejemplo n.º 1
0
Archivo: Union.cs Proyecto: japj/vulcan
        public Union(LoweringContext context, AstNode astNode)
            : base(context, astNode as AstTransformationNode)
        {
            _astUnionAllNode = astNode as AstUnionAllNode;

            if (_astUnionAllNode != null)
            {
                int i = 0;
                foreach (AstDataflowMappedInputPathNode ip in _astUnionAllNode.InputPaths)
                {
                    BindingList.Add(new MappedBinding(_astUnionAllNode.Name, ip.OutputPath.Transformation.Name, ip.OutputPath.SsisName, i, ip.Mappings));
                    i++;
                }
            }
        }
Ejemplo n.º 2
0
        private static AstUnionAllNode CreateUnionAllNode(AstLateArrivingLookupNode lookup, AstLookupNode codegenLookup, AstOleDBCommandNode insertPlaceholder)
        {
            var unionAll = new AstUnionAllNode(lookup.ParentItem) { Name = String.Format(CultureInfo.InvariantCulture, "__LALookupUnionAll_{0}", lookup.Name) };
            unionAll.InputPaths.Add(new AstDataflowMappedInputPathNode(unionAll) { OutputPath = codegenLookup.MatchPath });
            unionAll.InputPaths.Add(new AstDataflowMappedInputPathNode(unionAll) { OutputPath = insertPlaceholder.OutputPath });

            foreach (var outgoingPath in lookup.OutputPath.References)
            {
                if (outgoingPath.ReferencingItem != null && outgoingPath.PropertyName != null)
                {
                    PropertyInfo propertyInfo = outgoingPath.GetType().GetProperty(outgoingPath.PropertyName);
                    if (propertyInfo != null)
                    {
                        propertyInfo.SetValue(outgoingPath.ReferencingItem, unionAll.OutputPath, null);
                    }
                }
            }

            return unionAll;
        }
Ejemplo n.º 3
0
        private static List<AstTransformationNode> CreateScdWorkflowFragment(AstTableNode targetTable, IFrameworkItem parentItem, AstDataflowOutputPathNode outputPath)
        {
            var workflowFragment = new List<AstTransformationNode>();

            AstTableColumnBaseNode lateArrivingStatusColumn = targetTable.Columns.FirstOrDefault(item => item.Name == "_IsLate");

            var scd = new AstSlowlyChangingDimensionNode(parentItem);
            scd.Name = Utility.NameCleanerAndUniqifier(targetTable.Name + "_scd");
            scd.Connection = targetTable.Connection;
            scd.CurrentRowWhere = "[_scdFrom] IS NOT NULL AND [_scdFrom] IS NULL";
            scd.EnableInferredMember = targetTable.LateArriving;
            scd.FailOnFixedAttributeChange = true;
            scd.FailOnLookupFailure = false;
            scd.IncomingRowChangeType = 1;
            scd.InferredMemberIndicator = lateArrivingStatusColumn;

            // TODO:
            foreach (var column in targetTable.Columns)
            {
                if (column.IsAssignable && !column.IsAutoGenerated)
                {
                    ScdColumnMappingType mappingType;
                    switch (column.ScdType)
                    {
                        case ScdType.Error: 
                            mappingType = ScdColumnMappingType.FixedAttribute; 
                            break;
                        case ScdType.Historical: 
                            mappingType = ScdColumnMappingType.HistoricalAttribute; 
                            break;
                        case ScdType.Key:
                            mappingType = ScdColumnMappingType.Key;
                            break;
                        case ScdType.Other:
                            mappingType = ScdColumnMappingType.Other;
                            break;
                        case ScdType.Update:
                            mappingType = ScdColumnMappingType.ChangingAttribute;
                            break;
                        default:
                            mappingType = ScdColumnMappingType.Other; 
                            break;
                    }

                    scd.Mappings.Add(new AstScdTypeColumnMappingNode(scd) { MappingType = mappingType, QueryColumnName = column.Name });
                }
            }

            scd.Query = TableLowerer.EmitSelectAllStatement(targetTable);
            if (outputPath != null)
            {
                scd.InputPath = new AstDataflowMappedInputPathNode(scd) { OutputPath = outputPath };
            }

            workflowFragment.Add(scd);

            // Late Arriving Path
            if (targetTable.LateArriving)
            {
                BuildLateArrivingPath(targetTable, parentItem, workflowFragment, scd.InferredMemberPath);
            }

            // Change Path
            BuildChangePath(targetTable, parentItem, workflowFragment, scd.ChangingAttributePath);

            // Historical Path
            var historicalOutput = BuildHistoricalSubpath(targetTable, parentItem, workflowFragment, scd.HistoricalAttributePath);
            
            // Union Historical and New Paths
            var insertUnionAll = new AstUnionAllNode(parentItem) { Name = Utility.NameCleanerAndUniqifier(targetTable.Name + "_InsertUnionAll") };
            insertUnionAll.InputPaths.Add(new AstDataflowMappedInputPathNode(insertUnionAll) { OutputPath = scd.NewPath });
            insertUnionAll.InputPaths.Add(new AstDataflowMappedInputPathNode(insertUnionAll) { OutputPath = historicalOutput });
            workflowFragment.Add(insertUnionAll);

            // Insert Path
            BuildInsertPath(targetTable, parentItem, workflowFragment, insertUnionAll.OutputPath);

            return workflowFragment;
        }