presto-query-builder

A Java library that will help you create queries for Presto programmatically. This will help you test your code and create dynamic queries.

Лицензия

Лицензия

Группа

Группа

com.rapid7.presto
Идентификатор

Идентификатор

presto-query-builder
Последняя версия

Последняя версия

0.0.31
Дата

Дата

Тип

Тип

jar
Описание

Описание

presto-query-builder
A Java library that will help you create queries for Presto programmatically. This will help you test your code and create dynamic queries.
Ссылка на сайт

Ссылка на сайт

https://github.com/rapid7/presto-query-builder
Организация-разработчик

Организация-разработчик

Rapid 7, Inc.
Система контроля версий

Система контроля версий

https://github.com/rapid7/presto-query-builder

Скачать presto-query-builder

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.rapid7.presto/presto-query-builder/ -->
<dependency>
    <groupId>com.rapid7.presto</groupId>
    <artifactId>presto-query-builder</artifactId>
    <version>0.0.31</version>
</dependency>
// https://jarcasting.com/artifacts/com.rapid7.presto/presto-query-builder/
implementation 'com.rapid7.presto:presto-query-builder:0.0.31'
// https://jarcasting.com/artifacts/com.rapid7.presto/presto-query-builder/
implementation ("com.rapid7.presto:presto-query-builder:0.0.31")
'com.rapid7.presto:presto-query-builder:jar:0.0.31'
<dependency org="com.rapid7.presto" name="presto-query-builder" rev="0.0.31">
  <artifact name="presto-query-builder" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.rapid7.presto', module='presto-query-builder', version='0.0.31')
)
libraryDependencies += "com.rapid7.presto" % "presto-query-builder" % "0.0.31"
[com.rapid7.presto/presto-query-builder "0.0.31"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
com.facebook.presto : presto-parser jar 0.240.1
com.google.guava : guava jar 24.1-jre

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

PRESTO-QUERY-BUILDER

This library allows you to programmatically generate queries for Presto to enable dynamically generated queries.

Features:

SELECT

  • Union
  • With
  • Where
  • Order By
  • Group By
  • Join

INSERT

  • Mult-row inserts

DELETE

  • Where

Configuration

None required.

Usage

Select:

QueryFactory qf = new QueryFactory();
String query = qf.build(
    new SelectQueryBuilder(
    ).with(
        "with_table"
    ).select(
        false,
        projection("aliasa", ref("alias.a"))
    ).from(
        aliasedTable("alias", "b")
    ).end(
    ).select(
        false,
        projection("t1a", ref("t1.a")),
        projection("t2aliasa", ref("t2.aliasa"))
    )
    .from(
        aliasedTable("t1", "a")
    )
    .join(
        INNER,
        aliasedTable("t2", "with_table"),
        equal(ref("t1.a"), ref("t2.aliasa"))
    )
);

Insert:

QueryFactory qf = new QueryFactory();
qf.setParam("a", lit(1));
qf.setParam("b", lit(2));
qf.setParam("c", lit(3));

String query = qf.build(
    new InsertQueryBuilder(
    ).into(
        qualifiedName("t1"),
        Arrays.asList(
            identifier("a"),
            identifier("b"),
            identifier("c")
        )
    ).row(
    ).value(
        "a",
        QueryUtils.param(qf, "a")
    ).value(
        "b",
        QueryUtils.param(qf, "b")
    ).value(
        "c",
        QueryUtils.param(qf, "c")
    ).end()
);

Delete:

QueryFactory qf = new QueryFactory();
qf.setParam("a", lit(1));

String query = qf.build(
    new DeleteQueryBuilder(
    ).from(
        table("t")
    ).where(
        equal(ref("a"), QueryUtils.param(qf, "a"))
    )
);

Special Notes

  • Currently, this is pinned to Presto 0.227 but could probably be used with newer versions as well.
  • Most Presto connectors do not support INSERT and/or DELETE operations so the are not very feature rich.
  • Since you can always DELETE then INSERT, UPDATE was not prioritized. However, it's still on the TODO list.

TODO

  • add more tests
  • query builder for update queries
com.rapid7.presto

Rapid7

Версии библиотеки

Версия
0.0.31
0.0.30
0.0.29
0.0.26
0.0.25
0.0.24