googleapis / python-bigquery-sqlalchemy

SQLAlchemy dialect for BigQuery
MIT License
436 stars 130 forks source link

Support for BigQuery-specific functions #508

Open maxcorbeau opened 2 years ago

maxcorbeau commented 2 years ago

Background:

I have a question regarding functions (https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators?hl=en).

I see some of them are already supported via SQLALchemy itself (e.g. func.ST_CONTAINS) but BigQuery-specific functions aren't (e.g. REGEXP_CONTAINS).

I know we can write custom SQL using SQLAlchemy's text() fragments (https://docs.sqlalchemy.org/en/14/core/tutorial.html#using-text-fragments-inside-bigger-statements) but to me this defeats the point of using a library, which is to provide a programatic and structured way to query data to specifically avoid free-text inputs (prone to human errors).

Some people have already asked about specific functions:

But no clue has been given as to the direction the development of this library is taking, leaving us in the dark, hence the below question.

Question:

Is there any plan to systematically implement BigQuery functions in the SQLALchemy BigQuery dialect, if so when?

Thanks!

tswast commented 1 day ago

Hi @maxcorbeau , I'm curious if you've tried SQLAlchemy's .func.function_name(...) feature to call arbitrary functions? I'd like to understand a bit better the limitations of that. Perhaps there's only certain functions where that isn't sufficient?