Last active
December 20, 2018 05:03
-
-
Save jaor/0cd705c1c9f8f32a80fcde99c39efc3d to your computer and use it in GitHub Desktop.
Mark fields with a prefix as non-preferred
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
{ | |
"name": "Mark non-preferred", | |
"kind": "script", | |
"description": "Given a dataset, mark as non-preferred fields starting with a prefix", | |
"source_code": "script.whizzml", | |
"imports":[ | |
], | |
"inputs":[ | |
{ | |
"name": "dataset-id", | |
"type": "dataset-id", | |
"description": "The dataset whose fields we want to mark" | |
}, | |
{ | |
"name": "prefix", | |
"type": "string", | |
"description": "The prefix of the fields' names to mark" | |
}], | |
"outputs":[ | |
{ | |
"name": "result", | |
"type": "dataset-id", | |
"description": "The input dataset, now with marked fields" | |
}] | |
} |
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
(define (mark-fields ds-id prefix) | |
(let (fields (resource-fields ds-id) | |
ids (keys fields) | |
len (count prefix) | |
flags (for (f (values fields)) | |
{"preferred" (not (= prefix (subs (f "name") 0 len)))})) | |
(update ds-id {"fields" (make-map ids flags)}))) | |
(define result (mark-fields dataset-id prefix)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment