samredai commented on a change in pull request #4318:
URL: https://github.com/apache/iceberg/pull/4318#discussion_r837534695



##########
File path: python/tests/table/test_schema.py
##########
@@ -0,0 +1,246 @@
+# 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 pytest
+
+from iceberg.table import schema
+from iceberg.types import (
+    BooleanType,
+    IntegerType,
+    ListType,
+    MapType,
+    NestedField,
+    StringType,
+)
+
+
+def test_schema_str():
+    """Test casting a schema to a string"""
+    columns = [
+        NestedField(field_id=1, name="foo", field_type=StringType(), 
is_optional=False),
+        NestedField(field_id=2, name="bar", field_type=IntegerType(), 
is_optional=True),
+        NestedField(field_id=3, name="baz", field_type=BooleanType(), 
is_optional=False),
+    ]
+    table_schema = schema.Schema(*columns)
+    assert """table { 
+ 1: foo: required string

Review comment:
       The way multistring lines in python works it doesn't recognize the 
indentation which is meaningful to the code. The common method I've seen to 
avoid these weird looking strings is `dedent` from the standard library.
   ```py
   from textwrap import dedent
   ...
       table_schema = schema.Schema(*columns)
       assert str(table_schema) == dedent("""\
       table { 
        1: foo: required string
        2: bar: optional int
        3: baz: required boolean
        }""")
   ```




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