Skip to content
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

[SPARK-24131][PYSPARK][Followup] Add majorMinorVersion API to PySpark for determining Spark versions #21211

Closed
wants to merge 2 commits into from

Conversation

viirya
Copy link
Member

@viirya viirya commented May 2, 2018

What changes were proposed in this pull request?

More close to Scala API behavior when can't parse input by throwing exception. Add tests.

How was this patch tested?

Added tests.

@viirya
Copy link
Member Author

viirya commented May 2, 2018

cc @jkbradley @HyukjinKwon

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

Seems fine otherwise but let me leave it to @jkbradley.

"""
m = re.search('^(\d+)\.(\d+)(\..*)?$', version)
if m is None:
raise ValueError("invalid version string: " + version)
Copy link
Member

Choose a reason for hiding this comment

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

Shall we match the message with Scala side?

        throw new IllegalArgumentException(s"Spark tried to parse '$sparkVersion' as a Spark" +
          s" version string, but it could not find the major and minor version numbers.")

Provides utility method to determine Spark versions with given input string.
"""
@staticmethod
def majorMinorVersion(version):
Copy link
Member

Choose a reason for hiding this comment

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

version -> sparkVersion.

return (int(m.group(1)), int(m.group(2)))
"""
m = re.search('^(\d+)\.(\d+)(\..*)?$', version)
if m is None:
Copy link
Member

Choose a reason for hiding this comment

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

I'd do if m is not None to match the order with Scala side.

@staticmethod
def majorMinorVersion(version):
"""
Get major and minor version numbers for given Spark version string.
Copy link
Member

Choose a reason for hiding this comment

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

   * Given a Spark version string, return the (major version number, minor version number).
   * E.g., for 2.0.1-SNAPSHOT, return (2, 0).

def test_parsing_version_string(self):
from pyspark.util import VersionUtils

(major, minor) = VersionUtils.majorMinorVersion("2.4.0")
Copy link
Member

Choose a reason for hiding this comment

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

I think we don't need this since it's tested in doctests.

@SparkQA
Copy link

SparkQA commented May 2, 2018

Test build #90030 has finished for PR 21211 at commit e4b8867.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class VersionUtils(object):

@viirya
Copy link
Member Author

viirya commented May 2, 2018 via email

@viirya
Copy link
Member Author

viirya commented May 2, 2018

@HyukjinKwon Thanks for the comments above. I think I addressed them all.

@SparkQA
Copy link

SparkQA commented May 2, 2018

Test build #90064 has finished for PR 21211 at commit d2bcfe2.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

@jkbradley, have you had a change to take a look? If there's no more comments, will just merge it in few days.

@HyukjinKwon
Copy link
Member

retest this please

@SparkQA
Copy link

SparkQA commented May 8, 2018

Test build #90348 has finished for PR 21211 at commit d2bcfe2.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

Merged to master.

@asfgit asfgit closed this in b54bbe5 May 8, 2018
@viirya
Copy link
Member Author

viirya commented May 8, 2018

Thanks @HyukjinKwon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants