Spaces:
Sleeping
Sleeping
perf: acerto da query para refletir mudanças no schema json do novo banco de dados
Browse files
query.sql
CHANGED
@@ -6,50 +6,112 @@ SELECT
|
|
6 |
COALESCE(NULLIF(data->'responseData'->0->'response'->>'region', '[]'), 'Não especificado') AS "Região",
|
7 |
COALESCE(NULLIF(data->'responseData'->0->'response'->>'country', '[]'), 'Não especificado') AS "País",
|
8 |
COALESCE(NULLIF(data->'responseData'->0->'response'->>'extra_info', '[]'), 'Não especificado') AS "Informações adicionais",
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
COALESCE(NULLIF(data->'responseData'->
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
COALESCE(NULLIF(data->'responseData'->
|
40 |
-
|
41 |
-
COALESCE(NULLIF(data->'responseData'->2->'response'->>'oreConcentration', '[]'), 'Não especificado') AS "Concentração do minério",
|
42 |
-
COALESCE(NULLIF(data->'responseData'->2->'response'->>'oreConcentrationJustify', '[]'), 'Não especificado') AS "Justificativa de concentração do minério",
|
43 |
-
COALESCE(CASE WHEN data->'responseData'->2->'response'->>'wasOreConcentrationEstimated' = 'true' THEN true WHEN data->'responseData'->2->'response'->>'wasOreConcentrationEstimated' = 'false' THEN false ELSE NULL END, false) AS "Concentração do minério estimada?",
|
44 |
-
COALESCE(NULLIF(data->'responseData'->'set_mineralization_important_data'->'response'->>'structures', '[]'), 'Não especificado') AS "Estruturas",
|
45 |
-
COALESCE(NULLIF(data->'responseData'->2->'response'->>'mineralFabric', '[]'), 'Não especificado') AS "Textura mineral",
|
46 |
-
COALESCE(NULLIF(data->'responseData'->2->'response'->>'associatedMinerals', '[]'), 'Não especificado') AS "Minerais associados",
|
47 |
-
COALESCE(NULLIF(data->'responseData'->2->'response'->>'fluidInclusionsAnalysis', '[]'), 'Não especificado') AS "Análise de inclusões fluidas",
|
48 |
-
COALESCE(NULLIF(data->'responseData'->2->'response'->'hydrotermal_alterations'->>'alterationTypes', '[]'), 'Não especificado') AS "Tipos de alterações hidrotermais",
|
49 |
-
COALESCE(NULLIF(data->'responseData'->2->'response'->'hydrotermal_alterations'->>'associatedMinerals', '[]'), 'Não especificado') AS "Minerais associados a alterações hidrotermais",
|
50 |
-
COALESCE(NULLIF(data->'responseData'->2->'response'->>'mineralizationSignatures', '[]'), 'Não especificado') AS "Assinaturas de mineralização",
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
COALESCE(NULLIF(data->'responseData'->4->'response'->>'structureMineralizationRelation', '[]'), 'Não especificado') AS "Relação estrutura-mineralização",
|
54 |
COALESCE(NULLIF(data->'responseData'->5->'response'->>'stableIsotopes', '[]'), 'Não especificado') AS "Isótopos estáveis",
|
55 |
COALESCE(NULLIF(data->'responseData'->5->'response'->>'traceElementsAndRareEarths', '[]'), 'Não especificado') AS "Elementos traço e terras raras",
|
@@ -58,7 +120,9 @@ SELECT
|
|
58 |
COALESCE(NULLIF(data->'responseData'->7->'response'->>'additionalInformation', '[]'), 'Não especificado') AS "Informações adicionais de mineralização",
|
59 |
COALESCE(NULLIF(data->'responseData'->8->'response'->>'estimates', '[]'), 'Não especificado') AS "Estimativas de minério",
|
60 |
COALESCE(NULLIF(data->'responseData'->9->'response'->>'potential', '[]'), 'Não especificado') AS "Potencial de descoberta",
|
61 |
-
|
|
|
|
|
62 |
COALESCE(NULLIF(data->'responseData'->11->'response'->>'explanation', '[]'), 'Não especificado') AS "Explicação da favorabilidade",
|
63 |
COALESCE(NULLIF(data->'responseData'->11->'response'->>'favorability', '[]'), 'Não especificado') AS "Favorabilidade"
|
64 |
|
|
|
6 |
COALESCE(NULLIF(data->'responseData'->0->'response'->>'region', '[]'), 'Não especificado') AS "Região",
|
7 |
COALESCE(NULLIF(data->'responseData'->0->'response'->>'country', '[]'), 'Não especificado') AS "País",
|
8 |
COALESCE(NULLIF(data->'responseData'->0->'response'->>'extra_info', '[]'), 'Não especificado') AS "Informações adicionais",
|
9 |
+
--target or deposit
|
10 |
+
COALESCE(NULLIF(array_to_string(ARRAY(SELECT jsonb_array_elements_text(data->'responseData'->0->'response'->'target_or_deposit')), ', '), ''), 'Não especificado') AS "Alvo ou depósito",
|
11 |
+
--geological_context
|
12 |
+
COALESCE(NULLIF(data->'responseData'->0->'response'->'geological_context'->>'tectonic_context', ''), 'Não especificado') AS "Contexto tectônico",
|
13 |
+
COALESCE(NULLIF(data->'responseData'->0->'response'->'geological_context'->>'geological_context', ''), 'Não especificado') AS "Contexto geológico",
|
14 |
+
COALESCE(NULLIF(data->'responseData'->0->'response'->'geological_context'->>'context_of_present_rocks', ''), 'Não especificado') AS "Contexto das rochas presentes",
|
15 |
+
|
16 |
+
--rock_types_sedimentares
|
17 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
18 |
+
SELECT jsonb_extract_path_text(sedimentares, 'name')
|
19 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'sedimentares') AS sedimentares
|
20 |
+
), ', '), ''), 'Não identificado') AS "Nomes sedimentares",
|
21 |
+
|
22 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
23 |
+
SELECT jsonb_extract_path_text(sedimentares, 'type')
|
24 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'sedimentares') AS sedimentares
|
25 |
+
), ', '), ''), 'Não identificado') AS "Tipo sedimentares",
|
26 |
+
|
27 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
28 |
+
SELECT jsonb_extract_path_text(sedimentares, 'scientificName')
|
29 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'sedimentares') AS sedimentares
|
30 |
+
), ', '), ''), 'Não identificado') AS "Nomes cientificos sedimentares",
|
31 |
+
COALESCE(NULLIF(data->'responseData'->1->'response'->'rockTypes'->'sedimentares'->0->>'contact_relations', '[]'), 'Não especificado') AS "Relações de contato sedimentares",
|
32 |
+
|
33 |
+
|
34 |
+
--rock_types_metamorficas
|
35 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
36 |
+
SELECT jsonb_extract_path_text(metamorficas, 'name')
|
37 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'metamórficas') AS metamorficas
|
38 |
+
), ', '), ''), 'Não identificado') AS "Nomes metamórficas",
|
39 |
+
|
40 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
41 |
+
SELECT jsonb_extract_path_text(metamorficas, 'type')
|
42 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'metamórficas') AS metamorficas
|
43 |
+
), ', '), ''), 'Não identificado') AS "Tipo metamórficas",
|
44 |
+
|
45 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
46 |
+
SELECT jsonb_extract_path_text(metamorficas, 'scientificName')
|
47 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'metamórficas') AS metamorficas
|
48 |
+
), ', '), ''), 'Não identificado') AS "Nomes cientificos metamórficas",
|
49 |
+
COALESCE(NULLIF(NULLIF(data->'responseData'->1->'response'->'rockTypes'->'metamórficas'->0->>'contact_relations','[]'), '[""]'), 'Não especificado') AS "Relações de contato metamórficas",
|
50 |
+
|
51 |
+
|
52 |
+
--rock_types_igneas_intrusivas
|
53 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
54 |
+
SELECT jsonb_extract_path_text(igneas_intrusivas, 'name')
|
55 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'ígneas_intrusivas') AS igneas_intrusivas
|
56 |
+
), ', '), ''), 'Não identificado') AS "Nomes ígneas intrusivas",
|
57 |
+
|
58 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
59 |
+
SELECT jsonb_extract_path_text(igneas_intrusivas, 'type')
|
60 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'ígneas_intrusivas') AS igneas_intrusivas
|
61 |
+
), ', '), ''), 'Não identificado') AS "Tipo ígneas intrusivas",
|
62 |
|
63 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
64 |
+
SELECT jsonb_extract_path_text(igneas_intrusivas, 'scientificName')
|
65 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'ígneas_intrusivas') AS igneas_intrusivas
|
66 |
+
), ', '), ''), 'Não identificado') AS "Nomes cientificos ígneas intrusivas",
|
67 |
+
COALESCE(NULLIF(data->'responseData'->1->'response'->'rockTypes'->'ígneas_intrusivas'->0->>'contact_relations', '[]'), 'Não especificado') AS "Relações de contato ígneas intrusivas",
|
68 |
+
|
69 |
+
|
70 |
+
--rock_types_v
|
71 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
72 |
+
SELECT jsonb_extract_path_text(vulcanicas, 'name')
|
73 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'vulcânicas_e_subvulcânicas') AS vulcanicas
|
74 |
+
), ', '), ''), 'Não identificado') AS "Nomes vulcanicas",
|
75 |
+
|
76 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
77 |
+
SELECT jsonb_extract_path_text(vulcanicas, 'type')
|
78 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'vulcânicas_e_subvulcânicas') AS vulcanicas
|
79 |
+
), ', '), ''), 'Não identificado') AS "Tipo vulcanicas",
|
80 |
|
81 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
82 |
+
SELECT jsonb_extract_path_text(vulcanicas, 'scientificName')
|
83 |
+
FROM jsonb_array_elements(data->'responseData'->1->'response'->'rockTypes'->'vulcânicas_e_subvulcânicas') AS vulcanicas
|
84 |
+
), ', '), ''), 'Não identificado') AS "Nomes cientificos vulcanicas",
|
85 |
+
COALESCE(NULLIF(data->'responseData'->1->'response'->'rockTypes'->'vulcânicas_e_subvulcânicas'->0->>'contact_relations', '[]'), 'Não especificado') AS "Relações de contato vulcânicas e subvulcânicas",
|
86 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
+
-- mineralization_important_data
|
89 |
+
COALESCE(NULLIF(data->'responseData'->2->'response'->>'oreType', '[null]'), 'Não identificado') AS "Tipo de minério",
|
90 |
+
COALESCE(NULLIF(data->'responseData'->2->'response'->>'rockType', '[null]'), 'Não identificado') AS "Tipo de rocha",
|
91 |
+
--host_rocks
|
92 |
+
COALESCE(NULLIF(data->'responseData'->2->'response'->'host_rocks'->>'name', '[null]'), 'Não identificado') AS "Nomes rochas hospedeiras",
|
93 |
+
COALESCE(NULLIF(data->'responseData'->2->'response'->'host_rocks'->>'geologicalEnvironments', '[null]'), 'Não identificado') AS "Eventos geológicos rochas de hospedeiras",
|
94 |
+
COALESCE(NULLIF(array_to_string(ARRAY(SELECT jsonb_array_elements_text(data->'responseData'->2->'response'->'host_rocks'->'mineralizationStructures')), ', '), ''), 'Não identificado') AS "Estruturas de mineralização de rochas hospedeiras",
|
95 |
+
--oreContent
|
96 |
+
COALESCE(NULLIF(data->'responseData'->2->'response'->>'oreContent', '[null]'), 'Não identificado') AS "Quantidade do minério",
|
97 |
+
COALESCE(NULLIF(data->'responseData'->2->'response'->>'oreConcentration', '[null]'), 'Não identificado') AS "Concentração do minério",
|
98 |
+
|
99 |
+
COALESCE(NULLIF(array_to_string(ARRAY(SELECT jsonb_array_elements_text(data->'responseData'->2->'response'->'structures')), ', '), ''), 'Não identificado') AS "Estruturas",
|
100 |
+
COALESCE(NULLIF(array_to_string(ARRAY(SELECT jsonb_array_elements_text(data->'responseData'->2->'response'->'mineralFabric')), ', '), ''), 'Não identificado') AS "Textura mineral",
|
101 |
+
-- associatedMinerals
|
102 |
+
COALESCE(NULLIF(array_to_string(ARRAY(
|
103 |
+
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') || ')'
|
104 |
+
FROM jsonb_array_elements(data->'responseData'->2->'response'->'associatedMinerals') AS associatedMinerals
|
105 |
+
), ', '), ''), 'Não identificado') AS "Minerais associados",
|
106 |
+
|
107 |
+
COALESCE(NULLIF(data->'responseData'->2->'response'->>'fluidInclusionsAnalysis', '[]'), 'Não especificado') AS "Análise de inclusões fluidas",
|
108 |
+
|
109 |
+
--hydrotermal_alterations
|
110 |
+
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",
|
111 |
+
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",
|
112 |
+
COALESCE(NULLIF(data->'responseData'->2->'response'->>'mineralizationSignatures', ''), 'Não identificado') AS "Assinaturas de mineralização",
|
113 |
+
|
114 |
+
COALESCE(NULLIF(data->'responseData'->3->'response'->>'structural_mapping', '[]'), 'Não especificado') AS "Mapeamento estrutural",
|
115 |
COALESCE(NULLIF(data->'responseData'->4->'response'->>'structureMineralizationRelation', '[]'), 'Não especificado') AS "Relação estrutura-mineralização",
|
116 |
COALESCE(NULLIF(data->'responseData'->5->'response'->>'stableIsotopes', '[]'), 'Não especificado') AS "Isótopos estáveis",
|
117 |
COALESCE(NULLIF(data->'responseData'->5->'response'->>'traceElementsAndRareEarths', '[]'), 'Não especificado') AS "Elementos traço e terras raras",
|
|
|
120 |
COALESCE(NULLIF(data->'responseData'->7->'response'->>'additionalInformation', '[]'), 'Não especificado') AS "Informações adicionais de mineralização",
|
121 |
COALESCE(NULLIF(data->'responseData'->8->'response'->>'estimates', '[]'), 'Não especificado') AS "Estimativas de minério",
|
122 |
COALESCE(NULLIF(data->'responseData'->9->'response'->>'potential', '[]'), 'Não especificado') AS "Potencial de descoberta",
|
123 |
+
COALESCE(NULLIF(data->'responseData'->10->'response'->>'strengths', '[]'), 'Não especificado') AS "Pontos fortes",
|
124 |
+
COALESCE(NULLIF(data->'responseData'->10->'response'->>'investment_risk', '[]'), 'Não especificado') AS "Risco de investimento",
|
125 |
+
COALESCE(NULLIF(data->'responseData'->10->'response'->>'economic_potential', '[]'), 'Não especificado') AS "Potencial ecnômico",
|
126 |
COALESCE(NULLIF(data->'responseData'->11->'response'->>'explanation', '[]'), 'Não especificado') AS "Explicação da favorabilidade",
|
127 |
COALESCE(NULLIF(data->'responseData'->11->'response'->>'favorability', '[]'), 'Não especificado') AS "Favorabilidade"
|
128 |
|