Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Returns an universally unique identifier (UUID) string. The value is returned as a canonical UUID 36-character string.
Syntax
from pyspark.sql import functions as sf
sf.uuid(seed=None)
Parameters
| Parameter | Type | Description |
|---|---|---|
seed |
pyspark.sql.Column or int, optional |
Optional random number seed to use. |
Examples
Example 1: Generate UUIDs with random seed
from pyspark.sql import functions as sf
spark.range(5).select(sf.uuid()).show(truncate=False)
+------------------------------------+
|uuid() |
+------------------------------------+
|627ae05e-b319-42b5-b4e4-71c8c9754dd1|
|f781cce5-a2e2-464d-bc8b-426ff448e404|
|15e2e66e-8416-4ea2-af3c-409363408189|
|fb1d6178-7676-4791-baa9-f2ddcc494515|
|d48665e8-2657-4c6b-b7c8-8ae0cd646e41|
+------------------------------------+
Example 2: Generate UUIDs with a specified seed
from pyspark.sql import functions as sf
spark.range(0, 5, 1, 1).select(sf.uuid(seed=123)).show(truncate=False)
+------------------------------------+
|uuid() |
+------------------------------------+
|4c99192d-23d6-4d88-b814-a634398120f0|
|af506873-3c53-41e3-8354-a24856b8de8a|
|7b4b370e-e867-47e2-93c0-f6990463a12d|
|1c4d1733-ff1a-4a6c-b144-0b0345adf0d0|
|7478f235-f8bc-4112-8e59-a28f50e46890|
+------------------------------------+