sql - U-SQL:如何处理架构更改?

标签 sql visual-studio azure azure-data-factory u-sql

我原来的脚本是这样的:

@input = EXTRACT A string, B string, C string, 
         year string, month string, day string, filename string
    FROM @folder + "/{year}/{month}/{day}/{filename}.csv"
    USING Extractors.Csv(skipFirstNRows : 1);

@input = SELECT A, B, C FROM @input;

OUTPUT @input
    TO @parent + "/testtest.csv"
    USING Outputters.Csv(outputHeader : true);

这工作正常,但有时源文件的架构(列)可能会改变。这些列可能会变成 A、B、C、D 或 A、B、E。

我知道 Visual Studio 可以生成 EXTRACT 脚本。有没有办法让 U-SQL(或 Visual Studio)处理这个问题并动态自动生成提取脚本?

最佳答案

Csv 提取器不允许架构更改。 如果更改架构,您将需要更改 u-sql 代码!

解决方案是创建一个自定义提取器来完成您的工作,或者您可以检查允许灵活列架构的灵活提取器。

https://blogs.msdn.microsoft.com/mrys/2016/08/15/how-to-deal-with-files-containing-rows-with-different-column-counts-in-u-sql-introducing-a-flexible-schema-extractor/

关于sql - U-SQL:如何处理架构更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52877620/

相关文章:

azure - 用于将属性添加到 Azure Webapp 应用程序设置的 API

php - Mysql通过VARCHAR字段插入订单号

mysql - 在 ALTER_PROCEDURE DDL 触发器中获取过程名称

php - 如何实现 SQL 语句来创建 either/or 功能

.net - Azure WebJobs SDK 是否专门用于使用 Azure 存储?

c# - 在特定语言构造(即属性构造函数)上扩展 Intellisense

使用 MSI 连接到 Azure Vault

sql - 通过 Liquibase 使用外键插入新记录

c++ - 延迟加载的 DLL 在内存中的加载距离彼此太远

windows - 为什么 LocalStorage 元素在 Azure 服务定义架构的两个级别列出?