Code Monkey home page Code Monkey logo

query-builder's Introduction

Make it easy to write Google BigQuery query

Expressions & Functions

function            example                            output
--------------------------------------------------------------------------------
literal             literal('abc')                     'abc'

table               table('a.seo_visits')              a.seo_visits
column              column('time')                     time
select              select(column('foo'))              select foo

eq                  eq(expr1, expr2)                   expr1 = expr2
g                   g(expr1, expr2)                    expr1 > expr2
ge                  ge(expr1, expr2)                   expr1 >= expr2
l                   l(expr1, expr2)                    expr1 < expr2
le                  le(expr1, expr2)                   expr1 <= expr2
between             between(expr1, expr2, expr3)       expr1 BETWEEN expr2 AND expr3

and                 and(expr1, expr2, expr3)           expr1 AND expr2 AND expr3
or                  or(expr1, expr2, expr3)            expr1 OR expr2 OR expr3
not                 not(expr)                          NOT expr

div                 div(expr1, expr2)                  expr1 / expr2
count               count(expr)                        COUNT(expr)
sum                 sum(expr)                          SUM(expr)
like                like(expr1, expr2)                 expr1 LIKE expr2
max                 max(expr)                          MAX(expr)
min                 min(expr)                          MIN(expr)
distinct            distinct(expr)                     DISTINCT expr
within              within(subject, expr1, expr2)      subject IN (expr1, expr2)
iff                 iff(condition, expr1, expr2)       IF(condition, expr1, expr2)
date                date(expr)                         DATE(expr)
timestamp_millis    timestamp_millis(expr)             TIMESTAMP_MILLIS(expr)
timestamp           timestamp(expr)                    TIMESTAMP(expr)
timestamp_add       timestamp_add(expr, duration)      TIMESTAMP_ADD(expr, duration)
timestamp_sub       timestamp_sub(expr, duration)      TIMESTAMP_SUB(expr, duration)
unix_millis         unix_millis(expr)                  UNIX_MILLIS(expr)

duration            duration(number, unit)
                    duration(1, Duration.YEAR)         INTERVAL 1 YEAR
                    duration(10, Duration.MINUTE)      INTERVAL 10 MINUTE
cast                cast(expr, type)                   cast(expr as type)
                    cast(foo, Types.INT64)             cast(foo as INT64)

Constants

Duration
    Duration.YEAR
    Duration.MONTH
    Duration.DAY
    Duration.HOUR
    Duration.MINUTE
    Duration.SECOND

Types
    Types.INT64
    Typpes.STRING

query-builder's People

Contributors

stonezhong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.