pinaxlib 5.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pinaxlib-5.7.0/LICENSE ADDED
@@ -0,0 +1,180 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any other
81
+ Contribution embodied in the Work constitutes direct or contributory
82
+ patent infringement, then any patent licenses granted to You under
83
+ this License for that Work shall terminate as of the date such
84
+ litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or in addition to the
115
+ NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the
117
+ License.
118
+
119
+ You may add Your own license statement for Your modifications and
120
+ may provide additional grant of rights to use, copy, modify, merge,
121
+ publish, distribute, sublicense, and/or sell copies of the
122
+ Contribution, either on its own behalf or on behalf of the Licensor,
123
+ and only if You accept these terms.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
126
+ any Contribution intentionally submitted for inclusion in the Work
127
+ by You to the Licensor shall be under the terms and conditions of
128
+ this License, without any additional terms or conditions.
129
+ Notwithstanding the above, nothing herein shall supersede or modify
130
+ the terms of any separate license agreement you may have executed
131
+ with Licensor regarding such Contributions.
132
+
133
+ 6. Trademarks. This License does not grant permission to use the trade
134
+ names, trademarks, service marks, or product names of the Licensor,
135
+ except as required for reasonable and customary use in describing the
136
+ origin of the Work and reproducing the content of the NOTICE file.
137
+
138
+ 7. Disclaimer of Warranty. Unless required by applicable law or
139
+ agreed to in writing, Licensor provides the Work (and each
140
+ Contributor provides its Contributions) on an "AS IS" BASIS,
141
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
142
+ implied, including, without limitation, any conditions of TITLE,
143
+ NONINFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
144
+ PURPOSE. You are solely responsible for determining the
145
+ appropriateness of using or redistributing the Work and assume any
146
+ risks associated with Your exercise of permissions under this License.
147
+
148
+ 8. Limitation of Liability. In no event and under no legal theory,
149
+ whether in tort (including negligence), contract, or otherwise,
150
+ unless required by applicable law (such as deliberate and grossly
151
+ negligent acts) or agreed to in writing, shall any Contributor be
152
+ liable to You for damages, including any direct, indirect, special,
153
+ incidental, or exemplary damages of any character arising as a
154
+ result of this License or out of the use or inability to use the
155
+ Work (even if such Contributor has been advised of the possibility
156
+ of such damages).
157
+
158
+ 9. Accepting Warranty or Additional Liability. While redistributing
159
+ the Work or Derivative Works thereof, You may choose to offer,
160
+ and charge a fee for, acceptance of support, warranty, indemnity,
161
+ or other liability obligations and/or rights consistent with this
162
+ License. However, in accepting such obligations, You may offer only
163
+ conditions consistent with this License, and charge a fee for,
164
+ such acceptance.
165
+
166
+ END OF TERMS AND CONDITIONS
167
+
168
+ Copyright 2026 gabrielgellner
169
+
170
+ Licensed under the Apache License, Version 2.0 (the "License");
171
+ you may not use this file except in compliance with the License.
172
+ You may obtain a copy of the License at
173
+
174
+ http://www.apache.org/licenses/LICENSE-2.0
175
+
176
+ Unless required by applicable law or agreed to in writing, software
177
+ distributed under the License is distributed on an "AS IS" BASIS,
178
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179
+ See the License for the specific language governing permissions and
180
+ limitations under the License.
@@ -0,0 +1,422 @@
1
+ Metadata-Version: 2.4
2
+ Name: pinaxlib
3
+ Version: 5.7.0
4
+ Summary: Queryable open data catalog engine for DCAT-AP, StatDCAT-AP, CKAN, and SDMX
5
+ Keywords: sdmx,dcat,open-data,catalog,duckdb,statistical-data,ckan
6
+ Author: gabrielgellner
7
+ Author-email: gabrielgellner <gabrielgellner@gmail.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Topic :: Database
16
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
17
+ Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
18
+ Requires-Dist: attrs>=26.1.0
19
+ Requires-Dist: duckdb>=1.1
20
+ Requires-Dist: httpx>=0.28
21
+ Requires-Dist: polars>=1.39.3
22
+ Requires-Dist: sdmxlib>=0.19,<0.20
23
+ Requires-Dist: lancedb>=0.17 ; extra == 'search'
24
+ Requires-Dist: sentence-transformers>=3.0 ; extra == 'search'
25
+ Requires-Python: >=3.13
26
+ Project-URL: Homepage, https://gitlab.com/pinax-suite/pinax
27
+ Project-URL: Repository, https://gitlab.com/pinax-suite/pinax
28
+ Project-URL: Documentation, https://pinax-suite.gitlab.io/pinax
29
+ Project-URL: Issue Tracker, https://gitlab.com/pinax-suite/pinax/-/issues
30
+ Project-URL: Changelog, https://gitlab.com/pinax-suite/pinax/-/blob/main/CHANGELOG.md
31
+ Provides-Extra: search
32
+ Description-Content-Type: text/markdown
33
+
34
+ # pinax
35
+
36
+ > **Note:** This library has been written extensively with AI assistance
37
+ > (Claude Code). Users who are not comfortable with AI-generated code should
38
+ > take that into account before adopting it.
39
+
40
+ **pinax** is a Python library for building, managing, and querying statistical
41
+ metadata catalogs. Named after "bibliographic work composed by Callimachus
42
+ (310/305–240 BCE) that is popularly considered to be the first library catalog
43
+ in the West"[Pinax](https://en.wikipedia.org/wiki/Pinakes)
44
+
45
+ Inspired by DCAT and the broader landscape of metadata standards (SDMX, DDI),
46
+ pinax provides a general-purpose engine for catalog storage, discovery, and
47
+ retrieval — designed to be embedded in ETL pipelines, data platforms, and
48
+ analytical tooling rather than used as a standalone application. It pairs
49
+ naturally with domain-specific libraries like
50
+ [sdmxlib](https://gitlab.com/pinax-suite/sdmxlib-v3) for standards-aware
51
+ workflows.
52
+
53
+ ```python
54
+ import pinax as pk
55
+ ```
56
+
57
+ ## What it does
58
+
59
+ pinax materializes remote catalog and structural metadata into a local
60
+ DuckDB database and exposes a fluent Python API for discovery queries —
61
+ filtering by publisher, theme, dimension, code, free text, or provenance lineage.
62
+
63
+ **The catalog is a materialized graph.** Rather than federated queries across
64
+ separate REST endpoints, ingest pulls the full structural model into one database.
65
+ SQL JOINs are the graph traversal. No network round-trips at query time.
66
+
67
+ ## Installation
68
+
69
+ Requires Python 3.13+. Managed with [uv](https://docs.astral.sh/uv/).
70
+
71
+ ```bash
72
+ uv add pinaxlib
73
+ # or: pip install pinaxlib
74
+ ```
75
+
76
+ The distribution is published on PyPI as `pinaxlib`; the import name remains `pinax`.
77
+
78
+ ## Quick start
79
+
80
+ ```python
81
+ import pinax as pk
82
+ import pinax.query as q
83
+ import sdmxlib as sl
84
+
85
+ # Creates my_catalog/catalog.duckdb and my_catalog/data/
86
+ with pk.CatalogStore.open_or_create("my_catalog") as store:
87
+ with sl.RestRegistry(sl.Provider.ESTAT) as reg:
88
+ reg.get(sl.Dataflow, agency="ESTAT", id="NAMA_10_GDP").resolve()
89
+ pk.ingest_sdmx(store, reg.registry)
90
+
91
+ # Catalog query — no network needed
92
+ results = (
93
+ store.query(pk.AggregateDataset)
94
+ .filter(q.has_code("geo", "DE"))
95
+ .search("GDP")
96
+ .with_facets("themes", "frequency")
97
+ .execute()
98
+ )
99
+ print(results.total, "datasets found")
100
+ print(results.facets["themes"])
101
+ ```
102
+
103
+ ## Five dataset kinds
104
+
105
+ pinax uses a discriminated union of dataset types aligned with DCAT-AP and
106
+ StatDCAT-AP:
107
+
108
+ ```python
109
+ # Generic datasets (CKAN, open portals)
110
+ pk.OpenDataset(identifier="co2-2024", title=i18n("CO2 Emissions 2024"), ...)
111
+
112
+ # Statistical tables with SDMX structure (dimensions, codelists)
113
+ pk.AggregateDataset(identifier="ESTAT:UNE_RT_M(1.0)", ..., sdmx_dataflow_urn="urn:...")
114
+
115
+ # Survey microdata with variable-level metadata
116
+ pk.MicrodataDataset(identifier="lfs-2023", ..., variables=[...])
117
+
118
+ # Spatial datasets with bounding box and CRS
119
+ pk.GeospatialDataset(identifier="boundaries-2024", ..., crs="EPSG:4326")
120
+
121
+ # Articles, reports, and analytical publications
122
+ pk.PublicationDataset(identifier="pub-71-607-x", ..., doi="10.25318/...", authors=[...])
123
+ ```
124
+
125
+ All five share the same store and query API. Use `pk.BaseDataset` as the bound
126
+ for generic code; `pk.Dataset` is a type alias for the full union.
127
+
128
+ ## Source connectors
129
+
130
+ ### SDMX (Eurostat, OECD, BIS, ABS, ...)
131
+
132
+ ```python
133
+ import sdmxlib as sl
134
+ import pinax as pk
135
+
136
+ with pk.CatalogStore("my_catalog") as store:
137
+ with sl.RestRegistry(sl.Provider.ESTAT) as reg:
138
+ for df_id in ["NAMA_10_GDP", "UNE_RT_M", "PRIC_HPI_IDX"]:
139
+ reg.get(sl.Dataflow, agency="ESTAT", id=df_id).resolve()
140
+ pk.ingest_sdmx(store, reg.registry)
141
+
142
+ # Stream observation data to Parquet, attach as Distribution
143
+ pk.ingest_data(store, reg, "ESTAT:NAMA_10_GDP(latest)", measure_dim="na_item")
144
+ ```
145
+
146
+ ### Statistics Canada
147
+
148
+ ```python
149
+ from pinax.sources.statcan import WDSClient, NDMClient
150
+
151
+ with pk.CatalogStore("statcan") as store:
152
+ with WDSClient() as wds:
153
+ pk.ingest_statcan_table(store, wds, "14100287") # Labour Force Survey
154
+
155
+ with NDMClient() as ndm:
156
+ pk.ingest_statcan_publications(store, ndm, product_type="82", limit=200)
157
+ ```
158
+
159
+ ### CKAN (open.canada.ca, data.gov, ...)
160
+
161
+ ```python
162
+ from pinax.sources.ckan import CkanClient
163
+
164
+ with pk.CatalogStore("open_canada") as store:
165
+ with CkanClient("https://open.canada.ca/data") as client:
166
+ pk.ingest_ckan(store, client, organization="statcan", rows=500)
167
+ ```
168
+
169
+ ## Scope-based graph traversal
170
+
171
+ pinax exposes a lazy, scope-based API for navigating the catalog graph.
172
+ Navigation builds scope objects without executing SQL; only terminal methods
173
+ (`.collect()`, `.count()`) hit the database.
174
+
175
+ ```python
176
+ import pinax as pk
177
+
178
+ store = pk.CatalogStore("my_catalog")
179
+
180
+ # Navigate themes — no SQL until .collect()
181
+ concepts = store.themes["statcan"].collect() # ItemList[Concept]
182
+ concept = store.themes["statcan"]["13"].collect() # Concept
183
+
184
+ # Cross-entity navigation — .datasets returns a lazy QueryBuilder
185
+ datasets = store.themes["statcan"]["13"].datasets.collect()
186
+
187
+ # Enrich with sub-traversal expressions (like Polars' pl.col())
188
+ store.themes["statcan"].enrich(
189
+ n=pk.each("datasets").count(),
190
+ has_data=pk.each("datasets").exists(),
191
+ ).collect()
192
+
193
+ # Codelist navigation — pk.urn builds URN strings for you
194
+ codes = store.codelist(pk.urn.codelist("SDMX", "CL_GEO")).collect() # ItemList[Code]
195
+ code = store.codelist(pk.urn.codelist("SDMX", "CL_GEO"))["ON"].collect() # Code
196
+
197
+ # CodelistsScope — parallel to ThemesScope, supports enrich
198
+ # Enriched output includes labels resolved via sdmx.localized_text
199
+ store.codelists.lang("en").enrich(n=pk.each("datasets").count()).collect()
200
+ # → [{"urn": "...", "label": "Geography", "n": 5}, ...]
201
+
202
+ # Filter codelists by label text (SQL-level, case-insensitive)
203
+ store.codelists.filter(text_contains="geo").enrich(n=pk.each("datasets").count()).collect()
204
+
205
+ store.codelist(urn).label("en") # quick name lookup
206
+
207
+ # Enriched per-code output includes code name labels
208
+ store.codelist(urn).lang("en").enrich(n=pk.each("datasets").count()).collect()
209
+ # → [{"code_id": "ON", "label": "Ontario", "n": 5}, ...]
210
+
211
+ # Batch label resolution — single SQL query for many codes
212
+ store.codelist(geo_urn).batch_labels(["CA", "US", "DE"])
213
+ # → {"CA": "Canada", "US": "United States", "DE": "Germany"}
214
+
215
+ # Across multiple codelists at once
216
+ store.codelists.batch_labels([(geo_urn, "CA"), (freq_urn, "A")], lang="en")
217
+ # → {(geo_urn, "CA"): "Canada", (freq_urn, "A"): "Annual"}
218
+
219
+ # Dimension traversal
220
+ dims = store.dimensions(ds).collect() # ItemList[DimensionInfo]
221
+ codelist = store.dimensions(ds)["GEO"].codelist # CodelistScope (lazy)
222
+ ```
223
+
224
+ Scope classes: `ConceptSchemesScope`, `ConceptSchemeScope`, `ThemesScope`,
225
+ `SchemeScope`, `ConceptScope`, `CodelistsScope`, `CodelistScope`, `CodeScope`,
226
+ `DimensionsScope`, `DimensionScope`.
227
+
228
+ Expression types: `pk.each("edge")` creates a context-free sub-traversal
229
+ expression. Reusable across `.enrich()`, `.filter()`, and `.sort_by()`.
230
+
231
+ ## Query API
232
+
233
+ ### Structured filters
234
+
235
+ ```python
236
+ import pinax.query as q
237
+
238
+ # Field filters (keyword arguments)
239
+ store.query(pk.AggregateDataset).filter(publisher="ESTAT", status="current").all()
240
+
241
+ # Composable filter objects
242
+ store.query(pk.AggregateDataset).filter(
243
+ q.has_code("geo", "DE"), # datasets with GEO=DE in their codelist
244
+ q.has_dimensions(["geo", "freq"]), # datasets with both GEO and FREQ dimensions
245
+ ).all()
246
+
247
+ # Distribution and service filters
248
+ store.query(pk.OpenDataset).filter(
249
+ q.distribution(format="CSV"),
250
+ q.has_service(endpoint_url="https://..."),
251
+ ).all()
252
+ ```
253
+
254
+ ### Cross-entity queries
255
+
256
+ ```python
257
+ # Agents that publish datasets with code GEO=CA
258
+ store.query(pk.Agent).filter(
259
+ q.publishes(q.has_code("geo", "CA"), kind="aggregate")
260
+ ).all()
261
+
262
+ # Data services serving aggregate datasets
263
+ store.query(pk.DataService).filter(
264
+ q.serves(kind="aggregate")
265
+ ).all()
266
+ ```
267
+
268
+ ### MAP column filters
269
+
270
+ ```python
271
+ # Spatial coverage filter
272
+ store.query(pk.BaseDataset).filter(q.has_spatial("Canada")).all()
273
+
274
+ # Keyword filter
275
+ store.query(pk.BaseDataset).filter(q.has_keyword("employment")).all()
276
+
277
+ # Title/description search (case-insensitive ILIKE)
278
+ store.query(pk.BaseDataset).filter(q.title_contains("GDP")).all()
279
+ store.query(pk.BaseDataset).filter(q.description_contains("quarterly")).all()
280
+
281
+ # Sort by multilingual title
282
+ store.query(pk.BaseDataset).sort_by("title", lang="en").all()
283
+ store.query(pk.BaseDataset).sort_by("title", lang="en", desc=True).all()
284
+ ```
285
+
286
+ ### Selective relationship loading
287
+
288
+ By default, querying a list of datasets loads all relationships (~17 queries).
289
+ Use `.include()` to declare exactly which relationships to batch-load — the rest
290
+ are set to an `UNLOADED` sentinel:
291
+
292
+ ```python
293
+ # Only load publisher and themes — 3 queries instead of ~17
294
+ results = (
295
+ store.query(pk.BaseDataset)
296
+ .filter(status="published")
297
+ .include("publisher", "themes", "keywords")
298
+ .sort_by("issued", desc=True)
299
+ .limit(20)
300
+ .all()
301
+ )
302
+
303
+ # Explicit full hydration — useful to make the cost visible at the call site
304
+ results = store.query(pk.BaseDataset).filter(...).full().all()
305
+
306
+ # get() always loads everything — no include() needed
307
+ ds = store.get(pk.AggregateDataset, "ESTAT:NAMA_10_GDP(1.0)")
308
+ ```
309
+
310
+ Unloaded fields raise `pk.NotLoadedError` on access. Use `pk.is_unloaded(value)`
311
+ to check before accessing:
312
+
313
+ ```python
314
+ ds = store.query(pk.BaseDataset).include("publisher").first()
315
+ ds.publisher.name # OK
316
+ ds.themes[0] # raises NotLoadedError: 'themes' was not loaded
317
+
318
+ if not pk.is_unloaded(ds.themes):
319
+ print(ds.themes)
320
+ ```
321
+
322
+ Valid relationship names: `publisher`, `contact_point`, `frequency`, `licence`,
323
+ `themes`, `subject`, `dataset_type`, `keywords`, `spatial_coverage`,
324
+ `distributions`, `conforms_to`, `quality_annotations`, `provenance`,
325
+ `dimension_names`, `variables`, `feature_types`, `authors`.
326
+
327
+ ### Lightweight projections
328
+
329
+ When you need just a few columns (e.g. autocomplete), projection modifiers
330
+ bypass full object reconstruction — a single SQL query:
331
+
332
+ ```python
333
+ # Row projection — .select() + .rows() returns Row objects (dict subclass)
334
+ rows = (
335
+ store.query(pk.BaseDataset)
336
+ .filter(q.title_contains("GDP"))
337
+ .sort_by("title", lang="en")
338
+ .limit(3)
339
+ .select("identifier", "title", lang="en")
340
+ .rows()
341
+ )
342
+ # → [Row({"identifier": "GDP", "title": "GDP Growth"}), ...]
343
+ rows[0].identifier # attribute-style access
344
+ rows[0]["title"] # dict-style access — both work
345
+
346
+ # Flat value projection — .scalars() + .values() returns bare values
347
+ ids = store.query(pk.BaseDataset).filter(status="current").scalars("identifier").values()
348
+ # → ["EXR", "M1", "UNEMP", ...]
349
+
350
+ # Existence check — no object reconstruction
351
+ if store.query(pk.AggregateDataset).filter(q.has_code("geo", "DE")).exists():
352
+ ...
353
+ ```
354
+
355
+ ### Full-text search and facets
356
+
357
+ ```python
358
+ # BM25 search across titles, descriptions, keywords, themes, and dimensions
359
+ results = store.search("unemployment", limit=20)
360
+
361
+ # Combined search and filter
362
+ results = (
363
+ store.query(pk.AggregateDataset)
364
+ .filter(publisher="ESTAT")
365
+ .search("labour force")
366
+ .with_facets("themes", "frequency")
367
+ .execute()
368
+ )
369
+ print(results.facets["themes"]) # {"Labour": 18, "Economy": 6, ...}
370
+
371
+ # Aggregation counts
372
+ counts = store.facets("publisher", "themes", "frequency", "status")
373
+ ```
374
+
375
+ ### Lineage and provenance (PROV-O)
376
+
377
+ ```python
378
+ # Record derivation relationships between datasets
379
+ store.add_lineage(
380
+ "lfs-microdata",
381
+ "14100287",
382
+ "aggregated_from",
383
+ activity_type="aggregation",
384
+ activity_label="LFS monthly tabulation",
385
+ confidence="asserted",
386
+ )
387
+
388
+ # Transitive upstream/downstream traversal — returns QueryBuilder for chaining
389
+ ancestors = store.dataset("14100287").upstream(depth=5).collect()
390
+ dependents = store.dataset("CL_GEO").downstream(relationship="uses_classification").collect()
391
+
392
+ # Chain additional filters after traversal
393
+ current = store.dataset("14100287").upstream().filter(status="current").collect()
394
+
395
+ # Inspect lineage records
396
+ rows = store.dataset("14100287").lineage_records(role="target", relationship="aggregated_from")
397
+ ```
398
+
399
+ ## Architecture
400
+
401
+ Three layers share one DuckDB database:
402
+
403
+ ```
404
+ Discovery layer — CatalogStore (dataset, agent, concept_scheme, concept, distribution, lineage)
405
+ Structural layer — sdmxlib tables (dataflows, dsd_components, codes, codelists)
406
+ Observation layer — Polars / Parquet (actual time-series data)
407
+ ```
408
+
409
+ pinax owns the discovery layer. sdmxlib owns the structural layer. Both write
410
+ to the same DuckDB connection — queries JOIN freely across both. Parquet files live
411
+ alongside the database and are referenced via DCAT `Distribution` records.
412
+
413
+ ## Development
414
+
415
+ ```bash
416
+ just test # unit tests
417
+ just test-integration # integration tests (no network)
418
+ just test-live # live tests against real SDMX endpoints
419
+ just lint # ruff check
420
+ just typecheck # basedpyright
421
+ just docs # local docs server
422
+ ```