Skip to content

ARROW-15659 [R] strptime should return NA (not error) with format mismatch - #12402

Closed
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error
Closed

ARROW-15659 [R] strptime should return NA (not error) with format mismatch#12402
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error

Conversation

@dragosmg

@dragosmgdragosmg commented Feb 11, 2022

Copy link
Copy Markdown
Contributor

This PR aligns arrow's binding to strptime() to base::strptime() when the value passed to the format argument does not match the data. Currently arrow errors, when it should return NA.

library(lubridate)
library(arrow)
library(dplyr)
df<- tibble(x="2022-02-11")
df %>% mutate(z= strptime(x, format="%Y-%m %d"))
#> # A tibble: 1 × 2#> x z #> <chr> <dttm>#> 1 2022-02-11 NAdf %>% record_batch() %>% mutate(z= strptime(x, format="%Y-%m %d")) %>% collect()
#> Error: Invalid: Failed to parse string: '2022-02-11' as a scalar of type timestamp[ms]

Created on 2022-02-11 by the reprex package (v2.0.1)

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

⚠️ Ticket has not been started in JIRA, please click 'Start Progress'.

@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 7a2700d to d7fefa7CompareMarch 24, 2022 16:00
@dragosmg

dragosmg commented Mar 25, 2022

Copy link
Copy Markdown
ContributorAuthor

I think several things are needed:

  • new unit tests to show similar behaviour (returning NA in the same circumstances)
  • update existing unit tests. These are not using compare_dplyr_binding() and are not catching the fact that Arrow's strptime binding returns an object of a different class (POSIXct, a double vector) that base::strptime() (POSIXlt, a list)

waldo::compare() does ignore class when ignore_attr = TRUE, but it can't ignore typeof. I'm not sure we want to change the type of object Arrow's strptime binding returns.

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

@jonkeane

Copy link
Copy Markdown
Member

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

There are a few comments about this in the tests that reference this — I don't think it was unknown. POSIXlt is pretty unique to R (I'm sure there were other languages that have similar types), but they aren't super wide-spread, and Arrow doesn't support them directly (though you can see in the R package we make a (pseudo)-extension class for them).

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

This needs a rebase once #12732 gets merged.

Comment threadr/R/dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 0a1b35f to 727efbdCompareMarch 29, 2022 09:24
@dragosmg
dragosmg marked this pull request as ready for review March 29, 2022 12:21

@jonkeanejonkeane 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.

A few questions about the tests

Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmg requested a review from jonkeaneMarch 29, 2022 19:52
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 25863ef to f669be7CompareMarch 30, 2022 11:33
@ursabot

ursabot commented Mar 30, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 64560af and contender = ba04e7f. ba04e7f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.04%] test-mac-arm
[Failed ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.04% ⬆️0.0%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/419|ba04e7f8 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/405|ba04e7f8 test-mac-arm>
[Failed] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/405|ba04e7f8 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/415|ba04e7f8 ursa-thinkcentre-m75q>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/418|64560af6 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/404|64560af6 test-mac-arm>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/404|64560af6 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/414|64560af6 ursa-thinkcentre-m75q>
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@dragosmg
dragosmg deleted the strptime_return_na_vs_error branch April 26, 2022 09:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@dragosmg@jonkeane@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
ARROW-15659 [R] strptime should return NA (not error) with format mismatch by dragosmg · Pull Request #12402 · apache/arrow · GitHub
Skip to content

ARROW-15659 [R] strptime should return NA (not error) with format mismatch - #12402

Closed
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error
Closed

ARROW-15659 [R] strptime should return NA (not error) with format mismatch#12402
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error

Conversation

@dragosmg

@dragosmgdragosmg commented Feb 11, 2022

Copy link
Copy Markdown
Contributor

This PR aligns arrow's binding to strptime() to base::strptime() when the value passed to the format argument does not match the data. Currently arrow errors, when it should return NA.

library(lubridate)
library(arrow)
library(dplyr)
df<- tibble(x="2022-02-11")
df %>% mutate(z= strptime(x, format="%Y-%m %d"))
#> # A tibble: 1 × 2#> x z #> <chr> <dttm>#> 1 2022-02-11 NAdf %>% record_batch() %>% mutate(z= strptime(x, format="%Y-%m %d")) %>% collect()
#> Error: Invalid: Failed to parse string: '2022-02-11' as a scalar of type timestamp[ms]

Created on 2022-02-11 by the reprex package (v2.0.1)

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

⚠️ Ticket has not been started in JIRA, please click 'Start Progress'.

@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 7a2700d to d7fefa7CompareMarch 24, 2022 16:00
@dragosmg

dragosmg commented Mar 25, 2022

Copy link
Copy Markdown
ContributorAuthor

I think several things are needed:

  • new unit tests to show similar behaviour (returning NA in the same circumstances)
  • update existing unit tests. These are not using compare_dplyr_binding() and are not catching the fact that Arrow's strptime binding returns an object of a different class (POSIXct, a double vector) that base::strptime() (POSIXlt, a list)

waldo::compare() does ignore class when ignore_attr = TRUE, but it can't ignore typeof. I'm not sure we want to change the type of object Arrow's strptime binding returns.

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

@jonkeane

Copy link
Copy Markdown
Member

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

There are a few comments about this in the tests that reference this — I don't think it was unknown. POSIXlt is pretty unique to R (I'm sure there were other languages that have similar types), but they aren't super wide-spread, and Arrow doesn't support them directly (though you can see in the R package we make a (pseudo)-extension class for them).

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

