[英]"Cursor" and "FOR XML" clause in Azure data warehouse
While creating stored procedures in Azure data warehouse, I have got some error on "Cursor" and "FOR XML".在 Azure 数据仓库中创建存储过程时,“光标”和“FOR XML”出现错误。 So wanted to know if they are supported by Azure data warehouse or not.
所以想知道Azure数据仓库是否支持它们。 If not then what are the alternatives.
如果没有,那么有什么替代方案。
sample code with error msg pictures are attached herein.此处附有带有错误消息图片的示例代码。
Neither FOR XML
or cursors are supported in Azure Synapse dedicated SQL pools (formerly known as Azure SQL Data Warehouse) as per the documentation . Neither
FOR XML
or cursors are supported in Azure Synapse dedicated SQL pools (formerly known as Azure SQL Data Warehouse) as per the documentation . For cursors, either convert them to use a WHILE
loop which is supported or refactor the code to use a set-based approach.对于游标,要么将它们转换为使用受支持的
WHILE
循环,要么重构代码以使用基于集合的方法。 Another alternative is to use something external, like Azure Data Factory or Synapse Pipelines and use a For Each loop.另一种选择是使用外部的东西,比如 Azure 数据工厂或 Synapse 管道,并使用 For Each 循环。 Another alternative is to use a nearby Azure SQL DB to do some pre-processing.
另一种选择是使用附近的 Azure SQL DB 进行一些预处理。 You should be aware the the MPP architecture of Azure Synapse Analytics does not lend itself well to this kind of row-based processing and you should remember it's a big data platform meant for large volumes of data, millions, billions of rows and set-based approaches should be preferred.
您应该知道 Azure Synapse Analytics 的 MPP 架构不适合这种基于行的处理,您应该记住它是一个大数据平台,适用于大量数据、数百万、数十亿行和基于集合的数据方法应该是首选。
If you are just using FOR XML
to do that sleazy string concatenation trick then you should use STRING_AGG
instead which is fully supported in Synapse.如果您只是使用
FOR XML
来执行那种低俗的字符串连接技巧,那么您应该使用STRING_AGG
来代替,它在 Synapse 中完全受支持。 See this answer for a recent example.有关最近的示例,请参见此答案。 If you are actually producing XML then you will need to find an alternative method, eg a nearby Azure SQL DB.
如果您实际生产的是 XML,那么您将需要找到一种替代方法,例如附近的 Azure SQL DB。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.