This is a post to summarize some basic operations for PySpark.

First, we introduce Apache Zeppelin, this is a web-based notebook that acts as a Spark shell.

A sample is like this:

print('Hello Zeppelin')
from pyspark import HiveContext

# Show databases
spark.sql("show databases").collect()
spark.sql("use dw")

# Show tables
spark.sql("show tables").collect()

# Read Hive table as a DataFrame object
hc_rdd = HiveContext(sc).sql('from table_name select * where dt = get_date(-1) limit 100')

# Read a column from a DataFrame
target_id_col ="target_id")

Note that due to storage mechanism, operations on RDD is not like that for other Python objects. So far as I know, training phase is usually completed offline in Python but not online using Spark. Maybe I can have better idea on this when I learn more.