Skip to content

MySQL backtick quoting #55

Open
Open

Description

@derekchan

Hello!

Thanks for this great project. I have been experimenting with it quite a bit, hoping to get an existing DB-based dashboard working with Google BigQuery. The dashboard is written using a SQL framework, and the queries generated always have fields and table names quoted, like this:

select title, release_year AS year, `locations` from `film_locations` limit 10;

This is valid in MySQL but not BigQuery. We need to somehow remove the backtick quotes, or replace it with BigQuery quotes (which is [field_quoted])

2017/08/17 03:37:11.874755 resultreader.go:123: 0xc42072cd20 bq limit: 10 sel:SELECT title, release_year AS year, `locations` FROM [bigquery-public-data:san_francisco.film_locations] LIMIT 10
2017/08/17 03:37:12.438817 resultreader.go:148: could not run {Location: "query"; Message: "Field '`locations`' not found in table 'bigquery-public-data:san_francisco.film_locations'; did you mean 'locations'?"; Reason: "invalidQuery"}

Activity

  1. self-assigned this
    on Aug 17, 2017
  2. araddon commented on Aug 17, 2017

    @araddon
    Contributor

    Yes, let me plug in a different dialect writer for that adapter.
    https://github.com/araddon/qlbridge/blob/master/expr/dialect.go#L51

    Thanks for the report.

  3. araddon commented on Aug 19, 2017

    @araddon
    Contributor

    I think this is fixed now, added tests to verify, let me know. Also would love to hear more of your use/case feedback overall if you want.

  4. derekchan commented on Aug 21, 2017

    @derekchan
    Author

    @araddon - Thank you for the fix. But how do you build the project from a fresh clone? I've never used Golang before - and my builds is failing. It is complaining about cannot find package "cloud.google.com/go/civil" and "k8s.io/client-go/pkg/api/v1" and so on.

    Build logs here : https://circleci.com/gh/derekchan/dataux/1

  5. araddon commented on Aug 21, 2017

    @araddon
    Contributor

    I will push up binary releases, and docker later today, should have done that. I also need to start vendoring as well.

  6. araddon commented on Aug 21, 2017

    @araddon
    Contributor

    Pushed up these, will work on vendoring next. https://github.com/dataux/dataux/releases

  7. derekchan commented on Aug 22, 2017

    @derekchan
    Author

    I got this working! Found a minor edge case but I am able to work around it. It will fail if we do something like:

    select `b`.`name` from `bikeshare_stations` as `b` LIMIT 1;"
    
  8. araddon commented on Aug 22, 2017

    @araddon
    Contributor

    Thanks for the feedback, ill get tests for that as soon as i can!

  9. derekchan commented on Aug 22, 2017

    @derekchan
    Author

    And our use-case:

    We have a dashboard application written in PHP, which is based on a MVC framework with SQL support. The framework (part of Laravel) supports both MySQL and PostgreSQL, so everything was good when we stayed on MySQL, PgSQL or even AWS Redshift.

    We are recently experimenting with BigQuery, but BigQuery has no PHP driver. The closest thing is an ODBC driver. This leaves us with a few options:

    • Using the official Google PHP API client - This means a almost full re-write of the application, since most of the logic is based on the SQL framework.

    • Using the ODBC driver and hope it works. But no, it didn't. We got a few Segfaults from the drivers which we didn't investigate further.

    • Using a middleware (so we are here) that talks a SQL protocol and can translate the SQL syntax somehow.

    Our experience so far:

    • Setting up dataux is easy, but we will need to do the CREATE SOURCE every time the dataux starts up. I am planning to write a wrapper startup script for that.
    • Prepared statement from PHP does not work. Not sure why, but disabling prepared statement worked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions