microsoft / microsoft/vscode-powerquery-sdk

Invalid column reference in Table.AddColumn outputs null instead of an error

Open
#223 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

answered
Dominant language
TypeScript
Stars
92
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Preflight Checklist
Power Query SDK

0.2.1

Regression From

No response

Platform

Windows

Architecture

x64

OS Version

No response

VSCode version

No response

PQSdkTool Path

No response

Bug Description

In Power Query, when Table.AddColumn's column generator function references a non-existent column, the output generated for the new column should be an error.

Steps to Reproduce
  1. Create a new connector project with a .test.pq file defined as follows (the connector's contents don't matter):
    let
        Source = Table.View(null, [
                GetRows = () => #table({"A"}, {{1}}),
                GetType = () => Value.Type(GetRows())
            ]),
        Added = Table.AddColumn(Source, "B", each if [NonExistent] <> null then 1 else 2)
    in
        Added
    
  2. Evaluate the test script file.
Actual Experience

The following two-column table is returned:

A B
1 null

JSON version of the above:

"Output": [
    {
        "A": 1,
        "B": null
    }
]
Expected Experience

Column B should contain an error, not a null value.

Additional Context

If the same M code is evaluated in Power BI's Query Editor, the following output is produced (reflects the expected error):
image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in a connector project's .test.pq file using the supplied Table.View and Table.AddColumn example; start by tracing how the SDK evaluates the test script and represents cell errors. Done when the missing [NonExistent] reference produces an error in column B rather than null, matching Power BI Query Editor behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.