代码之家  ›  专栏  ›  技术社区  ›  Patterson

如何在Azure数据工厂复制活动中参数化查询

  •  0
  • Patterson  · 技术社区  · 11 月前

    我在ADF复制活动中有以下疑问

    SELECT
      deltaTable.*
    FROM Data.deltaTable
    LEFT OUTER JOIN Data.targetTable
      ON deltaTable.signature = targetTable.signature
    WHERE targetTable.signature IS NULL
    

    有人能告诉我如何参数化查询吗。当我尝试参数化查询时,我得到了错误:

    Parameter schema was not found under EX_SourceToRaw_Single_Table
    

    以下代码是我的尝试:

    @concat('SELECT * FROM ',pipeline().parameters.schema,'.',pipeline().parameters.DeltaTable)
    LEFT OUTER JOIN pipeline().parameters.schema,'.',pipeline().parameters.TargetTable)
      ON pipeline().parameters.DeltaTable).signature = pipeline().parameters.TargetTable).signature
    WHERE pipeline().parameters.TargetTable).signature IS NULL
    

    deltaTable和TargetTable看起来都像下面这样:

    ==========================================================================================================
    |    CountryName     |    CountryISO2     |    CountryISO3     |    SalesRegion     |     signature      |
    ==========================================================================================================
    |      Belgium       |     CHA            |     10             |        EMEA        |800e559a27d68f0478b6|
    |                    |                    |                    |                    |1c4c9f009e2418e86697|
    |                    |                    |                    |                    |1b6e54b549b51b1367ab|
    |                    |                    |                    |                    |        450d        |
    ----------------------------------------------------------------------------------------------------------
    |       Wales        |     steveO         |     WAL            |       Welsh        |e8c5149d54986dfe9ac9|
    |                    |                    |                    |                    |5a60a76b07603fe17c28|
    |                    |                    |                    |                    |2b552ec8255f123b279a|
    |                    |                    |                    |                    |        533a        |
    ----------------------------------------------------------------------------------------------------------
    |      Germany       |     DE             |     deletedupd     |        EMEA        |1232b1bd91d14a87ed83|
    |                    |                    |                    |                    |0f770d74cd8cabb87153|
    |                    |                    |                    |                    |5c4c2b7ff5bcb873fa80|
    |                    |                    |                    |                    |        d851        |
    ----------------------------------------------------------------------------------------------------------
    |       Italy        |     IT             |     ITA            |        EMEA        |584cf66de2f4af9eb4db|
    |                    |                    |                    |                    |febefea808b1b4e6a357|
    |                    |                    |                    |                    |87fcac1061de88cfb798|
    |                    |                    |                    |                    |        56df        |
    ----------------------------------------------------------------------------------------------------------
    
    1 回复  |  直到 11 月前
        1
  •  1
  •   Rakesh Govindula    11 月前

    创建后 schema , DeltaTable , TargetTable ADF管道中的参数,在复制活动的查询选项中使用以下表达式。在这里,对于示例,我使用了查找活动查询选项,其工作原理与复制活动查询选项相同。

    @concat('SELECT ',pipeline().parameters.DeltaTable,'.* FROM ',pipeline().parameters.schema,'.',pipeline().parameters.DeltaTable,' LEFT OUTER JOIN ',pipeline().parameters.schema,'.',pipeline().parameters.TargetTable,' ON ',pipeline().parameters.DeltaTable,'.signature = ',pipeline().parameters.TargetTable,'.signature WHERE ',pipeline().parameters.TargetTable,'.signature IS NULL')
    

    打开查询中的动态内容,给出如下表达式。

    enter image description here

    要检查生成的查询,您可以转到 管道运行 -> 活动运行 -> 输入 在这里,它将显示根据上述表达式生成的查询。您可以看到它生成了所需的查询。

    enter image description here

    如果您遇到任何错误,可以在此处交叉检查生成的查询,并可以根据您的要求进行修改。