microsoft / vscode-powerquery-sdk

Power Query Connector Development SDK for VS Code
MIT License
72 stars 12 forks source link

Add Method for Getting Type's Subtype Claim #240

Open bgribaudo opened 1 year ago

bgribaudo commented 1 year ago

Preflight Checklist

Problem

The standard library does not seem to provide an easy or accurate way to read a type's subtype claim.

Why is this important?

When a Table.View's OnAddColumns handler is invoked, it is passed a list of records describing the column(s) to add. One of the fields provided in these records is Type, which corresponds to Table.AddColumn's optional fourth columnType argument. (This fourth argument can be a basic M type [e.g. type number or type text] or one that is decorated with a subtype claim [like Int64.Type or Uri.Type].)

A connector's OnAddColumns handler may want to factor in type's subtype claim (for example, perhaps writing a different native query when an integer output is expected vs. when just a number back is the desire).

Desired Solution

An easy and accurate way to read (or check) a type's subtype claim.

Ideas:

Alternatives and Workarounds

A single-column table type can be made that uses the expected "add column" type as its column type. This table type can then be passed to Type.TableSchema, which outputs a schema details table. In that table, the TypeName column (which should contain the subtype claim name) can be read.

Unfortunately, while this column is supposed to contain the subtype claim's name, it does not always report out the correct value (like for claims Guid.Type or Uri.Type).

Additional Context

No response