Inspect an expression’s kind, backends, sources, tags, and caches through expr.ls
Every Xorq expression has an ls attribute. It returns a read-only accessor bound to the expression’s root operation, and it’s how you ask what an expression is built from: which backends it touches, which tables and files it reads, which tags it carries, and which caches it holds.
Kind, backends, and sources
import xorq.api as xoddb = xo.duckdb.connect()penguins = xo.examples.penguins.fetch(backend=ddb)expr = penguins.filter(xo._.year ==2008)print(penguins.ls.kind, expr.ls.kind)print(expr.ls.backends == (ddb,))print([type(dt).__name__for dt in expr.ls.dts])print(len(expr.ls.reads))
source expr
True
['Read']
1
kind is source for a leaf, expr for a bound expression with transforms, and unbound_expr for an expression built on xo.table(schema=...). A catalog composition reports composed and an expression wrapped by a registered builder reports expr_builder. See Expression types.
Moving part of a pipeline to a second engine makes it multi-engine:
is_cached looks at the root only; has_cached and cached_nodes look at the whole graph. cache is None unless the root is cached, and cache_exists() is None in that case too.
pin() replaces each cache with a direct read of its stored result; unpin() restores it. A pinned expression no longer counts as cached:
ExprKind: source, expr, unbound_expr, composed, or expr_builder
backends
Distinct backend connections in the graph
is_multiengine
True when backends has more than one entry
dts
Database tables, SQL query results, and reads, excluding cache and remote-table nodes
reads
Deferred Read nodes
tags
All Tag nodes, outermost first
get_tags(predicate)
Tag nodes whose metadata satisfies predicate
untagged
The expression with non-hashing tags removed
builder
The domain object recovered from the outermost registered tag, see ADR 0005
pipeline, pipelines
Unfitted Xorq Pipeline objects rebuilt from the step definitions a fitted pipeline leaves in its tags; pipeline takes the outermost and raises ValueError when there is none
is_cached
Whether the root is a CachedNode
has_cached
Whether any CachedNode is in the graph
cached_nodes
All CachedNode operations, outermost first
cache
The root’s cache object, or None
caches
The cache object of every CachedNode
cache_exists()
Whether the root cache is materialized, None when not cached
cache_path, get_cache_paths()
Storage paths for caches that write files
get_key(), get_keys()
Cache keys for the root or for every cache
uncached
The expression with every cache removed
pin(ensure_materialized=False), unpin()
Freeze caches into direct reads and back
fused
A catalog-composed expression with its catalog wrappers removed so it runs as one query
tokenized
The hex token the modification-time cache strategy keys on, see ADR 0015