Category / Section
Resolving Data Retrieval Issues in expression for the data source created with Google BigQuery
Published:
When working with Google BigQuery data source, you may encounter an error message similar to the one below:
Sf_Exception - Unable to retrieve data table. Reason: Status Code 400 BadRequest - { "error": { "code": 400, "message": "Could not cast literal \"\u0080\" to type DATETIME at [1:668]", "errors": [ { "message": "Could not cast literal \"\u0080\" to type DATETIME at [1:668]", "domain": "global", "reason": "invalidQuery", "location": "q", "locationType": "parameter" } ], "status": "INVALID_ARGUMENT" }}
This error typically occurs when there is an issue with the casting of a literal to a specific type, in this case, DATETIME.
Solution
To resolve this issue, you can use the SAFE_CAST
function in your expression for the problematic column. The syntax for this function is as follows:
SAFE_CAST(‘columnname’ AS DATETIME)
This function attempts to cast the value of the column to the specified type (in this case, DATETIME). If the cast is not possible, it returns NULL instead of throwing an error.
By applying this fix, you should be able to retrieve your data table without encountering the aforementioned error.