Closed anskarl closed 5 years ago
@anskarl I really like the idea. It allows us to write very elegant queries.
@Fokko I am glad that you like the idea. I will continue the implementation and hopefully create a PR soon.
Hello, so far I have implemented the following:
- flow-based builders for timeseries, group-by and top-n queries
- filter expressions
- having expressions
- aggregation expressions
Post-aggregation expressions is a work in progress
Examples of the current version can be found in https://github.com/anskarl/scruid/blob/master/src/test/scala/ing/wbaa/druid/dql/DQLSpec.scala
Fixed, so can be closed
I would like to propose a DSL for creating queries with SQL-like definition of filters.
I have implemented an initial version of builders in https://github.com/anskarl/scruid/blob/feature/dql/src/main/scala/ing/wbaa/druid/dql/DQL.scala and a DSL for defining filters https://github.com/anskarl/scruid/blob/feature/dql/src/main/scala/ing/wbaa/druid/dql/FilterDSL.scala
For example, a group-by query can be defined as below:
As you can see in the example, the filters over dimensions dim1 and dim2 in the where function are defined using a SQL-like representation (inspired by Apache Spark Dataframe API).
The current version of the DSL for filters supports various operators (e.g., and, or, not, notIn, isNull, isNotNul, etc) and the dimension names are represented by scala symbols (e.g., 'some_dim_name).
Below I am giving some additional example of where clauses:
There are also functions that support conjuctions or disjunctions over multiple filters:
If you believe that the proposed API is helpful, I would be happy to continue the implementation and thereafter create a PR.