简体   繁体   English

Azure数据工厂数据复制源中的查找活动-语法错误

[英]Lookup activity in an Azure Data Factory Data Copy Source - Syntax Error

Working through this https://docs.microsoft.com/en-us/azure/data-factory/tutorial-incremental-copy-portal 通过https://docs.microsoft.com/zh-cn/azure/data-factory/tutorial-incremental-copy-portal进行工作

I've one Lookup activity called GetCurrentWatermarkValue with sqlReaderQuery: 我使用sqlReaderQuery进行了一个名为GetCurrentWatermarkValue的查找活动:

Select WaterMarkValue as CurrentWatermarkValue\nfrom WatermarkTable

I've another activity called GetNewWatermarkValue with sqlReaderQuery: 我使用sqlReaderQuery进行了另一个名为GetNewWatermarkValue的活动:

select max(createdon) as NewWatermarkValue from shipment

I'm then trying to use them both in the source for a Data Copy activity using 然后,我尝试使用以下两种方式在源代码中同时使用它们:

select *
from Shipment
where CreatedOn > '@{activity('GetCurrentWatermarkValue').output.firstRow.CurrentWatermarkValue}' 
and CreatedOn <= '@{activity('GetNewWatermarkValue').output.firstRow.NewWatermarkValue}'

The Preview data button is greyed (but enabled when i remove the where condition) so there is obviouusly something wrong 预览数据按钮为灰色(但是当我删除where条件时启用),因此明显存在错误

After I've set the sink i try to set up the Mapping. 设置接收器后,我尝试设置映射。 Clicking Import schema on the Mapping tab gives: 单击“映射”选项卡上的“导入模式”,将得到:

A database operation failed with the following error: 'Incorrect syntax near 'GetCurrentWatermarkValue'.'. Activity ID:98794aa9-c866-48d6-b9ff-9cb277bac6ed

I thought maybe I should be using the add dynamic content option but that just gives 我想也许我应该使用添加动态内容选项,但这只是给

Query is required

I've read somewhere that the when First Row Only is set on the Lookup activity the text after firstRow. 我在某处阅读了在Lookup活动上设置“仅第一行”时,firstRow之后的文本。 should be [TableName] but that doesn't seem right. 应该是[TableName],但这似乎不正确。

Lookup: 抬头:

{
    "name": "GetCurrentWatermarkValue",
    "type": "Lookup",
    "policy": ...,
    "typeProperties": {
        "source": {
            "type": "AzureSqlSource",
            "sqlReaderQuery": "Select WaterMarkValue as CurrentWatermarkValue\nfrom WatermarkTable"
        },
        "dataset": {
            "referenceName": "WatermarkTable",
            "type": "DatasetReference"
        }
    }
}

Lookup: 抬头:

{
    "name": "GetNewWatermarkValue",
    "type": "Lookup",
    "policy": ...,
    "typeProperties": {
        "source": {
            "type": "AzureSqlSource",
            "sqlReaderQuery": "select max(createdon) as NewWatermarkValue from shipment"
        },
        "dataset": {
            "referenceName": "ShipmentsTable",
            "type": "DatasetReference"
        }
    }
}

Data Copy: 资料复制:

{
    "name": "ArchiveShipments",
    "type": "Copy",
    "dependsOn": [
        {
            "activity": "GetCurrentWatermarkValue",
            "dependencyConditions": [
                "Succeeded"
            ]
        },
        {
            "activity": "GetNewWatermarkValue",
            "dependencyConditions": [
                "Succeeded"
            ]
        }
    ],
    "policy": ...,
    "typeProperties": {
        "source": {
            "type": "AzureSqlSource",
            "sqlReaderQuery": {
                "value": "select *\nfrom Shipment\nwhere CreatedOn > '@{activity('GetCurrentWatermarkValue').output.firstRow.CurrentWatermarkValue}' \nand CreatedOn <= '@{activity('GetNewWatermarkValue').output.firstRow.NewWatermarkValue}'",
                "type": "Expression"
            }
        },
        "sink": {
            "type": "AzureSqlSink"
        },
        "enableStaging": false
    },
    "inputs": [
        {
            "referenceName": "ShipmentsTable",
            "type": "DatasetReference"
        }
    ],
    "outputs": [
        {
            "referenceName": "ShipmentArchiveTable",
            "type": "DatasetReference"
        }
    ]
}

This looks like a syntax issue, try this is the copy activity query: 这看起来像是语法问题,请尝试以下为复制活动查询:

@{CONCAT('select * from Shipment where CreatedOn > ', activity('GetCurrentWatermarkValue').output.firstRow.CurrentWatermarkValue, ' and CreatedOn <= ', activity('GetNewWatermarkValue').output.firstRow.NewWatermarkValue}

Dont use a mapping unless you want to manually set it, if column names are the same, then just click "Clear". 除非要手动设置映射,否则不要使用映射,如果列名相同,则只需单击“清除”。

Hope this helped! 希望这对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 数据工厂 -&gt; 查找、ForEach 和复制活动 - Azure Data Factory -> Lookup , ForEach and copy activity 在Azure数据工厂中将多个源复制到复制活动 - Multiple Source To a copy activity in Azure Data Factory Azure 数据工厂 - 将查找活动输出复制到 blob 中的 json - Azure Data Factory - copy Lookup activity output to json in blob Azure 数据工厂:复制数据活动总是从 REST 或 HTTP 源数据集返回错误 - Azure Data Factory: Copy Data activity always returning error from REST or HTTP source datasets Azure数据工厂复制活动 - Azure Data Factory Copy Activity Azure 数据工厂复制活动动态映射错误:语法错误:arguments 之间缺少逗号 - Azure data factory copy activity dynamic mapping error : Syntax error: Missing comma between arguments 值 2150002867256 的复制活动中的类型转换错误:Azure 数据工厂 - Type Conversion Error in Copy activity for value 2150002867256: Azure data factory 将 JSON 映射到 SQL 的 Azure 数据工厂复制活动错误 - Azure Data Factory Copy Activity error mapping JSON to SQL 计划的切片活动的Azure数据工厂语法 - azure data factory syntax for scheduled slice activity Azure数据工厂复制活动性能调整 - Azure data factory copy activity performance tuning
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM