Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions python/pyspark/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SQLContext:
register L{SchemaRDD}s as tables, execute sql over tables, cache tables, and read parquet files.
"""

def __init__(self, sparkContext):
def __init__(self, sparkContext, sqlContext = None):
"""
Create a new SQLContext.

Expand Down Expand Up @@ -58,10 +58,13 @@ def __init__(self, sparkContext):
self._jvm = self._sc._jvm
self._pythonToJavaMap = self._jvm.PythonRDD.pythonToJavaMap

if sqlContext:
self._scala_SQLContext = sqlContext

@property
def _ssql_ctx(self):
"""
Accessor for the JVM SparkSQL context. Subclasses can overrite this property to provide
Accessor for the JVM SparkSQL context. Subclasses can override this property to provide
their own JVM Contexts.
"""
if not hasattr(self, '_scala_SQLContext'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import org.apache.spark.util.Utils
/**
* The entry point for executing Spark SQL queries from a Java program.
*/
class JavaSQLContext(sparkContext: JavaSparkContext) {
class JavaSQLContext(val sqlContext: SQLContext) {

val sqlContext = new SQLContext(sparkContext.sc)
def this(sparkContext: JavaSparkContext) = this(new SQLContext(sparkContext.sc))

/**
* Executes a query expressed in SQL, returning the result as a JavaSchemaRDD
Expand Down