rdblue commented on a change in pull request #3450:
URL: https://github.com/apache/iceberg/pull/3450#discussion_r748890005



##########
File path: python/src/iceberg/transforms.py
##########
@@ -0,0 +1,520 @@
+# 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 base64
+import math
+import re
+import struct
+from datetime import datetime, timedelta
+from decimal import Decimal
+
+import mmh3  # type: ignore
+import pytz
+
+from .types import (
+    BinaryType,
+    DateType,
+    DecimalType,
+    DoubleType,
+    FixedType,
+    FloatType,
+    IntegerType,
+    LongType,
+    StringType,
+    TimestampType,
+    TimestamptzType,
+    TimeType,
+    Type,
+    UUIDType,
+)
+
+
+class Transform(object):
+    """
+    Transform base class for concrete transforms. The default implementation 
is for VoidTransform.
+    """
+
+    _EPOCH = datetime.utcfromtimestamp(0)
+
+    @staticmethod
+    def _human_day(day_ordinal):
+        time = Transform._EPOCH + timedelta(days=day_ordinal)
+        return "{0:0=4d}-{1:0=2d}-{2:0=2d}".format(time.year, time.month, 
time.day)
+
+    @staticmethod
+    def _unscale_decimal(decimal_value: Decimal):
+        value_tuple = decimal_value.as_tuple()
+        return int(
+            ("-" if value_tuple.sign else "")
+            + "".join([str(d) for d in value_tuple.digits])
+        )
+
+    def __init__(self, transform_string: str, repr_string: str):
+        self._transform_string = transform_string
+        self._repr_string = repr_string
+
+    def __repr__(self):
+        return self._repr_string
+
+    def __str__(self):
+        return self._transform_string
+
+    def apply(self, value):
+        return None
+
+    def can_transform(self, target: Type) -> bool:
+        return True
+
+    def get_result_type(self, source: Type) -> Type:
+        return source
+
+    def preserve_order(self) -> bool:

Review comment:
       If there is a published PEP that requires dropping the `s`, then we can 
go with that.
   
   Otherwise, use the form that is correct when reading code as a sentence:
   
   ```
   if transform.preserves_order():
       pass
   ```
   
   The form with `s` is used here because when you read it you get "if the 
transform preserves order". Without the `s` is not grammatically correct in 
that sentence.




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