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

Change TIMESTAMP and TIME parsing so that time zone information is preserved #641

Merged
merged 3 commits into from Oct 3, 2022
Merged

Change TIMESTAMP and TIME parsing so that time zone information is preserved #641

merged 3 commits into from Oct 3, 2022

Conversation

AugustoFKL
Copy link
Contributor

Fixing TIME and TIMESTAMP printing considering the input (1), instead of assuming that:

  • The absence of arguments is equal to WITHOUT TIME ZONE (the standard recommends this, but may not be followed by all dialects)
  • The presence of WITH TIME ZONE equals adding TZ to the name. I.e.: TIMESTAMP WITH TIME ZONE to TIMESTMAPTZ. For example, Oracle doesn't apply that logic (2), but PostgreSQL does (3).

[1] : https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#datetime-type
[2] : https://docs.oracle.com/en/database/oracle/oracle-database/12.2/nlspg/datetime-data-types-and-time-zone-support.html#GUID-3F1C388E-C651-43D5-ADBC-1A49E5C2CA05
[3] : https://www.postgresql.org/docs/current/datatype-datetime.html
Resolves: #640
Fixes: #589

@coveralls
Copy link

coveralls commented Sep 30, 2022

Pull Request Test Coverage Report for Build 3174140375

  • 45 of 49 (91.84%) changed or added relevant lines in 4 files are covered.
  • 335 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 85.592%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ast/data_type.rs 8 12 66.67%
Files with Coverage Reduction New Missed Lines %
src/ast/data_type.rs 1 87.36%
src/parser.rs 334 83.03%
Totals Coverage Status
Change from base Build 3166221109: 0.02%
Covered Lines: 10218
Relevant Lines: 11938

💛 - Coveralls

@alamb
Copy link
Collaborator

alamb commented Oct 1, 2022

cc @waitingkuo

src/ast/data_type.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@alamb alamb left a comment

Choose a reason for hiding this comment

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

This looks great -- thank you @AugustoFKL

assert_eq!(data_type, expected);
let data_type = parser.parse_data_type().unwrap();
assert_eq!(data_type, expected_type);
assert_eq!(expected_type.to_string(), expected_str.to_string());
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@alamb alamb changed the title 640 Fixing time zone printing format for TIMESTAMP and TIME Change TIMESTAMP and TIME parsing so that time zone information is preserved Oct 3, 2022
@alamb alamb merged commit 95464ec into sqlparser-rs:main Oct 3, 2022
@waitingkuo
Copy link
Contributor

@alamb @AugustoFKL I just reviewed the codes, it looks great! 👍
sorry for the late reply

i'll file a issue to datafusion to align with this

@AugustoFKL AugustoFKL deleted the 640_timestmap-and-time-time-zone-correct-usage branch October 4, 2022 18:10
ovr pushed a commit to cube-js/sqlparser-rs that referenced this pull request Mar 21, 2023
…s preserved (sqlparser-rs#641)

* 640 Fixing time zone printing format for TIMESTAMP and TIME

* 640 Removing unnecessary changes

* Update src/ast/data_type.rs

Fix comment typo

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
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.

Timestamp print format based on input
4 participants