Skip to content

Commit cfd91e6

Browse files
author
Davies Liu
committed
add more version for DataFrame API
1 parent 600834d commit cfd91e6

File tree

6 files changed

+89
-1
lines changed

6 files changed

+89
-1
lines changed

python/pyspark/sql/column.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def __init__(self, jc):
162162
bitwiseAND = _bin_op("bitwiseAND")
163163
bitwiseXOR = _bin_op("bitwiseXOR")
164164

165+
@since(1.3)
165166
def getItem(self, key):
166167
"""An expression that gets an item at position `ordinal` out of a list,
167168
or gets an item by key out of a dict.
@@ -182,6 +183,7 @@ def getItem(self, key):
182183
"""
183184
return self[key]
184185

186+
@since(1.3)
185187
def getField(self, name):
186188
"""An expression that gets a field by name in a StructField.
187189
@@ -214,6 +216,7 @@ def __getattr__(self, item):
214216
endswith = _bin_op("endsWith")
215217

216218
@ignore_unicode_prefix
219+
@since(1.3)
217220
def substr(self, startPos, length):
218221
"""
219222
Return a :class:`Column` which is a substring of the column
@@ -237,6 +240,7 @@ def substr(self, startPos, length):
237240
__getslice__ = substr
238241

239242
@ignore_unicode_prefix
243+
@since(1.3)
240244
def inSet(self, *cols):
241245
""" A boolean expression that is evaluated to true if the value of this
242246
expression is contained by the evaluated values of the arguments.
@@ -262,6 +266,7 @@ def inSet(self, *cols):
262266
isNull = _unary_op("isNull", "True if the current expression is null.")
263267
isNotNull = _unary_op("isNotNull", "True if the current expression is not null.")
264268

269+
@since(1.3)
265270
def alias(self, *alias):
266271
"""Returns this column aliased with a new name or names (in the case of expressions that
267272
return more than one column, such as explode).
@@ -277,6 +282,7 @@ def alias(self, *alias):
277282
return Column(getattr(self._jc, "as")(_to_seq(sc, list(alias))))
278283

279284
@ignore_unicode_prefix
285+
@since(1.3)
280286
def cast(self, dataType):
281287
""" Convert the column into type `dataType`
282288
@@ -297,6 +303,7 @@ def cast(self, dataType):
297303
return Column(jc)
298304

299305
@ignore_unicode_prefix
306+
@since(1.3)
300307
def between(self, lowerBound, upperBound):
301308
""" A boolean expression that is evaluated to true if the value of this
302309
expression is between the given columns.

python/pyspark/sql/context.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def getConf(self, key, defaultValue):
122122
return self._ssql_ctx.getConf(key, defaultValue)
123123

124124
@property
125-
@since(1.3)
125+
@since("1.3.1")
126126
def udf(self):
127127
"""Returns a :class:`UDFRegistration` for UDF registration."""
128128
return UDFRegistration(self)
@@ -149,6 +149,7 @@ def range(self, start, end, step=1, numPartitions=None):
149149
return DataFrame(jdf, self)
150150

151151
@ignore_unicode_prefix
152+
@since(1.2)
152153
def registerFunction(self, name, f, returnType=StringType()):
153154
"""Registers a lambda function as a UDF so it can be used in SQL statements.
154155
@@ -358,6 +359,7 @@ def registerDataFrameAsTable(self, df, tableName):
358359
else:
359360
raise ValueError("Can only register DataFrame as table")
360361

362+
@since(1.0)
361363
def parquetFile(self, *paths):
362364
"""Loads a Parquet file, returning the result as a :class:`DataFrame`.
363365
@@ -376,6 +378,7 @@ def parquetFile(self, *paths):
376378
jdf = self._ssql_ctx.parquetFile(jpaths)
377379
return DataFrame(jdf, self)
378380

381+
@since(1.0)
379382
def jsonFile(self, path, schema=None, samplingRatio=1.0):
380383
"""Loads a text file storing one JSON object per line as a :class:`DataFrame`.
381384
@@ -416,6 +419,7 @@ def jsonFile(self, path, schema=None, samplingRatio=1.0):
416419
return DataFrame(df, self)
417420

418421
@ignore_unicode_prefix
422+
@since(1.0)
419423
def jsonRDD(self, rdd, schema=None, samplingRatio=1.0):
420424
"""Loads an RDD storing one JSON object per string as a :class:`DataFrame`.
421425
@@ -500,6 +504,7 @@ def createExternalTable(self, tableName, path=None, source=None,
500504
return DataFrame(df, self)
501505

502506
@ignore_unicode_prefix
507+
@since(1.0)
503508
def sql(self, sqlQuery):
504509
"""Returns a :class:`DataFrame` representing the result of the given query.
505510
@@ -510,6 +515,7 @@ def sql(self, sqlQuery):
510515
"""
511516
return DataFrame(self._ssql_ctx.sql(sqlQuery), self)
512517

518+
@since(1.0)
513519
def table(self, tableName):
514520
"""Returns the specified table as a :class:`DataFrame`.
515521
@@ -557,10 +563,12 @@ def tableNames(self, dbName=None):
557563
else:
558564
return [name for name in self._ssql_ctx.tableNames(dbName)]
559565

566+
@since(1.0)
560567
def cacheTable(self, tableName):
561568
"""Caches the specified table in-memory."""
562569
self._ssql_ctx.cacheTable(tableName)
563570

571+
@since(1.0)
564572
def uncacheTable(self, tableName):
565573
"""Removes the specified table from the in-memory cache."""
566574
self._ssql_ctx.uncacheTable(tableName)

0 commit comments

Comments
 (0)