Keyed subset of Date to character should "just work"

Open
#3,506 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Reproduce the keyed Date subset example in the issue and trace the join-subset entry point used by DT[.('2019-01-01')]. Compare it with the working d == '2019-01-01' case, then resolve the proposed Date-to-character coercion and the .Date(0.1) rounding edge case before adding coverage.

Written by the indexing model from the issue text.

Description

IDate/ITime joins
DT = data.table(d = as.Date('2019-01-01'), key = 'd')

# fails since d is actually numeric
DT[.('2019-01-01')]

# this works since R coerces type for ==
DT[d == '2019-01-01']

Since we're already used to == implicitly coercing dates-as-strings to dates, I think there's reasonable expectation that join subsets would work similarly.

Logic is: if x's join key inherits from Date & i's join key is character, try as.IDate.

Type laxness presents a weird edge case -- what if x has .Date(0.1), should we round it first?

Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.