Repository navigation
sql-839: Report SQL string 'NULL' for table column defaults in mz_columns again - #40316
Merged
SangJunBak merged 4 commits intoOct 29, 2026
Conversation
mz_columns.default reads as the string NULL for a table column without a default, as it did in every release through v26.48. #40001 made it SQL NULL, which the Terraform provider (every release through v0.11.12) compares against its declared default of "NULL": it then replaces the table on every apply and drops its rows (SQL-839). Builtin tables read the string too, so the contract holds for every table and not only for user tables. The PostgreSQL-compatible views keep the behavior #40001 gave them by mapping the string to no default: pg_attribute.atthasdef is false, pg_attrdef has no row and information_schema.columns.column_default is NULL for such a column. Closes: SQL-839 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A table column without a default reads as the string NULL in mz_columns and as no default in pg_attribute, pg_attrdef and information_schema (SQL-839). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
aljoscha
approved these changes
Oct 29, 2026
ggevay
approved these changes
Oct 29, 2026
| item_columns_initial_mv 2 b true text <null> text -1 | ||
| item_columns_initial_mv 3 c1 true numeric <null> numeric -1 | ||
| item_columns_initial_table 1 a false integer <null> int4 -1 | ||
| item_columns_initial_table 1 a false integer NULL int4 -1 |
Contributor
There was a problem hiding this comment.
The two version branches now expect the same rows, and the comment above them ("From 26.49 on ... no default reads as SQL NULL") no longer holds. The guard and comment can go, leaving one query.
| .map_or(serde_json::Value::Null, |expr| { | ||
| json!(expr.to_ast_string_stable()) | ||
| }) | ||
| // A column without a default reads as the string NULL, see the |
Contributor
There was a problem hiding this comment.
Worth saying why here, so the next cleanup doesn't undo it: clients compare against this string, and the Terraform provider replaces a table whose column default reads as SQL NULL (SQL-839). Maybe also TODO(DEX-197): switch to SQL NULL once released providers read it as no default.
- Say at the decision point why a missing default reads as the string NULL - Drop the 26.49 version guard in the item_columns platform check, since both sides now expect the same rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SangJunBak
force-pushed
the
jun/sql-839-terraform-apply-drops-and-recreates-tables-after-the
branch
from
October 29, 2026 13:52
8d8f551 to
4e7e4aa
Compare
SangJunBak
deleted the
jun/sql-839-terraform-apply-drops-and-recreates-tables-after-the
branch
October 29, 2026 14:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before, tables whose columns' defaults were undefined we'd store their
mz_columnsdefault value as the SQL string 'NULL' but would store it as NULL for other relation objects. In #40001 , we decided to unify the behavior and store it as NULL for tables too. However, this created a regression in our terraform provider where it'd drop and create tables with no defaults on their columns because of a schema mismatch. Thus we change it back to the SQL stringNULL.Motivation
Closes: SQL-839
Verification
We still get pg compatibility by just changing the definition of the information_schema / pg views. This is why we don't need to update any of the SLT tests related to those views.