Created
April 24, 2019 01:40
-
-
Save xuechendi/e426065d8c31f514c869c12772f4d67a to your computer and use it in GitHub Desktop.
Apache_Arrow_PySpark_Verification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark.sql import SparkSession | |
def plus_one_func(v): | |
return v + 1 | |
spark = SparkSession.builder.appName("pyspark_expression").getOrCreate() | |
df = spark.read.load("/HiBench/DataFrame/Input") | |
df = df.withColumn('count', plus_one(df["count"])) | |
df.write.format("parquet").save("/HiBench/DataFrame/Output") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark.sql import SparkSession | |
from pyspark.sql.functions import pandas_udf | |
from pyspark.sql.types import IntegerType | |
def plus_one_func(v): | |
return v + 1 | |
plus_one = pandas_udf(plus_one_func, returnType=IntegerType()) | |
spark = SparkSession.builder.appName("pyspark_pandas_udf").getOrCreate() | |
df = spark.read.load("/HiBench/DataFrame/Input") | |
df = df.withColumn('count', plus_one(df["count"])) | |
df.write.format("parquet").save("/HiBench/DataFrame/Output") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark.sql import SparkSession | |
from pyspark.sql.functions import udf | |
from pyspark.sql.types import IntegerType | |
def plus_one_func(v): | |
return v + 1 | |
plus_one = udf(plus_one_func, IntegerType()) | |
spark = SparkSession.builder.appName("pyspark_udf").getOrCreate() | |
df = spark.read.load("/HiBench/DataFrame/Input") | |
df = df.withColumn('count', plus_one(df["count"])) | |
df.write.format("parquet").save("/HiBench/DataFrame/Output") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment