Skip to main content

DataQL Built to reshape data

Query, transform, and aggregate data with scripts that run in Java applications or Dataway APIs.

Query scriptDataQL
var price = 20;
var quantity = 3;
return {"quantity": quantity, "total": price * quantity};
Example resultJSON
{"quantity": 3, "total": 60}

Connect to data sources and services

  • MySQL
  • PostgreSQL
  • Hive
  • ClickHouse
  • MongoDB
  • Redis
  • Elasticsearch
  • Milvus
  • HTTP
  • Dubbo
  • Java

Data in the shape you need.

Transform

Select fields and compute new values in a single transformation.

Learn more
DataQLQuery script
var people = [
{"name": "Alice", "age": 25},
{"name": "Bob", "age": 30}
];

return people => [{
"name",
"nextAge": age + 1
}];
JSONExample result
[
{"name": "Alice", "nextAge": 26},
{"name": "Bob", "nextAge": 31}
]

Query SQL

Query a database with the SQL executor. This example uses ds1 from the example application.

Learn more
DataQLQuery script
hint FRAGMENT_SQL_DATA_SOURCE = "ds1"
hint FRAGMENT_SQL_OPEN_PACKAGE = "off"

var people = @@selectSql()<%
SELECT id AS "id", name AS "name", balance AS "balance"
FROM example_people
ORDER BY id
%>;
return people();
JSONExample result
[
{"id": 1, "name": "Alice", "balance": 100},
{"id": 2, "name": "Bob", "balance": 200}
]

Group

Import a built-in function to group records by a field.

Learn more
DataQLQuery script
import 'net.hasor.dataql.host.function.basic.CollectionUdfSource'
as collect;

var rows = [
{"name": "Alice", "team": "dev"},
{"name": "Bob", "team": "sales"},
{"name": "Carol", "team": "dev"}
];
return collect.groupBy(rows, 'team');
JSONExample result
{
"dev": [
{"name": "Alice", "team": "dev"},
{"name": "Carol", "team": "dev"}
],
"sales": [
{"name": "Bob", "team": "sales"}
]
}

Share your experience, report issues, and help improve DataQL.