PartiQL Playground provides the functionality to execute PartiQL in a web environment. It also provides REST API endpoints for the same functionality.
Please note, at this stage, the code as is in this package is considered experimental and should not be used for production.
- Ability to
parse
,explain
, andevaluate
given query statements. - Ability to share sessions with session import and export.
- Ability to run both as a docker container and standalone server.
- Expose
/parse
,/explain
, and/eval
REST APIs.
# Example for parsing `SELECT * FROM {'a': 1}` statement
curl -H 'Content-Type: application/json; charset=UTF-8' \
-H "Accept: application/json" \
--data '{"query": "SELECT * FROM {'a': 1}"}' \
-X POST http://localhost:8000/parse
"{\"text\":\"SELECT * FROM {a: 1}\",\"offsets\":{\"line_starts\":[0]},\"ast\":{\"Query\":{\"id\":9,\"node\":{\"set\":{\"id\":8,\"node\":{\"Select\":{\"id\":7,\"node\":{\"project\":{\"id\":1,\"node\":{\"kind\":\"ProjectStar\",\"setq\":\"All\"}},\"from\":{\"id\":6,\"node\":{\"source\":{\"FromLet\":{\"id\":5,\"node\":{\"expr\":{\"Struct\":{\"id\":4,\"node\":{\"fields\":[{\"first\":{\"VarRef\":{\"id\":2,\"node\":{\"name\":{\"value\":\"a\",\"case\":\"CaseInsensitive\"},\"qualifier\":\"Unqualified\"}}},\"second\":{\"Lit\":{\"id\":3,\"node\":{\"Int64Lit\":1}}}}]}}},\"kind\":\"Scan\",\"as_alias\":null,\"at_alias\":null,\"by_alias\":null}}}}},\"from_let\":null,\"where_clause\":null,\"group_by\":null,\"having\":null}}}},\"order_by\":null,\"limit\":null,\"offset\":null}}},\"locations\":{\"1\":{\"start\":0,\"end\":8},\"2\":{\"start\":15,\"end\":16},\"3\":{\"start\":18,\"end\":19},\"4\":{\"start\":14,\"end\":20},\"5\":{\"start\":14,\"end\":20},\"6\":{\"start\":9,\"end\":20},\"7\":{\"start\":0,\"end\":20},\"8\":{\"start\":0,\"end\":20},\"9\":{\"start\":0,\"end\":20}}}"%
# Example for explaining (logical planning) `SELECT * FROM {'a': 1}` statement
curl -H 'Content-Type: application/json; charset=UTF-8' \
-H "Accept: application/json" \
--data '{"query": "SELECT * FROM {'a': 1}"}' \
-X POST http://localhost:8000/explain
"\"LogicalPlan { nodes: [ProjectAll, Scan(Scan { expr: TupleExpr(TupleExpr { attrs: [VarRef(CaseInsensitive(\\\"a\\\"))], values: [Lit(1)] }), as_key: \\\"_1\\\", at_key: None }), Sink], edges: [(OpId(2), OpId(1), 0), (OpId(1), OpId(3), 0)] }\""%
# Example for evaluating `SELECT * FROM env` statement
curl -H 'Content-Type: application/json; charset=UTF-8' \
-H "Accept: application/json" \
--data '{"query": "SELECT * FROM env", "env": "{\"a\": 1, \"b\": 2}"}' \
-X POST http://localhost:8000/eval
"{\"Bag\":[{\"Tuple\":{\"attrs\":[\"a\",\"b\"],\"vals\":[{\"Integer\":1},{\"Integer\":2}]}}]}"%
- Logical Plan visualization
- More readable error reporting
- More structured and rigorous UI testing
- Better UX for query execution (E.g. using keyboard shortcuts)
For local usage follow the below steps.
- Ensure
wasm-pack
is installed on your machine by running the following command; if not, install it from here:
wasm-pack --version
# Sample output
wasm-pack 0.10.2
- Ensure
npm
is intalled on your machine; see here for more details:
npm --version
# Sample output
8.13.2
- Build the package using
make
:
make build
- Start the node server from
partiql-playground
package's root directory:
node src/server.ts
- Using your browser go to
http://localhost:8000/
- Ensure
docker
is installed on your machine, by running the following:
docker --version
# Example output
Docker version 20.10.17, build 100c701
- Build the package:
make build
- Build the container:
make container-build
- Run the container:
make container-run
- Confirm it's running:
docker ps
# Example output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1d666bba30c2 partiql-team/partiql-playground "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:8000->8000/tcp, 8080/tcp infallible_goldberg
# Ensure `connected` is in the curl output
curl -v http://localhost:8000 2>&1 |grep -i connected
# Example output
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to localhost (127.0.0.1) port 8000 (#0)
PartiQL Playground
uses WebAssembly (Wasm) for integrating the front-end with PartiQL Rust back-end.
Considering this, please install the wasm-pack
by following the instructions here.
Upon any changes to the package's Rust dependencies (E.g. partiql-parser
) or the wasm code under ./src/lib
of this package, you need to rebuild the Wasm package using the following command from the root of this package:
wasm-pack build --target web
Please note, as the package is experimental at this stage, all HTML code and assets reside in this package, but this doesn't necessarily mean that it'll be the case in the future.