This needs a rebase once #12732 gets merged.

Comment threadr/R/dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 0a1b35f to 727efbdCompareMarch 29, 2022 09:24
@dragosmg
dragosmg marked this pull request as ready for review March 29, 2022 12:21

@jonkeanejonkeane 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.

A few questions about the tests

Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmg requested a review from jonkeaneMarch 29, 2022 19:52
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 25863ef to f669be7CompareMarch 30, 2022 11:33
@ursabot

ursabot commented Mar 30, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 64560af and contender = ba04e7f. ba04e7f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.04%] test-mac-arm
[Failed ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.04% ⬆️0.0%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/419|ba04e7f8 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/405|ba04e7f8 test-mac-arm>
[Failed] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/405|ba04e7f8 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/415|ba04e7f8 ursa-thinkcentre-m75q>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/418|64560af6 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/404|64560af6 test-mac-arm>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/404|64560af6 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/414|64560af6 ursa-thinkcentre-m75q>
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@dragosmg
dragosmg deleted the strptime_return_na_vs_error branch April 26, 2022 09:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@dragosmg@jonkeane@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' ARROW-15659 [R] strptime should return NA (not error) with format mismatch by dragosmg · Pull Request #12402 · apache/arrow · GitHub
Skip to content

ARROW-15659 [R] strptime should return NA (not error) with format mismatch - #12402

Closed
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error
Closed

ARROW-15659 [R] strptime should return NA (not error) with format mismatch#12402
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error

Conversation

@dragosmg

@dragosmgdragosmg commented Feb 11, 2022

Copy link
Copy Markdown
Contributor

This PR aligns arrow's binding to strptime() to base::strptime() when the value passed to the format argument does not match the data. Currently arrow errors, when it should return NA.

library(lubridate)
library(arrow)
library(dplyr)
df<- tibble(x="2022-02-11")
df %>% mutate(z= strptime(x, format="%Y-%m %d"))
#> # A tibble: 1 × 2#> x z #> <chr> <dttm>#> 1 2022-02-11 NAdf %>% record_batch() %>% mutate(z= strptime(x, format="%Y-%m %d")) %>% collect()
#> Error: Invalid: Failed to parse string: '2022-02-11' as a scalar of type timestamp[ms]

Created on 2022-02-11 by the reprex package (v2.0.1)

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

⚠️ Ticket has not been started in JIRA, please click 'Start Progress'.

@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 7a2700d to d7fefa7CompareMarch 24, 2022 16:00
@dragosmg

dragosmg commented Mar 25, 2022

Copy link
Copy Markdown
ContributorAuthor

I think several things are needed:

  • new unit tests to show similar behaviour (returning NA in the same circumstances)
  • update existing unit tests. These are not using compare_dplyr_binding() and are not catching the fact that Arrow's strptime binding returns an object of a different class (POSIXct, a double vector) that base::strptime() (POSIXlt, a list)

waldo::compare() does ignore class when ignore_attr = TRUE, but it can't ignore typeof. I'm not sure we want to change the type of object Arrow's strptime binding returns.

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

@jonkeane

Copy link
Copy Markdown
Member

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

There are a few comments about this in the tests that reference this — I don't think it was unknown. POSIXlt is pretty unique to R (I'm sure there were other languages that have similar types), but they aren't super wide-spread, and Arrow doesn't support them directly (though you can see in the R package we make a (pseudo)-extension class for them).

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

