TextSocketSourceProvider¶
TextSocketSourceProvider is a StreamSourceProvider for Text Socket Data Source.
TextSocketSourceProvider requires two options (that you can set using option method):
hostwhich is the host name.portwhich is the port number. It must be an integer.
TextSocketSourceProvider also supports <
DataSourceRegister¶
TextSocketSourceProvider is a DataSourceRegister with the short name of socket.
includeTimestamp Option¶
createSource¶
createSource creates a TextSocketSource (with the host and port).
sourceSchema¶
sourceSchema returns textSocket as the name of the source and the schema that can be one of the two available schemas:
-
SCHEMA_REGULAR(default) which is a schema with a singlevaluefield of String type. -
SCHEMA_TIMESTAMPwhen<<includeTimestamp, includeTimestamp>>flag option is set. It is not, i.e.false, by default. The schema arevaluefield ofStringTypetype andtimestampfield of spark-sql-DataType.md#TimestampType[TimestampType] type of formatyyyy-MM-dd HH:mm:ss.
TIP: Read about spark-sql-schema.md[schema].
Internally, it starts by printing out the following WARN message to the logs:
The socket source should not be used for production applications! It does not support recovery and stores state indefinitely.
It then checks whether host and port parameters are defined and if not it throws a AnalysisException:
Set a host to read from with option("host", ...).