aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/pyspark/sql/functions.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/python/pyspark/sql/functions.py b/python/pyspark/sql/functions.py
index f9a15d4a66..bccde6083c 100644
--- a/python/pyspark/sql/functions.py
+++ b/python/pyspark/sql/functions.py
@@ -412,6 +412,30 @@ def sha2(col, numBits):
return Column(jc)
+@since(1.5)
+def shiftLeft(col, numBits):
+ """Shift the the given value numBits left.
+
+ >>> sqlContext.createDataFrame([(21,)], ['a']).select(shiftLeft('a', 1).alias('r')).collect()
+ [Row(r=42)]
+ """
+ sc = SparkContext._active_spark_context
+ jc = sc._jvm.functions.shiftLeft(_to_java_column(col), numBits)
+ return Column(jc)
+
+
+@since(1.5)
+def shiftRight(col, numBits):
+ """Shift the the given value numBits right.
+
+ >>> sqlContext.createDataFrame([(42,)], ['a']).select(shiftRight('a', 1).alias('r')).collect()
+ [Row(r=21)]
+ """
+ sc = SparkContext._active_spark_context
+ jc = sc._jvm.functions.shiftRight(_to_java_column(col), numBits)
+ return Column(jc)
+
+
@since(1.4)
def sparkPartitionId():
"""A column for partition ID of the Spark task.