This needs a rebase once #12732 gets merged.

Comment threadr/R/dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 0a1b35f to 727efbdCompareMarch 29, 2022 09:24
@dragosmg
dragosmg marked this pull request as ready for review March 29, 2022 12:21

@jonkeanejonkeane 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.

A few questions about the tests

Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmg requested a review from jonkeaneMarch 29, 2022 19:52
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 25863ef to f669be7CompareMarch 30, 2022 11:33
@ursabot

ursabot commented Mar 30, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 64560af and contender = ba04e7f. ba04e7f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.04%] test-mac-arm
[Failed ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.04% ⬆️0.0%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/419|ba04e7f8 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/405|ba04e7f8 test-mac-arm>
[Failed] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/405|ba04e7f8 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/415|ba04e7f8 ursa-thinkcentre-m75q>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/418|64560af6 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/404|64560af6 test-mac-arm>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/404|64560af6 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/414|64560af6 ursa-thinkcentre-m75q>
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@dragosmg
dragosmg deleted the strptime_return_na_vs_error branch April 26, 2022 09:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@dragosmg@jonkeane@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' ARROW-15659 [R] strptime should return NA (not error) with format mismatch by dragosmg · Pull Request #12402 · apache/arrow · GitHub
Skip to content

ARROW-15659 [R] strptime should return NA (not error) with format mismatch - #12402

Closed
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error
Closed

ARROW-15659 [R] strptime should return NA (not error) with format mismatch#12402
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error

Conversation

@dragosmg

@dragosmgdragosmg commented Feb 11, 2022

Copy link
Copy Markdown
Contributor

This PR aligns arrow's binding to strptime() to base::strptime() when the value passed to the format argument does not match the data. Currently arrow errors, when it should return NA.

library(lubridate)
library(arrow)
library(dplyr)
df<- tibble(x="2022-02-11")
df %>% mutate(z= strptime(x, format="%Y-%m %d"))
#> # A tibble: 1 × 2#> x z #> <chr> <dttm>#> 1 2022-02-11 NAdf %>% record_batch() %>% mutate(z= strptime(x, format="%Y-%m %d")) %>% collect()
#> Error: Invalid: Failed to parse string: '2022-02-11' as a scalar of type timestamp[ms]

Created on 2022-02-11 by the reprex package (v2.0.1)

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

⚠️ Ticket has not been started in JIRA, please click 'Start Progress'.

@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 7a2700d to d7fefa7CompareMarch 24, 2022 16:00
@dragosmg

dragosmg commented Mar 25, 2022

Copy link
Copy Markdown
ContributorAuthor

I think several things are needed:

  • new unit tests to show similar behaviour (returning NA in the same circumstances)
  • update existing unit tests. These are not using compare_dplyr_binding() and are not catching the fact that Arrow's strptime binding returns an object of a different class (POSIXct, a double vector) that base::strptime() (POSIXlt, a list)

waldo::compare() does ignore class when ignore_attr = TRUE, but it can't ignore typeof. I'm not sure we want to change the type of object Arrow's strptime binding returns.

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

@jonkeane

Copy link
Copy Markdown
Member

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

There are a few comments about this in the tests that reference this — I don't think it was unknown. POSIXlt is pretty unique to R (I'm sure there were other languages that have similar types), but they aren't super wide-spread, and Arrow doesn't support them directly (though you can see in the R package we make a (pseudo)-extension class for them).

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

