经过一些研究,我发现了我的问题。我的路径写得不正确。我必须使用file:/ my path而不是//我的路径。
所以这个帖子可以关闭。谢谢你的答案。
我建议仔细检查您的代码段
# Displays the content of the DataFrame to stdout df = sqlContext.createDataFrame(rdd,schema)
看起来您应首先将数据帧转换为RDD,然后使用将其映射到构造的架构中
rdd = df.rdd
我做了一个小实验。
//read csv file df = spark.read.csv('/<path_to_csv>', header=True) //casting types for specific columns because loaded data is string at it has unicode prefix df = df.select(df.<column_name>.cast('timestamp'),df.<column_name>.cast('int'),df.<column_name>.cast('int'),df.<column_name>.cast('int')) //creating dataframe using schema dt = spark.createDataFrame(df.rdd,schema) //write as parquet dt.write.parquet('/path_to_parquet_file')