Serverless Pool: Msg 15872, Level 16, State 1, Line 13 NOT NULL is not allowed for external table columns.
- Dominant language
- C#
- Stars
- 460
- Forks
- 29
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 7
Description
- SqlPackage or DacFx Version: 162.2.111.2
- .NET Framework (Windows-only) or .NET Core:
- Environment (local platform and source/target platforms):
**Steps to Reproduce:**
1. Create an External Table in serverless pool
```
CREATE EXTERNAL TABLE [dbo].[test2]
WITH (
LOCATION = '/stage/test',
DATA_SOURCE =[dls] ,
FILE_FORMAT = ParquetFormat
)
AS
SELECT 1 as Id
```
3. Note that in SSMS it shows the column as not null

4 now try to recreate this table specifying NOT NULL
```
DROP EXTERNAL TABLE [dbo].[test]
CREATE EXTERNAL TABLE [dbo].[test]
(
[Id] [int] NOT NULL
)
WITH (DATA_SOURCE = [dls],LOCATION = N'/stage/test',FILE_FORMAT = [ParquetFormat])
GO
```
this error occurs
Msg 15872, Level 16, State 1, Line 13 NOT NULL is not allowed for external table columns.
it is also worth noting that SMSS 19.3 will correctly script this out:
```
CREATE EXTERNAL TABLE [dbo].[test]
(
[Id] [int] NULL
)
WITH (DATA_SOURCE = [dls],LOCATION = N'/stage/test',FILE_FORMAT = [ParquetFormat])
GO
```
However ADS Schema compare scripts it out as NOT NULL
which it successfully builds in database project / sqlpackage however the resulting script fails when trying to deploy.
to be honest I'm not entirely sure where the bug is here. There seems to be a disagreement between SSMS and DACFX as to what is allowed. In any case this isn't desired or expected behavior.
I would assert we should be able to define a column as not null in the table definition in serverlesss pool or if not the behavior across all tools should be consistent.
(DacFx/SqlPackage/SSMS/Azure Data Studio)
Contributor guide
Research direction
No source file or test is named. Start by reproducing the external-table scripts in a serverless pool, then compare the output from SSMS 19.3, Azure Data Studio Schema Compare, and SqlPackage/database projects. Done means the tools agree on the column nullability and deployment no longer emits an invalid NOT NULL definition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- databases, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100