A query builder constructs database queries by chaining composable operations such as filtering, projection, limiting, aggregation, ordering, and set operations. The resulting relational object remains reusable and acts like a table, view, or common table expression. section 6.2.2
(population_table
.filter('Population > 10000000') #1
.project("Country, Population") #2
.limit(5)
.show()
)
Filter populations above ten million, select columns, limit the result, and execute the composed query with show(). section 6.2.2
Operations do not materialize intermediate results in the relational API, so their order does not affect performance. Execution is deferred until show() is called, while the builder can still accept operations such as offset or limit. section 6.2.2
Reuse a population filter
Define over_10m once, then aggregate average population by Region and order by the result. The same relation can also support filtering, counting, intersection, or exclusion. section 6.2.2

