dramaticlly commented on a change in pull request #4262:
URL: https://github.com/apache/iceberg/pull/4262#discussion_r819040339



##########
File path: python/src/iceberg/literals.py
##########
@@ -0,0 +1,580 @@
+# 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 datetime
+import uuid
+from decimal import ROUND_HALF_UP, Decimal
+
+import pytz
+
+from .types import *
+
+
+class Literals(object):
+
+    EPOCH = datetime.datetime.utcfromtimestamp(0)
+    EPOCH_DAY = EPOCH.date()
+
+    @staticmethod
+    def above_max():
+        return ABOVE_MAX
+
+    @staticmethod
+    def below_min():
+        return BELOW_MIN
+
+
+def from_(value):  # noqa: C901
+    if value is None:
+        raise RuntimeError("Cannot create an expression literal from None")
+    if isinstance(value, bool):
+        return BooleanLiteral(value)
+    elif isinstance(value, int):
+        if Literal.JAVA_MIN_INT < value < Literal.JAVA_MAX_INT:
+            return IntegerLiteral(value)
+        return LongLiteral(value)
+    elif isinstance(value, float):
+        if Literal.JAVA_MIN_FLOAT < value < Literal.JAVA_MAX_FLOAT:
+            return FloatLiteral(value)
+        return DoubleLiteral(value)
+    elif isinstance(value, str):
+        return StringLiteral(value)
+    elif isinstance(value, uuid.UUID):
+        return UUIDLiteral(value)
+    elif isinstance(value, bytearray):
+        return BinaryLiteral(value)
+    elif isinstance(value, bytes):
+        return FixedLiteral(value)
+    elif isinstance(value, Decimal):
+        return DecimalLiteral(value)
+    else:
+        raise NotImplementedError("Unimplemented Type Literal for value: %s" % 
value)

Review comment:
       as moved to python module methods, this looks very similar to LINE81 to 
101, so I am thinking about merge them so we can have only 1 factory.




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

Reply via email to