pyspark.sql.DataFrame.asTable#

DataFrame.asTable()[source]#

Converts the DataFrame into a table_arg.TableArg object, which can be used as a table argument in a TVF(Table-Valued Function) including UDTF (User-Defined Table Function).

After obtaining a TableArg from a DataFrame using this method, you can specify partitioning and ordering for the table argument by calling methods such as partitionBy, orderBy, and withSinglePartition on the TableArg instance. - partitionBy: Partitions the data based on the specified columns. This method cannot be called after withSinglePartition() has been called. - orderBy: Orders the data within partitions based on the specified columns. - withSinglePartition: Indicates that the data should be treated as a single partition. This method cannot be called after partitionBy() has been called.

New in version 4.0.0.

Returns
table_arg.TableArg

A TableArg object representing a table argument.