This needs a rebase once #12732 gets merged.

Comment threadr/R/dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 0a1b35f to 727efbdCompareMarch 29, 2022 09:24
@dragosmg
dragosmg marked this pull request as ready for review March 29, 2022 12:21

@jonkeanejonkeane 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.

A few questions about the tests

Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmg requested a review from jonkeaneMarch 29, 2022 19:52
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 25863ef to f669be7CompareMarch 30, 2022 11:33
@ursabot

ursabot commented Mar 30, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 64560af and contender = ba04e7f. ba04e7f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.04%] test-mac-arm
[Failed ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.04% ⬆️0.0%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/419|ba04e7f8 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/405|ba04e7f8 test-mac-arm>
[Failed] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/405|ba04e7f8 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/415|ba04e7f8 ursa-thinkcentre-m75q>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/418|64560af6 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/404|64560af6 test-mac-arm>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/404|64560af6 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/414|64560af6 ursa-thinkcentre-m75q>
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@dragosmg
dragosmg deleted the strptime_return_na_vs_error branch April 26, 2022 09:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@dragosmg@jonkeane@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' ARROW-15659 [R] strptime should return NA (not error) with format mismatch by dragosmg · Pull Request #12402 · apache/arrow · GitHub
Skip to content

ARROW-15659 [R] strptime should return NA (not error) with format mismatch - #12402

Closed
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error
Closed

ARROW-15659 [R] strptime should return NA (not error) with format mismatch#12402
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error

Conversation

@dragosmg

@dragosmgdragosmg commented Feb 11, 2022

Copy link
Copy Markdown
Contributor

This PR aligns arrow's binding to strptime() to base::strptime() when the value passed to the format argument does not match the data. Currently arrow errors, when it should return NA.

library(lubridate)
library(arrow)
library(dplyr)
df<- tibble(x="2022-02-11")
df %>% mutate(z= strptime(x, format="%Y-%m %d"))
#> # A tibble: 1 × 2#> x z #> <chr> <dttm>#> 1 2022-02-11 NAdf %>% record_batch() %>% mutate(z= strptime(x, format="%Y-%m %d")) %>% collect()
#> Error: Invalid: Failed to parse string: '2022-02-11' as a scalar of type timestamp[ms]

Created on 2022-02-11 by the reprex package (v2.0.1)

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

⚠️ Ticket has not been started in JIRA, please click 'Start Progress'.

@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 7a2700d to d7fefa7CompareMarch 24, 2022 16:00
@dragosmg

dragosmg commented Mar 25, 2022

Copy link
Copy Markdown
ContributorAuthor

I think several things are needed:

  • new unit tests to show similar behaviour (returning NA in the same circumstances)
  • update existing unit tests. These are not using compare_dplyr_binding() and are not catching the fact that Arrow's strptime binding returns an object of a different class (POSIXct, a double vector) that base::strptime() (POSIXlt, a list)

waldo::compare() does ignore class when ignore_attr = TRUE, but it can't ignore typeof. I'm not sure we want to change the type of object Arrow's strptime binding returns.

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

@jonkeane

Copy link
Copy Markdown
Member

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

There are a few comments about this in the tests that reference this — I don't think it was unknown. POSIXlt is pretty unique to R (I'm sure there were other languages that have similar types), but they aren't super wide-spread, and Arrow doesn't support them directly (though you can see in the R package we make a (pseudo)-extension class for them).

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

This needs a rebase once #12732 gets merged.

Comment threadr/R/dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 0a1b35f to 727efbdCompareMarch 29, 2022 09:24
@dragosmg
dragosmg marked this pull request as ready for review March 29, 2022 12:21

@jonkeanejonkeane 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.

A few questions about the tests

Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmg requested a review from jonkeaneMarch 29, 2022 19:52
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 25863ef to f669be7CompareMarch 30, 2022 11:33
@ursabot

