![dbt_node_selector package icon](/_next/image?url=https%3A%2F%2Fcdn.wasmer.io%2FCACHE%2Fimages%2Ficon%2Fpackage%2F595a4adc-b797-4a1f-8729-880b545796ca_default_icon%2F3a64a6bdeb4f8ffd801d4e9bc7519fb0.png&w=96&q=75)
![dbt_node_selector package icon](/_next/image?url=https%3A%2F%2Fcdn.wasmer.io%2FCACHE%2Fimages%2Ficon%2Fpackage%2F595a4adc-b797-4a1f-8729-880b545796ca_default_icon%2F3a64a6bdeb4f8ffd801d4e9bc7519fb0.png&w=96&q=75)
dbt Node Selector
This library aims to solve the Node Selection problem currently solved in dbt-core in Python, written in Rust, compiled down to WASM. Many files have code links to the original implementation this was based on. The Rust implementation aims to stay fairly close to the original Python logic, in order to best position this library to be used in a production setting, maintained by core developers.
The reason this library was written was to solve a problem: the upcoming dbt Explorer (nee Docs) project will have no ability to interact with dbt at launch. In order to achieve parity with the original generated docs, we would need to support the dbt Selector logic, meaning the dbt Explorer launch required, at a minimum, a TypeScript port of today's selector logic and the longterm expectation to keep it in sync with core's definition.
There are 3 launch targets for this library: Either in the dbt Explorer frontend logic or in the Cloud Artifacts API endpoint for retrieving the DAG, and aspirationally this logic could one day replace the logic living in dbt Core for selecting nodes.
Library Structure
This library builds to WASM and uses Wasmer to generate a python and JS wrapper libraries. The dbt-node-selector.wai file specifies an interface to be used between rust and the target languages.
The *.wai
file generates the WAI Bindgen code, which is then implemented in this rust code as the Guest WASM library which will be used in a Python or JS Host library.
The core logic is broken down into Graph logic and Selector logic, where Graph logic encapsulates nodes, edges, and graph traversal, while the Selector logic encapsulates parsing a dbt selector string (Node Selector Syntax), and determining how to traverse a graph using the criteria determined from the node selector.