Building Queries
Learn how to query and transform data in Pixeltable using where() and select()
Learn more about queries and expressions with this in-depth guide.
What are Queries?
Queries in Pixeltable allow you to filter, transform, and extract data from tables and views. Using Pixeltable’s expressive query interface, you can build powerful data pipelines without writing complex SQL or using external transformation tools.
Pixeltable queries use a fluent API design where operations can be chained together to:
- Filter rows based on specific conditions using
where()
- Select and transform columns using
select()
- Sort results with
order_by()
- Limit result sets with
limit()
- Perform aggregations and calculations
Queries don’t execute until you call collect()
, making them efficient for complex operations. You can build queries incrementally, adding conditions and transformations as needed.
Basic Filtering
This guide builds on tables created in previous sections. The movies
table from Tables
Use where()
to filter rows based on basic conditions:
title | year | budget |
---|---|---|
Titanic | 1997 | 200.0 |
Avengers: Endgame | 2019 | 356.0 |
Intermediate Queries
Advanced Queries
Text Analysis
Analyze plot text and titles:
Numeric Analysis
Budget calculations and comparisons:
Complex Filtering
Combine multiple operations:
Key Concepts
Column References
Access columns using dot notation (movies.title
).
Chaining Operations
Combine where()
, select()
, order_by()
, and limit()
in any order.
Boolean Logic
Use &
(and), |
(or), and ~
(not) for complex conditions.
Transformations
Transform data during selection with mathematical and string operations.
Build complex queries incrementally by starting with basic filters and adding operations one at a time. This makes debugging easier and helps ensure your query returns the expected results.
Was this page helpful?