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

Enhance SqlToSlackOperator to support attachments #9145

Closed
JeffryMAC opened this issue Jun 4, 2020 · 18 comments · Fixed by #26374
Closed

Enhance SqlToSlackOperator to support attachments #9145

JeffryMAC opened this issue Jun 4, 2020 · 18 comments · Fixed by #26374
Labels
contributors-workshop Issues that are good for first-time contributor's workshop good first issue kind:feature Feature Requests

Comments

@JeffryMAC
Copy link

Use case / motivation
following to #9023
Current implementation of SnowflakeToSlackOperator adds the data frame result to the slack message. That way it's not suitable for large data. Even 50 rows is too much. In some cases it's better to send the message with attachment as csv file.

@kishvanchee
Copy link
Contributor

kishvanchee commented Oct 7, 2020

Is this taken? Can I work on this?

I feel the SlackAPIFileOperator

class SlackAPIFileOperator(SlackAPIOperator):
might be used here?

I'm thinking something along the lines of storing the dataframe as a csv in /tmp/ and then pass it through? Not sure if streaming the dataframe as a file is a possible option..

@JeffryMAC
Copy link
Author

@kishvanchee
Copy link
Contributor

kishvanchee commented Oct 7, 2020

Should I be using SlackHook only for file uploads while at the moment the operator is using SlackWebhookHook ?

Docstring for SlackWebhookHook says

:param attachments: The attachments to send on Slack. Should be a list of
dictionaries representing Slack attachments.
:type attachments: list

This is confusing to me since I can attach list of dictionaries, but not file objects.

While for SlackHook I can find a suitable call method which actually does the file upload.

def call(self, api_method: str, *args, **kwargs) -> None:

This stackoverflow answer says that I can't use a webhook, but must use an api for file upload. The WebClient is what is actually being used in the SlackAPIFileOperator too.

class SlackAPIFileOperator(SlackAPIOperator):

@JeffryMAC any thoughts?

@JeffryMAC
Copy link
Author

worth asking @simond as the author of the original PR and @feluelle @turbaszek who approved it.

@simond
Copy link
Contributor

simond commented Oct 9, 2020

Oof, I can't really remember the reason I used the SlackWebHook over SlackHook unfortunately. I think it was because it is simpler to use for basic messages. Now that you want to add an attachment too then yea, you may have to move to the SlackHook instead!

@kishvanchee
Copy link
Contributor

Ah okie. Does it make more sense to use SlackHook now just for the attachment part? Or should I try refactoring the current implementation with SlackHook itself? Not sure about design choices/patterns here.

I would appreciate any help @turbaszek @feluelle

@turbaszek
Copy link
Member

Does it make more sense to use SlackHook now just for the attachment part? Or should I try refactoring the current implementation with SlackHook itself?

I think it would be best to reuse what we already have 👍

@fatmumuhomer
Copy link
Contributor

@turbaszek I can work on this one for the workshop.

@feluelle
Copy link
Member

I thought @kishvanchee liked to work on that one?

I think using SlackHook for the file upload makes sense and the use the SlackWebHook for the rest.

@kishvanchee
Copy link
Contributor

@feluelle I am, I didn't get this assigned to me though. Although now I am confused whether I should be working on this...

@fatmumuhomer
Copy link
Contributor

fatmumuhomer commented Oct 23, 2020

@kishvanchee please keep the issue and work on it if you would like. I was using this as a practice issue to learn how to contribute in the workshop that @turbaszek was teaching. I'm happy to grab a different issue.

@fatmumuhomer fatmumuhomer removed their assignment Oct 25, 2020
@feluelle
Copy link
Member

Thanks @fatmumuhomer :)

@JeffryMAC
Copy link
Author

@kishvanchee did you had time to work on it?

@eladkal eladkal added the provider:snowflake Issues related to Snowflake provider label Mar 16, 2021
@eladkal
Copy link
Contributor

eladkal commented Mar 16, 2021

@kishvanchee due to passed time I'm unassigning you.
This issue is available for anyone who wants to pick it

@eladkal eladkal added the contributors-workshop Issues that are good for first-time contributor's workshop label May 27, 2022
@eladkal eladkal changed the title Enhance SnowflakeToSlackOperator to support attachments Enhance SqlToSlackOperator to support attachments Jun 29, 2022
@eladkal
Copy link
Contributor

eladkal commented Jun 29, 2022

Update:
Now that #24663 is merged. The feature should be implemented in SqlToSlackOperator

@eladkal eladkal added provider:messages apps and removed provider:snowflake Issues related to Snowflake provider labels Jun 29, 2022
@kevgeo
Copy link
Contributor

kevgeo commented Jul 10, 2022

Hi @Taragolis, are you still working on adding an enhancement. Could I take up this issue?

@Taragolis
Copy link
Contributor

Hi @kevgeo I have a hectic weeks, so feel free to take this issue, you could grab some my previous changes if you find some useful parts.

I have a plan to make changes in Slack hooks first however I really do not know when I have a time for that.

@kevgeo
Copy link
Contributor

kevgeo commented Jul 10, 2022

Thanks @Taragolis, I will look into your previous PR too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributors-workshop Issues that are good for first-time contributor's workshop good first issue kind:feature Feature Requests
Projects
None yet