public interface QueryBuilder
The same builder can be used to create multiple queries.
The following query involves a single dataset:
Query<Tuple> query = dataset.createQuery("SELECT * FROM customer");
The following query involves a join between two datasets,
where dataset0
is the default dataset and
dataset1
is named s1
:
QueryBuilder builder = dataset0.createQueryBuilder().addDataset("s1", dataset1);
Query<Tuple> query = builder
.build("SELECT t1.c_custkey, t2.o_orderkey " +
"FROM customer t1 " +
"INNER JOIN s1.orders t2 " +
" ON t1.c_custkey=t2.o_custkey.c_custkey ");
The default dataset dataset0
will have the default name _public
.
Adaptation.createQueryBuilder()
Modifier and Type | Method and Description |
---|---|
QueryBuilder |
addDataset(String aName,
Adaptation aDataset)
Adds the specified dataset using the provided name.
|
Query<Tuple> |
build(String aSql)
Creates a query from the specified SQL string, whose result will return
Tuple objects. |
<T> Query<T> |
build(String aSql,
Class<T> aClass)
Creates a query from the specified SQL string, whose result will return
objects of the specified type.
|
QueryBuilder addDataset(String aName, Adaptation aDataset)
aName
- the name under which the dataset is registered.aDataset
- the dataset to be registered.IllegalArgumentException
- if there are problems with the dataset, and it cannot be used.Query<Tuple> build(String aSql)
Tuple
objects.aSql
- the SQL string that will be used to create the query object.QueryParseException
- if the query string is not valid; for example, it contains syntax errors,
it references missing tables, missing columns, etc.<T> Query<T> build(String aSql, Class<T> aClass)
aSql
- the SQL string that will be used to create the query object.QueryParseException
- if the SQL query is not valid; for example, it contains syntax errors,
it references missing tables, missing columns, etc.