0
에 제공된 기본 예제를 실행하려고합니다. Apache SPARK 설명서의 부분을 리플렉션을 사용하여 유추합니다. 내가 클라우 데라 빠른 VM (CDH5)SQLContext :: IndexError가있는 Apache SPARK
내가 실행하기 위해 노력하고있어 예에서이 작업을하고 있어요
은 다음과 같습니다 :
# sc is an existing SparkContext.
from pyspark.sql import SQLContext, Row
sqlContext = SQLContext(sc)
# Load a text file and convert each line to a Row.
lines = sc.textFile("/user/cloudera/analytics/book6_sample.csv")
parts = lines.map(lambda l: l.split(","))
people = parts.map(lambda p: Row(name=p[0], age=int(p[1])))
# Infer the schema, and register the DataFrame as a table.
schemaPeople = sqlContext.createDataFrame(people)
schemaPeople.registerTempTable("people")
# SQL can be run over DataFrames that have been registered as a table.
teenagers = sqlContext.sql("SELECT name FROM people WHERE age >= 13 AND age <= 19")
# The results of SQL queries are RDDs and support all the normal RDD operations.
teenNames = teenagers.map(lambda p: "Name: " + p.name)
for teenName in teenNames.collect():
print(teenName)
내가 정확하게 코드를 실행 위와 같지만로 같이 마지막 명령 (for 루프)을 실행하면 항상 오류 IndexError : 목록 색인 범위 외 "이 표시됩니다.
입력 파일 book6_sample은 book6_sample.csv에 있습니다.
위와 같이 코드를 실행했지만 마지막 명령 (for 루프)을 실행할 때 항상 "IndexError : list index out of range"오류가 발생합니다.
어디에서 잘못 될지 알려주십시오.
미리 감사드립니다.
감사합니다, 스리랑카
sachin 이봐, 한 작품을 작동 희망 줄을 제거한다 끝에 하나 개의 빈 라인을 가지고 제안 된 변경 사항을 적용한 후. – Sri