Playground
If you have super installed, a common pattern for experimentation is to
“echo” some input to the super -c command, e.g.,
echo <values> | super -c <query> -
But you can also experiment with SuperDB using the browser-embedded
playground. The super binary has been
compiled into Web assembly
and executes a super -c <query> - command like this:
# spq
SELECT upper(message) AS out
# input
{id:0,message:"Hello"}
{id:1,message:"Goodbye"}
# expected output
{out:"HELLO"}
{out:"GOODBYE"}
The QUERY and INPUT panes are editable. So go ahead and experiment.
Try changing upper to lower in the query text
and you should get this alternative output in the RESULT panel above:
{out:"hello"}
{out:"goodbye"}
The input in the playground examples are generally formatted as
SUP but the super playground command autodetects
the format, so feel free to experiment with other text formats like CSV or JSON.
For example, if you change the input above to
id,message
0,"Hello"
1,"Goodbye"
super will detect this as CSV and you will get the same result.
Examples
To explore a broad range of SuperSQL functionality, try browsing the documentation for pipe operators or functions. Each operator and function has a section of examples with playgrounds where you can edit the example queries and inputs to explore how SuperSQL works. The tutorials section also has many playground examples.
Here are a few examples to get going.
Hello, world
super -s -c "SELECT 'hello, world' as s"
produces this SUP output
{s:"hello, world"}
Some values of available data types
# spq
SELECT in as out
# input
{in:1}
{in:1.5}
{in:[1,"foo"]}
{in:|["apple","banana"]|}
# expected output
{out:1}
{out:1.5}
{out:[1,"foo"]}
{out:|["apple","banana"]|}
The types of various data
# spq
SELECT typeof(in) as typ
# input
{in:1}
{in:1.5}
{in:[1,"foo"]}
{in:|["apple","banana"]|}
# expected output
{typ:<int64>}
{typ:<float64>}
{typ:<[int64|string]>}
{typ:<|[string]|>}
A simple aggregation
# spq
sum(val) by key | sort key
# input
{key:"foo",val:1}
{key:"bar",val:2}
{key:"foo",val:3}
# expected output
{key:"bar",sum:2}
{key:"foo",sum:4}
Read CSV input and cast a to an integer from default float
# spq
a:=a::int64
# input
a,b
1,foo
2,bar
# expected output
{a:1,b:"foo"}
{a:2,b:"bar"}
Read JSON input and cast to an integer from default float
# spq
a:=a::int64
# input
{"a":1,"b":"foo"}
{"a":2,"b":"bar"}
# expected output
{a:1,b:"foo"}
{a:2,b:"bar"}
Make a schema-rigid Parquet file using fuse, then output the Parquet file as SUP
echo '{a:1}{a:2}{b:3}' | super -f parquet -o tmp.parquet -c fuse -
super -s tmp.parquet
produces
{a:1,b:null::int64}
{a:2,b:null::int64}
{a:null::int64,b:3}