auroflow commented on code in PR #28924: URL: https://github.com/apache/flink/pull/28924#discussion_r3781351941
########## flink-python/pyflink/table/literal.py: ########## @@ -0,0 +1,219 @@ +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ + +import calendar +import datetime +import time +from array import array + +from pyflink.common import Row +from pyflink.java_gateway import get_gateway +from pyflink.table.types import ( + _array_type_mappings, + _to_java_data_type, + ArrayType, + DataType, + DateType, + DayTimeIntervalType, + LocalZonedTimestampType, + MapType, + MultisetType, + RowType, + TimeType, + TimestampType, + ZonedTimestampType, +) +from pyflink.util.api_stability_decorators import Internal + + +@Internal() +def _to_java_literal_value(value, data_type: DataType = None): + """Converts Python-only literal values into objects accepted by Py4J.""" + if data_type is None: + return _to_java_inferred_literal_value(value) + return _to_java_typed_literal_value(value, data_type) + + +def _to_java_inferred_literal_value(value): + if value is None: + return value + + gateway = get_gateway() + jvm = gateway.jvm + if isinstance(value, datetime.datetime): + return _to_java_typed_literal_value(value, TimestampType()) Review Comment: You’re right. The previous implementation discarded the timezone offset while preserving the wall-clock fields, which was incorrect. I’ve changed it to convert the instant to the client’s system timezone before creating the TIMESTAMP literal. -- 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]
