Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Fabric Warehouse currently supports the OPENROWSET function, which allows you to read CSV files directly. However, when it comes to reading JSON files, you need to use a workaround. This involves treating JSON files as text or CSV files and then using OPENJSON and JSON functions to parse the JSON documents. While this method works, it is considered a hacky workaround and not very elegant.
To improve this, Fabric Warehouse should add a native support for JSON in the OPENROWSET function. This would eliminate the need for tricks with OPENJSON and JSON functions, making the process of reading JSON files more straightforward and elegan.
The current workaround for reading json is:
SELECT
TRY_CAST(JSON_VALUE(jsonContent,'$.orderId') AS INT) AS orderId,
JSON_VALUE(jsonContent,'$.orderDate') AS orderDate,
JSON_QUERY(jsonContent,'$.orderDetails') AS orderDetailsObject,
JSON_QUERY(jsonContent,'$.deliveryAddress') AS deliveryAddressArray
FROM
OPENROWSET(
BULK 'https://<storage>.dfs.core.windows.net/datalakehouseuk/raw/json/orders.json',
FORMAT = 'CSV',
FIELDTERMINATOR ='0x0b',
FIELDQUOTE = '0x0b'
)
WITH (
jsonContent VARCHAR(500)
) AS r;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This feature is in public preview: JSON Lines Support in OPENROWSET for Fabric Data Warehouse and Lakehouse SQL Endpoints (Preview) | M...
We are supporitng JSONL format. Oter formats are not in the roadmap.