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.
Copy
Ask AI
# A basic query that filters, transforms, and sorts dataroi = movies.revenue / movies.budgetresult = movies.where( (movies.year >= 2000) & (movies.budget > 100.0)).select( movies.title, roi=roi).order_by( roi, asc=False).limit(5).collect()
# Find movies with "secret" in plotmovies.where( movies.plot.contains('secret')).collect()# Find movies with "Park" in titlemovies.where( movies.title.contains('Park')).collect()
# Sort by budget (highest first)movies.order_by( movies.budget, asc=False).collect()# Sort by year then budget (chain multiple order_by calls)movies.order_by(movies.year, asc=True).order_by(movies.budget, asc=False).collect()
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.