【问题标题】:Validate SSIS packages for VS_NEEDSNEWMETADATA验证 VS_NEEDSNEWMETADATA 的 SSIS 包
【发布时间】:2016-05-04 17:40:38
【问题描述】:

我想自动检查我部署的包是否存在任何元数据问题,例如列数据长度是否在运行之前从 varchar(20) 增加到 varchar(60)。我在午夜遇到了包裹中的错误,我希望能早日发现它。

[SSISDB].[catalog].[validate_package]catalog.validate_project 我都试过了,但奇怪的是,它们没有似乎发现了这个特定的错误。但是,如果我打开 Visual Studio,错误会立即显示在数据流组件中,而无需运行包。

是否有任何方法可以验证包的元数据更改?

编辑:附加信息。这是一个 Oracle Source 数据库,所以我使用 Attunity Oracle Source Connector。我在数据流任务上将 DelayValidation 设置为 False,在 Source 组件上设置为 ValidateExternalMetadata = True。

【问题讨论】:

  • 点击查看上下文
  • @billinkc 我应该寻找什么具体的东西?我在主帖中添加了一些关于验证设置和源类型的附加信息。

标签: ssis sql-server-2012


【解决方案1】:

如果您右键单击包并选择验证,在幕后,正如您所确定的,SSISDB.catalog.validate_package 过程将被执行。

它执行并记录到 SSISDB.catalog.operation_messages

您要做的是查找 message_type 为 110(警告)或 120(错误)的消息

复制

我创建了下表。

CREATE TABLE dbo.so_37034528
(
    Col1 int
,   Col2 int
,   Col3 varchar(20) 
,   Col4 bigint
);

还有一个简单的 SSIS 包,它选择所有列并路由到行计数组件。

biml 是

<Biml xmlns="http://schemas.varigence.com/biml.xsd">
    <Connections>
        <OleDbConnection Name="tempdb" ConnectionString="Data Source=localhost\dev2014;Initial Catalog=tempdb;Provider=SQLNCLI11.0;Integrated Security=SSPI;"/>
    </Connections>
    <Packages>
        <Package Name="so_37034528">
            <Variables>
                <Variable DataType="Int32" Name="RowCount">0</Variable>
            </Variables>
            <Tasks>
                <Dataflow Name="string">
                    <Transformations>
                        <OleDbSource ConnectionName="tempdb" Name="OLESRC GetData">
                            <DirectInput>SELECT * FROM dbo.so_37034528;</DirectInput>
                        </OleDbSource>
                        <RowCount Name="RC Original Rows" VariableName="User.RowCount" />
                    </Transformations>
                </Dataflow>
            </Tasks>
        </Package>
    </Packages>
</Biml>

我将它部署到我的服务器并运行以下查询

DECLARE @validation_id bigint;
EXECUTE SSISDB.catalog.validate_package
    @package_name = N'so_37034528.dtsx'
,   @validation_id = @validation_id OUTPUT
,   @folder_name = N'so'
,   @project_name = N'so'
,   @use32bitruntime = False
,   @environment_scope = A
,   @reference_id = NULL;

SELECT
    @validation_id;

-- Wait some finite amount of time for validation

WAITFOR DELAY '00:00:20';


SELECT
    D.message_desc
,   OM.message
FROM
    SSISDB.catalog.validations AS V
    INNER JOIN
        SSISDB.catalog.operation_messages AS OM
        ON OM.operation_id = V.validation_id
    INNER JOIN
    (
        VALUES
            (-1,'Unknown')
        ,   (120,'Error')
        ,   (110,'Warning')
        ,   (70,'Information')
        ,   (10,'Pre-validate')
        ,   (20,'Post-validate')
        ,   (30,'Pre-execute')
        ,   (40,'Post-execute')
        ,   (60,'Progress')
        ,   (50,'StatusChange')
        ,   (100,'QueryCancel')
        ,   (130,'TaskFailed')
        ,   (90,'Diagnostic')
        ,   (200,'Custom')
        ,   (140,'DiagnosticEx Whenever an Execute Package task executes a child package, it logs this event. The event message consists of the parameter values passed to child packages.  The value of the message column for DiagnosticEx is XML text.')
        ,   (400,'NonDiagnostic')
        ,   (80,'VariableValueChanged')
    ) D (message_type, message_desc)
    ON D.message_type = OM.message_type
WHERE
    V.validation_id = @validation_id
ORDER BY
    V.validation_id;

我的结果看起来像

Information     The validate operation has started.
Pre-validate    so_37034528:Validation has started.
Pre-validate    string:Validation has started.
Information     string:Information: Validation phase is beginning.
Post-validate   string:Validation is complete.
Post-validate   so_37034528:Validation is complete.
Information     The validate operation has completed.

看到我没有任何警告,我在对表进行更改时重复了这些操作。首先我扩展了一列

ALTER TABLE dbo.so_37034528
ALTER COLUMN Col3 varchar(80);

这导致了警告

Warning     string:Warning: Truncation may occur due to retrieving data from database column "Col3" with a length of 80 to data flow column "Col3" with a length of 20.
Warning     string:Warning: The external columns for OLESRC GetData are out of synchronization with the data source columns. The external column "Col3" needs to be updated.

我重置了我的列长度,这次删除了一个列

ALTER TABLE dbo.so_37034528
ALTER COLUMN Col3 varchar(20);


ALTER TABLE dbo.so_37034528
DROP COLUMN Col4;

现在我有以下输出

Warning    string:Warning: The external columns for OLESRC GetData are out of synchronization with the data source columns. The OLESRC GetData.Outputs[Output].ExternalColumns[Col4] needs to be removed from the external columns.
Error      string:Error: "OLESRC GetData" failed validation and returned validation status "VS_NEEDSNEWMETADATA".
Error      string:Error: One or more component failed validation.
Error      string:Error: There were errors during task validation.

【讨论】:

  • 必须运行,但会以 ~ 结束,如果你有警告/错误,你应该在午夜之前采取行动。根据需要经常投票
  • 最初,我只看到两条信息消息..“验证操作已开始/完成”。但是,将环境范围更改为 D(无)最终给了我上面显示的警告。至于我的场景,这是由于整个包的 DelayValidation 设置为 true 。我只检查了数据流任务的属性。这就是为什么我的验证没有发现这些错误。感谢@billinkc 的全面回答!
  • 补充一下我之前的评论:我们使用项目参数从环境变量中设置连接字符串,这就是我们将 DelayValidation 设置为 true 的原因。
猜你喜欢
  • 1970-01-01
  • 2017-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多