Created
October 1, 2020 03:17
-
-
Save welly87/2c9778b0946181f17b58d03934489f62 to your computer and use it in GitHub Desktop.
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
? |
Author
welly87
commented
Oct 1, 2020
check spark version
!spark-3.0.1-bin-hadoop2.7/bin/spark-shell -version
import findspark
findspark.init("spark-3.0.1-bin-hadoop2.7")
from pyspark.sql import SparkSession
spark = SparkSession \
.builder \
.appName("Python Spark SQL basic example") \
.config("spark.some.config.option", "some-value") \
.getOrCreate()
sdf = spark.read.csv("/content/sample_data/california_housing_train.csv", header=True)
pdf = sdf.select("*").toPandas()
sdf.createOrReplaceTempView("california_housing")
sqlDF = spark.sql("SELECT sum(population) FROM california_housing WHERE total_rooms > 1000")
sqlDF.head()
!apt-get install openjdk-8-jdk-headless -qq > /dev/null
!wget -q https://downloads.apache.org/spark/spark-2.4.7/spark-2.4.7-bin-hadoop2.7.tgz
!tar xf spark-2.4.7-bin-hadoop2.7.tgz
!pip install -q findspark
!pip install -q pyarrow
!rm -rf *.tgz
!rm -rf spark-3.0.1-bin-hadoop2.7/
!wget https://github.com/welly87/spark-load/raw/master/mysql-connector-java-8.0.14.jar
!mv /content/mysql-connector-java-8.0.14.jar /content/spark-2.4.7-bin-hadoop2.7/jars/mysql-connector-java-8.0.14.jar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment