@dataif/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/bin/dataif.js +623 -0
- package/package.json +26 -0
- package/scripts/build-template.mjs +72 -0
- package/templates/dataif/README.md +157 -0
- package/templates/dataif/infra/.env.example +119 -0
- package/templates/dataif/infra/.env.stg.example +119 -0
- package/templates/dataif/infra/airflow/Dockerfile +11 -0
- package/templates/dataif/infra/airflow/Dockerfile.release +17 -0
- package/templates/dataif/infra/airflow/requirements.txt +3 -0
- package/templates/dataif/infra/docker-compose.yml +306 -0
- package/templates/dataif/infra/init-db/01-init-dataif.sh +129 -0
- package/templates/dataif/infra/init-db/pnp-curated-views.sqlinc +444 -0
- package/templates/dataif/infra/init-db/pnp-raw-staging-curated.sqlinc +701 -0
- package/templates/dataif/infra/keycloak/Dockerfile +4 -0
- package/templates/dataif/infra/keycloak/realm-dataif.json +73 -0
- package/templates/dataif/infra/ollama/Dockerfile +9 -0
- package/templates/dataif/infra/ollama/bootstrap-model.sh +100 -0
- package/templates/dataif/infra/ollama/sabia-7b.Modelfile +14 -0
- package/templates/dataif/infra/postgres/Dockerfile +4 -0
- package/templates/dataif/pipelines/airflow/dags/generated/.gitkeep +1 -0
- package/templates/dataif/pipelines/airflow/dags/generated/2020_financeiro_fcc6f1f3_sync.py +9 -0
- package/templates/dataif/pipelines/dataif_pipelines/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/airflow/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/airflow/pnp_pipeline_factory.py +167 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/base/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/base/connector.py +28 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/base/types.py +14 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/nilo_pecanha/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/nilo_pecanha/config.py +19 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/nilo_pecanha/connector.py +558 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/nilo_pecanha/powerbi_microdados.py +728 -0
- package/templates/dataif/pipelines/dataif_pipelines/connectors/nilo_pecanha/transform.py +296 -0
- package/templates/dataif/pipelines/dataif_pipelines/jobs/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/jobs/nilo_pipeline.py +112 -0
- package/templates/dataif/pipelines/dataif_pipelines/orchestration/__init__.py +21 -0
- package/templates/dataif/pipelines/dataif_pipelines/orchestration/pnp_workflow.py +783 -0
- package/templates/dataif/pipelines/dataif_pipelines/repositories/__init__.py +1 -0
- package/templates/dataif/pipelines/dataif_pipelines/repositories/pnp_raw_repository.py +860 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/__init__.py +19 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/pnp_curated_service.py +66 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/pnp_download_service.py +534 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/pnp_quality_service.py +9 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/pnp_raw_ingestion_service.py +124 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/pnp_staging_service.py +271 -0
- package/templates/dataif/pipelines/dataif_pipelines/services/powerbi_catalog_service.py +159 -0
- package/templates/dataif/pipelines/sql/staging/020_pnp_matriculas.sql +112 -0
- package/templates/dataif/pipelines/sql/staging/030_pnp_eficiencia_academica.sql +83 -0
- package/templates/dataif/pipelines/sql/staging/040_pnp_servidores.sql +90 -0
- package/templates/dataif/pipelines/sql/staging/050_pnp_financeiro.sql +72 -0
- package/templates/dataif/pipelines/sql/views_curated/004_mv_pnp_dashboard_fast.sql +204 -0
- package/templates/dataif/pipelines/sql/views_curated/010_vw_pnp_admin_ingestao.sql +51 -0
- package/templates/dataif/pipelines/sql/views_curated/020_vw_pnp_qualidade_dados.sql +114 -0
- package/templates/dataif/pipelines/sql/views_curated/030_vw_pnp_matriculas.sql +67 -0
- package/templates/dataif/pipelines/sql/views_curated/040_vw_pnp_eficiencia.sql +33 -0
- package/templates/dataif/pipelines/sql/views_curated/050_vw_pnp_servidores.sql +30 -0
- package/templates/dataif/pipelines/sql/views_curated/060_vw_pnp_financeiro.sql +22 -0
- package/templates/dataif/pipelines/sql/views_curated/070_vw_pnp_vanna.sql +115 -0
- package/templates/dataif/scripts/configure-env.sh +149 -0
- package/templates/dataif/scripts/create_metabase_pnp_dashboard.py +943 -0
- package/templates/dataif/scripts/create_metabase_pnp_matriculas_dashboard.py +580 -0
- package/templates/dataif/scripts/deploy.sh +79 -0
- package/templates/dataif/scripts/fix_metabase_template_tag_ids.py +91 -0
- package/templates/dataif/scripts/pnp_powerbi_microdados_probe.py +14 -0
- package/templates/dataif/scripts/pnp_validate_raw_run.py +330 -0
- package/templates/dataif/scripts/publish-images.sh +31 -0
- package/templates/dataif/scripts/sync_metabase_dashboard_field_filters.py +241 -0
- package/templates/dataif/scripts/use-vanna-ollama.sh +139 -0
- package/templates/dataif/services/api/.dockerignore +18 -0
- package/templates/dataif/services/api/Dockerfile +12 -0
- package/templates/dataif/services/api/app/__init__.py +1 -0
- package/templates/dataif/services/api/app/auth.py +48 -0
- package/templates/dataif/services/api/app/config.py +59 -0
- package/templates/dataif/services/api/app/keycloak_admin.py +215 -0
- package/templates/dataif/services/api/app/main.py +2432 -0
- package/templates/dataif/services/api/app/metabase_admin.py +191 -0
- package/templates/dataif/services/api/app/metabase_bootstrap.py +44 -0
- package/templates/dataif/services/api/app/metabase_embed.py +15 -0
- package/templates/dataif/services/api/app/pnp_dag_provisioner.py +113 -0
- package/templates/dataif/services/api/app/pnp_instance_repository.py +951 -0
- package/templates/dataif/services/api/app/pnp_powerbi.py +438 -0
- package/templates/dataif/services/api/app/vanna_client.py +32 -0
- package/templates/dataif/services/api/requirements.txt +9 -0
- package/templates/dataif/services/vanna/.dockerignore +18 -0
- package/templates/dataif/services/vanna/Dockerfile +12 -0
- package/templates/dataif/services/vanna/app/config.py +57 -0
- package/templates/dataif/services/vanna/app/main.py +108 -0
- package/templates/dataif/services/vanna/app/runtime_config.py +114 -0
- package/templates/dataif/services/vanna/app/sql_guard.py +123 -0
- package/templates/dataif/services/vanna/app/vanna_engine.py +382 -0
- package/templates/dataif/services/vanna/requirements.txt +8 -0
- package/templates/dataif/services/web/.dockerignore +13 -0
- package/templates/dataif/services/web/Dockerfile +16 -0
- package/templates/dataif/services/web/index.html +12 -0
- package/templates/dataif/services/web/nginx.conf +74 -0
- package/templates/dataif/services/web/package-lock.json +4397 -0
- package/templates/dataif/services/web/package.json +32 -0
- package/templates/dataif/services/web/postcss.config.mjs +5 -0
- package/templates/dataif/services/web/src/App.jsx +2817 -0
- package/templates/dataif/services/web/src/adminAuth.js +245 -0
- package/templates/dataif/services/web/src/assets/avatar_placeholder.png +0 -0
- package/templates/dataif/services/web/src/assets/github_logo_icon_229278.svg +1 -0
- package/templates/dataif/services/web/src/assets/if-logo.png +0 -0
- package/templates/dataif/services/web/src/assets/if.svg +0 -0
- package/templates/dataif/services/web/src/assets/pnp-horizontal.svg +1 -0
- package/templates/dataif/services/web/src/components/AppHeader.jsx +233 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/base-components/mobile-header.tsx +56 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/base-components/nav-account-card.tsx +209 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/base-components/nav-item-button.tsx +67 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/base-components/nav-item.tsx +108 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/base-components/nav-list.tsx +83 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/config.ts +23 -0
- package/templates/dataif/services/web/src/components/application/app-navigation/header-navigation.tsx +240 -0
- package/templates/dataif/services/web/src/components/application/pagination/pagination-base.tsx +376 -0
- package/templates/dataif/services/web/src/components/application/pagination/pagination-dot.tsx +52 -0
- package/templates/dataif/services/web/src/components/application/pagination/pagination-line.tsx +48 -0
- package/templates/dataif/services/web/src/components/application/pagination/pagination.tsx +328 -0
- package/templates/dataif/services/web/src/components/application/tabs/tabs.tsx +223 -0
- package/templates/dataif/services/web/src/components/base/avatar/avatar-label-group.tsx +28 -0
- package/templates/dataif/services/web/src/components/base/avatar/avatar.tsx +129 -0
- package/templates/dataif/services/web/src/components/base/avatar/base-components/avatar-add-button.tsx +32 -0
- package/templates/dataif/services/web/src/components/base/avatar/base-components/avatar-company-icon.tsx +24 -0
- package/templates/dataif/services/web/src/components/base/avatar/base-components/avatar-online-indicator.tsx +29 -0
- package/templates/dataif/services/web/src/components/base/avatar/base-components/index.tsx +4 -0
- package/templates/dataif/services/web/src/components/base/avatar/base-components/verified-tick.tsx +32 -0
- package/templates/dataif/services/web/src/components/base/badges/badge-types.ts +264 -0
- package/templates/dataif/services/web/src/components/base/badges/badges.tsx +415 -0
- package/templates/dataif/services/web/src/components/base/button-group/button-group.tsx +104 -0
- package/templates/dataif/services/web/src/components/base/buttons/button.tsx +267 -0
- package/templates/dataif/services/web/src/components/base/input/hint-text.tsx +31 -0
- package/templates/dataif/services/web/src/components/base/input/input.tsx +269 -0
- package/templates/dataif/services/web/src/components/base/input/label.tsx +48 -0
- package/templates/dataif/services/web/src/components/base/radio-buttons/radio-buttons.tsx +127 -0
- package/templates/dataif/services/web/src/components/base/select/combobox.tsx +150 -0
- package/templates/dataif/services/web/src/components/base/select/multi-select.tsx +361 -0
- package/templates/dataif/services/web/src/components/base/select/popover.tsx +32 -0
- package/templates/dataif/services/web/src/components/base/select/select-item.tsx +95 -0
- package/templates/dataif/services/web/src/components/base/select/select-native.tsx +67 -0
- package/templates/dataif/services/web/src/components/base/select/select.tsx +144 -0
- package/templates/dataif/services/web/src/components/base/tags/base-components/tag-close-x.tsx +32 -0
- package/templates/dataif/services/web/src/components/base/tooltip/tooltip.tsx +107 -0
- package/templates/dataif/services/web/src/components/foundations/dot-icon.tsx +22 -0
- package/templates/dataif/services/web/src/components/foundations/logo/untitledui-logo-minimal.tsx +170 -0
- package/templates/dataif/services/web/src/components/foundations/logo/untitledui-logo.tsx +58 -0
- package/templates/dataif/services/web/src/hooks/use-breakpoint.ts +34 -0
- package/templates/dataif/services/web/src/hooks/use-resize-observer.ts +67 -0
- package/templates/dataif/services/web/src/main.jsx +14 -0
- package/templates/dataif/services/web/src/providers/theme-provider.jsx +62 -0
- package/templates/dataif/services/web/src/styles/globals.css +60 -0
- package/templates/dataif/services/web/src/styles/theme.css +1326 -0
- package/templates/dataif/services/web/src/styles/typography.css +430 -0
- package/templates/dataif/services/web/src/styles.css +1287 -0
- package/templates/dataif/services/web/src/utils/cx.ts +24 -0
- package/templates/dataif/services/web/src/utils/is-react-component.ts +33 -0
- package/templates/dataif/services/web/vite.config.js +14 -0
- package/templates/dataif/sql/ddl/001_schemas.sql +6 -0
- package/templates/dataif/sql/ddl/003_pnp_raw_staging_curated.sql +699 -0
- package/templates/dataif/sql/migrations/001_pnp_phase1_backfill.sql +3 -0
- package/templates/dataif/sql/migrations/002_pnp_phase2_admin_config_backfill.sql +184 -0
- package/templates/dataif/sql/migrations/003_pnp_phase3_raw_tabular_backfill.sql +3 -0
- package/templates/dataif/sql/migrations/004_pnp_phase3_raw_backfill_support_index.sql +3 -0
- package/templates/dataif/sql/migrations/005_pnp_phase7_staging_support_indexes.sql +2 -0
- package/templates/dataif/sql/migrations/006_pnp_phase7_staging_autovacuum_tuning.sql +2 -0
- package/templates/dataif/sql/migrations/007_pnp_phase7b_run_packages.sql +20 -0
- package/templates/dataif/sql/migrations/008_pnp_phase7a_pipeline_endpoints.sql +169 -0
- package/templates/dataif/sql/migrations/009_pnp_phase8_curated.sql +35 -0
- package/templates/dataif/sql/migrations/010_pnp_phase10_staging_incremental_upsert.sql +3 -0
- package/templates/dataif/sql/migrations/010_pnp_pipeline_uuid.sql +51 -0
- package/templates/dataif/sql/migrations/011_app_settings.sql +7 -0
- package/templates/dataif/sql/staging/020_pnp_matriculas.sql +112 -0
- package/templates/dataif/sql/staging/030_pnp_eficiencia_academica.sql +83 -0
- package/templates/dataif/sql/staging/040_pnp_servidores.sql +90 -0
- package/templates/dataif/sql/staging/050_pnp_financeiro.sql +72 -0
- package/templates/dataif/sql/views_curated/003_vw_pnp_microdados_admin.sql +160 -0
- package/templates/dataif/sql/views_curated/004_mv_pnp_dashboard_fast.sql +204 -0
- package/templates/dataif/sql/views_curated/010_vw_pnp_admin_ingestao.sql +51 -0
- package/templates/dataif/sql/views_curated/020_vw_pnp_qualidade_dados.sql +114 -0
- package/templates/dataif/sql/views_curated/030_vw_pnp_matriculas.sql +67 -0
- package/templates/dataif/sql/views_curated/040_vw_pnp_eficiencia.sql +33 -0
- package/templates/dataif/sql/views_curated/050_vw_pnp_servidores.sql +30 -0
- package/templates/dataif/sql/views_curated/060_vw_pnp_financeiro.sql +22 -0
- package/templates/dataif/sql/views_curated/070_vw_pnp_vanna.sql +115 -0
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_admin_ingestao AS
|
|
2
|
+
WITH package_counts AS (
|
|
3
|
+
SELECT run_id, COUNT(*) AS package_count
|
|
4
|
+
FROM raw.pnp_run_packages
|
|
5
|
+
GROUP BY run_id
|
|
6
|
+
),
|
|
7
|
+
quarantine_counts AS (
|
|
8
|
+
SELECT run_id, COUNT(*) AS quarantine_count
|
|
9
|
+
FROM raw.pnp_ingestion_quarantine
|
|
10
|
+
GROUP BY run_id
|
|
11
|
+
)
|
|
12
|
+
SELECT
|
|
13
|
+
runs.run_id,
|
|
14
|
+
runs.instance_key,
|
|
15
|
+
instances.connection_key,
|
|
16
|
+
instances.connection_name,
|
|
17
|
+
runs.airflow_dag_id,
|
|
18
|
+
runs.airflow_dag_run_id,
|
|
19
|
+
runs.trigger_mode,
|
|
20
|
+
runs.requested_by,
|
|
21
|
+
runs.logical_date,
|
|
22
|
+
runs.status,
|
|
23
|
+
runs.catalog_entry_count,
|
|
24
|
+
runs.selected_download_count,
|
|
25
|
+
runs.downloaded_file_count,
|
|
26
|
+
runs.raw_record_count,
|
|
27
|
+
COALESCE(staging.deduplicated_record_count, 0) AS staging_record_count,
|
|
28
|
+
COALESCE(package_counts.package_count, 0) AS package_count,
|
|
29
|
+
COALESCE(quarantine_counts.quarantine_count, 0) AS quarantine_count,
|
|
30
|
+
staging.quality_status,
|
|
31
|
+
runs.started_at,
|
|
32
|
+
runs.finished_at,
|
|
33
|
+
CASE
|
|
34
|
+
WHEN runs.finished_at IS NULL THEN NULL
|
|
35
|
+
ELSE EXTRACT(EPOCH FROM (runs.finished_at - runs.started_at))::BIGINT
|
|
36
|
+
END AS duration_seconds,
|
|
37
|
+
runs.error_message,
|
|
38
|
+
runs.run_summary_json
|
|
39
|
+
FROM raw.pnp_runs runs
|
|
40
|
+
LEFT JOIN raw.pnp_instances instances
|
|
41
|
+
ON instances.instance_key = runs.instance_key
|
|
42
|
+
LEFT JOIN staging.pnp_ingestion_runs staging
|
|
43
|
+
ON staging.run_id = runs.run_id
|
|
44
|
+
LEFT JOIN package_counts
|
|
45
|
+
ON package_counts.run_id = runs.run_id
|
|
46
|
+
LEFT JOIN quarantine_counts
|
|
47
|
+
ON quarantine_counts.run_id = runs.run_id;
|
|
48
|
+
|
|
49
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_qualidade_dados AS
|
|
50
|
+
WITH quality_rows AS (
|
|
51
|
+
SELECT
|
|
52
|
+
run_id,
|
|
53
|
+
instance_key,
|
|
54
|
+
'Matrículas'::TEXT AS tipo_microdados,
|
|
55
|
+
instituicao,
|
|
56
|
+
uf,
|
|
57
|
+
sexo,
|
|
58
|
+
cor_raca,
|
|
59
|
+
renda_familiar,
|
|
60
|
+
faixa_etaria,
|
|
61
|
+
NULL::NUMERIC AS liquidacoes_totais,
|
|
62
|
+
NULL::NUMERIC AS numero_registros
|
|
63
|
+
FROM staging.pnp_matriculas
|
|
64
|
+
UNION ALL
|
|
65
|
+
SELECT
|
|
66
|
+
run_id,
|
|
67
|
+
instance_key,
|
|
68
|
+
'Eficiência Acadêmica'::TEXT AS tipo_microdados,
|
|
69
|
+
instituicao,
|
|
70
|
+
uf,
|
|
71
|
+
sexo,
|
|
72
|
+
cor_raca,
|
|
73
|
+
renda_familiar,
|
|
74
|
+
faixa_etaria,
|
|
75
|
+
NULL::NUMERIC AS liquidacoes_totais,
|
|
76
|
+
NULL::NUMERIC AS numero_registros
|
|
77
|
+
FROM staging.pnp_eficiencia_academica
|
|
78
|
+
UNION ALL
|
|
79
|
+
SELECT
|
|
80
|
+
run_id,
|
|
81
|
+
instance_key,
|
|
82
|
+
'Servidores'::TEXT AS tipo_microdados,
|
|
83
|
+
instituicao,
|
|
84
|
+
NULL::TEXT AS uf,
|
|
85
|
+
NULL::TEXT AS sexo,
|
|
86
|
+
NULL::TEXT AS cor_raca,
|
|
87
|
+
NULL::TEXT AS renda_familiar,
|
|
88
|
+
NULL::TEXT AS faixa_etaria,
|
|
89
|
+
NULL::NUMERIC AS liquidacoes_totais,
|
|
90
|
+
numero_registros
|
|
91
|
+
FROM staging.pnp_servidores
|
|
92
|
+
UNION ALL
|
|
93
|
+
SELECT
|
|
94
|
+
run_id,
|
|
95
|
+
instance_key,
|
|
96
|
+
'Financeiro'::TEXT AS tipo_microdados,
|
|
97
|
+
NULL::TEXT AS instituicao,
|
|
98
|
+
NULL::TEXT AS uf,
|
|
99
|
+
NULL::TEXT AS sexo,
|
|
100
|
+
NULL::TEXT AS cor_raca,
|
|
101
|
+
NULL::TEXT AS renda_familiar,
|
|
102
|
+
NULL::TEXT AS faixa_etaria,
|
|
103
|
+
liquidacoes_totais,
|
|
104
|
+
NULL::NUMERIC AS numero_registros
|
|
105
|
+
FROM staging.pnp_financeiro
|
|
106
|
+
)
|
|
107
|
+
SELECT
|
|
108
|
+
quality_rows.run_id,
|
|
109
|
+
quality_rows.instance_key,
|
|
110
|
+
quality_rows.tipo_microdados,
|
|
111
|
+
COUNT(*) AS registros,
|
|
112
|
+
COUNT(*) FILTER (
|
|
113
|
+
WHERE quality_rows.tipo_microdados <> 'Financeiro'
|
|
114
|
+
AND quality_rows.instituicao IS NULL
|
|
115
|
+
) AS registros_sem_instituicao,
|
|
116
|
+
COUNT(*) FILTER (
|
|
117
|
+
WHERE quality_rows.tipo_microdados IN ('Matrículas', 'Eficiência Acadêmica')
|
|
118
|
+
AND quality_rows.uf IS NULL
|
|
119
|
+
) AS registros_sem_uf,
|
|
120
|
+
COUNT(*) FILTER (
|
|
121
|
+
WHERE quality_rows.tipo_microdados IN ('Matrículas', 'Eficiência Acadêmica')
|
|
122
|
+
AND quality_rows.sexo IS NULL
|
|
123
|
+
) AS registros_sem_sexo,
|
|
124
|
+
COUNT(*) FILTER (
|
|
125
|
+
WHERE quality_rows.tipo_microdados IN ('Matrículas', 'Eficiência Acadêmica')
|
|
126
|
+
AND quality_rows.cor_raca IS NULL
|
|
127
|
+
) AS registros_sem_cor_raca,
|
|
128
|
+
COUNT(*) FILTER (
|
|
129
|
+
WHERE quality_rows.tipo_microdados IN ('Matrículas', 'Eficiência Acadêmica')
|
|
130
|
+
AND quality_rows.renda_familiar IS NULL
|
|
131
|
+
) AS registros_sem_renda_familiar,
|
|
132
|
+
COUNT(*) FILTER (
|
|
133
|
+
WHERE quality_rows.tipo_microdados IN ('Matrículas', 'Eficiência Acadêmica')
|
|
134
|
+
AND quality_rows.faixa_etaria IS NULL
|
|
135
|
+
) AS registros_sem_faixa_etaria,
|
|
136
|
+
COUNT(*) FILTER (
|
|
137
|
+
WHERE quality_rows.tipo_microdados = 'Financeiro'
|
|
138
|
+
AND quality_rows.liquidacoes_totais IS NULL
|
|
139
|
+
) AS registros_financeiros_sem_valor,
|
|
140
|
+
COUNT(*) FILTER (
|
|
141
|
+
WHERE quality_rows.tipo_microdados = 'Servidores'
|
|
142
|
+
AND quality_rows.numero_registros IS NULL
|
|
143
|
+
) AS registros_servidores_sem_quantidade,
|
|
144
|
+
ROUND(
|
|
145
|
+
100.0 * COUNT(*) FILTER (
|
|
146
|
+
WHERE quality_rows.tipo_microdados <> 'Financeiro'
|
|
147
|
+
AND quality_rows.instituicao IS NULL
|
|
148
|
+
) / NULLIF(COUNT(*), 0),
|
|
149
|
+
2
|
|
150
|
+
) AS pct_sem_instituicao,
|
|
151
|
+
ROUND(
|
|
152
|
+
100.0 * COUNT(*) FILTER (
|
|
153
|
+
WHERE quality_rows.tipo_microdados IN ('Matrículas', 'Eficiência Acadêmica')
|
|
154
|
+
AND quality_rows.uf IS NULL
|
|
155
|
+
) / NULLIF(COUNT(*), 0),
|
|
156
|
+
2
|
|
157
|
+
) AS pct_sem_uf
|
|
158
|
+
FROM quality_rows
|
|
159
|
+
GROUP BY quality_rows.run_id, quality_rows.instance_key, quality_rows.tipo_microdados;
|
|
160
|
+
|
|
161
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_matriculas_perfil AS
|
|
162
|
+
SELECT
|
|
163
|
+
run_id,
|
|
164
|
+
instance_key,
|
|
165
|
+
ano,
|
|
166
|
+
instituicao,
|
|
167
|
+
regiao,
|
|
168
|
+
uf,
|
|
169
|
+
municipio,
|
|
170
|
+
sexo,
|
|
171
|
+
cor_raca,
|
|
172
|
+
renda_familiar,
|
|
173
|
+
faixa_etaria,
|
|
174
|
+
situacao_matricula,
|
|
175
|
+
COUNT(*) AS matriculas,
|
|
176
|
+
SUM(vagas_ofertadas) AS vagas_ofertadas,
|
|
177
|
+
SUM(total_inscritos) AS inscritos
|
|
178
|
+
FROM staging.pnp_matriculas
|
|
179
|
+
GROUP BY run_id, instance_key, ano, instituicao, regiao, uf, municipio, sexo, cor_raca, renda_familiar, faixa_etaria, situacao_matricula;
|
|
180
|
+
|
|
181
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_matriculas_oferta AS
|
|
182
|
+
SELECT
|
|
183
|
+
run_id,
|
|
184
|
+
instance_key,
|
|
185
|
+
ano,
|
|
186
|
+
instituicao,
|
|
187
|
+
regiao,
|
|
188
|
+
uf,
|
|
189
|
+
municipio,
|
|
190
|
+
modalidade_ensino,
|
|
191
|
+
tipo_curso,
|
|
192
|
+
tipo_oferta,
|
|
193
|
+
turno,
|
|
194
|
+
eixo_tecnologico,
|
|
195
|
+
subeixo_tecnologico,
|
|
196
|
+
nome_curso,
|
|
197
|
+
COUNT(*) AS matriculas,
|
|
198
|
+
SUM(vagas_ofertadas) AS vagas_ofertadas,
|
|
199
|
+
SUM(total_inscritos) AS inscritos
|
|
200
|
+
FROM staging.pnp_matriculas
|
|
201
|
+
GROUP BY run_id, instance_key, ano, instituicao, regiao, uf, municipio, modalidade_ensino, tipo_curso, tipo_oferta, turno, eixo_tecnologico, subeixo_tecnologico, nome_curso;
|
|
202
|
+
|
|
203
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_eficiencia_situacao AS
|
|
204
|
+
SELECT
|
|
205
|
+
run_id,
|
|
206
|
+
instance_key,
|
|
207
|
+
ano,
|
|
208
|
+
instituicao,
|
|
209
|
+
regiao,
|
|
210
|
+
uf,
|
|
211
|
+
municipio,
|
|
212
|
+
sexo,
|
|
213
|
+
cor_raca,
|
|
214
|
+
renda_familiar,
|
|
215
|
+
faixa_etaria,
|
|
216
|
+
categoria_situacao,
|
|
217
|
+
situacao_matricula,
|
|
218
|
+
matricula_atendida,
|
|
219
|
+
COUNT(*) AS registros
|
|
220
|
+
FROM staging.pnp_eficiencia_academica
|
|
221
|
+
GROUP BY run_id, instance_key, ano, instituicao, regiao, uf, municipio, sexo, cor_raca, renda_familiar, faixa_etaria, categoria_situacao, situacao_matricula, matricula_atendida;
|
|
222
|
+
|
|
223
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_servidores_quadro AS
|
|
224
|
+
SELECT
|
|
225
|
+
run_id,
|
|
226
|
+
instance_key,
|
|
227
|
+
ano,
|
|
228
|
+
instituicao,
|
|
229
|
+
regiao,
|
|
230
|
+
classe,
|
|
231
|
+
jornada_trabalho,
|
|
232
|
+
titulacao,
|
|
233
|
+
rsc,
|
|
234
|
+
vinculo_carreira,
|
|
235
|
+
vinculo_contrato,
|
|
236
|
+
vinculo_professor,
|
|
237
|
+
COUNT(*) AS servidores,
|
|
238
|
+
SUM(numero_registros) AS total_registros
|
|
239
|
+
FROM staging.pnp_servidores
|
|
240
|
+
GROUP BY run_id, instance_key, ano, instituicao, regiao, classe, jornada_trabalho, titulacao, rsc, vinculo_carreira, vinculo_contrato, vinculo_professor;
|
|
241
|
+
|
|
242
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_financeiro_execucao AS
|
|
243
|
+
SELECT
|
|
244
|
+
run_id,
|
|
245
|
+
instance_key,
|
|
246
|
+
ano,
|
|
247
|
+
nome_uo,
|
|
248
|
+
uo,
|
|
249
|
+
cod_acao,
|
|
250
|
+
nome_acao,
|
|
251
|
+
grupo_despesa,
|
|
252
|
+
COUNT(*) AS registros,
|
|
253
|
+
SUM(liquidacoes_totais) AS liquidacoes_totais
|
|
254
|
+
FROM staging.pnp_financeiro
|
|
255
|
+
GROUP BY run_id, instance_key, ano, nome_uo, uo, cod_acao, nome_acao, grupo_despesa;
|
|
256
|
+
|
|
257
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_vanna_catalogo AS
|
|
258
|
+
SELECT 'vw_pnp_admin_ingestao' AS relation_name, 'administrativo' AS relation_group, 'Resumo operacional das execucoes da pipeline PNP.' AS relation_description
|
|
259
|
+
UNION ALL
|
|
260
|
+
SELECT 'vw_pnp_qualidade_dados', 'administrativo', 'Indicadores de completude e consistencia por tipo de microdado.'
|
|
261
|
+
UNION ALL
|
|
262
|
+
SELECT 'vw_pnp_matriculas_perfil', 'matriculas', 'Agregacoes de matriculas por perfil socioeconomico e situacao.'
|
|
263
|
+
UNION ALL
|
|
264
|
+
SELECT 'vw_pnp_matriculas_oferta', 'matriculas', 'Agregacoes de matriculas por curso, oferta e eixo tecnologico.'
|
|
265
|
+
UNION ALL
|
|
266
|
+
SELECT 'vw_pnp_eficiencia_situacao', 'eficiencia', 'Agregacoes de eficiencia academica por categoria e situacao.'
|
|
267
|
+
UNION ALL
|
|
268
|
+
SELECT 'vw_pnp_servidores_quadro', 'servidores', 'Agregacoes do quadro de servidores por carreira e titulacao.'
|
|
269
|
+
UNION ALL
|
|
270
|
+
SELECT 'vw_pnp_financeiro_execucao', 'financeiro', 'Agregacoes da execucao financeira por ano, UO e grupo de despesa.';
|
|
271
|
+
|
|
272
|
+
CREATE OR REPLACE VIEW curated.vw_pnp_vanna_resumo AS
|
|
273
|
+
SELECT run_id, instance_key, 'matriculas' AS dominio, 'matriculas' AS indicador, ano, instituicao, regiao, uf, municipio, SUM(matriculas)::NUMERIC AS valor
|
|
274
|
+
FROM curated.vw_pnp_matriculas_perfil
|
|
275
|
+
GROUP BY run_id, instance_key, ano, instituicao, regiao, uf, municipio
|
|
276
|
+
UNION ALL
|
|
277
|
+
SELECT run_id, instance_key, 'eficiencia' AS dominio, 'registros' AS indicador, ano, instituicao, regiao, uf, municipio, SUM(registros)::NUMERIC AS valor
|
|
278
|
+
FROM curated.vw_pnp_eficiencia_situacao
|
|
279
|
+
GROUP BY run_id, instance_key, ano, instituicao, regiao, uf, municipio
|
|
280
|
+
UNION ALL
|
|
281
|
+
SELECT run_id, instance_key, 'servidores' AS dominio, 'total_registros' AS indicador, ano, instituicao, regiao, NULL::TEXT AS uf, NULL::TEXT AS municipio, SUM(total_registros)::NUMERIC AS valor
|
|
282
|
+
FROM curated.vw_pnp_servidores_quadro
|
|
283
|
+
GROUP BY run_id, instance_key, ano, instituicao, regiao
|
|
284
|
+
UNION ALL
|
|
285
|
+
SELECT run_id, instance_key, 'financeiro' AS dominio, 'liquidacoes_totais' AS indicador, ano, nome_uo AS instituicao, NULL::TEXT AS regiao, NULL::TEXT AS uf, NULL::TEXT AS municipio, SUM(liquidacoes_totais)::NUMERIC AS valor
|
|
286
|
+
FROM curated.vw_pnp_financeiro_execucao
|
|
287
|
+
GROUP BY run_id, instance_key, ano, nome_uo;
|
|
288
|
+
|
|
289
|
+
DROP MATERIALIZED VIEW IF EXISTS curated.mv_pnp_dashboard_matriculas CASCADE;
|
|
290
|
+
CREATE MATERIALIZED VIEW curated.mv_pnp_dashboard_matriculas AS
|
|
291
|
+
SELECT
|
|
292
|
+
run_id,
|
|
293
|
+
instance_key,
|
|
294
|
+
ano,
|
|
295
|
+
instituicao,
|
|
296
|
+
regiao,
|
|
297
|
+
uf,
|
|
298
|
+
municipio,
|
|
299
|
+
sexo,
|
|
300
|
+
cor_raca,
|
|
301
|
+
renda_familiar,
|
|
302
|
+
faixa_etaria,
|
|
303
|
+
situacao_matricula,
|
|
304
|
+
modalidade_ensino,
|
|
305
|
+
tipo_curso,
|
|
306
|
+
tipo_oferta,
|
|
307
|
+
turno,
|
|
308
|
+
nome_curso,
|
|
309
|
+
COUNT(*) AS matriculas,
|
|
310
|
+
SUM(vagas_ofertadas) AS vagas_ofertadas,
|
|
311
|
+
SUM(total_inscritos) AS inscritos
|
|
312
|
+
FROM staging.pnp_matriculas
|
|
313
|
+
GROUP BY run_id, instance_key, ano, instituicao, regiao, uf, municipio, sexo, cor_raca, renda_familiar, faixa_etaria, situacao_matricula, modalidade_ensino, tipo_curso, tipo_oferta, turno, nome_curso;
|
|
314
|
+
|
|
315
|
+
CREATE INDEX idx_mv_pnp_dashboard_matriculas_geo
|
|
316
|
+
ON curated.mv_pnp_dashboard_matriculas (run_id, ano, instituicao, regiao, uf, municipio);
|
|
317
|
+
CREATE INDEX idx_mv_pnp_dashboard_matriculas_perfil
|
|
318
|
+
ON curated.mv_pnp_dashboard_matriculas (sexo, cor_raca, renda_familiar, faixa_etaria, situacao_matricula);
|
|
319
|
+
CREATE INDEX idx_mv_pnp_dashboard_matriculas_oferta
|
|
320
|
+
ON curated.mv_pnp_dashboard_matriculas (modalidade_ensino, tipo_curso, tipo_oferta, turno);
|
|
321
|
+
CREATE INDEX idx_mv_pnp_dashboard_matriculas_curso
|
|
322
|
+
ON curated.mv_pnp_dashboard_matriculas (nome_curso);
|
|
323
|
+
|
|
324
|
+
DROP MATERIALIZED VIEW IF EXISTS curated.mv_pnp_dashboard_eficiencia CASCADE;
|
|
325
|
+
CREATE MATERIALIZED VIEW curated.mv_pnp_dashboard_eficiencia AS
|
|
326
|
+
SELECT
|
|
327
|
+
run_id,
|
|
328
|
+
instance_key,
|
|
329
|
+
ano,
|
|
330
|
+
instituicao,
|
|
331
|
+
regiao,
|
|
332
|
+
uf,
|
|
333
|
+
municipio,
|
|
334
|
+
sexo,
|
|
335
|
+
cor_raca,
|
|
336
|
+
renda_familiar,
|
|
337
|
+
faixa_etaria,
|
|
338
|
+
categoria_situacao,
|
|
339
|
+
situacao_matricula,
|
|
340
|
+
matricula_atendida,
|
|
341
|
+
SUM(registros) AS registros
|
|
342
|
+
FROM curated.vw_pnp_eficiencia_situacao
|
|
343
|
+
GROUP BY run_id, instance_key, ano, instituicao, regiao, uf, municipio, sexo, cor_raca, renda_familiar, faixa_etaria, categoria_situacao, situacao_matricula, matricula_atendida;
|
|
344
|
+
|
|
345
|
+
CREATE INDEX idx_mv_pnp_dashboard_eficiencia_geo
|
|
346
|
+
ON curated.mv_pnp_dashboard_eficiencia (run_id, ano, instituicao, regiao, uf, municipio);
|
|
347
|
+
CREATE INDEX idx_mv_pnp_dashboard_eficiencia_perfil
|
|
348
|
+
ON curated.mv_pnp_dashboard_eficiencia (sexo, cor_raca, renda_familiar, faixa_etaria);
|
|
349
|
+
CREATE INDEX idx_mv_pnp_dashboard_eficiencia_situacao
|
|
350
|
+
ON curated.mv_pnp_dashboard_eficiencia (categoria_situacao, situacao_matricula, matricula_atendida);
|
|
351
|
+
|
|
352
|
+
DROP MATERIALIZED VIEW IF EXISTS curated.mv_pnp_dashboard_servidores CASCADE;
|
|
353
|
+
CREATE MATERIALIZED VIEW curated.mv_pnp_dashboard_servidores AS
|
|
354
|
+
SELECT
|
|
355
|
+
run_id,
|
|
356
|
+
instance_key,
|
|
357
|
+
ano,
|
|
358
|
+
instituicao,
|
|
359
|
+
regiao,
|
|
360
|
+
classe,
|
|
361
|
+
jornada_trabalho,
|
|
362
|
+
titulacao,
|
|
363
|
+
vinculo_carreira,
|
|
364
|
+
vinculo_contrato,
|
|
365
|
+
vinculo_professor,
|
|
366
|
+
SUM(servidores) AS servidores,
|
|
367
|
+
SUM(total_registros) AS total_registros
|
|
368
|
+
FROM curated.vw_pnp_servidores_quadro
|
|
369
|
+
GROUP BY run_id, instance_key, ano, instituicao, regiao, classe, jornada_trabalho, titulacao, vinculo_carreira, vinculo_contrato, vinculo_professor;
|
|
370
|
+
|
|
371
|
+
CREATE INDEX idx_mv_pnp_dashboard_servidores_geo
|
|
372
|
+
ON curated.mv_pnp_dashboard_servidores (run_id, ano, instituicao, regiao);
|
|
373
|
+
CREATE INDEX idx_mv_pnp_dashboard_servidores_dim
|
|
374
|
+
ON curated.mv_pnp_dashboard_servidores (classe, jornada_trabalho, titulacao, vinculo_carreira, vinculo_contrato, vinculo_professor);
|
|
375
|
+
|
|
376
|
+
DROP MATERIALIZED VIEW IF EXISTS curated.mv_pnp_dashboard_financeiro CASCADE;
|
|
377
|
+
CREATE MATERIALIZED VIEW curated.mv_pnp_dashboard_financeiro AS
|
|
378
|
+
SELECT
|
|
379
|
+
run_id,
|
|
380
|
+
instance_key,
|
|
381
|
+
ano,
|
|
382
|
+
nome_uo,
|
|
383
|
+
uo,
|
|
384
|
+
cod_acao,
|
|
385
|
+
nome_acao,
|
|
386
|
+
grupo_despesa,
|
|
387
|
+
SUM(registros) AS registros,
|
|
388
|
+
SUM(liquidacoes_totais) AS liquidacoes_totais
|
|
389
|
+
FROM curated.vw_pnp_financeiro_execucao
|
|
390
|
+
GROUP BY run_id, instance_key, ano, nome_uo, uo, cod_acao, nome_acao, grupo_despesa;
|
|
391
|
+
|
|
392
|
+
CREATE INDEX idx_mv_pnp_dashboard_financeiro_dim
|
|
393
|
+
ON curated.mv_pnp_dashboard_financeiro (run_id, ano, nome_uo, grupo_despesa, cod_acao, nome_acao);
|
|
394
|
+
|
|
395
|
+
DROP MATERIALIZED VIEW IF EXISTS curated.mv_pnp_dashboard_qualidade CASCADE;
|
|
396
|
+
CREATE MATERIALIZED VIEW curated.mv_pnp_dashboard_qualidade AS
|
|
397
|
+
SELECT
|
|
398
|
+
run_id,
|
|
399
|
+
instance_key,
|
|
400
|
+
tipo_microdados,
|
|
401
|
+
registros,
|
|
402
|
+
registros_sem_instituicao,
|
|
403
|
+
registros_sem_uf,
|
|
404
|
+
registros_sem_sexo,
|
|
405
|
+
registros_sem_cor_raca,
|
|
406
|
+
registros_sem_renda_familiar,
|
|
407
|
+
registros_sem_faixa_etaria,
|
|
408
|
+
registros_financeiros_sem_valor,
|
|
409
|
+
registros_servidores_sem_quantidade,
|
|
410
|
+
pct_sem_instituicao,
|
|
411
|
+
pct_sem_uf
|
|
412
|
+
FROM curated.vw_pnp_qualidade_dados;
|
|
413
|
+
|
|
414
|
+
DROP MATERIALIZED VIEW IF EXISTS curated.mv_pnp_dashboard_ingestao CASCADE;
|
|
415
|
+
CREATE MATERIALIZED VIEW curated.mv_pnp_dashboard_ingestao AS
|
|
416
|
+
SELECT
|
|
417
|
+
run_id,
|
|
418
|
+
instance_key,
|
|
419
|
+
connection_key,
|
|
420
|
+
connection_name,
|
|
421
|
+
airflow_dag_id,
|
|
422
|
+
airflow_dag_run_id,
|
|
423
|
+
trigger_mode,
|
|
424
|
+
requested_by,
|
|
425
|
+
logical_date,
|
|
426
|
+
status,
|
|
427
|
+
catalog_entry_count,
|
|
428
|
+
selected_download_count,
|
|
429
|
+
downloaded_file_count,
|
|
430
|
+
raw_record_count,
|
|
431
|
+
staging_record_count,
|
|
432
|
+
package_count,
|
|
433
|
+
quarantine_count,
|
|
434
|
+
quality_status,
|
|
435
|
+
started_at,
|
|
436
|
+
finished_at,
|
|
437
|
+
duration_seconds,
|
|
438
|
+
error_message
|
|
439
|
+
FROM curated.vw_pnp_admin_ingestao;
|
|
440
|
+
|
|
441
|
+
CREATE INDEX idx_mv_pnp_dashboard_ingestao_run
|
|
442
|
+
ON curated.mv_pnp_dashboard_ingestao (run_id, status);
|
|
443
|
+
|
|
444
|
+
GRANT SELECT ON ALL TABLES IN SCHEMA curated TO metabase_user, vanna_user;
|