Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating custom expressions with spaces in the name, then filtering, results in an error #22310

Closed
jack-cook-repo opened this issue May 1, 2022 · 0 comments · Fixed by #23771
Assignees
Labels
.Backend Database/BigQuery Drainable:Yes Candidate for ramping up in a product area Priority:P2 Average run of the mill bug Querying/Nested Queries Questions based on other saved questions Querying/Notebook/Custom Expression Querying/Processor Type:Bug Product defects
Milestone

Comments

@jack-cook-repo
Copy link

jack-cook-repo commented May 1, 2022

Describe the bug
When creating a custom expression that has spaces in the name, e.g.
image
then applying a filter - the resulting question ends up with an error.

This error is caused by the subquery changing spaces in the column name to underscores (e.g. Example_custom_expression), then the final SELECT statement errors as it tries to select the column with the old name (Example custom expression).

This issue seems to occur when adding filters, as it results in the subquery being created with the underscores replacing spaces.

Logs

400 Bad Request POST https://www.googleapis.com/bigquery/v2/projects/crested-unity-321617/queries { "code" : 400, "errors" : [ { "domain" : "global", "location" : "q", "locationType" : "parameter", "message" : "Name Example custom expression not found inside source at [2:72]", "reason" : "invalidQuery" } ], "message" : "Name Example custom expression not found inside source at [2:72]", "status" : "INVALID_ARGUMENT" }

To Reproduce
Steps to reproduce the behavior:

  1. Create a new question with any custom expression that has a name with spaces in it
  2. Add a group by
  3. Add a filter

image

Expected behavior
A 400 bad request error due to the final SELECT statement using the custom expression name with spaces, and a subquery with the custom column aliases with underscores instead

Screenshots
BigQuery editor showing the compiled SQL and the corresponding error.
image

This can be fixed manually by editing the SQL subquery to change the column name.

Information about your Metabase Installation:

{
  "browser-info": {
    "language": "en-GB",
    "platform": "MacIntel",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.14.1+1",
    "java.vendor": "Eclipse Adoptium",
    "java.vendor.url": "https://adoptium.net/",
    "java.version": "11.0.14.1",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.14.1+1",
    "os.name": "Linux",
    "os.version": "5.10.76-linuxkit",
    "user.language": "en",
    "user.timezone": "GMT"
  },
  "metabase-info": {
    "databases": [
      "h2",
      "bigquery-cloud-sdk"
    ],
    "hosting-env": "unknown",
    "application-database": "h2",
    "application-database-details": {
      "database": {
        "name": "H2",
        "version": "1.4.197 (2018-03-18)"
      },
      "jdbc-driver": {
        "name": "H2 JDBC Driver",
        "version": "1.4.197 (2018-03-18)"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2022-04-07",
      "tag": "v0.42.4",
      "branch": "release-x.42.x",
      "hash": "7c3ce2d"
    },
    "settings": {
      "report-timezone": null
    }
  }
}

Severity
Low for someone who is used to SQL and can manually edit queries, potentially medium otherwise

Additional context
N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.Backend Database/BigQuery Drainable:Yes Candidate for ramping up in a product area Priority:P2 Average run of the mill bug Querying/Nested Queries Questions based on other saved questions Querying/Notebook/Custom Expression Querying/Processor Type:Bug Product defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants