Skip to content

[SPARK-31571][R] Overhaul stop/message/warning calls to be more canonical - #28365

Closed
MichaelChirico wants to merge 18 commits into
apache:masterfrom
MichaelChirico:r-stop-paste
Closed

[SPARK-31571][R] Overhaul stop/message/warning calls to be more canonical#28365
MichaelChirico wants to merge 18 commits into
apache:masterfrom
MichaelChirico:r-stop-paste

Conversation

@MichaelChirico

@MichaelChiricoMichaelChirico commented Apr 27, 2020

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Internal usages like {stop,warning,message}({paste,paste0,sprintf} and {stop,warning,message}(some_literal_string_as_variable have been removed and replaced as appropriate.

Why are the changes needed?

CRAN policy recommends against using such constructions to build error messages, in particular because it makes the process of creating portable error messages for the package more onerous.

Does this PR introduce any user-facing change?

There may be some small grammatical changes visible in error messaging.

How was this patch tested?

Not done

Comment threadR/pkg/R/DataFrame.R
specialtype <- specialtypeshandle(x)
if (is.null(specialtype)) {
stop(paste("Unsupported data type: ", x))
stop("Unsupported data type: ", x)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

here, paste was creating an extra space, now fixed

Comment threadR/pkg/R/client.R Outdated
Comment threadR/pkg/R/utils.R Outdated
Comment threadR/pkg/R/utils.R Outdated
Comment threadR/pkg/R/sparkR.R Outdated
Comment threadR/pkg/R/install.R Outdated
Comment threadR/pkg/R/install.R Outdated
Comment threadR/pkg/R/install.R
Comment threadR/pkg/R/install.R Outdated
Comment threadR/pkg/R/install.R Outdated
Comment threadR/pkg/R/SQLContext.R Outdated
Comment threadR/pkg/R/DataFrame.R Outdated
Comment threadR/pkg/R/DataFrame.R Outdated
@HyukjinKwon

Copy link
Copy Markdown
Member

add to whitelist

@HyukjinKwon

Copy link
Copy Markdown
Member

ok to test

@HyukjinKwonHyukjinKwon changed the title [SPARK-31571][R] overhaul stop/message/warning calls to be more translation-friendly/canonical[SPARK-31571][R] Overhaul stop/message/warning calls to be more translation-friendly/canonicalApr 27, 2020
@SparkQA

Copy link
Copy Markdown

Test build #121897 has finished for PR 28365 at commit 1940eb8.

  • This patch fails SparkR unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #121900 has finished for PR 28365 at commit e4b8ca9.

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

@HyukjinKwon

Copy link
Copy Markdown
Member

cc @felixcheung and @shivaram FYI

@SparkQA

Copy link
Copy Markdown

Test build #121941 has finished for PR 28365 at commit b0cf844.

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

@MichaelChirico

Copy link
Copy Markdown
ContributorAuthor

Not sure why the Documents task failed, looks like the roxygen2 part succeeded

@MichaelChirico

Copy link
Copy Markdown
ContributorAuthor

I would leave the JVM stuff to the developers working more closely with that code base. Translations only have to be updated at release time & the marginal cost from release to release would generally be low.

Anyway let's table that since you're right it's a bit premature. I'll split off the gettextf changes in a while

Comment threadR/pkg/R/DataFrame.R Outdated
"left", "leftouter", "left_outer",
"right", "rightouter", "right_outer",
"semi", "left_semi", "leftsemi", "anti", "left_anti", "leftanti")) {
"semi", "left_semi", "leftsemi", "anti", "left_anti", "leftanti")

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

noting here that i changed this error message slightly (removed the or and aligned the ordering (leftsemi/left_semi and leftanti/left_anti are swapped vis-a-vis the %in% condition).

it may be preferable to just change the test not to be so exact. LMK

@MichaelChirico

Copy link
Copy Markdown
ContributorAuthor

@HyukjinKwon have reverted all gettextf usage, please have another look

@MichaelChiricoMichaelChirico changed the title [SPARK-31571][R] Overhaul stop/message/warning calls to be more translation-friendly/canonical[SPARK-31571][R] Overhaul stop/message/warning calls to be more canonicalApr 29, 2020
@SparkQA

Copy link
Copy Markdown

Test build #122025 has finished for PR 28365 at commit 5f36b1a.

  • This patch fails SparkR unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #122031 has finished for PR 28365 at commit 4d86dc6.

  • This patch fails SparkR unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #122037 has finished for PR 28365 at commit 2c92360.

  • This patch fails SparkR unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #122040 has finished for PR 28365 at commit f278f95.

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

@srowensrowen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If it's just improving the code, seems fine.

Comment threadR/pkg/tests/fulltests/test_sparkSQL.R Outdated
@SparkQA

Copy link
Copy Markdown

Test build #122085 has finished for PR 28365 at commit 3b3c1af.

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

@HyukjinKwonHyukjinKwon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks okay but would need a closer look from me or somebody else.

Comment threadR/pkg/R/DataFrame.R Outdated
Comment threadR/pkg/R/utils.R
if (!(is.logical(value) || is.numeric(value) || is.character(value) || is.null(value))) {
stop(paste0("Unsupported type for ", name, " : ", class(value),
". Supported types are logical, numeric, character and NULL."), call. = FALSE)
stop("Unsupported type for ", name, " : ", toString(class(value)), ". ",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Quick question, why do we need to do toString? Were there any differences at stop(paste(..., ...)) vs stop(..., ...)?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

stop uses sep='', so stop(paste0(...)) is equivalent to stop(...)

toString collapses in cases length>1, compare:

stop(toString(class(Sys.time())))
stop(class(Sys.time()))

@SparkQA

Copy link
Copy Markdown

Test build #122167 has finished for PR 28365 at commit 02d1728.

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

HyukjinKwon pushed a commit that referenced this pull request May 3, 2020
…ical
### What changes were proposed in this pull request?
Internal usages like `{stop,warning,message}({paste,paste0,sprintf}` and `{stop,warning,message}(some_literal_string_as_variable` have been removed and replaced as appropriate.
### Why are the changes needed?
CRAN policy recommends against using such constructions to build error messages, in particular because it makes the process of creating portable error messages for the package more onerous.
### Does this PR introduce any user-facing change?
There may be some small grammatical changes visible in error messaging.
### How was this patch tested?
Not done
Closes#28365 from MichaelChirico/r-stop-paste.
Authored-by: Michael Chirico <michael.chirico@grabtaxi.com>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
(cherry picked from commit f53d8c6)
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
@HyukjinKwon

Copy link
Copy Markdown
Member

Merged to master and branch-3.0.

huaxingao pushed a commit to huaxingao/spark that referenced this pull request May 4, 2020
…ical
### What changes were proposed in this pull request?
Internal usages like `{stop,warning,message}({paste,paste0,sprintf}` and `{stop,warning,message}(some_literal_string_as_variable` have been removed and replaced as appropriate.
### Why are the changes needed?
CRAN policy recommends against using such constructions to build error messages, in particular because it makes the process of creating portable error messages for the package more onerous.
### Does this PR introduce any user-facing change?
There may be some small grammatical changes visible in error messaging.
### How was this patch tested?
Not done
Closesapache#28365 from MichaelChirico/r-stop-paste.
Authored-by: Michael Chirico <michael.chirico@grabtaxi.com>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@MichaelChirico@HyukjinKwon@SparkQA@srowen