-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-13792][SQL] Addendum: Fix Python API #13800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,7 +77,7 @@ def _set_json_opts(self, schema, primitivesAsString, prefersDecimal, | |
| def _set_csv_opts(self, schema, sep, encoding, quote, escape, | ||
| comment, header, inferSchema, ignoreLeadingWhiteSpace, | ||
| ignoreTrailingWhiteSpace, nullValue, nanValue, positiveInf, negativeInf, | ||
| dateFormat, maxColumns, maxCharsPerColumn, mode): | ||
| dateFormat, maxColumns, maxCharsPerColumn, maxMalformedLogPerPartition, mode): | ||
| """ | ||
| Set options based on the CSV optional parameters | ||
| """ | ||
|
|
@@ -115,6 +115,8 @@ def _set_csv_opts(self, schema, sep, encoding, quote, escape, | |
| self.option("maxColumns", maxColumns) | ||
| if maxCharsPerColumn is not None: | ||
| self.option("maxCharsPerColumn", maxCharsPerColumn) | ||
| if maxMalformedLogPerPartition is not None: | ||
| self.option("maxMalformedLogPerPartition", maxMalformedLogPerPartition) | ||
| if mode is not None: | ||
| self.option("mode", mode) | ||
|
|
||
|
|
@@ -268,10 +270,12 @@ def json(self, path, schema=None, primitivesAsString=None, prefersDecimal=None, | |
| [('age', 'bigint'), ('name', 'string')] | ||
|
|
||
| """ | ||
| self._set_json_opts(schema, primitivesAsString, prefersDecimal, | ||
| allowComments, allowUnquotedFieldNames, allowSingleQuotes, | ||
| allowNumericLeadingZero, allowBackslashEscapingAnyCharacter, | ||
| mode, columnNameOfCorruptRecord) | ||
| self._set_json_opts( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @tdas previously these options were too susceptible to positional change in the arg list. |
||
| schema=schema, primitivesAsString=primitivesAsString, prefersDecimal=prefersDecimal, | ||
| allowComments=allowComments, allowUnquotedFieldNames=allowUnquotedFieldNames, | ||
| allowSingleQuotes=allowSingleQuotes, allowNumericLeadingZero=allowNumericLeadingZero, | ||
| allowBackslashEscapingAnyCharacter=allowBackslashEscapingAnyCharacter, | ||
| mode=mode, columnNameOfCorruptRecord=columnNameOfCorruptRecord) | ||
| if isinstance(path, basestring): | ||
| path = [path] | ||
| if type(path) == list: | ||
|
|
@@ -343,7 +347,8 @@ def text(self, paths): | |
| def csv(self, path, schema=None, sep=None, encoding=None, quote=None, escape=None, | ||
| comment=None, header=None, inferSchema=None, ignoreLeadingWhiteSpace=None, | ||
| ignoreTrailingWhiteSpace=None, nullValue=None, nanValue=None, positiveInf=None, | ||
| negativeInf=None, dateFormat=None, maxColumns=None, maxCharsPerColumn=None, mode=None): | ||
| negativeInf=None, dateFormat=None, maxColumns=None, maxCharsPerColumn=None, | ||
| maxMalformedLogPerPartition=None, mode=None): | ||
| """Loads a CSV file and returns the result as a :class:`DataFrame`. | ||
|
|
||
| This function will go through the input once to determine the input schema if | ||
|
|
@@ -408,11 +413,13 @@ def csv(self, path, schema=None, sep=None, encoding=None, quote=None, escape=Non | |
| >>> df.dtypes | ||
| [('_c0', 'string'), ('_c1', 'string')] | ||
| """ | ||
|
|
||
| self._set_csv_opts(schema, sep, encoding, quote, escape, | ||
| comment, header, inferSchema, ignoreLeadingWhiteSpace, | ||
| ignoreTrailingWhiteSpace, nullValue, nanValue, positiveInf, negativeInf, | ||
| dateFormat, maxColumns, maxCharsPerColumn, mode) | ||
| self._set_csv_opts( | ||
| schema=schema, sep=sep, encoding=encoding, quote=quote, escape=escape, comment=comment, | ||
| header=header, inferSchema=inferSchema, ignoreLeadingWhiteSpace=ignoreLeadingWhiteSpace, | ||
| ignoreTrailingWhiteSpace=ignoreTrailingWhiteSpace, nullValue=nullValue, | ||
| nanValue=nanValue, positiveInf=positiveInf, negativeInf=negativeInf, | ||
| dateFormat=dateFormat, maxColumns=maxColumns, maxCharsPerColumn=maxCharsPerColumn, | ||
| maxMalformedLogPerPartition=maxMalformedLogPerPartition, mode=mode) | ||
| if isinstance(path, basestring): | ||
| path = [path] | ||
| return self._df(self._jreader.csv(self._spark._sc._jvm.PythonUtils.toSeq(path))) | ||
|
|
@@ -958,10 +965,12 @@ def json(self, path, schema=None, primitivesAsString=None, prefersDecimal=None, | |
| >>> json_sdf.schema == sdf_schema | ||
| True | ||
| """ | ||
| self._set_json_opts(schema, primitivesAsString, prefersDecimal, | ||
| allowComments, allowUnquotedFieldNames, allowSingleQuotes, | ||
| allowNumericLeadingZero, allowBackslashEscapingAnyCharacter, | ||
| mode, columnNameOfCorruptRecord) | ||
| self._set_json_opts( | ||
| schema=schema, primitivesAsString=primitivesAsString, prefersDecimal=prefersDecimal, | ||
| allowComments=allowComments, allowUnquotedFieldNames=allowUnquotedFieldNames, | ||
| allowSingleQuotes=allowSingleQuotes, allowNumericLeadingZero=allowNumericLeadingZero, | ||
| allowBackslashEscapingAnyCharacter=allowBackslashEscapingAnyCharacter, | ||
| mode=mode, columnNameOfCorruptRecord=columnNameOfCorruptRecord) | ||
| if isinstance(path, basestring): | ||
| return self._df(self._jreader.json(path)) | ||
| else: | ||
|
|
@@ -1019,7 +1028,8 @@ def text(self, path): | |
| def csv(self, path, schema=None, sep=None, encoding=None, quote=None, escape=None, | ||
| comment=None, header=None, inferSchema=None, ignoreLeadingWhiteSpace=None, | ||
| ignoreTrailingWhiteSpace=None, nullValue=None, nanValue=None, positiveInf=None, | ||
| negativeInf=None, dateFormat=None, maxColumns=None, maxCharsPerColumn=None, mode=None): | ||
| negativeInf=None, dateFormat=None, maxColumns=None, maxCharsPerColumn=None, | ||
| maxMalformedLogPerPartition=None, mode=None): | ||
| """Loads a CSV file stream and returns the result as a :class:`DataFrame`. | ||
|
|
||
| This function will go through the input once to determine the input schema if | ||
|
|
@@ -1085,11 +1095,13 @@ def csv(self, path, schema=None, sep=None, encoding=None, quote=None, escape=Non | |
| >>> csv_sdf.schema == sdf_schema | ||
| True | ||
| """ | ||
|
|
||
| self._set_csv_opts(schema, sep, encoding, quote, escape, | ||
| comment, header, inferSchema, ignoreLeadingWhiteSpace, | ||
| ignoreTrailingWhiteSpace, nullValue, nanValue, positiveInf, negativeInf, | ||
| dateFormat, maxColumns, maxCharsPerColumn, mode) | ||
| self._set_csv_opts( | ||
| schema=schema, sep=sep, encoding=encoding, quote=quote, escape=escape, comment=comment, | ||
| header=header, inferSchema=inferSchema, ignoreLeadingWhiteSpace=ignoreLeadingWhiteSpace, | ||
| ignoreTrailingWhiteSpace=ignoreTrailingWhiteSpace, nullValue=nullValue, | ||
| nanValue=nanValue, positiveInf=positiveInf, negativeInf=negativeInf, | ||
| dateFormat=dateFormat, maxColumns=maxColumns, maxCharsPerColumn=maxCharsPerColumn, | ||
| maxMalformedLogPerPartition=maxMalformedLogPerPartition, mode=mode) | ||
| if isinstance(path, basestring): | ||
| return self._df(self._jreader.csv(path)) | ||
| else: | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function could be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea. There are a bunch of things I want to do to the readwrite.py (mainly break it apart). I will do it there and merge this to unblock the rc.