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

Support alternate formats for unparsing datetime to timestamp and interval #11466

Merged

Conversation

y-f-u
Copy link
Contributor

@y-f-u y-f-u commented Jul 15, 2024

Which issue does this PR close?

This PR address more dialect variety in unparser:

  • interval for standard and postgres style
  • cast datetime as datetime or timestamp

Rationale for this change

SQLStandard format interval is needed for dbms like dremio.
datetime is missing for certain dbms too: dremio, trino.

What changes are included in this PR?

See "What issue does this PR close"

Are these changes tested?

Yes, unit tests added

Are there any user-facing changes?

n/a. But changed one CustomDialect::new to be deprecated in favor of CustomDialectBuilder

y-f-u and others added 2 commits July 15, 2024 13:12
* use timestamp as the identifier for date64

* rename

* implement CustomDialectBuilder

* fix
---------

Co-authored-by: Phillip LeBlanc <phillip@leblanc.tech>
@github-actions github-actions bot added the sql SQL Planner label Jul 15, 2024
Copy link
Contributor

@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.

Thank you @y-f-u -- other than the comments on CustomDialectBuilder I think this PR looks really nice to me 🙏

datafusion/sql/src/unparser/dialect.rs Outdated Show resolved Hide resolved
datafusion/sql/src/unparser/expr.rs Show resolved Hide resolved
datafusion/sql/src/unparser/expr.rs Show resolved Hide resolved
y-f-u and others added 2 commits July 16, 2024 15:30
@y-f-u y-f-u requested a review from alamb July 16, 2024 05:49
@alamb alamb changed the title Unparser datetime to timestamp and interval Support alternate formats for unparsing datetime to timestamp and interval Jul 16, 2024
Copy link
Contributor

@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.

Thanks @y-f-u -- this looks great to me 🙏

datafusion/sql/src/unparser/expr.rs Show resolved Hide resolved
@alamb alamb merged commit 55b792a into apache:main Jul 16, 2024
24 checks passed
@phillipleblanc phillipleblanc deleted the unparser-datetime-to-timestamp-and-interval branch July 16, 2024 22:23
xinlifoobar pushed a commit to xinlifoobar/datafusion that referenced this pull request Jul 17, 2024
… `interval` (apache#11466)

* Unparser rule for datatime cast (apache#10)

* use timestamp as the identifier for date64

* rename

* implement CustomDialectBuilder

* fix

* dialect with interval style (apache#11)

---------

Co-authored-by: Phillip LeBlanc <phillip@leblanc.tech>

* fmt

* clippy

* doc

* Update datafusion/sql/src/unparser/expr.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

* update the doc for CustomDialectBuilder

* fix doc test

---------

Co-authored-by: Phillip LeBlanc <phillip@leblanc.tech>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
xinlifoobar pushed a commit to xinlifoobar/datafusion that referenced this pull request Jul 18, 2024
… `interval` (apache#11466)

* Unparser rule for datatime cast (apache#10)

* use timestamp as the identifier for date64

* rename

* implement CustomDialectBuilder

* fix

* dialect with interval style (apache#11)

---------

Co-authored-by: Phillip LeBlanc <phillip@leblanc.tech>

* fmt

* clippy

* doc

* Update datafusion/sql/src/unparser/expr.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

* update the doc for CustomDialectBuilder

* fix doc test

---------

Co-authored-by: Phillip LeBlanc <phillip@leblanc.tech>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
wiedld pushed a commit to influxdata/arrow-datafusion that referenced this pull request Jul 31, 2024
… `interval` (apache#11466)

* Unparser rule for datatime cast (#10)

* use timestamp as the identifier for date64

* rename

* implement CustomDialectBuilder

* fix

* dialect with interval style (#11)

---------

Co-authored-by: Phillip LeBlanc <phillip@leblanc.tech>

* fmt

* clippy

* doc

* Update datafusion/sql/src/unparser/expr.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

* update the doc for CustomDialectBuilder

* fix doc test

---------

Co-authored-by: Phillip LeBlanc <phillip@leblanc.tech>
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
sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants