6
$\begingroup$

fixed in 10.0.2


Given data:

titanic = ExampleData[{"Dataset", "Titanic"}]

This Association Query works:

titanic[All, <| "newKey" -> "age"|>]

But numeric or Symbol Keys,

titanic[All, <| 1 -> "age"|>]
titanic[All, <| newKey -> "age"|>]

fail with error: Missing[KeyAbsent]. Known issue?

Numeric keys are especially conveninent for multiple, parametrized queries. Currently, that requires the workaround KeyMap[ToString] and later back ToExpression.

$\endgroup$
6
$\begingroup$

Ah, the <| field -> op |> constructor notation specifically requires string keys. I'll relax that -- should show up in 10.0.2.

| improve this answer | |
$\endgroup$
  • $\begingroup$ For what it's worth: I noticed that if one relaxes that condition on Dataset`Query`PackagePrivate`comp then the correct results are generated. But then the result does not render properly in the front-end unless a similar relaxation is made to Dataset`FormattingDispatch`PackagePrivate`tocolboxes. I suspect that there could be similar knock-on consequences elsewhere. $\endgroup$ – WReach Sep 8 '14 at 21:18
  • 1
    $\begingroup$ @WReach it's not quite as bad as that: if we make the output type of ApplyThrough (the underlying operator form of <| |>) be an Assoc rather than Struct when keys aren't all strings, then everything downstream will Just Work. We lose a bit of type information -- but the only alternative, which is to allow Structs to contain keys of an arbitrary kind, is an invasive change that is unlikely to happen soon. $\endgroup$ – Taliesin Beynon Sep 9 '14 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.