Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/src/main/python/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

# A JSON dataset is pointed to by path.
# The path can be either a single text file or a directory storing text files.
path = os.environ['SPARK_HOME'] + "examples/src/main/resources/people.json"
path = os.path.join(os.environ['SPARK_HOME'], "examples/src/main/resources/people.json")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it maybe simpler to just add a / ? This makes it look like the path is platform independent but it isn't as the following path always has /

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just trying to make this consistent with other code in python/pyspark/**.py. It is OK if you believe add a '/' is better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency is good too. Leave it unless someone else thinks it should change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the os.path.join is fine; I think it's more clear / less brittle. If it turns out that we do need to make changes to the path separator in order to support Windows, then using os.path.join makes it easier to spot where path construction is taking place in order to find the code that needs to be changed.

# Create a SchemaRDD from the file(s) pointed to by path
people = sqlContext.jsonFile(path)
# root
Expand Down