alamb commented on code in PR #13130:
URL: https://github.com/apache/datafusion/pull/13130#discussion_r1826963449


##########
datafusion/functions/src/datetime/from_unixtime.rs:
##########
@@ -93,12 +124,59 @@ fn get_from_unixtime_doc() -> &'static Documentation {
         Documentation::builder()
             .with_doc_section(DOC_SECTION_DATETIME)
             .with_description("Converts an integer to RFC3339 timestamp format 
(`YYYY-MM-DDT00:00:00.000000000Z`). Integers and unsigned integers are 
interpreted as nanoseconds since the unix epoch (`1970-01-01T00:00:00Z`) return 
the corresponding timestamp.")
-            .with_syntax_example("from_unixtime(expression)")
+            .with_syntax_example("from_unixtime(expression, timezone)")

Review Comment:
   I think the difference is that you need to take the *value* of the timezone 
argument, not just the type
    
   You can fix this by using `return_type_from_exprs` instead of `return_type`:
   
   
https://github.com/apache/datafusion/blob/b7f4db4b56e945944c0448f84c61b6f3b86728f8/datafusion/expr/src/udf.rs#L451



##########
datafusion/functions/src/datetime/from_unixtime.rs:
##########
@@ -93,12 +124,59 @@ fn get_from_unixtime_doc() -> &'static Documentation {
         Documentation::builder()
             .with_doc_section(DOC_SECTION_DATETIME)
             .with_description("Converts an integer to RFC3339 timestamp format 
(`YYYY-MM-DDT00:00:00.000000000Z`). Integers and unsigned integers are 
interpreted as nanoseconds since the unix epoch (`1970-01-01T00:00:00Z`) return 
the corresponding timestamp.")
-            .with_syntax_example("from_unixtime(expression)")
+            .with_syntax_example("from_unixtime(expression, timezone)")

Review Comment:
   I actually did this and found a bug: 
   
   ```sql
   > select from_unixtime(1730592000, 'America/New_York');
   Internal error: Failed due to a difference in schemas, original schema: 
DFSchema { inner: Schema { fields: [Field { name: "from_unixtime(ts_data.ts / 
Int64(1000000000),Utf8(\"America/New_York\"))", data_type: Timestamp(Second, 
Some("Utf8")), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} 
}, Field { name: "from_unixtime(Int64(1730592000),Utf8(\"America/New_York\"))", 
data_type: Timestamp(Second, Some("Utf8")), nullable: true, dict_id: 0, 
dict_is_ordered: false, metadata: {} }, Field { name: 
"arrow_typeof(from_unixtime(Int64(1730592000),Utf8(\"America/New_York\")))", 
data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: 
{} }], metadata: {} }, field_qualifiers: [None, None, None], 
functional_dependencies: FunctionalDependencies { deps: [] } }, new schema: 
DFSchema { inner: Schema { fields: [Field { name: "from_unixtime(ts_data.ts / 
Int64(1000000000),Utf8(\"America/New_York\"))", data_type: Timestamp(Second, 
Some("Utf8")), nullable: true, dic
 t_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: 
"from_unixtime(Int64(1730592000),Utf8(\"America/New_York\"))", data_type: 
Timestamp(Second, Some("America/New_York")), nullable: false, dict_id: 0, 
dict_is_ordered: false, metadata: {} }, Field { name: 
"arrow_typeof(from_unixtime(Int64(1730592000),Utf8(\"America/New_York\")))", 
data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: 
{} }], metadata: {} }, field_qualifiers: [None, None, None], 
functional_dependencies: FunctionalDependencies { deps: [] } }.
   ```



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to