Description Details Public fields Methods Examples
This class was designed as a thin wrapper around Spark's
SparkSession
. It is initialized when spark_submit
is called.
Note, running. sc$stop
will end your session. For information on
methods and types requirements, refer to the Javadoc:
https://spark.apache.org/docs/2.3.0/api/java/org/apache/spark/sql/SparkSession.html
Not all methods are implemented due to compatability
and tidyspark best practice usage conflicts. If you need to use a method not
included, try calling it using call_method(sc$jobj, <yourMethod>)
.
jobj
SparkSession
java object
conf
get the RuntimeConfig
sparkContext
the sparkContext associated with the session
new()
Create a new SparkSession
SparkSession$new(session_jobj)
session_jobj
the session's jobj
print()
print SparkSession
SparkSession$print()
close()
Stop the underlying SparkContext.
SparkSession$close()
emptyDataFrame()
Returns a DataFrame with no rows or columns. Range
SparkSession$emptyDataFrame()
range()
Creates a Dataset with a single LongType column named id, containing elements in a range from start to end (exclusive) with a step value, with partition number specified.
SparkSession$range(start = 0, end, step = NULL, numPartitions = NULL)
start
integer, starting value
end
integer, ending value
step
integer, the number of steps
numPartitions
integer, the target number of partitions
a spark_tbl
SQL
sql()
Executes a SQL query using Spark, returning the result as a DataFrame. The dialect that is used for SQL parsing can be configured with 'spark.sql.dialect'.
SparkSession$sql(sqlText)
sqlText
string, a SQL query
Table
table()
Returns the specified table/view as a DataFrame.
SparkSession$table(tableName)
tableName
is either a qualified or unqualified name that designates a table or view. If a database is specified, it identifies the table/view from the database. Otherwise, it first attempts to find a temporary view with the given name and then match the table/view from the current database. Note that, the global temporary view database is also valid here.
a spark_tbl
Version
version()
The version of Spark on which this application is running.
SparkSession$version()
clone()
The objects of this class are cloneable with this method.
SparkSession$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 4 5 6 7 8 9 | ## Not run:
spark <- spark_session()
rdd <- spark$range(1, 10)
rdd$collect()
spark_session_stop()
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.