Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No suggested facets when a column named 'value' is included #2208

Open
rgieseke opened this issue Nov 15, 2023 · 1 comment
Open

No suggested facets when a column named 'value' is included #2208

rgieseke opened this issue Nov 15, 2023 · 1 comment

Comments

@rgieseke
Copy link
Contributor

When a column named 'value' is included there are no suggested facets is shown as the query uses an alias of 'value'.

suggested_facet_sql = """
select {column} as value, count(*) as n from (
{sql}
) where value is not null
group by value
limit {limit}
""".format(

Currently the following is shown (from https://latest.datasette.io/fixtures/facetable)

image

When I add a column named 'value' only the JSON facets are processed.

image

I think that not using aliases could be a solution (except if someone wants to use a column named count(*) though this seems to be unlikely). I'll open a PR with that.

There is also a TODO with a similar question in the same file. I have not looked into that yet.

# TODO: does this query break if inner sql produces value or count columns?

@rgieseke
Copy link
Contributor Author

Without aliases:

image

The proposed fix in #2209 also works when the 'value' column is actually facetable (just added another value in the 'value' column).

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant