简体   繁体   English

如何在Azure SQL数据仓库中解析JSON格式的字符串?

[英]How to parse a JSON formatted string in Azure SQL Data Warehouse?

T-SQL has a couple of functions that can parse JSON data, but none of them are applicable to Azure SQL Data Warehouse. T-SQL具有可以解析JSON数据的几个功能,但是其中一个都不适用于Azure SQL数据仓库。

I have data in JSON format in a VARCHAR column that looks like: 我在VARCHAR列中具有JSON格式的数据,如下所示:

{'Purpose': 'Purpose 1', 'Activity': 'This activity'}

I could extract the 'Purpose' field in SQL Server by using the JSON_VALUE function: 我可以使用JSON_VALUE函数提取SQL Server中的“目的”字段:

SELECT JSON_VALUE('{'Purpose': 'Purpose 1', 'Activity': 'This activity'}', '$.Purpose');

But this is not supported in SQL Data Warehouse. 但这在SQL数据仓库中不受支持。 Is there a way to do this in SQL Data Warehouse? 有没有办法在SQL数据仓库中做到这一点?

https://docs.microsoft.com/en-us/sql/t-sql/functions/json-functions-transact-sql https://docs.microsoft.com/zh-cn/sql/t-sql/functions/json-functions-transact-sql

Update June 2019: This feature is in preview as at end of May 2019: 2019年6月更新:此功能于2019年5月底处于预览状态:

https://azure.microsoft.com/en-us/blog/azure-sql-data-warehouse-releases-new-capabilities-for-performance-and-security/ https://azure.microsoft.com/zh-CN/blog/azure-sql-data-warehouse-releases-new-capabilities-for-performance-and-security/

You should still consider if this is appropriate to do in your expensive Azure SQL Data Warehouse. 您仍应考虑在昂贵的Azure SQL数据仓库中是否适合这样做。


No. Do this kind of processing in Azure SQL Database which does actually support JSON processing. 否。在实际上支持JSON处理的Azure SQL数据库中执行这种处理。 Start here: 从这里开始:

Getting started with JSON features in Azure SQL Database Azure SQL数据库中的JSON功能入门

https://docs.microsoft.com/en-us/azure/sql-database/sql-database-json-features https://docs.microsoft.com/zh-cn/azure/sql-database/sql-database-json-features

You should also read this SQL Data Warehouse patterns and anti-patterns article. 您还应该阅读此SQL数据仓库模式和反模式文章。 Consider if your expensive MPP is the right place for this type of processing: https://blogs.msdn.microsoft.com/sqlcat/2017/09/05/azure-sql-data-warehouse-workload-patterns-and-anti-patterns/ 考虑一下昂贵的MPP是否适合这种处理类型: https : //blogs.msdn.microsoft.com/sqlcat/2017/09/05/azure-sql-data-warehouse-workload-patterns-and-anti -模式/

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

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