Example #1
0
        private void EmitAddNewColumn(AstDerivedColumnNode column)
        {
            IDTSOutputColumn100 col = Component.OutputCollection[0].OutputColumnCollection.New();
            col.Name = column.Name;

            col.ErrorRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
            col.TruncationRowDisposition = DTSRowDisposition.RD_FailComponent;

            // TODO: Workaround for AstDesigner bug where IsExplicitlySet isn't working
            col.SetDataTypeProperties(
                GetDataTypeFromString(column.DerivedColumnType),
                column.IsLengthExplicitlySet || column.Length > 0 ? column.Length : 0,
                column.IsPrecisionExplicitlySet || column.Precision > 0 ? column.Precision : 0,
                column.IsScaleExplicitlySet || column.Scale > 0 ? column.Scale : 0,
                column.IsCodepageExplicitlySet || column.Codepage > 0 ? column.Codepage : 0);
            col.ExternalMetadataColumnID = 0;
            col.ErrorOrTruncationOperation = "Computation";

            IDTSVirtualInput100 vi = Component.InputCollection[0].GetVirtualInput();

            IDTSCustomProperty100 propExpression = col.CustomPropertyCollection.New();
            propExpression.Name = "Expression";
            Expression exp = ExpressionHandler.ExpressionCleanerAndInputMapBuilder(column.Expression.Trim(), this, vi, DTSUsageType.UT_READONLY);
            propExpression.Value = exp.ProcessedExpression;
            propExpression.ContainsID = exp.ContainsId;

            IDTSCustomProperty100 propFriendlyExpression = col.CustomPropertyCollection.New();
            propFriendlyExpression.Name = "FriendlyExpression";
            propFriendlyExpression.Value = exp.FriendlyExpression;
            propFriendlyExpression.ExpressionType = DTSCustomPropertyExpressionType.CPET_NOTIFY;
            propFriendlyExpression.ContainsID = exp.ContainsId;
        }
Example #2
0
        public static void ProcessIsNullPatcherTransformations(SymbolTable symbolTable)
        {
            var snapshotSymbolTable = new List<IReferenceableItem>(symbolTable);
            foreach (var astNamedNode in snapshotSymbolTable)
            {
                var nullPatcherNode = astNamedNode as AstIsNullPatcherNode;
                if (nullPatcherNode != null && astNamedNode.FirstThisOrParent<ITemplate>() == null)
                {
                    var astDerivedColumnListNode = new AstDerivedColumnListNode(nullPatcherNode.ParentItem)
                                                       {
                                                           Name = nullPatcherNode.Name,
                                                           ValidateExternalMetadata = nullPatcherNode.ValidateExternalMetadata
                                                       };

                    foreach (AstIsNullPatcherColumnNode patchColumn in nullPatcherNode.Columns)
                    {
                        var column = new AstDerivedColumnNode(astDerivedColumnListNode)
                                         {
                                             Name = patchColumn.Name,
                                             ReplaceExisting = true,
                                             Expression = String.Format(CultureInfo.InvariantCulture, "ISNULL({0}) ? {1} : {0}", patchColumn.Name, patchColumn.DefaultValue),
                                             DerivedColumnType = VulcanEngine.IR.Ast.ColumnType.Object
                                         };
                        astDerivedColumnListNode.Columns.Add(column);
                    }

                    Utility.Replace(nullPatcherNode, new List<AstTransformationNode> { astDerivedColumnListNode });
                }
            }
        }
Example #3
0
        private void EmitReplaceExisting(AstDerivedColumnNode dc)
        {
            IDTSInputColumn100 col = SetInputColumnUsage(0, dc.Name, DTSUsageType.UT_READWRITE, true);
            IDTSVirtualInput100 vi = Component.InputCollection[0].GetVirtualInput();
            Expression expression = ExpressionHandler.ExpressionCleanerAndInputMapBuilder(dc.Expression, this, vi, DTSUsageType.UT_READONLY);

            col.CustomPropertyCollection["Expression"].Value = expression.ProcessedExpression;
            col.CustomPropertyCollection["FriendlyExpression"].Value = expression.FriendlyExpression;
        }