alamb opened a new issue, #5575:
URL: https://github.com/apache/arrow-datafusion/issues/5575

                 I made changes to the code based on the feedback received. 
While testing the code, I discovered a problem with how a table was being 
created using a DDL query. The issue was that the table was made with 
non-nullable columns by default, which contradicts PostgreSQL 15.
   
   ```sql
   CREATE TABLE table_without_values(field1 BIGINT, field2 BIGINT);
   ```
   DDL query. It defaults to non-nullable columns while creating a table, which 
is not the case in [PostgreSQL 
15](https://www.postgresql.org/docs/current/sql-createtable.html).
   
   > NULL
   > The column is allowed to contain null values. This is the default.
   > This clause is only provided for compatibility with non-standard SQL 
databases. Its use is discouraged in new applications.
   
   To fix this issue, I changed the DDL queries to explicitly specify that the 
columns can contain null values, like this: `CREATE TABLE 
table_without_values(field1 BIGINT NULL, field2 BIGINT NULL);`. This was 
necessary because when using the `AS VALUES ...` statement to insert data into 
the table, it created a plan that assumed the schema was nullable, which is not 
compatible with a schema that has non-nullable fields.
   
   PS: The code piece that results non-nullable default:
   
https://github.com/apache/arrow-datafusion/blob/1a22f9fd436c9892566b668e535e0d6c8cb9fbd3/datafusion/sql/src/planner.rs#L127-L144
   
   _Originally posted by @metesynnada in 
https://github.com/apache/arrow-datafusion/issues/5520#issuecomment-1465991022_
               


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