简体   繁体   English

在 Azure 数据工厂中添加日期列

[英]Add a date column in Azure Data Factory

I am wondering if it is possible to add a date column to each file uploaded.我想知道是否可以为每个上传的文件添加一个日期列。

For example each month a CSV is produced.例如,每个月都会生产一个 CSV。 I am wanted to add for example "December 2020" to each row and then for the next months upload add "January 2021" to every row in the CSV file.例如,我想将“2020 年 12 月”添加到每一行,然后在接下来的几个月将“2021 年 1 月”上传到 CSV 文件的每一行。 Before copying this into a SQL database.在将其复制到 SQL 数据库之前。

eg file name "Latest Rating December 2020" I would want the 'December 2020' as a column and be the same value for all rows.例如,文件名“2020 年 12 月最新评级”我希望将“2020 年 12 月”作为一列,并且所有行的值都相同。 The naming convention will be the same for each months upload.每个月上传的命名约定都相同。

Thanks谢谢

I've created a test to add a column to the csv file.我创建了一个测试来向 csv 文件添加一列。
The result is as follows:结果如下: 在此处输入图像描述

  1. We can get file name via Child Items in Get MetaData activity.我们可以通过 Get MetaData 活动中的Child Items获取文件名。 在此处输入图像描述 The dataset is to the container in ADLS.数据集到 ADLS 中的容器。 在此处输入图像描述

  2. Then we can declare a variable FileName to store the file name via the expression @activity('Get Metadata1').output.childItems[0].name .然后我们可以通过表达式@activity('Get Metadata1').output.childItems[0].name声明一个变量FileName来存储文件名。 在此处输入图像描述

3.We can use additional column in Copy activity, and use the expression @concat(split(variables('FileName'),' ')[2],' ',split(variables('FileName'),' ')[3]) to get the value we need. 3.我们可以在复制活动中使用附加列,并使用表达式@concat(split(variables('FileName'),' ')[2],' ',split(variables('FileName'),' ')[3])来获得我们需要的值。 Note that the single quote contains a space.请注意,单引号包含一个空格。 在此处输入图像描述 In the dataset, we need key in a dynamic content @variables('FileName') to specify which file to be copied.在数据集中,我们需要键入动态内容@variables('FileName')来指定要复制的文件。 在此处输入图像描述 The sink is the same as source in Copy activity.接收器与复制活动中的源相同。 在此处输入图像描述

  1. Then we can run debug to confirm it.然后我们可以运行调试来确认它。

Here I think we also can copy into SQL table directly, when we set the sink to a sql table.这里我想我们也可以直接复制到 SQL 表中,当我们将接收器设置为 sql 表时。

暂无
暂无

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

相关问题 是否可以在Azure Data Factory管道中向数据添加具有特定值的列 - Is it possible to add a column with specific value to data in azure data factory pipeline 如何在 Azure 数据工厂的复制活动期间将日期添加到文件名? - How to add date to filename during copy activity in Azure Data Factory? 如何将日期选择器字段作为参数添加到 azure 数据工厂管道? - How to add a date picker field as a parameter to azure data factory pipelines? 无法在 Azure 数据工厂的复制活动中向接收器“Azure 数据资源管理器”添加额外的列 - Not able to add additional column to the sink `Azure Data Explorer` in the Copy Activity of Azure Data Factory Azure数据工厂:处理以前的日期数据 - Azure data factory : Process previous date data Azure 使用派生列的多种日期格式的数据工厂“数据流”时间转换 - Azure Data Factory 'Data Flow' time conversion for multiple Date Formats using Derived Column Azure 数据工厂将日期转换为 YYYYMMDD,然后转换为字符串 - Azure Data Factory Convert Date to YYYYMMDD then to String 如何使用 Azure 数据工厂对日期或键列执行增量加载 - How to perform Incremental Load with date or key column using Azure data factory 使用 azure 数据工厂的无日期或主键列的增量加载 - Incremental load without date or primary key column using azure data factory 如何在Azure数据工厂的数据流聚合活动中添加动态GroupBy列 - How to add Dynamic GroupBy Column in Data Flow Aggregate Activity in Azure Data Factory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM