You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update publisher filter syntax in notebook docs (#309)
* Update publisher filter syntax docs
Publisher's filter annotation syntax changed from JSON-style
(`#(filter) {"type": "Star"}` on dimensions plus a `##(filters)`
notebook annotation) to source-level declarations with name=/dimension=/type=
parameters. Notebooks now inherit filters automatically from imported
sources—no notebook-level configuration needed.
Updates notebooks.malloynb to match the spec at
malloydata/publisher/docs/filters.md, including the new filter types
(equal/in/like/greater_than/less_than), the implicit/required flags,
and the multiple-filters-per-dimension pattern for date ranges.
* DCO Remediation Commit for James Swirhun <james@credibledata.com>
I, James Swirhun <james@credibledata.com>, hereby add my Signed-off-by to this commit: ccff94b
Signed-off-by: James Swirhun <james@credibledata.com>
---------
Signed-off-by: James Swirhun <james@credibledata.com>
Copy file name to clipboardExpand all lines: src/documentation/user_guides/notebooks.malloynb
+54-47Lines changed: 54 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -118,88 +118,95 @@ my-analytics/
118
118
119
119
## Interactive Filters
120
120
121
-
Notebooks can include interactive dropdown filters that allow viewers to filter query results dynamically. When a user selects filter values, all queries in the notebook automatically re-execute with those filters applied.
121
+
Notebooks can expose interactive filter controls that let viewers narrow query results dynamically. When a user changes a filter value, Publisher rewrites each query with a `where:` clause on the server and re-executes the affected cells.
122
122
123
123
> **Note:** Interactive filters are rendered when viewing notebooks via [Publisher](publishing/publishing.malloynb) or the Publisher SDK. They are not currently displayed in VS Code—that capability is coming soon.
124
124
125
125
### How It Works
126
126
127
-
1. **Annotate dimensions** in your Malloy source files to mark them as filterable
128
-
2. **Add a `##(filters)` annotation** in your notebook to specify which dimensions appear as filter controls
129
-
3. When published, the notebook displays filter dropdowns that users can interact with
127
+
Filters are declared on the **source** using `#(filter)` annotations. Publisher parses these annotations, exposes filter metadata through its API, renders widgets above the notebook, and injects matching `where:` clauses into queries at execution time. Any notebook that imports the source automatically inherits its filters—no notebook-level configuration is required.
130
128
131
-
### Step 1: Annotate Filterable Dimensions
129
+
### Declaring Filters
132
130
133
-
In your Malloy source file, add `#(filter)` annotations to dimensions you want to expose as filters:
131
+
Place one or more `#(filter)` annotations immediately above a source definition:
134
132
135
133
```malloy
136
-
source: flights is duckdb.table('data/flights.parquet') extend {
In your notebook, add a `##(filters)` annotation in the code cell that imports your model. The annotation lists which dimensions should appear as filters using `source.dimension` format:
171
+
Give each filter a unique `name` to declare multiple controls over the same dimension. This is the standard pattern for date ranges:
The filter type for each dimension is determined by the `#(filter)` annotation on that dimension in the source file.
178
+
Each filter operates independently and maps to its own API parameter.
179
+
180
+
### Widget Rendering
181
+
182
+
Publisher selects the widget type based on the underlying dimension's Malloy data type:
183
+
184
+
| Dimension Type | Widget |
185
+
|---------------|--------|
186
+
| `string` (with `in` or `like`) | Searchable multi-select or text input |
187
+
| `boolean` | Toggle / dropdown |
188
+
| `date` / `timestamp` | Date picker |
189
+
| `number` | Numeric input |
190
+
191
+
Implicit filters are hidden from the UI but still applied server-side.
175
192
176
193
### Custom Labels
177
194
178
-
By default, filters display the dimension field name. You can customize the label using the `# label="..."` annotation in your source file:
195
+
By default, filter widgets display the dimension name. Use the `# label="..."` annotation on the dimension to customize it:
179
196
180
197
```malloy
181
198
source: recalls is duckdb.table('data/recalls.csv') extend {
182
199
dimension:
183
-
#(filter) {"type": "Star"}
184
200
# label="Vehicle Manufacturer"
185
201
Manufacturer is Manufacturer_old
186
202
}
187
203
```
188
204
189
-
### Match Types
190
-
191
-
Each filter type supports different match types that users can select:
192
-
193
-
| Filter Type | Available Match Types |
194
-
|------------|----------------------|
195
-
| Star | Equals, Contains |
196
-
| MinMax | Equals, Less Than, Greater Than, Between |
197
-
| DateMinMax | Equals, Before, After, Between |
198
-
| Boolean | Equals (True/False) |
199
-
200
205
### Example
201
206
202
-
See the [Carrier Analysis notebook](https://github.com/credibledata/malloy-samples/blob/main/faa/carrier_analysis.malloynb#L4) and [Auto Recalls notebook](https://github.com/credibledata/malloy-samples/blob/main/auto_recalls/README.malloynb#L10) for working examples of interactive filters.
207
+
See the [Auto Recalls notebook](https://github.com/credibledata/malloy-samples/blob/main/auto_recalls/README.malloynb) for a working example of interactive filters.
208
+
209
+
For the full specification—including API details, bypass filters, and MCP tool integration—see the [Publisher filter documentation](https://github.com/malloydata/publisher/blob/main/docs/filters.md).
0 commit comments