docs/sql-data-sources-text.md
Spark SQL provides spark.read().text("file_name") to read a file or directory of text files into a Spark DataFrame, and dataframe.write().text("path") to write to a text file. When reading a text file, each line becomes each row that has string "value" column by default. The line separator can be changed as shown in the example below. The option() function can be used to customize the behavior of reading or writing, such as controlling behavior of the line separator, compression, and so on.
Data source options of text can be set via:
.option/.options methods of
DataFrameReaderDataFrameWriterDataStreamReaderDataStreamWriterOPTIONS clause at CREATE TABLE USING DATA_SOURCE