ursabot commented Mar 30, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 64560af and contender = ba04e7f. ba04e7f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.04%] test-mac-arm
[Failed ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.04% ⬆️0.0%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/419|ba04e7f8 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/405|ba04e7f8 test-mac-arm>
[Failed] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/405|ba04e7f8 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/415|ba04e7f8 ursa-thinkcentre-m75q>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/418|64560af6 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/404|64560af6 test-mac-arm>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/404|64560af6 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/414|64560af6 ursa-thinkcentre-m75q>
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@dragosmg
dragosmg deleted the strptime_return_na_vs_error branch April 26, 2022 09:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@dragosmg@jonkeane@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' ARROW-15659 [R] strptime should return NA (not error) with format mismatch by dragosmg · Pull Request #12402 · apache/arrow · GitHub
Skip to content

ARROW-15659 [R] strptime should return NA (not error) with format mismatch - #12402

Closed
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error
Closed

ARROW-15659 [R] strptime should return NA (not error) with format mismatch#12402
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error

Conversation

@dragosmg

@dragosmgdragosmg commented Feb 11, 2022

Copy link
Copy Markdown
Contributor

This PR aligns arrow's binding to strptime() to base::strptime() when the value passed to the format argument does not match the data. Currently arrow errors, when it should return NA.

library(lubridate)
library(arrow)
library(dplyr)
df<- tibble(x="2022-02-11")
df %>% mutate(z= strptime(x, format="%Y-%m %d"))
#> # A tibble: 1 × 2#> x z #> <chr> <dttm>#> 1 2022-02-11 NAdf %>% record_batch() %>% mutate(z= strptime(x, format="%Y-%m %d")) %>% collect()
#> Error: Invalid: Failed to parse string: '2022-02-11' as a scalar of type timestamp[ms]

Created on 2022-02-11 by the reprex package (v2.0.1)

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

⚠️ Ticket has not been started in JIRA, please click 'Start Progress'.

@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 7a2700d to d7fefa7CompareMarch 24, 2022 16:00
@dragosmg

dragosmg commented Mar 25, 2022

Copy link
Copy Markdown
ContributorAuthor

I think several things are needed:

  • new unit tests to show similar behaviour (returning NA in the same circumstances)
  • update existing unit tests. These are not using compare_dplyr_binding() and are not catching the fact that Arrow's strptime binding returns an object of a different class (POSIXct, a double vector) that base::strptime() (POSIXlt, a list)

waldo::compare() does ignore class when ignore_attr = TRUE, but it can't ignore typeof. I'm not sure we want to change the type of object Arrow's strptime binding returns.

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

@jonkeane

Copy link
Copy Markdown
Member

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

There are a few comments about this in the tests that reference this — I don't think it was unknown. POSIXlt is pretty unique to R (I'm sure there were other languages that have similar types), but they aren't super wide-spread, and Arrow doesn't support them directly (though you can see in the R package we make a (pseudo)-extension class for them).

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

This needs a rebase once #12732 gets merged.

Comment threadr/R/dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 0a1b35f to 727efbdCompareMarch 29, 2022 09:24
@dragosmg
dragosmg marked this pull request as ready for review March 29, 2022 12:21

@jonkeanejonkeane 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.

A few questions about the tests

Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmg requested a review from jonkeaneMarch 29, 2022 19:52
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 25863ef to f669be7CompareMarch 30, 2022 11:33
@ursabot

ursabot commented Mar 30, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 64560af and contender = ba04e7f. ba04e7f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.04%] test-mac-arm
[Failed ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.04% ⬆️0.0%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/419|ba04e7f8 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/405|ba04e7f8 test-mac-arm>
[Failed] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/405|ba04e7f8 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/415|ba04e7f8 ursa-thinkcentre-m75q>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/418|64560af6 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/404|64560af6 test-mac-arm>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/404|64560af6 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/414|64560af6 ursa-thinkcentre-m75q>
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@dragosmg
dragosmg deleted the strptime_return_na_vs_error branch April 26, 2022 09:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@dragosmg@jonkeane@ursabot
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); ARROW-15659 [R] strptime should return NA (not error) with format mismatch by dragosmg · Pull Request #12402 · apache/arrow · GitHub
Skip to content

ARROW-15659 [R] strptime should return NA (not error) with format mismatch - #12402

Closed
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error
Closed

