# SQL  and PySpark functions

1. Aggregation function
2. Window functions
3. Create /  Drop tables
4. Create / Drop database
5. Insert and modify&#x20;
6. Other Useful PySpark functions

   1. **lit**(value).alias(column\_name): 用于添加新的column到table而column的值=value 或者 value 是原来的table的某列的值， 之后再用alias重新命名
   2. **pivot**(column\_name) .count() 用于把某一列的类别值展开变成multi-onehot的形式

```
tmp.groupBy("movieId").pivot("splitted_genres").count().fillna(0).show()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wenkangwei.gitbook.io/leetcode-notes/sql/sql-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
