Consider the following dataset.
titanic = ExampleData[{"Dataset", "Titanic"}]
If I use the lookup syntax of the dataset like following it creates an equivalent Query
syntax which is compiled and then applied to the dataset.
titanic[Select[#survived == True && #age > 60 &], {"class", "sex"}] // InputForm
If you look at the input syntax above you can see the TypeSystem
being used for storage and also the Query
used to arrive at the current dataset from the previous one.
I want to extract the Query
being used. I tried the following with no success.
query=First@Cases[%, x_Query :> x, \[Infinity], Heads -> True]
Once the Query
is extracted I can just use Normal[query]
to get the optimized version.
Can someone help me get out the Query
from the Dataset
. I know it is trivial in this case but I want to use this as a base to work with more complex queries and have a way to track previous datasets using their "ID"s
and connecting Query
like a Graph
with ID
as Vertices
and Query
as Edges
in a workflow diagram.