Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nothing columns in DB backends #11757

Closed
radeusgd opened this issue Dec 4, 2024 · 5 comments
Closed

Nothing columns in DB backends #11757

radeusgd opened this issue Dec 4, 2024 · 5 comments
Assignees
Labels
-libs Libraries: New libraries to be implemented l-db-connector Libraries: database connectors

Comments

@radeusgd
Copy link
Member

radeusgd commented Dec 4, 2024

Most DB backends do not allow to create a table with a column that has NULL column type. So we disallow Value_Type.Null in select_into_database_table.

However, we should make it possible to use Nothing in expressions, and perhaps create an all-nothing column. Just some cautious usage of the value-types needs to be done so that we can use the Null type in the temporary column but don't do anything invalid like CAST(x as NULL).

There are existing Expression_Spec tests that just need to be enabled to test this.

@radeusgd radeusgd added -libs Libraries: New libraries to be implemented l-db-connector Libraries: database connectors labels Dec 4, 2024
@radeusgd radeusgd self-assigned this Dec 4, 2024
@github-project-automation github-project-automation bot moved this to ❓New in Issues Board Dec 4, 2024
radeusgd added a commit that referenced this issue Dec 4, 2024
radeusgd added a commit that referenced this issue Dec 4, 2024
radeusgd added a commit that referenced this issue Dec 4, 2024
@radeusgd
Copy link
Member Author

radeusgd commented Dec 9, 2024

Check behaviour of SELECT 1, NULL, 'a';

@radeusgd radeusgd moved this from ❓New to 📤 Backlog in Issues Board Dec 18, 2024
radeusgd added a commit that referenced this issue Dec 19, 2024
radeusgd added a commit that referenced this issue Dec 19, 2024
radeusgd added a commit that referenced this issue Dec 19, 2024
@radeusgd radeusgd moved this from 📤 Backlog to 🔧 Implementation in Issues Board Jan 20, 2025
@radeusgd
Copy link
Member Author

It seems that there is no good way to have a NULL type column in Postgres. Creating such column in CREATE TABLE obviously does not make sense, but even a 'virtual' column (e.g. result of SELECT NULL;) gets some type - defaulting to Char if no constraints.

After a discussion we decided that it just doesn't make sense to try creating some weird construction to get Null column type to work in DB.

The only real issue with it is that expressions that have Nothing as left-hand side won't work in DB - e.g. Nothing + [A] or ISNULL(Nothing). But such expressions have little utility in practice. Currently they will fail with Unsupported_Database_Operation - e.g. Postgres tables do not support Null types.

@github-project-automation github-project-automation bot moved this from 🔧 Implementation to 🟢 Accepted in Issues Board Jan 22, 2025
@radeusgd
Copy link
Member Author

Check behaviour of SELECT 1, NULL, 'a';

In Postgres:

> c.query (..Raw_SQL "SELECT 1 AS a, NULL AS b, 'a' AS c") . column_info . print
   | Column | Items Count | Value Type
---+--------+-------------+--------------------------------
 0 | a      | 1           | (Value_Type.Integer 32 bits)
 1 | b      | 0           | (Value_Type.Char Nothing True)
 2 | c      | 1           | (Value_Type.Char Nothing True)

@radeusgd
Copy link
Member Author

After a discussion we decided that it just doesn't make sense to try creating some weird construction to get Null column type to work in DB.

Exception is SQLite which cares little about types so it seems to make sense to have a Nothing column there. We can disable it though if it would be causing any problems.

@enso-bot
Copy link

enso-bot bot commented Jan 23, 2025

Radosław Waśko reports a new STANDUP for yesterday (2025-01-22):

Progress: Updated tests in the upstream PR according to the discussion. Created a draft for the single-value column intersection type. Debugging interpreter crashes, got it resolved with Jaroslav's help. It should be finished by 2025-01-22.

Next Day: Next day I will be working on the #12095 task. Prepare PR for the intersection type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-libs Libraries: New libraries to be implemented l-db-connector Libraries: database connectors
Projects
Status: 🟢 Accepted
Development

No branches or pull requests

1 participant