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

[bug]: get_latest_partition_timestamp: has a undeclared variable #86

Open
2 tasks done
shivam221098 opened this issue Apr 29, 2023 · 5 comments
Open
2 tasks done
Labels
bug-bigfunction Report a bug in a BigFunction

Comments

@shivam221098
Copy link
Contributor

shivam221098 commented Apr 29, 2023

Check the bug has not already been reported

Edit function_name and the short error description in title above

  • I wrote the correct function name and a short error description in the title above

What happened and what did you expect?

No matter what table I pass into this procedure, it shows me this error.
image

As you see this bigfunction_result variable is used without its declaration.
image

@shivam221098 shivam221098 added the bug-bigfunction Report a bug in a BigFunction label Apr 29, 2023
@datawaves-gs
Copy link

Hi, I have just encountered this issue too.

To fix it, I added an output parameter in the definition of the function :

CREATE OR REPLACE PROCEDURE get_latest_partition_timestamp (fully_qualified_table STRING, OUT bigfunction_result timestamp)

Now, I would like to add it in the source code, any idea ?

@shivam221098
Copy link
Contributor Author

Thanks, But unfortunately BigQuery stored procedures doesn't supports INOUT variables like Postgres. It only supports parameters of IN type, which means you can pass values into the procedure but cannot return values directly through the parameters.

@shivam221098
Copy link
Contributor Author

I fixed this and updated a few more things to handle in case of an error.

When the correct table name is passed as an argument
Screenshot 2024-02-07 at 1 27 06 PM
Results:
Screenshot 2024-02-07 at 1 27 19 PM
When table name is not fully qualified
Screenshot 2024-02-07 at 1 27 46 PM

@datawaves-gs
Copy link

Thanks, But unfortunately BigQuery stored procedures doesn't supports INOUT variables like Postgres. It only supports parameters of IN type, which means you can pass values into the procedure but cannot return values directly through the parameters.

Hi @shivam221098, I have found the feature here, perhaps it is new :

https://cloud.google.com/bigquery/docs/reference/standard-sql/procedural-language#call

@shivam221098
Copy link
Contributor Author

That's good to know.
From a BigQuery user perspective, if we implement the above logic then it will require a user to declare a variable then call the procedure then select the declared variable. It will be a three-step process

However, I still don't agree with the current architecture of the procedure because it is still a two-step process. I would say we can do a select bigfunction_result as lastest_partition_timestamp within the procedure so that it will be a one-step process to get the result.

What are your opinions @unytics?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-bigfunction Report a bug in a BigFunction
Projects
None yet
Development

No branches or pull requests

2 participants