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

dsv type option #301

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

dsv type option #301

wants to merge 1 commit into from

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Sep 8, 2022

Screen Shot 2022-09-07 at 6 40 32 PM

Open questions (with my inclination):

  • Should we pass-through columns that are not mentioned without typing? (Yes. At the end?)
  • Should we support the “drop” type, if we want to suppress a column? (Yes if pass-through is default.)
  • Should we support the “auto” type, with the same behavior as d3.autoType for a single column? (Maybe.)
  • Should we support the “bigint” type? (Probably.)
  • Should we require ISO 8601 for dates rather than using the lax Date constructor? (Probably.)
  • Any special handling for the empty string? (Probably not.)
  • Should we use the Function constructor to make this faster, like d3-dsv does? (Maybe.)
  • Or should we use Object.fromEntries? (Probably slower.)

@mbostock mbostock requested a review from enjalot September 8, 2022 01:45
switch (`${type}`) {
case "number": return Number;
case "string": return String;
case "boolean": return Boolean;
Copy link

Choose a reason for hiding this comment

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

this differs from autotype in that it will not turn "false" into false. is that ok?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, no, that wasn’t intentional.

}
switch (`${type}`) {
case "number": return Number;
case "string": return String;
Copy link

Choose a reason for hiding this comment

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

in autoType the string gets trimmed. probably not something to include in casting, but will be different

}

function NewDate(value) {
return new Date(value);
Copy link

Choose a reason for hiding this comment

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

do we want to do the timezone workaround for Safari?

@enjalot
Copy link

enjalot commented Sep 8, 2022

Should we pass-through columns that are not mentioned without typing? (Yes. At the end?)

I agree that unmentioned columns be included by default

Should we support the “drop” type, if we want to suppress a column? (Yes if pass-through is default.)

I agree, nice to explicitly drop unwanted columns (also documents the decision nicely)

Should we support the “auto” type, with the same behavior as d3.autoType for a single column? (Maybe.)

I don't think so. The primary interface for this implies that auto already suggested the type for the column. I like this level of interface being explicit.

Should we support the “bigint” type? (Probably.)

Seems like something we want to support across the platform better right?

Should we require ISO 8601 for dates rather than using the lax Date constructor? (Probably.)

i agree, we should standardize. if someone wants a variation the inline function is easy to use.

Any special handling for the empty string? (Probably not.)

I don't think so.

Should we use the Function constructor to make this faster, like d3-dsv does? (Maybe.)
Or should we use Object.fromEntries? (Probably slower.)

Don't have a strong opinion, but making it as fast as possible seems a worthy goal.

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.

2 participants