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

feat(query): add interval type #16990

Merged
merged 2 commits into from
Dec 14, 2024
Merged

feat(query): add interval type #16990

merged 2 commits into from
Dec 14, 2024

Conversation

TCeason
Copy link
Collaborator

@TCeason TCeason commented Dec 3, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

Support new datatype Interval.

It represent periods of time that can be added to or subtracted from DATE, TIMESTAMP.

:) DESCRIBE t

┌───────────────────────────────────────────────┐
│  Field │   Type   │  Null  │ Default │  Extra │
│ String │  String  │ String │  String │ String │
├────────┼──────────┼────────┼─────────┼────────┤
│ c      │ INTERVAL │ YES    │ NULL    │        │
└───────────────────────────────────────────────┘


:) insert into t values('1 month 1 day 1 hours');
:) select * from  t;
┌───────────────────────┐
│           c           │
│   Nullable(Interval)  │
├───────────────────────┤
│ 1 month               │
│ 1 month 1 day 1:00:00 │
│ 1 month 1 day 1:00:00 │
│ 1 month 1 day 1:00:00 │
└───────────────────────┘
4 rows read in 0.061 sec. Processed 4 rows, 68B (65.57 rows/s, 1.09 KiB/s)

Note: Since MySQL does not support the INTERVAL type, querying the INTERVAL type using the MySQL client will result in an error.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@TCeason TCeason requested a review from drmingdrmer as a code owner December 3, 2024 13:00
@TCeason TCeason marked this pull request as draft December 3, 2024 13:01
@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Dec 3, 2024
Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

The meta data part looks good to me. Do not forget to add a new version test:
image.png

Reviewed 4 of 42 files at r1.
Reviewable status: 4 of 42 files reviewed, all discussions resolved

@TCeason TCeason force-pushed the interval branch 5 times, most recently from b43edcf to add4db2 Compare December 4, 2024 02:35
@TCeason
Copy link
Collaborator Author

TCeason commented Dec 4, 2024

wait databendlabs/bendsql#517 merge

@TCeason TCeason marked this pull request as ready for review December 5, 2024 08:11
@TCeason TCeason marked this pull request as draft December 5, 2024 08:25
@TCeason TCeason force-pushed the interval branch 2 times, most recently from 17816e4 to 9e58cd9 Compare December 5, 2024 08:49
@rad-pat
Copy link

rad-pat commented Dec 5, 2024

@TCeason, when this is completed, will we be able to write such conversion as to_interval('454664 seconds') and get result Interval 5days 06:17:44 ? i.e. just pass conversion value in total seconds.

@TCeason
Copy link
Collaborator Author

TCeason commented Dec 5, 2024

when this is completed, will we be able to write such conversion as to_interval('454664 seconds') and get result Interval 5days 06:17:44 ? i.e. just pass conversion value in total seconds.

Yes, the results are quite similar. I’ve encountered a few issues currently, and I’ll add some similar tests later.

@rad-pat
Copy link

rad-pat commented Dec 5, 2024

Yes, the results are quite similar. I’ve encountered a few issues currently, and I’ll add some similar tests later.

Excellent, this will hopefully make it easy to wrap in SQLAlchemy for Python 👍

@TCeason
Copy link
Collaborator Author

TCeason commented Dec 6, 2024

databendlabs/bendsql#530

@TCeason TCeason marked this pull request as ready for review December 6, 2024 04:05
@TCeason TCeason requested a review from sundy-li December 6, 2024 04:05
Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

metadata part LGTM :lgtm:

Reviewed 2 of 33 files at r4.
Reviewable status: 6 of 72 files reviewed, 1 unresolved discussion (waiting on @sundy-li and @TCeason)

@TCeason
Copy link
Collaborator Author

TCeason commented Dec 6, 2024

Marking this as a draft: Compression support for FixedSizeBinaryColumn is required when using the fs storage type. Implementation is targeted for completion next week.

@TCeason TCeason marked this pull request as draft December 6, 2024 13:14
Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 19 files at r9, all commit messages.
Reviewable status: 6 of 78 files reviewed, 1 unresolved discussion (waiting on @sundy-li and @TCeason)

@TCeason TCeason marked this pull request as ready for review December 12, 2024 11:46
@TCeason TCeason requested a review from b41sh December 12, 2024 11:48
src/common/column/src/fixedsizebinary/builder.rs Outdated Show resolved Hide resolved
src/common/column/src/fixedsizebinary/builder.rs Outdated Show resolved Hide resolved
src/common/column/src/fixedsizebinary/mod.rs Outdated Show resolved Hide resolved
src/common/column/src/fixedsizebinary/builder.rs Outdated Show resolved Hide resolved
@TCeason TCeason marked this pull request as draft December 13, 2024 04:40
@TCeason TCeason marked this pull request as ready for review December 13, 2024 05:58
@TCeason TCeason requested review from b41sh and sundy-li December 13, 2024 05:58
:) select to_interval('02:01'), to_interval('1 year 1 day 1 hour');

┌───────────────────────────────────────────────────────────┐
│ to_interval('02:01') │ to_interval('1 year 1 day 1 hour') │
│       Interval       │              Interval              │
├──────────────────────┼────────────────────────────────────┤
│ 2:01:00              │ 1year 1day 1:00:00                 │
└───────────────────────────────────────────────────────────┘
@sundy-li sundy-li added this pull request to the merge queue Dec 14, 2024
Merged via the queue into databendlabs:main with commit 2e5fec4 Dec 14, 2024
72 of 73 checks passed
@BohuTANG
Copy link
Member

@soyeric128 Could you help document the new interval type? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Add Support for INTERVAL Data Type - Already Supported in Parquet & Arrow
6 participants