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

Add support for DATE, TIME, DATETIME and TIMESTAMP #393

Merged
merged 12 commits into from
Dec 29, 2023

Conversation

yangzq50
Copy link
Contributor

@yangzq50 yangzq50 commented Dec 28, 2023

What problem does this PR solve?

  • Add support for DATE, TIME, DATETIME and TIMESTAMP
  • Fix DESCRIBE table
  • Fix constant function output
  • Fix build scripts

Issue link: #371

What is changed and how it works?

Now we have initial support for DATE, TIME, DATETIME and TIMESTAMP

Representation in characters:

  • DATE should be represented in the format "YYYY-MM-DD" or "YYYY/MM/DD"
  • TIME should be represented in the format "HH:MM:SS"
  • DATETIME should be represented in the format DATE + " " + TIME
  • TIMESTAMP is the same as DATETIME

Supported sql query statements:

example 1:
  • CREATE TABLE date1selectwhere (i INTEGER, d1 DATE, d2 DATE);
  • DESCRIBE date1selectwhere;
  • INSERT INTO date1selectwhere VALUES (11, DATE '1870-11-1', DATE '2570-1-1');
  • INSERT INTO date1selectwhere VALUES (111, DATE '6570-11-1', DATE '5570-6-21');
  • SELECT * FROM date1selectwhere WHERE d1 < d2;
  • SELECT * FROM date1selectwhere WHERE d1 = DATE '1970-1-1' + INTERVAL -100 YEAR + INTERVAL 10 MONTH;
example 2:
  • CREATE TABLE datetimeselectwhere (t TIME, dt DATETIME, ts TIMESTAMP);
  • DESCRIBE datetimeselectwhere;
  • INSERT INTO datetimeselectwhere VALUES (TIME '12:0:0', DATETIME '5570-8-31 0:0:0', TIMESTAMP '6570-12-31 12:0:0');
  • SELECT EXTRACT('year' FROM ts + (INTERVAL 1 DAY)) FROM datetimeselectwhere WHERE EXTRACT('hour' FROM t) = 12;

Code changes

  • Has Code change

Check List

  • Unit test
  • sqllogictest

Side effects

Changed parser.y
Changed src/network/connection.cpp
Changed scripts/Dockerfile_infinity_builder_centos7
Changed scripts/infinity-deps-ubuntu2004.sh
Changed scripts/infinity-deps-ubuntu2204.sh
Changed scripts/infinity-deps-ubuntu2310.sh

@JinHai-CN JinHai-CN merged commit c55bfd9 into infiniflow:main Dec 29, 2023
2 of 5 checks passed
JinHai-CN pushed a commit that referenced this pull request Jan 3, 2024
* add some function for DateT

* support constant result for function

* add sqllogictest scripts

* add initial support for TimeType and DateTimeType

* edit parser.y

* fix pg protocol send

* support extract y/m/d/h/m/s from TIME, DATETIME and TIMESTAMP

* change TIME unit from millisecond to second

* add sqllogictest for TIME, DATETIME and TIMESTAMP

* add GetEpochTime for DATETIME and TIMESTAMP

* fix doc

* update unit_test
@yangzq50 yangzq50 deleted the fix_date branch March 21, 2024 05:23
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