zeroshade commented on code in PR #118:
URL: https://github.com/apache/iceberg-go/pull/118#discussion_r1715458705


##########
dev/provision.py:
##########
@@ -0,0 +1,391 @@
+# 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.
+
+from pyspark.sql import SparkSession
+from pyspark.sql.functions import current_date, date_add, expr
+
+from pyiceberg.catalog import load_catalog
+from pyiceberg.schema import Schema
+from pyiceberg.types import FixedType, NestedField, UUIDType
+
+spark = SparkSession.builder.getOrCreate()
+
+catalogs = {
+    'rest': load_catalog(
+        "rest",
+        **{
+            "type": "rest",
+            "uri": "http://rest:8181";,
+            "s3.endpoint": "http://minio:9000";,
+            "s3.access-key-id": "admin",
+            "s3.secret-access-key": "password",
+        },
+    ),
+    # 'hive': load_catalog(
+    #     "hive",
+    #     **{
+    #         "type": "hive",
+    #         "uri": "http://hive:9083";,
+    #         "s3.endpoint": "http://minio:9000";,
+    #         "s3.access-key-id": "admin",
+    #         "s3.secret-access-key": "password",
+    #     },
+    # ),
+}
+
+for catalog_name, catalog in catalogs.items():
+    spark.sql(
+        f"""
+      CREATE DATABASE IF NOT EXISTS default;
+    """
+    )
+
+    schema = Schema(
+        NestedField(field_id=1, name="uuid_col", field_type=UUIDType(), 
required=False),
+        NestedField(field_id=2, name="fixed_col", field_type=FixedType(25), 
required=False),
+    )
+
+    
catalog.create_table(identifier=f"default.test_uuid_and_fixed_unpartitioned", 
schema=schema)
+
+    spark.sql(
+        f"""
+        INSERT INTO default.test_uuid_and_fixed_unpartitioned VALUES
+        ('102cb62f-e6f8-4eb0-9973-d9b012ff0967', 
CAST('1234567890123456789012345' AS BINARY)),
+        ('ec33e4b2-a834-4cc3-8c4a-a1d3bfc2f226', 
CAST('1231231231231231231231231' AS BINARY)),
+        ('639cccce-c9d2-494a-a78c-278ab234f024', 
CAST('12345678901234567ass12345' AS BINARY)),
+        ('c1b0d8e0-0b0e-4b1e-9b0a-0e0b0d0c0a0b', 
CAST('asdasasdads12312312312111' AS BINARY)),
+        ('923dae77-83d6-47cd-b4b0-d383e64ee57e', 
CAST('qweeqwwqq1231231231231111' AS BINARY));
+        """
+    )
+
+    spark.sql(
+        f"""
+      CREATE OR REPLACE TABLE default.test_null_nan
+      USING iceberg
+      AS SELECT
+        1            AS idx,
+        float('NaN') AS col_numeric
+    UNION ALL SELECT
+        2            AS idx,
+        null         AS col_numeric
+    UNION ALL SELECT
+        3            AS idx,
+        1            AS col_numeric;
+    """
+    )
+
+    spark.sql(
+        f"""
+      CREATE OR REPLACE TABLE default.test_null_nan_rewritten
+      USING iceberg
+      AS SELECT * FROM default.test_null_nan;
+    """
+    )
+
+    spark.sql(
+        f"""
+    CREATE OR REPLACE TABLE default.test_limit as
+      SELECT * LATERAL VIEW explode(ARRAY(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) AS 
idx;
+    """
+    )
+
+    spark.sql(
+        f"""
+    CREATE OR REPLACE TABLE default.test_positional_mor_deletes (
+        dt     date,
+        number integer,
+        letter string
+    )
+    USING iceberg
+    TBLPROPERTIES (
+        'write.delete.mode'='merge-on-read',
+        'write.update.mode'='merge-on-read',
+        'write.merge.mode'='merge-on-read',
+        'format-version'='2'
+    );
+    """
+    )
+
+    # Partitioning is not really needed, but there is a bug:
+    # https://github.com/apache/iceberg/pull/7685
+    spark.sql(f"ALTER TABLE default.test_positional_mor_deletes ADD PARTITION 
FIELD years(dt) AS dt_years")
+
+    spark.sql(
+        f"""
+    INSERT INTO default.test_positional_mor_deletes
+    VALUES
+        (CAST('2023-03-01' AS date), 1, 'a'),
+        (CAST('2023-03-02' AS date), 2, 'b'),
+        (CAST('2023-03-03' AS date), 3, 'c'),
+        (CAST('2023-03-04' AS date), 4, 'd'),
+        (CAST('2023-03-05' AS date), 5, 'e'),
+        (CAST('2023-03-06' AS date), 6, 'f'),
+        (CAST('2023-03-07' AS date), 7, 'g'),
+        (CAST('2023-03-08' AS date), 8, 'h'),
+        (CAST('2023-03-09' AS date), 9, 'i'),
+        (CAST('2023-03-10' AS date), 10, 'j'),
+        (CAST('2023-03-11' AS date), 11, 'k'),
+        (CAST('2023-03-12' AS date), 12, 'l');
+    """
+    )
+
+    spark.sql(f"ALTER TABLE default.test_positional_mor_deletes CREATE TAG 
tag_12")
+
+    spark.sql(f"ALTER TABLE default.test_positional_mor_deletes CREATE BRANCH 
without_5")
+
+    spark.sql(f"DELETE FROM 
default.test_positional_mor_deletes.branch_without_5 WHERE number = 5")
+
+    spark.sql(f"DELETE FROM default.test_positional_mor_deletes WHERE number = 
9")
+
+    spark.sql(
+        f"""
+      CREATE OR REPLACE TABLE default.test_positional_mor_double_deletes (
+        dt     date,
+        number integer,
+        letter string
+      )
+      USING iceberg
+      TBLPROPERTIES (
+        'write.delete.mode'='merge-on-read',
+        'write.update.mode'='merge-on-read',
+        'write.merge.mode'='merge-on-read',
+        'format-version'='2'
+      );
+    """
+    )
+
+    # Partitioning is not really needed, but there is a bug:
+    # https://github.com/apache/iceberg/pull/7685

Review Comment:
   pulled the comment from the `provision.py` file in `iceberg-python`. I'll 
remove it.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to