statmike / vertex-ai-mlops

Google Cloud Platform Vertex AI end-to-end workflows for machine learning operations
Apache License 2.0
494 stars 221 forks source link

Bad Request: 400 Syntax Error : Missing whitespace between literal and alias at [1:36] in 04 - Vertex AI Custom Model - scikit-learn - in Notebook #35

Closed rsher60 closed 1 year ago

rsher60 commented 1 year ago

hey Mike! Firstly , A Big Thank you for teaching people like me about Vertex AI and sharing your code.Really appreciate it and will be forever grateful for the awesome stuff.

Regarding the error in code block [15] for which I got the above error :Bad Request: 400 Syntax Error : Missing whitespace between literal and alias at [1:36]

query = f"SELECT * FROM {BQ_PROJECT}.{BQ_DATASET}.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '{BQ_TABLE}'"
schema = bq.query(query).to_dataframe()
schema

I think it only needs :

query = f"SELECT * FROM `{BQ_PROJECT}.{BQ_DATASET}.INFORMATION_SCHEMA.COLUMNS` WHERE TABLE_NAME = '{BQ_TABLE}'"
schema = bq.query(query).to_dataframe()
schema

this worked!

statmike commented 1 year ago

Hello @rsher60, Thank you for pointing this out! In our examples we use names for projects/dataset/tables that work without quoting: start with letter or _ and don't have blanks. To be careful and make the code work even when names start with numbers or have spaces we should always use the backtick quoting. We will mark this to be updated in the next update. https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical

@goodrules

statmike commented 1 year ago

I was running these notebooks for a project and realized that we forgot to make the change. I just updated the full 04 series of notebooks to have the backticks around BigQuery table references. Thank you @rsher60 for bringing this to our attention!

Commit: https://github.com/statmike/vertex-ai-mlops/commit/1386ff22feab52e2db9b99ce9c474998f2879f4e