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:
Add method Type.SubTypeClaim(Int64.Type) // returns the string "Int64.Type"
Add a SubTypeClaim field to the record output by Type.Facets.
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).
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
'sOnAddColumns
handler is invoked, it is passed a list of records describing the column(s) to add. One of the fields provided in these records isType
, which corresponds toTable.AddColumn
's optional fourthcolumnType
argument. (This fourth argument can be a basic M type [e.g.type number
ortype text
] or one that is decorated with a subtype claim [likeInt64.Type
orUri.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:
Type.SubTypeClaim(Int64.Type)
// returns the string "Int64.Type"SubTypeClaim
field to the record output byType.Facets
.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, theTypeName
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
orUri.Type
).Additional Context
No response