leaves12138 opened a new issue, #1233:
URL: https://github.com/apache/incubator-paimon/issues/1233

   ### Search before asking
   
   - [X] I searched in the 
[issues](https://github.com/apache/incubator-paimon/issues) and found nothing 
similar.
   
   
   ### Motivation
   
   In spark, insert into a non-null column (primary-key) with a nullable value 
will display a error:
   Cannot write nullable values to non-null column 'pkey'
   
   But we can use the nvl or coalesce to work around. We need a docs in 
https://paimon.apache.org/docs/master/how-to/writing-tables/#applying-recordschanges-to-tables
 to demonstrate this.
   
   we also need a test case to cover this like:
       @Test
       public void testNonnull() {
           spark.sql(
                   "CREATE TABLE T (a INT NOT NULL, b INT, c STRING) 
TBLPROPERTIES"
                           + " ('primary-key'='a', 'file.format'='avro')");
           spark.sql(
                   "CREATE TABLE T2 (a INT, b INT, c STRING) TBLPROPERTIES"
                           + " ('file.format'='avro')");
           spark.sql("INSERT INTO T2 VALUES (1, 11, '111'), (null, 22, 
'222')").collectAsList();
           Assertions.assertNoException(spark.sql("INSERT INTO T SELECT nvl(a, 
1), b, c FROM T2"));
       }
   in class SparkWriteITCase
   
   
   
   ### Solution
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


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

Reply via email to