Skip to content

GH-38217: [R] Map format = "text" to format = "csv" in write_dataset() - #50367

Open
thisisnic wants to merge 5 commits into
apache:mainfrom
thisisnic:worktree-GH-38217-text-to-csv
Open

thisisnic wants to merge 5 commits into
apache:mainfrom
thisisnic:worktree-GH-38217-text-to-csv

Conversation

@thisisnic

@thisisnic thisisnic commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

Rationale for this change

write_dataset() errors on format="text" even though open_dataset() allows it.

What changes are included in this PR?

Map "text" to "csv" so write_dataset() mirrors open_dataset()

Are these changes tested?

Yes

Are there any user-facing changes?

No

@thisisnic
thisisnic requested a review from jonkeane as a code owner July 4, 2026 22:15
Copilot AI lite review requested due to automatic review settings July 4, 2026 22:15
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #38217 has been automatically assigned in GitHub to PR creator.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns the R write_dataset() format handling with open_dataset() by treating format = "text" as an alias of CSV, so users can write delimited text datasets with the same expectations as when opening them.

Changes:

  • Map format = "text" to "csv" inside write_dataset() so it uses CSV defaults (notably comma delimiter) and generates .csv filenames.
  • Narrow the “delimiter required” validation to only apply to format = "txt", avoiding the previous error for format = "text".
  • Update tests to cover the new format = "text" behavior and remove the old expectation that it errors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
r/R/dataset-write.R Adds text -> csv mapping and updates delimiter validation to only enforce a delimiter for txt.
r/tests/testthat/test-dataset-write.R Replaces the previous error expectation for format="text" with a round-trip test asserting .csv output and correct data.

@thisisnic
thisisnic marked this pull request as draft July 5, 2026 13:48
@thisisnic thisisnic changed the title GH-38217: [R] Map format = "text to format = "csv" in write_dataset() GH-38217: [R] Map format = "text" to format = "csv" in write_dataset() Aug 18, 2026
@thisisnic
thisisnic force-pushed the worktree-GH-38217-text-to-csv branch from d048f45 to 4292634 Compare August 18, 2026 13:49
@thisisnic
thisisnic marked this pull request as ready for review August 18, 2026 13:49
Copilot AI review requested due to automatic review settings August 18, 2026 13:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

r/R/dataset-write.R:156

  • PR description says there are no user-facing changes, but this change makes write_dataset(format = "text") succeed where it previously errored (a user-visible behavior change). Consider updating the PR description/release-note wording to reflect this bugfix.
  if (format == "text") {
    format <- "csv"
  }

Copilot AI review requested due to automatic review settings August 25, 2026 10:07
@thisisnic
thisisnic force-pushed the worktree-GH-38217-text-to-csv branch from 4292634 to 85d49ac Compare August 25, 2026 10:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comment thread r/tests/testthat/test-dataset-write.R
Copilot AI review requested due to automatic review settings August 25, 2026 10:42
@github-actions github-actions Bot added awaiting review Awaiting review awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Aug 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread r/tests/testthat/test-dataset-write.R Outdated
Comment thread r/R/dataset-write.R Outdated
Copilot AI review requested due to automatic review settings September 4, 2026 10:26
@github-actions github-actions Bot removed awaiting review Awaiting review awaiting changes Awaiting changes labels Sep 4, 2026
@github-actions github-actions Bot added the awaiting review Awaiting review label Sep 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is narrowly scoped, matches the linked issue’s acceptance criteria, and is covered by an explicit regression test.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Sep 4, 2026

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

I'm fine with this in principle but the distinction between "text" and "txt" (if I'm reading that correctly?) seems very strange.

Comment thread r/R/dataset-write.R Outdated
Comment on lines +197 to +200
if (format %in% c("txt", "text") && !any(c("delimiter", "delim") %in% names(dots))) {
if (format == "txt" && !any(c("delimiter", "delim") %in% names(dots))) {

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.

Does this mean that "text" and "txt" will behave differently now? As in: "text" will automagically be CSV, but "txt" one needs to supply a delimiter (which might be a comma)?

@thisisnic thisisnic Sep 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, mapping "text" to "csv" is to mirror open_dataset() but it's a bit weird.

"txt" is what write_delim_dataset() passes internally and it always sends a delimiter, so I've left that check alone rather than also defaulting it to comma.

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.

How bad would it be to make open_dataset() be consistent with this? (and also internally 😂 )?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, this is a super weird one, I think we can actually just totally get rid of "txt" given it was originally added so that write_delim_dataset() could force users to specify a delimiter, and isn't even documented, it just happens to work. We could probably clean up the API a bit by deprecating it tbh. I'll update the PR so both sides are symmetrical but without this weirdness!

Copilot AI lite review requested due to automatic review settings October 4, 2026 22:22
@thisisnic
thisisnic force-pushed the worktree-GH-38217-text-to-csv branch from f8b53f5 to 71a2932 Compare October 4, 2026 22:22
@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 4, 2026
@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Oct 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved review issues were identified.

Review effort: Lite
Findings: None

Resolved since last review (2)

Sign up for free to 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.

3 participants