Skip to content

Conversation

@JavierLopezT
Copy link
Contributor

@JavierLopezT JavierLopezT commented May 8, 2021

This modification will log useful info about the execution. Some examples are:

Statement execution info - {'status': 'Statement executed successfully.'}
Statement execution info - {'status': 'Table STG_GOOGLE_ADS_HOURLY_CAMPAIGN successfully created.'}
Statement execution info - {'status': 'Copy executed with 0 files processed.'}
Statement execution info - {'number of rows deleted': 0}
Statement execution info - {'number of rows inserted': 0}

Also, these values are returned so that we can further implement behavior modifications in the Operators. For instance, in S3ToSnowflakeOperator, if the status is Copy executed with 0 files processed we could raise an error

I think new tests are not necessary since it just logs more info and returns a value

@boring-cyborg boring-cyborg bot added area:providers provider:snowflake Issues related to Snowflake provider labels May 8, 2021
@github-actions
Copy link

github-actions bot commented May 8, 2021

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@JavierLopezT JavierLopezT changed the title Log info about query execution SnowflakeHook Logging and returning info about query execution SnowflakeHook May 8, 2021
@potiuk
Copy link
Member

potiuk commented May 8, 2021

I guess we can also add it as value returned by SnowflakeOperator's execute method ? It's backwards compatible, and with do_xcom_push = True (default) it will automatically create XCom with the output. Might be really useful.

@JavierLopezT
Copy link
Contributor Author

JavierLopezT commented Jun 30, 2021

I guess we can also add it as value returned by SnowflakeOperator's execute method ? It's backwards compatible, and with do_xcom_push = True (default) it will automatically create XCom with the output. Might be really useful.

Done :)

Edit: it seems that the test of the XCom is failing
Could not serialize the XCom value into JSON. If you are using pickle instead of JSON for XCom, then you need to enable pickle support for XCom in your airflow config.

Any idea how to solve it? Thanks

@uranusjr
Copy link
Member

It means the value you want to push cannot be serialised into JSON. What is the value that caused the failure?

@potiuk
Copy link
Member

potiuk commented Jun 30, 2021

Seems that execution_info are "rows" returned by Cursor which is not json-serializable.

This PyMSQL shows an example how you can do it: https://programmersought.com/article/12771376188/

@JavierLopezT
Copy link
Contributor Author

Seems that execution_info are "rows" returned by Cursor which is not json-serializable.

This PyMSQL shows an example how you can do it: https://programmersought.com/article/12771376188/

I made a workaround eventually. The real output is a list of dicts, so it is serializable with real data. The error was due to the mocking I think.

Everything green now, I hope it can be merged soon

@potiuk
Copy link
Member

potiuk commented Jul 1, 2021

Seems that execution_info are "rows" returned by Cursor which is not json-serializable.
This PyMSQL shows an example how you can do it: https://programmersought.com/article/12771376188/

I made a workaround eventually. The real output is a list of dicts, so it is serializable with real data. The error was due to the mocking I think.

I see. Yeah . Plausible.

@potiuk potiuk merged commit 8b41c2e into apache:main Jul 1, 2021
@JavierLopezT JavierLopezT deleted the extra_info_snowflake branch August 31, 2021 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:snowflake Issues related to Snowflake provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants