emidiosouza commited on
Commit
9ac8087
·
verified ·
1 Parent(s): d23ce76

fix: multiple miralizations

Browse files
Files changed (1) hide show
  1. query.sql +61 -61
query.sql CHANGED
@@ -1,74 +1,72 @@
1
  SELECT
2
  id,
3
  name AS "Nome do documento",
4
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->'region'->>'target_or_deposit', '[]'), 'Não especificado') AS "Alvo ou depósito", -- OK
5
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->>'ore', ''), 'Não especificado') AS "Tipo de mineralização", -- OK
6
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->'region'->>'country', '[]'), 'Não especificado') AS "País", -- OK
7
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->'region'->>'state', '[]'), 'Não especificado') AS "Estado", -- OK
8
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->'region'->>'city', '[]'), 'Não especificado') AS "Cidade", -- OK
9
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->'region'->>'region_name', '[]'), 'Não especificado') AS "Região", -- ok
10
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->>'quantity', ''), 'Não especificado') AS "Quantidade de mineralização", -- OK
11
- -- Este item foi ocultado a pedido do Johann
12
- -- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->>'region', ''), 'Não especificado') AS "Região do alvo",
13
 
14
- COALESCE(NULLIF(array_to_string(ARRAY(
15
  SELECT jsonb_extract_path_text(concentration, 'name_of_ore') || ' - (' || jsonb_extract_path_text(concentration, 'concentration_of_ore') || ')'
16
- FROM jsonb_array_elements(data->'responseData'->0->'response'->'mineralizations'->0->'concentration') AS concentration
17
- ), ', '), ''), 'Não especificado') AS "Concentração de mineralização",
18
 
19
-
20
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->'region'->>'extra_info', '[]'), 'Não especificado') AS "Informações adicionais", -- OK
21
  COALESCE(NULLIF(data->'responseData'->2->'response'->>'mineralizationSignatures', ''), 'Não identificado') AS "Assinaturas de mineralização", -- OK
22
-
23
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->'geological_context'->>'tectonic_context', ''), 'Não especificado') AS "Contexto tectônico", -- OK
24
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->'geological_context'->>'geological_context_description', ''), 'Não especificado') AS "Contexto geológico", --OK
25
- COALESCE(NULLIF(data->'responseData'->0->'response'->'mineralizations'->0->'geological_context'->>'context_of_present_rocks', ''), 'Não especificado') AS "Rochas presentes", -- OK
26
-
27
- --rock_types_sedimentares
28
- COALESCE(NULLIF(array_to_string(ARRAY(
29
- SELECT jsonb_extract_path_text(sedimentares, 'name') || ' (' || 'Tipo: ' || jsonb_extract_path_text(sedimentares, 'type') || ', Relações de contato: ' || jsonb_extract_path_text(sedimentares, 'contact_relations') || ')'
30
- FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'sedimentares') AS sedimentares
31
- ), '; '), ''), 'Não identificado') AS "Rochas sedimentares",
32
 
33
- --rock_types_metamorficas
34
- COALESCE(NULLIF(array_to_string(ARRAY(
35
- SELECT jsonb_extract_path_text(metamorficas, 'name') || ' (' || 'Tipo: ' || jsonb_extract_path_text(metamorficas, 'type') || ', Relações de contato: ' || jsonb_extract_path_text(metamorficas, 'contact_relations') || ')'
36
- FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'metamórficas') AS metamorficas
37
- ), '; '), ''), 'Não identificado') AS "Rochas metamórficas",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
- --rock_types_igneas_intrusivas
40
- COALESCE(NULLIF(array_to_string(ARRAY(
41
- SELECT jsonb_extract_path_text(igneas_i, 'name') || ' (' || 'Tipo: ' || jsonb_extract_path_text(igneas_i, 'type') || ', Relações de contato: ' || jsonb_extract_path_text(igneas_i, 'contact_relations') || ')'
42
- FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'ígneas_intrusivas') AS igneas_i
43
- ), '; '), ''), 'Não identificado') AS "Rochas ígneas intrusivas",
44
 
45
- --rock_types_igneas_extrusivas
46
- COALESCE(NULLIF(array_to_string(ARRAY(
47
- SELECT jsonb_extract_path_text(igneas_e, 'name') || ' (' || 'Tipo: ' || jsonb_extract_path_text(igneas_e, 'type') || ', Relações de contato: ' || jsonb_extract_path_text(igneas_e, 'contact_relations') || ')'
48
- FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'ígneas_extrusivas') AS igneas_e
49
- ), '; '), ''), 'Não identificado') AS "Rochas ígneas extrusivas",
50
 
51
- --rock_types_sv
52
- COALESCE(NULLIF(array_to_string(ARRAY(
53
- SELECT jsonb_extract_path_text(sv, 'name') || ' (' || 'Tipo: ' || jsonb_extract_path_text(sv, 'type') || ', Relações de contato: ' || jsonb_extract_path_text(sv, 'contact_relations') || ')'
54
- FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'ígneas_subvulcânicas') AS sv
55
- ), '; '), ''), 'Não identificado') AS "Rochas ígneas subvulcânicas",
 
 
 
56
 
57
- --host_rocks
58
- COALESCE(NULLIF(data->'responseData'->2->'response'->'host_rocks'->>'name', '[null]'), 'Não identificado') AS "Nomes de rochas hospedeiras",
59
- COALESCE(NULLIF(data->'responseData'->2->'response'->'host_rocks'->>'geologicalEnvironments', '[null]'), 'Não identificado') AS "Ambiente geológico",
60
- COALESCE(NULLIF(array_to_string(ARRAY(SELECT jsonb_array_elements_text(data->'responseData'->2->'response'->'mineralFabric')), ', '), ''), 'Não identificado') AS "Textura de mineralização",
61
- COALESCE(NULLIF(array_to_string(ARRAY(
62
- SELECT jsonb_extract_path_text(associatedMinerals, 'name') || ' (' || 'Cor: ' || jsonb_extract_path_text(associatedMinerals, 'color') || ', Textura: ' || jsonb_extract_path_text(associatedMinerals, 'textures') || ', Nível de Alteração: ' || jsonb_extract_path_text(associatedMinerals, 'alterationLevel') || ')'
63
- FROM jsonb_array_elements(data->'responseData'->2->'response'->'associatedMinerals') AS associatedMinerals
64
- ), ', '), ''), 'Não identificado') AS "Minerais associados",
65
 
66
- COALESCE(NULLIF(data->'responseData'->2->'response'->>'fluidInclusionsAnalysis', '[]'), 'Não especificado') AS "Análise de inclusões fluidas",
67
- --hydrotermal_alterations
68
- COALESCE(NULLIF(array_to_string(ARRAY(SELECT jsonb_array_elements_text(data->'responseData'->2->'response'->'hydrotermal_alterations'->'alterationTypes')), ', '), ''), 'Não identificado') AS "Tipos de alterações hidrotermais",
69
- COALESCE(NULLIF(array_to_string(ARRAY(SELECT jsonb_array_elements_text(data->'responseData'->2->'response'->'hydrotermal_alterations'->'associatedMinerals')), ', '), ''), 'Não identificado') AS "Minerais associados a alterações hidrotermais",
70
 
71
- COALESCE(NULLIF(data->'responseData'->3->'response'->>'structural_mapping', '[]'), 'Não especificado') AS "Geologia estrutural da região",
72
  COALESCE(NULLIF(data->'responseData'->4->'response'->>'structureMineralizationRelation', '[]'), 'Não especificado') AS "Relação estrutura-mineralização",
73
  COALESCE(NULLIF(data->'responseData'->5->'response'->>'stableIsotopes', '[]'), 'Não especificado') AS "Isótopos Estáveis e Radiogênicos",
74
  COALESCE(NULLIF(data->'responseData'->5->'response'->>'traceElementsAndRareEarths', '[]'), 'Não especificado') AS "Elementos traço e terras raras",
@@ -78,8 +76,10 @@ SELECT
78
  COALESCE(NULLIF(data->'responseData'->10->'response'->>'strengths', '[]'), 'Não especificado') AS "Pontos fortes",
79
  COALESCE(NULLIF(data->'responseData'->10->'response'->>'investment_risk', '[]'), 'Não especificado') AS "Risco de investimento",
80
  COALESCE(NULLIF(data->'responseData'->10->'response'->>'economic_potential', '[]'), 'Não especificado') AS "Potencial econômico",
81
- COALESCE(NULLIF(data->'responseData'->11->'response'->>'explanation', '[]'), 'Não especificado') AS "Explicação da favorabilidade",
82
- COALESCE(NULLIF(data->'responseData'->11->'response'->>'favorability', '[]'), 'Não especificado') AS "Favorabilidade"
83
-
84
  FROM
85
- public."Extraction";
 
 
 
1
  SELECT
2
  id,
3
  name AS "Nome do documento",
4
+ COALESCE(NULLIF(mineralization->'region'->>'target_or_deposit', '[]'), 'Não especificado') AS "Alvo ou depósito", -- OK
5
+ COALESCE(NULLIF(mineralization->>'ore', ''), 'Não especificado') AS "Tipo de mineralização", -- OK
6
+ COALESCE(NULLIF(mineralization->'region'->>'country', '[]'), 'Não especificado') AS "País", -- OK
7
+ COALESCE(NULLIF(mineralization->'region'->>'state', '[]'), 'Não especificado') AS "Estado", -- OK
8
+ COALESCE(NULLIF(mineralization->'region'->>'city', '[]'), 'Não especificado') AS "Cidade", -- OK
9
+ COALESCE(NULLIF(mineralization->'region'->>'region_name', '[]'), 'Não especificado') AS "Região", -- OK
10
+ COALESCE(NULLIF(mineralization->>'quantity', ''), 'Não especificado') AS "Quantidade de mineralização", -- OK
 
 
11
 
12
+ COALESCE(NULLIF(array_to_string(ARRAY(
13
  SELECT jsonb_extract_path_text(concentration, 'name_of_ore') || ' - (' || jsonb_extract_path_text(concentration, 'concentration_of_ore') || ')'
14
+ FROM jsonb_array_elements(mineralization->'concentration') AS concentration
15
+ ), ', '), ''), 'Não especificado') AS "Concentração de mineralização",
16
 
17
+ COALESCE(NULLIF(mineralization->'region'->>'extra_info', '[]'), 'Não especificado') AS "Informações adicionais", -- OK
 
18
  COALESCE(NULLIF(data->'responseData'->2->'response'->>'mineralizationSignatures', ''), 'Não identificado') AS "Assinaturas de mineralização", -- OK
 
 
 
 
 
 
 
 
 
 
19
 
20
+ COALESCE(NULLIF(mineralization->'geological_context'->>'tectonic_context', ''), 'Não especificado') AS "Contexto tectônico", -- OK
21
+ COALESCE(NULLIF(mineralization->'geological_context'->>'geological_context_description', ''), 'Não especificado') AS "Contexto geológico", -- OK
22
+ COALESCE(NULLIF(mineralization->'geological_context'->>'context_of_present_rocks', ''), 'Não especificado') AS "Rochas presentes", -- OK
23
+
24
+ -- Rochas sedimentares
25
+ COALESCE(NULLIF(array_to_string(ARRAY(
26
+ SELECT jsonb_extract_path_text(sedimentares, 'name') || ' (' || 'Tipo: ' || jsonb_extract_path_text(sedimentares, 'type') || ', Relações de contato: ' || jsonb_extract_path_text(sedimentares, 'contact_relations') || ')'
27
+ FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'sedimentares') AS sedimentares
28
+ ), '; '), ''), 'Não identificado') AS "Rochas sedimentares",
29
+
30
+ -- Rochas metamórficas
31
+ COALESCE(NULLIF(array_to_string(ARRAY(
32
+ SELECT jsonb_extract_path_text(metamorficas, 'name') || ' (' || 'Tipo: ' || jsonb_extract_path_text(metamorficas, 'type') || ', Relações de contato: ' || jsonb_extract_path_text(metamorficas, 'contact_relations') || ')'
33
+ FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'metamórficas') AS metamorficas
34
+ ), '; '), ''), 'Não identificado') AS "Rochas metamórficas",
35
+
36
+ -- Rochas ígneas intrusivas
37
+ COALESCE(NULLIF(array_to_string(ARRAY(
38
+ SELECT jsonb_extract_path_text(igneas_i, 'name') || ' (' || 'Tipo: ' || jsonb_extract_path_text(igneas_i, 'type') || ', Relações de contato: ' || jsonb_extract_path_text(igneas_i, 'contact_relations') || ')'
39
+ FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'ígneas_intrusivas') AS igneas_i
40
+ ), '; '), ''), 'Não identificado') AS "Rochas ígneas intrusivas",
41
 
42
+ -- Rochas ígneas extrusivas
43
+ COALESCE(NULLIF(array_to_string(ARRAY(
44
+ SELECT jsonb_extract_path_text(igneas_e, 'name') || ' (' || 'Tipo: ' || jsonb_extract_path_text(igneas_e, 'type') || ', Relações de contato: ' || jsonb_extract_path_text(igneas_e, 'contact_relations') || ')'
45
+ FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'ígneas_extrusivas') AS igneas_e
46
+ ), '; '), ''), 'Não identificado') AS "Rochas ígneas extrusivas",
47
 
