concept SQL syntax in category pyspark

This is an excerpt from Manning's book Data Analysis with Python and PySpark.
The last piece of SQL syntax we will look on its own is the subquery and the common table expression. A lot of SQL references do not talk about them until very late which is a shame because they are a) easy to understand and b) are very helpful in keeping your code clean. In a nutshell, they allow to create tables that are local to your query. In Python, this would be similar to using the
withstatement or using a function block to limit the scope of a query. I will show the function approach as it is much more commonfootnote::[Thewithstatement is usually used with resources that need to be cleaned up at the end. It doesn’t really apply here, but I felt like the comparison was worth mentionning.].