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

GH-43118: [JS] Add interval for unit MONTH_DAY_NANO #43117

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

handstuyennn
Copy link

@handstuyennn handstuyennn commented Jul 2, 2024

Rationale for this change

This PR handle for Interval type with MONTH_DAY_NANO unit, This is currently not supported in Arrow JS implementation.
See #43118

What changes are included in this PR?

Handle Interval with MONTH_DAY_NAO unit with relations
Adding tests for builder and unittest

Are these changes tested?

Yes. Unit tests have been added

Copy link

github-actions bot commented Jul 2, 2024

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

In the case of PARQUET issues on JIRA the title also supports:

PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

See also:

@handstuyennn handstuyennn changed the title MINOR [JS]: Add interval for unit MONTH_DAY_NANO GH-43118: [JS] Add interval for unit MONTH_DAY_NANO Jul 2, 2024
Copy link

github-actions bot commented Jul 2, 2024

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

Copy link
Member

@domoritz domoritz left a comment

Choose a reason for hiding this comment

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

Looks good overall. Please fix the CI issues.

I'll defer to @trxcllnt for a final ok.

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels Jul 2, 2024
Copy link
Member

Choose a reason for hiding this comment

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

Could you add our license header?

Copy link
Author

Choose a reason for hiding this comment

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

I added the license

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting merge Awaiting merge labels Jul 2, 2024
@kou
Copy link
Member

kou commented Jul 2, 2024

Could you fix lint failures?

https://github.com/apache/arrow/actions/runs/9760275633/job/26955306166?pr=43117#step:5:150

$ eslint src test

/build/js/src/type.ts
  492:132  error  Missing semicolon  @typescript-eslint/semi

/build/js/src/util/buffer.ts
  134:18  warning  Move generator function 'wrap' to the outer scope        unicorn/consistent-function-scoping
  172:18  warning  Move async generator function 'wrap' to the outer scope  unicorn/consistent-function-scoping

/build/js/test/generate-test-data.ts
  327:5   warning  Unnecessarily cloning an array  unicorn/no-useless-spread
  349:5   warning  Unnecessarily cloning an array  unicorn/no-useless-spread
  370:20  warning  Unnecessarily cloning an array  unicorn/no-useless-spread
  380:20  warning  Unnecessarily cloning an array  unicorn/no-useless-spread
  488:51  warning  Unnecessarily cloning an array  unicorn/no-useless-spread
  626:49  warning  Unnecessarily cloning an array  unicorn/no-useless-spread

/build/js/test/unit/vector/interval-month-day-nano-tests.ts
   1:56  error  Strings must use singlequote                                 @typescript-eslint/quotes
   6:25  error  Expected a semicolon                                         @typescript-eslint/member-delimiter-style
  16:5   error  This `if` statement can be replaced by a ternary expression  unicorn/prefer-ternary
  28:42  error  Missing semicolon                                            @typescript-eslint/semi
  39:5   error  Use a `for-of` loop instead of this `for` loop               unicorn/no-for-loop
  41:9   error  Use a `for-of` loop instead of this `for` loop               unicorn/no-for-loop
  84:4   error  Newline required at end of file but not found                eol-last

✖ 16 problems (8 errors, 8 warnings)
  8 errors and 0 warnings potentially fixable with the `--fix` option.

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Jul 3, 2024
@handstuyennn
Copy link
Author

Could you fix lint failures?

https://github.com/apache/arrow/actions/runs/9760275633/job/26955306166?pr=43117#step:5:150

$ eslint src test

/build/js/src/type.ts
  492:132  error  Missing semicolon  @typescript-eslint/semi

/build/js/src/util/buffer.ts
  134:18  warning  Move generator function 'wrap' to the outer scope        unicorn/consistent-function-scoping
  172:18  warning  Move async generator function 'wrap' to the outer scope  unicorn/consistent-function-scoping

/build/js/test/generate-test-data.ts
  327:5   warning  Unnecessarily cloning an array  unicorn/no-useless-spread
  349:5   warning  Unnecessarily cloning an array  unicorn/no-useless-spread
  370:20  warning  Unnecessarily cloning an array  unicorn/no-useless-spread
  380:20  warning  Unnecessarily cloning an array  unicorn/no-useless-spread
  488:51  warning  Unnecessarily cloning an array  unicorn/no-useless-spread
  626:49  warning  Unnecessarily cloning an array  unicorn/no-useless-spread

/build/js/test/unit/vector/interval-month-day-nano-tests.ts
   1:56  error  Strings must use singlequote                                 @typescript-eslint/quotes
   6:25  error  Expected a semicolon                                         @typescript-eslint/member-delimiter-style
  16:5   error  This `if` statement can be replaced by a ternary expression  unicorn/prefer-ternary
  28:42  error  Missing semicolon                                            @typescript-eslint/semi
  39:5   error  Use a `for-of` loop instead of this `for` loop               unicorn/no-for-loop
  41:9   error  Use a `for-of` loop instead of this `for` loop               unicorn/no-for-loop
  84:4   error  Newline required at end of file but not found                eol-last

✖ 16 problems (8 errors, 8 warnings)
  8 errors and 0 warnings potentially fixable with the `--fix` option.

I updated it

@trxcllnt
Copy link
Contributor

trxcllnt commented Jul 3, 2024

@handstuyennn Thanks for the PR. Would you mind also removing these two lines so the new functionality is validated against the other Arrow implementations?

@handstuyennn
Copy link
Author

@handstuyennn Thanks for the PR. Would you mind also removing these two lines so the new functionality is validated against the other Arrow implementations?

I updated this

@domoritz
Copy link
Member

domoritz commented Jul 5, 2024

Can you fix the integration test?

@domoritz
Copy link
Member

@handstuyennn could you look into the last remaining test so we can merge this?

@handstuyennn
Copy link
Author

@handstuyennn could you look into the last remaining test so we can merge this?

I will handle it this weekend


generate_month_day_nano_interval_case(),
generate_month_day_nano_interval_case()
.skip_tester('JS'),
Copy link
Member

Choose a reason for hiding this comment

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

Why skip this test? Isn't this the point of this pull request?

Choose a reason for hiding this comment

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

Hi @domoritz The issues about interval data in JSON format just been fixed in the latest commit. Please check it. Thank you

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Sep 5, 2024
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Sep 27, 2024
Copy link
Contributor

@trxcllnt trxcllnt left a comment

Choose a reason for hiding this comment

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

Need to revisit changes to vectorloader.ts.

@trxcllnt trxcllnt self-requested a review September 30, 2024 22:08
Comment on lines +270 to +274
(data.type.unit === IntervalUnit.MONTH_DAY_NANO)
? getIntervalMonthDayNano(data as Data<IntervalMonthDayNano>, index)
: (data.type.unit === IntervalUnit.DAY_TIME)
? getIntervalDayTime(data as Data<IntervalDayTime>, index)
: getIntervalYearMonth(data as Data<IntervalYearMonth>, index);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we split these conditions out into separate methods and assign them to the GetVisitor prototype separately?

Comment on lines +296 to +300
(data.type.unit === IntervalUnit.MONTH_DAY_NANO)
? setIntervalMonthDaynano(data as Data<IntervalMonthDayNano>, index, value)
: (data.type.unit === IntervalUnit.DAY_TIME)
? setIntervalDayTime(data as Data<IntervalDayTime>, index, value)
: setIntervalYearMonth(data as Data<IntervalYearMonth>, index, value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here.

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

5 participants