phillipleblanc opened a new issue, #10796:
URL: https://github.com/apache/datafusion/issues/10796
### 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 > to_timestamp('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](https://github.com/apache/datafusion/blob/16346022ed4564211c0fb4bf20ac165f2c481a90/datafusion/sql/src/unparser/expr.rs#L93-L94))
Add a test to
[expr_to_sql_ok](https://github.com/apache/datafusion/blob/16346022ed4564211c0fb4bf20ac165f2c481a90/datafusion/sql/src/unparser/expr.rs#L912-L913)
Note you can run the tests like
```
cargo test -p datafusion-sql -- expr_to_sql_ok
```
### Additional context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]