简体   繁体   English

在 ADF 中将 DateTime 列转换为字符串

[英]converting a DateTime column to string in ADF

I am trying to build a fully parametrised pipeline template in ADF.我正在尝试在 ADF 中构建一个完全参数化的管道模板。 With the work I have done so far, I can do a full load without any issues but when it comes to delta load, it seems like my queries are not working.通过我目前所做的工作,我可以毫无问题地完成全部负载,但是当涉及到增量负载时,我的查询似乎不起作用。 I believe the reason for this is that my "where" statement looks somewhat like this:我相信这样做的原因是我的“where”语句看起来有点像这样:

SELECT @{item().source_columns} FROM @{item().source_schema}.@{item().source_table} 
WHERE @{item().source_watermarkcolumn} > @{item().max_watermarkcolumn_loaded} AND @{item().source_watermarkcolumn} <= @{activity('Watermarkvalue').output.firstRow.max_watermarkcolumn_loaded}

where the 'max_watermarkcolumn_loaded' is a datetime format and the 'activity' output is obviously a string format.其中“max_watermarkcolumn_loaded”是日期时间格式,“活动”output 显然是字符串格式。

Please correct me if my assumption is wrong and let me know what I can do to fix.如果我的假设是错误的,请纠正我,让我知道我可以做些什么来解决。

EDIT: screenshot of the error编辑:错误截图在此处输入图像描述

ADF is picking a date from SQL column 'max_watermarkcolumn_loaded' in this format '"2021-09-29T06:11:16.333Z"' and I think thats where the problem is. ADF 从 SQL 列“max_watermarkcolumn_loaded”中选择一个日期,格式为“2021-09-29T06:11:16.333Z”,我认为这就是问题所在。

I tried to repro this error.我试图重现这个错误。 I gave the parameter without single quotes to a sample Query.我将不带单引号的参数提供给示例查询。在此处输入图像描述

Wrap the date parameters with single quotes.用单引号将日期参数括起来。

Corrected Query更正查询

SELECT @{item().source_columns} FROM 
@{item().source_schema}.@{item().source_table} 
WHERE @{item().source_watermarkcolumn} > 
'@{item().max_watermarkcolumn_loaded}' AND 
@{item().source_watermarkcolumn} <= 
'@{activity('Watermarkvalue').output.firstRow.max_watermarkcolumn_loaded}'

With this query, pipeline is run successfully.通过此查询,管道成功运行。在此处输入图像描述

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM