-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCoerceTo.Table.pq
More file actions
31 lines (31 loc) · 1.08 KB
/
CoerceTo.Table.pq
File metadata and controls
31 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// CoerceToTable
let
CoerceToTable =
(source as any) as any =>
// as table =>
let
// currently these are redundant as case statements, but I may use multiple later
isRecord = Type.Is(sourceType, Record.Type),
isTable = Type.Is(sourceType, Table.Type),
isText = Type.Is(sourceType, Text.Type),
sourceType = Value.Type(source),
other =
error
Error.Record(
"UnhandledTypeConversion",
"UnhandledType",
sourceType
)
in
if false then
null
else if isRecord then
Record.ToTable(source) as table
else if isText then
#table(1, {source}) as table
else if isTable then
source as table
else
try other catch (e) => e[Message]
in
CoerceToTable