d-tw opened a new issue, #7771:
URL: https://github.com/apache/iceberg/issues/7771

   ### Apache Iceberg version
   
   1.2.1 (latest release)
   
   ### Query engine
   
   Spark
   
   ### Please describe the bug 🐞
   
   When creating an iceberg table via Spark using a Glue catalog, the 
non-nullability of columns is not preserved - all columns are stored as 
nullable.
   I don't know if this is a bug, or a config issue, but I'm using a vanilla 
config and couldn't find anything in the docs.
   
   Launching spark as follows:
   
   ```sh
   /opt/spark/bin/pyspark --packages 
"org.apache.iceberg:iceberg-spark-runtime-3.3_2.12:1.0.0,software.amazon.awssdk:bundle:2.17.178,software.amazon.awssdk:url-connection-client:2.17.178"
 \
       --conf 
spark.sql.catalog.my_catalog=org.apache.iceberg.spark.SparkCatalog \
       --conf spark.sql.catalog.my_catalog.warehouse=/unused-warehouse \
       --conf 
spark.sql.catalog.my_catalog.catalog-impl=org.apache.iceberg.aws.glue.GlueCatalog
 \
       --conf 
spark.sql.catalog.my_catalog.io-impl=org.apache.iceberg.aws.s3.S3FileIO \
       --conf 
spark.sql.catalog.spark_catalog=org.apache.iceberg.spark.SparkSessionCatalog \
       --conf spark.sql.catalog.spark_catalog.type=hive \
       --conf spark.hadoop.fs.s3a.access.key=$AWS_ACCESS_KEY_ID \
       --conf spark.hadoop.fs.s3a.secret.key=$AWS_SECRET_ACCESS_KEY \
       --conf 
"spark.driver.extraJavaOptions=-Dsoftware.amazon.awssdk.http.service.impl=software.amazon.awssdk.http.urlconnection.UrlConnectionSdkHttpService
 -Dderby.system.home=/tmp/derby -Divy.cache.dir=/tmp -Divy.home=/tmp" \
       --conf 
"spark.executor.extraJavaOptions=-Dsoftware.amazon.awssdk.http.service.impl=software.amazon.awssdk.http.urlconnection.UrlConnectionSdkHttpService
 -Dderby.system.home=/tmp/derby -Divy.cache.dir=/tmp -Divy.home=/tmp"
   ```
   
   
   Running the following commands:
   
   ```py
   from pyspark.sql.types import StructType, StructField, StringType
   
   schema = StructType([StructField('foo', StringType(), nullable=False)])
   
   df = spark.createDataFrame([], schema=schema)
   
   df.printSchema()
   # root
   # |-- foo: string (nullable = false)
   
   df.writeTo('my_table_with_non_null_fields').create()
   
   spark.table('my_table_with_non_null_fields').printSchema()
   # root
   # |-- foo: string (nullable = true)
   ```
   
   When I check the contents of the Glue catalog, I find:
   
   ```json
   "Columns": [
       {
           "Name": "foo",
           "Type": "string",
           "Parameters": {
               "iceberg.field.current": "true",
               "iceberg.field.id": "1",
               "iceberg.field.optional": "true"
           }
       }
   ]
   ```
   


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