Giter Site home page Giter Site logo

pql's Introduction

pipelined query language

Website Playground Discord

This Go library compiles a pipelined-based query language (inspired by the Kusto Query Language) into SQL. It has been specifically tested to work with the Clickhouse SQL dialect, but the generated SQL is intentionally database agnostic. This repository contains a the Go library, and a CLI to invoke the library.

For example, the following expression:

StormEvents
| where DamageProperty > 5000 and EventType == "Thunderstorm Wind"
| top 3 by DamageProperty

will be compiled to SQL that is similar to:

SELECT *
FROM StormEvents
WHERE DamageProperty > 5000 AND EventType = 'Thunderstorm Wind'
ORDER BY DamageProperty DESC
LIMIT 3;

Getting Started

If you'd like to see a demo along with some examples, check out https://pql.dev.

To use pql in your go code, a minimal example might look like this

package main

import (
	"github.com/runreveal/pql"
)

func main() {
	sql, err := pql.Compile("users | project id, email | limit 5")
	if err != nil {
		panic(err)
	}
	println(sql)
}

Running this program should give you the following output

$ go run test.go

WITH "__subquery0" AS (SELECT "id" AS "id", "email" AS "email" FROM "users")
SELECT * FROM "__subquery0" LIMIT 5;

Documentation

The following tabular operators are supported and the Microsoft KQL documentation is representative of the current pql api.

The following scalar functions implemented within pql. Functions not in this list will be passed through to the underlying SQL engine. This allows the usage of the full APIs implemented by the underlying

Column names with special characters can be escaped with backticks.

Get involved

License

Apache 2.0

pql's People

Contributors

zombiezen avatar ejcx avatar shellcromancer avatar abraithwaite 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.