Skip to content

Make trait_names optional in get_trait_data_pft() #3985

@omkarrr2533

Description

@omkarrr2533

Splitting this out from #3978 since @mdietze suggested it as a separate issue.

Right now get_trait_data_pft() requires the caller to pass a non-empty trait_names. There's a useful case where you just want "all priors for this PFT" — you shouldn't need to know the trait list up front, which today means doing an extra DB query before calling.

The fix is small: let trait_names default to NULL. When it's NULL, pass NULL (or empty trstr) to query.priors so it returns all priors for the pft_id, and then derive trait_names from rownames(prior_distns) for the trait query that follows.

Fully backward compatible — anyone passing trait_names explicitly today sees no change.

One thing I want to check before the PR: query.priors needs to handle trstr = NULL (or empty) and return all priors. If it doesn't already, it's a small tweak to drop the WHERE name IN (...) clause when there's nothing to filter on. Happy to include that in the same PR if needed.

Will pick this up after #3978 lands.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions