Code Monkey home page Code Monkey logo

zetasql-sandbox's Introduction

It is personal toy project using official Java wrapper of ZetaSQL (Google's SQL dialect parser & analyzer) by Kotlin. Officially, ZetaSQL supports only Linux so it should be run on Docker.

build

$ ./gradlew jibDockerBuild --image=zetasql-sandbox

format

It format query from standard input.

$ echo "SELECT * FROM table" | docker run -i --rm zetasql-sandbox format

from file

$ docker run -i --rm zetasql-sandbox format < input.sql

extract-table

It extract referenced table from standard input.

$ echo 'SELECT actor_attributes.* FROM `bigquery-public-data.samples.github_nested`' | docker run -i --rm zetasql-sandbox extract-table
bigquery-public-data.samples.github_nested

analyze-print-with-bqschema

Query analysis using actual table metadata. It use GCP credentials by ADC.

Use gcloud credentials

$ docker run -i --rm --volume ${HOME}/.config/gcloud:/root/.config/gcloud zetasql-sandbox analyze-print-with-bqschema \
             <<< 'SELECT actor_attributes.* FROM `bigquery-public-data.samples.github_nested`'           
SELECT
  `bigquery-public-data.samples.github_nested_2`.a_1.blog AS blog,
  `bigquery-public-data.samples.github_nested_2`.a_1.company AS company,
  `bigquery-public-data.samples.github_nested_2`.a_1.email AS email,
  `bigquery-public-data.samples.github_nested_2`.a_1.gravatar_id AS gravatar_id,
  `bigquery-public-data.samples.github_nested_2`.a_1.location AS location,
  `bigquery-public-data.samples.github_nested_2`.a_1.login AS login,
  `bigquery-public-data.samples.github_nested_2`.a_1.name AS name,
  `bigquery-public-data.samples.github_nested_2`.a_1.type AS type
FROM
  (
    SELECT
      `bigquery-public-data.samples.github_nested`.actor_attributes AS a_1
    FROM
      `bigquery-public-data.samples.github_nested`
  ) AS `bigquery-public-data.samples.github_nested_2`;

Limitation

Doesn't yet support:

  • Table wildcard(_TABLE_SUFFIX)
  • Case-sensitiveness of quoted identifier
  • INFORMATION_SCHEMA of BigQuery
  • and more

zetasql-sandbox's People

Contributors

apstndb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

zetasql-sandbox's Issues

Overcoming limitations

Hi thanks for this project, i was struggling a lot with getting the build setup using the main repo directly.

In the limitations i can see that _PARTITIONTIME pseudo columns are not supported. Do you have any work arounds in mind that we can explore?

Is it an issue with the underlying zeta lib or with this sandbox

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.