-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and rename folder_stats.sql to calculate_datasize.sql
Only include datasize calculation part and update variable name to indicate the script works for both folder and project
- Loading branch information
Showing
2 changed files
with
74 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
This is a script to calculate total data size in GiB for each ENTITY_ID (folder or project). | ||
ENTITY_IDs can be a single Synapse folder/project ID or a list of Synapse folder/proejct IDs seperated by comma | ||
*/ | ||
|
||
USE ROLE DATA_ANALYTICS; | ||
USE DATABASE synapse_data_warehouse; | ||
USE WAREHOUSE COMPUTE_XSMALL; | ||
|
||
-- The list of folders to be checked | ||
SET | ||
ENTITY_IDs = ''; | ||
|
||
-- Calculate Data Size | ||
WITH RECURSIVE nodesnapshots | ||
-- Column list of the "view" | ||
( | ||
ID, | ||
PARENT_ID, | ||
NAME, | ||
NODE_TYPE, | ||
FILE_HANDLE_ID, | ||
ENTITY_ID | ||
) | ||
AS | ||
-- Common Table Expression | ||
( | ||
-- Anchor Clause | ||
SELECT | ||
ID, | ||
PARENT_ID, | ||
NAME, | ||
NODE_TYPE, | ||
FILE_HANDLE_ID, | ||
ID AS ENTITY_ID | ||
FROM | ||
synapse_data_warehouse.synapse.node_latest | ||
WHERE | ||
ID IN ( | ||
SELECT | ||
REPLACE(VALUE, 'syn', '') | ||
FROM | ||
TABLE(SPLIT_TO_TABLE($ENTITY_IDs, ',')) | ||
) | ||
|
||
UNION ALL | ||
|
||
-- Recursive Clause | ||
SELECT | ||
node.ID, | ||
node.PARENT_ID, | ||
node.NAME, | ||
node.NODE_TYPE, | ||
node.FILE_HANDLE_ID, | ||
nodesnapshots.ENTITY_ID | ||
FROM | ||
synapse_data_warehouse.synapse.node_latest AS node | ||
JOIN | ||
nodesnapshots | ||
ON | ||
node.PARENT_ID = nodesnapshots.ID | ||
) | ||
-- This is the "main select". | ||
SELECT | ||
'syn' || nodesnapshots.ENTITY_ID AS ENTITY_ID, | ||
sum(filesnapshots.CONTENT_SIZE)/ power(2, 30) AS CONTENT_SIZE_in_GiB | ||
FROM | ||
nodesnapshots | ||
JOIN | ||
synapse_data_warehouse.synapse.file_latest AS filesnapshots | ||
ON | ||
nodesnapshots.file_handle_id = filesnapshots.ID | ||
GROUP BY | ||
nodesnapshots.ENTITY_ID; |
This file was deleted.
Oops, something went wrong.