Skip to content

Commit

Permalink
modify explode logic to avoid losing rows where there are not failure…
Browse files Browse the repository at this point in the history
…s and hide job_id
  • Loading branch information
pritishpai committed Nov 18, 2024
1 parent f3e7c25 commit 8f45c02
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/databricks/labs/ucx/queries/assessment/main/30_3_jobs.sql
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
/*
--title 'Incompatible Jobs'
--title 'Jobs Details'
--width 6
--overrides '{"spec":{
"encodings":{
"columns": [
{"fieldName": "job_name", "booleanValues": ["false", "true"], "linkUrlTemplate": "/jobs/{{ job_id }}", "linkTextTemplate": "{{ @ }}", "linkTitleTemplate": "{{ @ }}", "linkOpenInNewTab": true, "type": "string", "displayAs": "link", "title": "job_name"},
{"fieldName": "job_id", "booleanValues": ["false", "true"], "type": "integer", "displayAs": "number", "title": "job_id"},
{"fieldName": "finding", "booleanValues": ["false", "true"], "type": "string", "displayAs": "string", "title": "finding"},
{"fieldName": "creator", "booleanValues": ["false", "true"], "type": "string", "displayAs": "string", "title": "creator"}
{"fieldName": "creator", "booleanValues": ["false", "true"], "type": "string", "displayAs": "string", "title": "creator"},
{"fieldName": "problem", "booleanValues": ["false", "true"], "type": "string", "displayAs": "string", "title": "problem"}
]}
}}'
*/
SELECT
job_name,
job_id,
EXPLODE(FROM_JSON(failures, 'array<string>')) AS finding,
creator
creator,
EXPLODE(
CASE
WHEN failures IS NULL OR failures = '[]' THEN ARRAY(NULL)
ELSE FROM_JSON(failures, 'array<string>')
END
) AS problem
FROM inventory.jobs
WHERE
NOT job_name LIKE '[UCX]%'
Expand Down

0 comments on commit 8f45c02

Please sign in to comment.