48
+ -- Rochas ígneas subvulcânicas
49
+ COALESCE(NULLIF(array_to_string(ARRAY(
50
+ SELECT jsonb_extract_path_text(sv, 'name') || ' (' || 'Tipo: ' || jsonb_extract_path_text(sv, 'type') || ', Relações de contato: ' || jsonb_extract_path_text(sv, 'contact_relations') || ')'
51
+ FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'ígneas_subvulcânicas') AS sv
52
+ ), '; '), ''), 'Não identificado') AS "Rochas ígneas subvulcânicas",
53
 
54
+ -- Rochas hospedeiras
55
+ COALESCE(NULLIF(data->'responseData'->2->'response'->'host_rocks'->>'name', '[null]'), 'Não identificado') AS "Nomes de rochas hospedeiras",
56
+ COALESCE(NULLIF(data->'responseData'->2->'response'->'host_rocks'->>'geologicalEnvironments', '[null]'), 'Não identificado') AS "Ambiente geológico",
57
+ COALESCE(NULLIF(array_to_string(ARRAY(SELECT jsonb_array_elements_text(data->'responseData'->2->'response'->'mineralFabric')), ', '), ''), 'Não identificado') AS "Textura de mineralização",
58
+ COALESCE(NULLIF(array_to_string(ARRAY(
59
+ SELECT jsonb_extract_path_text(associatedMinerals, 'name') || ' (' || 'Cor: ' || jsonb_extract_path_text(associatedMinerals, 'color') || ', Textura: ' || jsonb_extract_path_text(associatedMinerals, 'textures') || ', Nível de Alteração: ' || jsonb_extract_path_text(associatedMinerals, 'alterationLevel') || ')'
60
+ FROM jsonb_array_elements(data->'responseData'->2->'response'->'associatedMinerals') AS associatedMinerals
61
+ ), ', '), ''), 'Não identificado') AS "Minerais associados",
62
 
63
+ COALESCE(NULLIF(data->'responseData'->2->'response'->>'fluidInclusionsAnalysis', '[]'), 'Não especificado') AS "Análise de inclusões fluidas",
 
 
 
 
 
 
 
64
 
65
+ -- Alterações hidrotermais
66
+ COALESCE(NULLIF(array_to_string(ARRAY(SELECT jsonb_array_elements_text(data->'responseData'->2->'response'->'hydrotermal_alterations'->'alterationTypes')), ', '), ''), 'Não identificado') AS "Tipos de alterações hidrotermais",
67
+ COALESCE(NULLIF(array_to_string(ARRAY(SELECT jsonb_array_elements_text(data->'responseData'->2->'response'->'hydrotermal_alterations'->'associatedMinerals')), ', '), ''), 'Não identificado') AS "Minerais associados a alterações hidrotermais",
 
68
 
69
+ COALESCE(NULLIF(data->'responseData'->3->'response'->>'structural_mapping', '[]'), 'Não especificado') AS "Geologia estrutural da região",
70
  COALESCE(NULLIF(data->'responseData'->4->'response'->>'structureMineralizationRelation', '[]'), 'Não especificado') AS "Relação estrutura-mineralização",
71
  COALESCE(NULLIF(data->'responseData'->5->'response'->>'stableIsotopes', '[]'), 'Não especificado') AS "Isótopos Estáveis e Radiogênicos",
72
  COALESCE(NULLIF(data->'responseData'->5->'response'->>'traceElementsAndRareEarths', '[]'), 'Não especificado') AS "Elementos traço e terras raras",
 
76
  COALESCE(NULLIF(data->'responseData'->10->'response'->>'strengths', '[]'), 'Não especificado') AS "Pontos fortes",
77
  COALESCE(NULLIF(data->'responseData'->10->'response'->>'investment_risk', '[]'), 'Não especificado') AS "Risco de investimento",
78
  COALESCE(NULLIF(data->'responseData'->10->'response'->>'economic_potential', '[]'), 'Não especificado') AS "Potencial econômico",
79
+ COALESCE(NULLIF(data->'responseData'->11->'response'->>'explanation', '[]'), 'Não especificado') AS "Explicação da favorabilidade",
80
+ COALESCE(NULLIF(data->'responseData'->11->'response'->>'favorability', '[]'), 'Não especificado') AS "Favorabilidade"
81
+
82
  FROM
83
+ public."Extraction"
84
+ CROSS JOIN LATERAL
85
+ jsonb_array_elements(data->'responseData'->0->'response'->'mineralizations') AS t(mineralization);