Fxztam / sql_to_ibis

A Python package that parses sql and converts it to ibis expressions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sql_to_ibis

image

image

image

image

image

image

image

sql_to_ibis is a Python package that translates SQL syntax into ibis expressions. This provides the capability of using only one SQL dialect to target many different backends

Installation

Usage

Registering and removing temp tables

To use an ibis table in sql_to_ibis you must register it. Note that for joins or queries that involve more than one table you must use the same ibis client when creating both ibis tables. Once the table is registered you can query it using SQL with the query function. In the example below, we create and query a pandas DataFrame

This would output a DataFrame that looks like:

column1 my_col2
1 5
2 6
3 7

SQL Syntax

The sql syntax for sql_to_ibis is as follows (Note that all syntax is case insensitive):

Select statement

Example:

Note that columns with spaces in them can be expressed using double quotes. For example:

Set operations

Example:

Joins

Order by and limit

Example:

Windowed aggregation

Supported expressions and functions

  • Anything in <> is meant to be some string
  • Anything in [] is optional
  • Anything in {} is grouped together

Supported Data Types for cast expressions include:

  • VARCHAR, STRING
  • INT16, SMALLINT
  • INT32, INT, INTEGER
  • INT64, BIGINT
  • FLOAT16
  • FLOAT32
  • FLOAT, FLOAT64
  • BOOL
  • DATETIME64, TIMESTAMP
  • CATEGORY
  • OBJECT

About

A Python package that parses sql and converts it to ibis expressions

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 99.1%Language:Shell 0.9%