ARROW-15659 [R] strptime should return NA (not error) with format mismatch#12402
dragosmg wants to merge 13 commits into
apache:masterfrom
dragosmg:strptime_return_na_vs_error

Conversation

@dragosmg

@dragosmgdragosmg commented Feb 11, 2022

Copy link
Copy Markdown
Contributor

This PR aligns arrow's binding to strptime() to base::strptime() when the value passed to the format argument does not match the data. Currently arrow errors, when it should return NA.

library(lubridate)
library(arrow)
library(dplyr)
df<- tibble(x="2022-02-11")
df %>% mutate(z= strptime(x, format="%Y-%m %d"))
#> # A tibble: 1 × 2#> x z #> <chr> <dttm>#> 1 2022-02-11 NAdf %>% record_batch() %>% mutate(z= strptime(x, format="%Y-%m %d")) %>% collect()
#> Error: Invalid: Failed to parse string: '2022-02-11' as a scalar of type timestamp[ms]

Created on 2022-02-11 by the reprex package (v2.0.1)

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

⚠️ Ticket has not been started in JIRA, please click 'Start Progress'.

@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 7a2700d to d7fefa7CompareMarch 24, 2022 16:00
@dragosmg

dragosmg commented Mar 25, 2022

Copy link
Copy Markdown
ContributorAuthor

I think several things are needed:

  • new unit tests to show similar behaviour (returning NA in the same circumstances)
  • update existing unit tests. These are not using compare_dplyr_binding() and are not catching the fact that Arrow's strptime binding returns an object of a different class (POSIXct, a double vector) that base::strptime() (POSIXlt, a list)

waldo::compare() does ignore class when ignore_attr = TRUE, but it can't ignore typeof. I'm not sure we want to change the type of object Arrow's strptime binding returns.

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

@jonkeane

Copy link
Copy Markdown
Member

@jonkeane what do you think? Is the type of the object returned by strptime of concern? base::strptime() returns a list (POSIXlt), while the Arrow one returns an atomic vector. We hadn't caught this before as the unit tests for strptime did not compare the {dplyr} and {arrow} pipelines.

There are a few comments about this in the tests that reference this — I don't think it was unknown. POSIXlt is pretty unique to R (I'm sure there were other languages that have similar types), but they aren't super wide-spread, and Arrow doesn't support them directly (though you can see in the R package we make a (pseudo)-extension class for them).

@dragosmg

Copy link
Copy Markdown
ContributorAuthor

This needs a rebase once #12732 gets merged.

Comment threadr/R/dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 0a1b35f to 727efbdCompareMarch 29, 2022 09:24
@dragosmg
dragosmg marked this pull request as ready for review March 29, 2022 12:21

@jonkeanejonkeane 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.

A few questions about the tests

Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
Comment threadr/tests/testthat/test-dplyr-funcs-datetime.R Outdated
@dragosmg
dragosmg requested a review from jonkeaneMarch 29, 2022 19:52
@dragosmg
dragosmgforce-pushed the strptime_return_na_vs_error branch from 25863ef to f669be7CompareMarch 30, 2022 11:33
@ursabot

ursabot commented Mar 30, 2022

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 64560af and contender = ba04e7f. ba04e7f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️0.21% ⬆️0.04%] test-mac-arm
[Failed ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.04% ⬆️0.0%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/419|ba04e7f8 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/405|ba04e7f8 test-mac-arm>
[Failed] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/405|ba04e7f8 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/415|ba04e7f8 ursa-thinkcentre-m75q>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ec2-t3-xlarge-us-east-2/builds/418|64560af6 ec2-t3-xlarge-us-east-2>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-test-mac-arm/builds/404|64560af6 test-mac-arm>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-i9-9960x/builds/404|64560af6 ursa-i9-9960x>
[Finished] <https://buildkite.com/apache-arrow/arrow-bci-benchmark-on-ursa-thinkcentre-m75q/builds/414|64560af6 ursa-thinkcentre-m75q>
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@dragosmg
dragosmg deleted the strptime_return_na_vs_error branch April 26, 2022 09:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@dragosmg@jonkeane@ursabot