@@ -274,33 +274,6 @@ def _inferSchema(self, rdd, samplingRatio=None):
274274 schema = rdd .map (_infer_schema ).reduce (_merge_type )
275275 return schema
276276
277- @ignore_unicode_prefix
278- def inferSchema (self , rdd , samplingRatio = None ):
279- """
280- .. note:: Deprecated in 1.3, use :func:`createDataFrame` instead.
281- """
282- warnings .warn ("inferSchema is deprecated, please use createDataFrame instead." )
283-
284- if isinstance (rdd , DataFrame ):
285- raise TypeError ("Cannot apply schema to DataFrame" )
286-
287- return self .createDataFrame (rdd , None , samplingRatio )
288-
289- @ignore_unicode_prefix
290- def applySchema (self , rdd , schema ):
291- """
292- .. note:: Deprecated in 1.3, use :func:`createDataFrame` instead.
293- """
294- warnings .warn ("applySchema is deprecated, please use createDataFrame instead" )
295-
296- if isinstance (rdd , DataFrame ):
297- raise TypeError ("Cannot apply schema to DataFrame" )
298-
299- if not isinstance (schema , StructType ):
300- raise TypeError ("schema should be StructType, but got %s" % type (schema ))
301-
302- return self .createDataFrame (rdd , schema )
303-
304277 def _createFromRDD (self , rdd , schema , samplingRatio ):
305278 """
306279 Create an RDD for DataFrame from an existing RDD, returns the RDD and schema.
@@ -450,90 +423,6 @@ def dropTempTable(self, tableName):
450423 """
451424 self ._ssql_ctx .dropTempTable (tableName )
452425
453- def parquetFile (self , * paths ):
454- """Loads a Parquet file, returning the result as a :class:`DataFrame`.
455-
456- .. note:: Deprecated in 1.4, use :func:`DataFrameReader.parquet` instead.
457-
458- >>> sqlContext.parquetFile('python/test_support/sql/parquet_partitioned').dtypes
459- [('name', 'string'), ('year', 'int'), ('month', 'int'), ('day', 'int')]
460- """
461- warnings .warn ("parquetFile is deprecated. Use read.parquet() instead." )
462- gateway = self ._sc ._gateway
463- jpaths = gateway .new_array (gateway .jvm .java .lang .String , len (paths ))
464- for i in range (0 , len (paths )):
465- jpaths [i ] = paths [i ]
466- jdf = self ._ssql_ctx .parquetFile (jpaths )
467- return DataFrame (jdf , self )
468-
469- def jsonFile (self , path , schema = None , samplingRatio = 1.0 ):
470- """Loads a text file storing one JSON object per line as a :class:`DataFrame`.
471-
472- .. note:: Deprecated in 1.4, use :func:`DataFrameReader.json` instead.
473-
474- >>> sqlContext.jsonFile('python/test_support/sql/people.json').dtypes
475- [('age', 'bigint'), ('name', 'string')]
476- """
477- warnings .warn ("jsonFile is deprecated. Use read.json() instead." )
478- if schema is None :
479- df = self ._ssql_ctx .jsonFile (path , samplingRatio )
480- else :
481- scala_datatype = self ._ssql_ctx .parseDataType (schema .json ())
482- df = self ._ssql_ctx .jsonFile (path , scala_datatype )
483- return DataFrame (df , self )
484-
485- @ignore_unicode_prefix
486- @since (1.0 )
487- def jsonRDD (self , rdd , schema = None , samplingRatio = 1.0 ):
488- """Loads an RDD storing one JSON object per string as a :class:`DataFrame`.
489-
490- If the schema is provided, applies the given schema to this JSON dataset.
491- Otherwise, it samples the dataset with ratio ``samplingRatio`` to determine the schema.
492-
493- >>> df1 = sqlContext.jsonRDD(json)
494- >>> df1.first()
495- Row(field1=1, field2=u'row1', field3=Row(field4=11, field5=None), field6=None)
496-
497- >>> df2 = sqlContext.jsonRDD(json, df1.schema)
498- >>> df2.first()
499- Row(field1=1, field2=u'row1', field3=Row(field4=11, field5=None), field6=None)
500-
501- >>> from pyspark.sql.types import *
502- >>> schema = StructType([
503- ... StructField("field2", StringType()),
504- ... StructField("field3",
505- ... StructType([StructField("field5", ArrayType(IntegerType()))]))
506- ... ])
507- >>> df3 = sqlContext.jsonRDD(json, schema)
508- >>> df3.first()
509- Row(field2=u'row1', field3=Row(field5=None))
510- """
511-
512- def func (iterator ):
513- for x in iterator :
514- if not isinstance (x , basestring ):
515- x = unicode (x )
516- if isinstance (x , unicode ):
517- x = x .encode ("utf-8" )
518- yield x
519- keyed = rdd .mapPartitions (func )
520- keyed ._bypass_serializer = True
521- jrdd = keyed ._jrdd .map (self ._jvm .BytesToString ())
522- if schema is None :
523- df = self ._ssql_ctx .jsonRDD (jrdd .rdd (), samplingRatio )
524- else :
525- scala_datatype = self ._ssql_ctx .parseDataType (schema .json ())
526- df = self ._ssql_ctx .jsonRDD (jrdd .rdd (), scala_datatype )
527- return DataFrame (df , self )
528-
529- def load (self , path = None , source = None , schema = None , ** options ):
530- """Returns the dataset in a data source as a :class:`DataFrame`.
531-
532- .. note:: Deprecated in 1.4, use :func:`DataFrameReader.load` instead.
533- """
534- warnings .warn ("load is deprecated. Use read.load() instead." )
535- return self .read .load (path , source , schema , ** options )
536-
537426 @since (1.3 )
538427 def createExternalTable (self , tableName , path = None , source = None , schema = None , ** options ):
539428 """Creates an external table based on the dataset in a data source.
0 commit comments