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

Implement ScalarValue::TimestampNanosecond -> String Support #10796

Closed
phillipleblanc opened this issue Jun 5, 2024 · 1 comment · Fixed by #10984
Closed

Implement ScalarValue::TimestampNanosecond -> String Support #10796

phillipleblanc opened this issue Jun 5, 2024 · 1 comment · Fixed by #10984
Assignees
Labels
enhancement New feature or request

Comments

@phillipleblanc
Copy link
Contributor

phillipleblanc commented Jun 5, 2024

Is your feature request related to a problem or challenge?

Part of #9494 to complete support for Unparsing LogicalPlan to SQL String.

Converting LogicalPlans back to SQL is valuable for several usecases such as using DataFusion in federated databases (e.g. generate SQL to push down) or using DataFusion's expr APIs to programmatically create SQL.

Describe the solution you'd like

Support converting expression that are scalar timestamp values:

Here ts is a column with the schema: Timestamp(Millisecond, None)

> describe timestamp_test;
+----------------+------------------------------+-------------+
| column_name    | data_type                    | is_nullable |
+----------------+------------------------------+-------------+
...
| time           | Timestamp(Millisecond, None) | YES         |
sql> select * from timestamp_test where ts > '2024-01-01';
External error: This feature is not implemented: Unsupported DataType: conversion: Timestamp(Nanosecond, None)

The logical plan derived from parsing the above query should be able to be turned back into SQL.

Describe alternatives you've considered

The basic pattern is:

Implement the Expr --> AST reverse code in Unparser::expr_to_sql(source link)
Add a test to expr_to_sql_ok
Note you can run the tests like

cargo test -p datafusion-sql -- expr_to_sql_ok

Additional context

No response

@phillipleblanc phillipleblanc added the enhancement New feature or request label Jun 5, 2024
@goldmedal
Copy link
Contributor

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants