具有默认值的列 - USQL [英] Columns with default values - USQL

查看:99
本文介绍了具有默认值的列 - USQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在生成我的usql脚本,动态地读取表模式。我有数据湖存储上存在的tsv文件,我需要将新数据附加到那些现有的tsv文件。

但是当我生成usql脚本时,表模式可能会发生变化,表可能有额外的列添加。

据我所知,我们需要在usc脚本中使用与tsv文件中相同数量的列。

是否可以将这些新添加具有一些默认值的列?

例如

 @ Result = EXTRACT id  string 
firstname string
lastname string
department string =

emp_id int = 0
FROM @inputfile
使用提取器.Tsv();





如你所见,d epartment和emp_id列是新添加的,我想在输出文件中插入一些默认值。

如果tsv中已存在列,请选择列值,否则为它们插入一些默认值。



谢谢,

Lokesh



我有什么尝试过:



我没有找到任何帮助。

解决方案

I让它工作,参考下面的链接。



OUTER UNION·U-SQL教程 [ ^ ]



Azure数据Lake U-SQL 2016年9月更新:OUTER UNION,按名称,FILE和PARTITION内部函数设置操作等等! - Azure Data Lake& Azure HDInsight博客 [ ^ ]



c# - 处理包含不同列的文件USQL - 堆栈溢出 [ ^ ]

Hi,
I am generating my usql script dynamically reading a table schema. I have existing tsv files present on data lake store and I need to append the new data to those exsiting tsv files.
But when I generate usql script, table schema may get change and table may have extra columns added.
As far as I know, we need to have same number of columns in usql script as that of in tsv file.
Is it possible to have these newly added columns with some default values?
for e.g.

@Result =    EXTRACT id string,            
firstname string,            
lastname string,			
department string = "",

emp_id int = 0
    FROM @inputfile
    USING Extractors.Tsv();



As you can see, department and emp_id columns are newly added and I want to insert them in output file with some default values.
If columns are already present in the tsv, pick up the column values else insert some default values for them.

Thanks,
Lokesh

What I have tried:

I didn't find any help regarding this.

解决方案

I got it working referring below links.

OUTER UNION · U-SQL Tutorial[^]

Azure Data Lake U-SQL September 2016 Updates: OUTER UNION, Set operations by name, FILE and PARTITION intrinsic functions and more! – Azure Data Lake & Azure HDInsight Blog[^]

c# - Handling Files With Different Columns in USQL - Stack Overflow[^]


这篇关于具有默认值的列 - USQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