Quick Start
Last updated
Was this helpful?
Last updated
Was this helpful?
DUQL (Dangerously Usable Query Language) is a powerful, YAML-based query language designed for data transformation and analysis. DUQL is a variant of with additional usability improvements, focusing primary on readability and the creation of UI-based query experiences. This guide will help you understand the basics of DUQL and get you started with writing your own queries.
A DUQL query typically consists of the following components:
dataset
: Required. Specifies the main data source for your query.
steps
: Optional, but typically used. Defines the sequence of operations to perform on your data.
DUQL supports various operators for constructing expressions:
Arithmetic: +
, -
, *
, /
, %
(modulo), **
(exponentiation)
Comparison: ==
, !=
, >
, <
, >=
, <=
Logical: &&
(AND), ||
(OR), !
(NOT)
String: +
(concatenation), ~=
(regex match)
Example:
DUQL includes many built-in functions for data manipulation:
Aggregate functions (These return a scalar when used within summarize
, or a column when used anywhere else.:
min
max
sum
average
stddev
all
any
concat_array
count
String functions:
lower
upper
trim
length
contains
ends_with
extract
ltrim
rtrim
replace
starts_with
extract
Date functions:
to_text
Mathematical functions:
abs
acos
asin
atan
ceil
cos
degrees
exp
floor
ln
log
log10
pi
pow
radians
round
sin
sqrt
tan
Window functions
lag
lead
first
last
rank
rank_dense
row_number
Example:
Here are some frequently used transformation steps:
Selects rows based on a condition:
Creates new columns or modifies existing ones:
Aggregates data based on specified columns:
Orders the results:
Limits the number of rows returned:
Here's an example that combines multiple steps to analyze sales data:
This query:
Filters for orders from 2023 onwards
Calculates the total amount for each order and extracts the year
Groups the data by category and year, summarizing total sales and order count
Filters for categories with over $10,000 in sales
Sorts the results by year (descending) and total sales (descending)
Takes the top 5 results
Stores the result in a dataset named top_selling_categories
As you become more comfortable with DUQL, you can explore more advanced features such as:
Joining multiple datasets
Window functions for complex analytics
Declaring reusable variables and functions
Using subqueries and complex expressions
Remember, DUQL is designed to be intuitive and expressive. Don't hesitate to experiment with different combinations of steps and functions to achieve your data analysis goals!