獸人(DataFrameWriter)

以 ORC 格式儲存在 DataFrame 指定路徑上的內容。

語法

orc(path, mode=None, partitionBy=None, compression=None)

參數

參數 類型 說明
path str 任何支援 Hadoop 的檔案系統中的路徑。
mode 力量,選用 當資料已經存在時的行為。 接受的值為 'append''overwrite''ignore''error''errorifexists' (預設值)。
partitionBy 力量或列表,選擇性 分割欄位名稱。
compression 力量,選用 要用壓縮編碼器。

退貨

沒有

Examples

將 DataFrame 寫入 ORC 檔案並讀取。

import tempfile
with tempfile.TemporaryDirectory(prefix="orc") as d:
    spark.createDataFrame(
        [{"age": 100, "name": "Alice"}]
    ).write.orc(d, mode="overwrite")

    spark.read.format("orc").load(d).show()
    # +---+------------+
    # |age|        name|
    # +---+------------+
    # |100|Alice|
    # +---+------------+