{"html_url": "https://github.com/simonw/datasette/issues/251#issuecomment-386879509", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/251", "id": 386879509, "node_id": "MDEyOklzc3VlQ29tbWVudDM4Njg3OTUwOQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-05-06T13:29:26Z", "updated_at": "2018-05-06T13:29:26Z", "author_association": "OWNER", "body": "We can solve this using the `sqlite_timelimit(conn, 20)` helper, which can tell SQLite to give up after 20ms. We can wrap that around the following SQL:\r\n\r\n select distinct COLUMN from TABLE limit 21;\r\n\r\nThen we look at the number of rows returned. If it's 21 or more we know that this table had more than 21 distinct values, so we'll treat it as \"unlimited\". Likewise, if the SQL times out before 20ms is up we will skip this introspection.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 320592643, "label": "Explore \"distinct values for column\" in inspect()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/251#issuecomment-386879840", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/251", "id": 386879840, "node_id": "MDEyOklzc3VlQ29tbWVudDM4Njg3OTg0MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-05-06T13:34:24Z", "updated_at": "2018-05-06T13:34:24Z", "author_association": "OWNER", "body": "Here's a quick demo of that exploration: https://datasette-distinct-column-values.now.sh/-/inspect\r\n\r\nExample output:\r\n\r\n```\r\n{\r\n \"antiquities-act/actions_under_antiquities_act\": {\r\n \"columns\": [\r\n \"current_name\",\r\n \"states\",\r\n \"original_name\",\r\n \"current_agency\",\r\n \"action\",\r\n \"date\",\r\n \"year\",\r\n \"pres_or_congress\",\r\n \"acres_affected\"\r\n ],\r\n \"count\": 344,\r\n \"distinct_values_by_column\": {\r\n \"acres_affected\": null,\r\n \"action\": null,\r\n \"current_agency\": [\r\n \"NPS\",\r\n \"State of Montana\",\r\n \"BLM\",\r\n \"State of Arizona\",\r\n \"USFS\",\r\n \"State of North Dakota\",\r\n \"NPS, BLM\",\r\n \"State of South Carolina\",\r\n \"State of New York\",\r\n \"FWS\",\r\n \"FWS, NOAA\",\r\n \"NPS, FWS\",\r\n \"NOAA\",\r\n \"BLM, USFS\",\r\n \"NOAA, FWS\"\r\n ],\r\n \"current_name\": null,\r\n \"date\": null,\r\n \"original_name\": null,\r\n \"pres_or_congress\": null,\r\n \"states\": null,\r\n \"year\": null\r\n },\r\n \"foreign_keys\": {\r\n \"incoming\": [],\r\n \"outgoing\": []\r\n },\r\n \"fts_table\": null,\r\n \"hidden\": false,\r\n \"label_column\": null,\r\n \"name\": \"antiquities-act/actions_under_antiquities_act\",\r\n \"primary_keys\": []\r\n }\r\n}\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 320592643, "label": "Explore \"distinct values for column\" in inspect()"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/251#issuecomment-386879878", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/251", "id": 386879878, "node_id": "MDEyOklzc3VlQ29tbWVudDM4Njg3OTg3OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-05-06T13:34:57Z", "updated_at": "2018-05-06T13:34:57Z", "author_association": "OWNER", "body": "If I'm going to expand column introspection in this way it would be useful to also capture column type information.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 320592643, "label": "Explore \"distinct values for column\" in inspect()"}, "performed_via_github_app": null}