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

Error with Variable Declaration in BigQuery query -> Statement NOT supported #344

Open
windsurfing33 opened this issue Jul 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@windsurfing33
Copy link

windsurfing33 commented Jul 27, 2024

What happened?

I am encountering an issue when attempting to run a BigQuery query that involves declaring a temporary variable and performing explicit type conversions. The query works fine in the standard BigQuery environment but fails when run in the BigQuery emulator. Below is the script that is causing the problem:

Query

`
DECLARE target_date DATE;

SET target_date = (
SELECT DATE(date) -- Convertir la colonne date en type DATE
FROM {bigquery_service.project_id}.{bigquery_service.dataset_id}.{bigquery_service.table_id}
WHERE conversation.botman_session = @botman_session_value
AND date IS NOT NULL
LIMIT 1
);

SELECT *
FROM {bigquery_service.project_id}.{bigquery_service.dataset_id}.{bigquery_service.table_id}
WHERE DATE(date) = target_date
AND conversation.botman_session = @botman_session_value;
`

Error message :

{ "message": "Catching global error: 500 failed to analyze: INVALID_ARGUMENT: Statement not supported: VariableDeclaration [at 3:9]; message: failed to analyze: INVALID_ARGUMENT: Statement not supported: VariableDeclaration [at 3:9], reason: jobInternalError }

What did you expect to happen?

The query should run successfully, declaring the variable target_date and using it in the main query for comparison.

How can we reproduce it (as minimally and precisely as possible)?

The query fails with the error: INVALID_ARGUMENT: Statement not supported: VariableDeclaration.

Anything else we need to know?

No response

@windsurfing33 windsurfing33 added the bug Something isn't working label Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant