Miki Maine
Miki Maine

Reputation: 350

BigQuery dialect grammar file PEG

I'm working on an SQL query dialect converter. For example, given a MySQL query, it can convert it to Postgres or BigQuery. It was easy to find MySQL, SQLite, and part of the PostgreSQL grammar file, and the identification and conversation between these worked well.

What I'm looking for is a grammar file preferably in PEG but it doesn't matter, which has the standard BigQuery grammar. Is there an official or unofficial relatively complete BigQuery grammar file?

I looked at a couple of packages but they are kinda incomplete, this (node-sql-parser) for example but don't have BigQuery dialect that much. Any recommendation from the community is welcome.

Upvotes: 0

Views: 42

Answers (1)

jggp1094
jggp1094

Reputation: 155

Well BigQuery's SQL dialect is quite extensive and constantly evolving with new features and functions. Just like you mentioned, I think the workaround for this one is using sqlparse library in python as it can parse SQL statements into an abstract syntax tree. You could use this to analyze BigQuery queries and perform some transformations. It's not perfect and might not handle all edge cases, but it's a practical option for many tasks.

Upvotes: 0

Related Questions