Revision 14330
Added by Aaron Marcuse-Kubitza over 10 years ago
schema.sql | ||
---|---|---|
198 | 198 |
-- clear derived cols so old values won't be used in calculations |
199 | 199 |
new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = NULL; |
200 | 200 |
new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL; |
201 |
new."matched~Name[_no_author]___@TNRS__@vegpath.org" = NULL; |
|
201 | 202 |
new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL; |
202 | 203 |
new.matched_has_accepted = NULL; |
203 | 204 |
new."Accepted_family__@TNRS__@vegpath.org" = NULL; |
... | ... | |
222 | 223 |
new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL; |
223 | 224 |
new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = NULL; |
224 | 225 |
new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL; |
225 |
new."matched~Name[_no_author]___@TNRS__@vegpath.org" = NULL; |
|
226 | 226 |
|
227 | 227 |
-- populate derived cols |
228 | 228 |
new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = (SELECT "*Unmatched_terms" FROM (SELECT new.*) new); |
229 | 229 |
new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT ("*Genus_matched" || ' '::text) || "*Specific_epithet_matched" FROM (SELECT new.*) new); |
230 |
new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "*Name_matched" || COALESCE((' '::text || "*Name_matched_author"), ''::text) FROM (SELECT new.*) new); |
|
230 |
new."matched~Name[_no_author]___@TNRS__@vegpath.org" = (SELECT NULLIF("*Name_matched", 'No suitable matches found.'::text) FROM (SELECT new.*) new); |
|
231 |
new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE((' '::text || "*Name_matched_author"), ''::text) FROM (SELECT new.*) new); |
|
231 | 232 |
new.matched_has_accepted = (SELECT "*Accepted_name" IS NOT NULL FROM (SELECT new.*) new); |
232 | 233 |
new."Accepted_family__@TNRS__@vegpath.org" = (SELECT COALESCE("*Accepted_name_family", |
233 | 234 |
CASE |
... | ... | |
287 | 288 |
END FROM (SELECT new.*) new); |
288 | 289 |
new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE |
289 | 290 |
WHEN matched_has_accepted THEN "*Accepted_name" |
290 |
ELSE "*Name_matched"
|
|
291 |
ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
|
|
291 | 292 |
END FROM (SELECT new.*) new); |
292 | 293 |
new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE |
293 | 294 |
WHEN matched_has_accepted THEN "*Accepted_name_author" |
... | ... | |
297 | 298 |
WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" |
298 | 299 |
ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" |
299 | 300 |
END FROM (SELECT new.*) new); |
300 |
new."matched~Name[_no_author]___@TNRS__@vegpath.org" = (SELECT NULLIF("*Name_matched", 'No suitable matches found.'::text) FROM (SELECT new.*) new); |
|
301 | 301 |
|
302 | 302 |
RETURN new; |
303 | 303 |
END; |
... | ... | |
476 | 476 |
END))), |
477 | 477 |
CONSTRAINT "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text))))), |
478 | 478 |
CONSTRAINT "[accepted_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet}"[2]))), |
479 |
CONSTRAINT "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("*Name_matched" || COALESCE((' '::text || "*Name_matched_author"), ''::text))))),
|
|
479 |
CONSTRAINT "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE((' '::text || "*Name_matched_author"), ''::text))))),
|
|
480 | 480 |
CONSTRAINT "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM (("*Genus_matched" || ' '::text) || "*Specific_epithet_matched")))), |
481 | 481 |
CONSTRAINT "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" CHECK ((NOT ("[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS DISTINCT FROM "*Unmatched_terms"))), |
482 | 482 |
CONSTRAINT "[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS DISTINCT FROM |
... | ... | |
513 | 513 |
CONSTRAINT "[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM |
514 | 514 |
CASE |
515 | 515 |
WHEN matched_has_accepted THEN "*Accepted_name" |
516 |
ELSE "*Name_matched"
|
|
516 |
ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
|
|
517 | 517 |
END))), |
518 | 518 |
CONSTRAINT "[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM |
519 | 519 |
CASE |
... | ... | |
640 | 640 |
-- |
641 | 641 |
|
642 | 642 |
COMMENT ON COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS ' |
643 |
= "*Name_matched" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)
|
|
643 |
= "matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)
|
|
644 | 644 |
|
645 | 645 |
derived column |
646 | 646 |
|
647 | 647 |
to modify expr: |
648 |
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"*Name_matched" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)$$)::util.derived_col_def);
|
|
648 |
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)$$)::util.derived_col_def);
|
|
649 | 649 |
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass); |
650 | 650 |
|
651 | 651 |
to rename: |
... | ... | |
1136 | 1136 |
COMMENT ON COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS ' |
1137 | 1137 |
= CASE |
1138 | 1138 |
WHEN matched_has_accepted THEN "*Accepted_name" |
1139 |
ELSE "*Name_matched"
|
|
1139 |
ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
|
|
1140 | 1140 |
END |
1141 | 1141 |
|
1142 | 1142 |
derived column |
... | ... | |
1144 | 1144 |
to modify expr: |
1145 | 1145 |
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE |
1146 | 1146 |
WHEN matched_has_accepted THEN "*Accepted_name" |
1147 |
ELSE "*Name_matched"
|
|
1147 |
ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
|
|
1148 | 1148 |
END$$)::util.derived_col_def); |
1149 | 1149 |
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass); |
1150 | 1150 |
|
Also available in: Unified diff
bugfix: inputs/.TNRS/schema.sql: taxon_match: derived columns: use new "matched~Name[_no_author]___@TNRS__@vegpath.org" instead of "*Name_matched" so that "No suitable matches found." is removed before concatenating with other fields