Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

CREATE TABLE: SPARSE MASKED WITH (...) column order (per MS docs) fails to parse; reversed order parses fine

Đang mở
#216 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp, sql
Lĩnh vực
compilers, tooling

Hướng nghiên cứu

Bắt đầu với ngữ pháp column_definition và tái hiện vấn đề bằng TSql160Parser cùng câu lệnh CREATE TABLE tối thiểu. So sánh thứ tự SPARSE MASKED được tài liệu hóa với thứ tự đảo ngược đã hoạt động trong các phiên bản parser bị ảnh hưởng. Được coi là hoàn thành khi thứ tự được tài liệu hóa được phân tích với 0 lỗi và hành vi hiện có vẫn được bao phủ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

CREATE TABLE column definitions that combine SPARSE and MASKED WITH (FUNCTION = ...) fail to parse (Incorrect syntax near 'MASKED') when the clauses appear in the order documented by Microsoft's own T-SQL reference (COLLATESPARSEMASKED WITH). The reversed, non-standard order (MASKED WITH (...) before SPARSE) parses without error. This looks like an order-handling gap in the column_definition grammar rather than a missing feature — both SPARSE and MASKED WITH are individually well supported.

Repro

CREATE TABLE t (
    c varchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS SPARSE MASKED WITH (FUNCTION = 'default()') NULL
);

Minimal reduction (no COLLATE needed):

CREATE TABLE t (c varchar(100) SPARSE MASKED WITH (FUNCTION = 'default()') NULL);
TSql160Parser parser = new(initialQuotedIdentifiers: true);
using StringReader reader = new(sql);
TSqlFragment fragment = parser.Parse(reader, out IList<ParseError> errors);
// errors.Count == 1
// errors[0].Message == "Incorrect syntax near 'MASKED'."

Swapping the clause order makes the identical statement parse cleanly:

CREATE TABLE t (c varchar(100) MASKED WITH (FUNCTION = 'default()') SPARSE NULL);
-- errors.Count == 0

Per the official CREATE TABLE grammar reference (https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql), the documented <column_definition> order is:

column_name <data_type>
    [ FILESTREAM ]
    [ COLLATE collation_name ]
    [ SPARSE ]
    [ MASKED WITH ( FUNCTION = 'mask_function' ) ]
    ...

i.e. SPARSE before MASKED WITH. That documented order is exactly the order that fails to parse.

Scope tested

Parser classes (package version 180.37.3) — tested all concrete TSqlParser subclasses against the repro:

Parser Result
TSql80Parser / TSql90Parser fails on SPARSE itself (expected — predates the feature)
TSql100Parser / TSql110Parser / TSql120Parser Expected FILESTREAM but encountered MASKED instead.
TSql130ParserTSql180Parser Incorrect syntax near 'MASKED'.
TSqlFabricDWParser Incorrect syntax near 'MASKED'.

Every parser class from TSql100Parser onward (i.e. every version where MASKED is otherwise supported) rejects the SPARSE MASKED WITH (...) ordering.

Package versions — reproduced with the default (TSql160Parser)/latest-appropriate parser across every published version from 170.3.0 through the current latest:

170.3.0, 170.12.0, 170.64.0, 170.121.2, 170.157.0, 170.191.0, 180.6.0, 180.18.1, 180.37.3

All affected, no regression/fix in any tested version.

Expected behavior

COLLATE ... SPARSE MASKED WITH (FUNCTION = ...) — the order documented in Microsoft's own T-SQL reference, and valid, functioning DDL against a real SQL Server / Azure SQL instance — should parse without error, matching the already-working reversed order.

Additional notes

  • Searched existing issues for MASKED, SPARSE, and combinations thereof; found no duplicate.
  • Encountered this while building a T-SQL static-analysis tool against a real-world database schema using Dynamic Data Masking on sparse columns (a documented, supported SQL Server feature combination).
Ngôn ngữ chính
GAP
Star
277
Fork
43
Merge trung bình
6 ngày 17 giờ
Pull request đã merge (30 ngày)
3

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/SqlScriptDOM

Tất cả issue của microsoft/SqlScriptDOM

Issue tương tự

Thêm issue về Compilers

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.