Skip to content

Commit 3e53f91

Browse files
committed
Fixed Python.
1 parent 83735da commit 3e53f91

File tree

1 file changed

+8
-32
lines changed

1 file changed

+8
-32
lines changed

python/pyspark/sql.py

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ def applySchema(self, rdd, schema):
14581458

14591459
jrdd = self._jvm.SerDeUtil.toJavaArray(rdd._to_java_object_rdd())
14601460
srdd = self._ssql_ctx.applySchemaToPythonRDD(jrdd.rdd(), schema.json())
1461-
return SchemaRDD(srdd.toJavaSchemaRDD(), self)
1461+
return SchemaRDD(srdd, self)
14621462

14631463
def registerRDDAsTable(self, rdd, tableName):
14641464
"""Registers the given RDD as a temporary table in the catalog.
@@ -1487,7 +1487,7 @@ def parquetFile(self, path):
14871487
>>> sorted(srdd.collect()) == sorted(srdd2.collect())
14881488
True
14891489
"""
1490-
jschema_rdd = self._ssql_ctx.parquetFile(path).toJavaSchemaRDD()
1490+
jschema_rdd = self._ssql_ctx.parquetFile(path)
14911491
return SchemaRDD(jschema_rdd, self)
14921492

14931493
def jsonFile(self, path, schema=None, samplingRatio=1.0):
@@ -1549,7 +1549,7 @@ def jsonFile(self, path, schema=None, samplingRatio=1.0):
15491549
else:
15501550
scala_datatype = self._ssql_ctx.parseDataType(schema.json())
15511551
srdd = self._ssql_ctx.jsonFile(path, scala_datatype)
1552-
return SchemaRDD(srdd.toJavaSchemaRDD(), self)
1552+
return SchemaRDD(srdd, self)
15531553

15541554
def jsonRDD(self, rdd, schema=None, samplingRatio=1.0):
15551555
"""Loads an RDD storing one JSON object per string as a L{SchemaRDD}.
@@ -1619,7 +1619,7 @@ def func(iterator):
16191619
else:
16201620
scala_datatype = self._ssql_ctx.parseDataType(schema.json())
16211621
srdd = self._ssql_ctx.jsonRDD(jrdd.rdd(), scala_datatype)
1622-
return SchemaRDD(srdd.toJavaSchemaRDD(), self)
1622+
return SchemaRDD(srdd, self)
16231623

16241624
def sql(self, sqlQuery):
16251625
"""Return a L{SchemaRDD} representing the result of the given query.
@@ -1630,7 +1630,7 @@ def sql(self, sqlQuery):
16301630
>>> srdd2.collect()
16311631
[Row(f1=1, f2=u'row1'), Row(f1=2, f2=u'row2'), Row(f1=3, f2=u'row3')]
16321632
"""
1633-
return SchemaRDD(self._ssql_ctx.sql(sqlQuery).toJavaSchemaRDD(), self)
1633+
return SchemaRDD(self._ssql_ctx.sql(sqlQuery), self)
16341634

16351635
def table(self, tableName):
16361636
"""Returns the specified table as a L{SchemaRDD}.
@@ -1641,7 +1641,7 @@ def table(self, tableName):
16411641
>>> sorted(srdd.collect()) == sorted(srdd2.collect())
16421642
True
16431643
"""
1644-
return SchemaRDD(self._ssql_ctx.table(tableName).toJavaSchemaRDD(), self)
1644+
return SchemaRDD(self._ssql_ctx.table(tableName), self)
16451645

16461646
def cacheTable(self, tableName):
16471647
"""Caches the specified table in-memory."""
@@ -1686,24 +1686,6 @@ def _ssql_ctx(self):
16861686
def _get_hive_ctx(self):
16871687
return self._jvm.HiveContext(self._jsc.sc())
16881688

1689-
def hiveql(self, hqlQuery):
1690-
"""
1691-
DEPRECATED: Use sql()
1692-
"""
1693-
warnings.warn("hiveql() is deprecated as the sql function now parses using HiveQL by" +
1694-
"default. The SQL dialect for parsing can be set using 'spark.sql.dialect'",
1695-
DeprecationWarning)
1696-
return SchemaRDD(self._ssql_ctx.hiveql(hqlQuery).toJavaSchemaRDD(), self)
1697-
1698-
def hql(self, hqlQuery):
1699-
"""
1700-
DEPRECATED: Use sql()
1701-
"""
1702-
warnings.warn("hql() is deprecated as the sql function now parses using HiveQL by" +
1703-
"default. The SQL dialect for parsing can be set using 'spark.sql.dialect'",
1704-
DeprecationWarning)
1705-
return self.hiveql(hqlQuery)
1706-
17071689

17081690
class LocalHiveContext(HiveContext):
17091691

@@ -1716,12 +1698,6 @@ def _get_hive_ctx(self):
17161698
return self._jvm.LocalHiveContext(self._jsc.sc())
17171699

17181700

1719-
class TestHiveContext(HiveContext):
1720-
1721-
def _get_hive_ctx(self):
1722-
return self._jvm.TestHiveContext(self._jsc.sc())
1723-
1724-
17251701
def _create_row(fields, values):
17261702
row = Row(*values)
17271703
row.__FIELDS__ = fields
@@ -1846,7 +1822,7 @@ def __init__(self, jschema_rdd, sql_ctx):
18461822
self.sql_ctx = sql_ctx
18471823
self._sc = sql_ctx._sc
18481824
clsName = jschema_rdd.getClass().getName()
1849-
assert clsName.endswith("JavaSchemaRDD"), "jschema_rdd must be JavaSchemaRDD"
1825+
assert clsName.endswith("SchemaRDD"), "jschema_rdd must be SchemaRDD"
18501826
self._jschema_rdd = jschema_rdd
18511827
self._id = None
18521828
self.is_cached = False
@@ -1880,7 +1856,7 @@ def limit(self, num):
18801856
>>> srdd.limit(0).collect()
18811857
[]
18821858
"""
1883-
rdd = self._jschema_rdd.baseSchemaRDD().limit(num).toJavaSchemaRDD()
1859+
rdd = self._jschema_rdd.baseSchemaRDD().limit(num)
18841860
return SchemaRDD(rdd, self.sql_ctx)
18851861

18861862
def toJSON(self, use_unicode=False):

0 commit comments

Comments
 (0)