Timm0 commented on code in PR #29070:
URL: https://github.com/apache/flink/pull/29070#discussion_r3932985286


##########
flink-python/pyflink/dataframe/dataframe.py:
##########
@@ -1139,6 +1237,50 @@ def _quote_identifier(name: str) -> str:
     return "`" + name.replace("`", "``") + "`"
 
 
+def _resolve_window_time_column(on: Union[str, Expression]) -> Expression:
+    if isinstance(on, str):
+        return table_col(on)
+    if isinstance(on, Expression):
+        return on
+    raise TypeError("on must be a column name or expression")
+
+
+def _window_dataframe(
+    table: Table, window_kind: str, time_col: Expression, *interval_exprs: Any
+) -> "DataFrame":
+    jvm = get_gateway().jvm
+    kind = getattr(
+        
jvm.org.apache.flink.table.operations.WindowTableFunctionQueryOperation.WindowKind,
+        window_kind,
+    )
+    intervals = jvm.java.util.ArrayList()
+    for interval in interval_exprs:
+        intervals.add(interval)
+    operation_tree_builder = table._t_env._j_tenv.getOperationTreeBuilder()
+    window_op = operation_tree_builder.windowTableFunction(
+        kind,
+        time_col._j_expr,
+        intervals,
+        table._j_table.getQueryOperation(),
+    )
+    j_table = table._t_env._j_tenv.createTable(window_op)
+    return DataFrame(Table(j_table, table._t_env))
+
+
+def _to_interval_expression(value: Union["datetime.timedelta", Expression]) -> 
Any:
+    if isinstance(value, datetime.timedelta):
+        millis = value // datetime.timedelta(milliseconds=1)

Review Comment:
   Correct me if I'm wrong but Flink supports ms resolution, while Python 
`timedelta` supports sub-ms. Therefore we are dropping any sub-ms here. One 
thing we could do here though is to throw a `ValueError` for non-zero sub-ms 
instead of silently dropping. If you think that this would be the right call 
here, then I'm happy to add a guard.



-- 
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]

Reply via email to