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

Databricks SQL sensor #30477

Merged
merged 2 commits into from
Apr 11, 2023
Merged

Databricks SQL sensor #30477

merged 2 commits into from
Apr 11, 2023

Conversation

harishkesavarao
Copy link
Contributor

Databricks SQL Sensor.

@harishkesavarao
Copy link
Contributor Author

@potiuk @hussein-awala @alexott @eladkal @josh-fell @bilalaslamseattle @o-nikolas can you please review my new PR here since #30428 was almost approved but ran into the git UI rebase bug so I closed it and opened a new PR? Thank you?

@harishkesavarao
Copy link
Contributor Author

harishkesavarao commented Apr 5, 2023

@hussein-awala to avoid the UI rebase bug causing a problem, what steps did you execute/run to locally clean your branch when you faced the problem?

And is there a way to reuse the same PR when the problem occurs or do we need to open new PRs for the force pushes?

@potiuk
Copy link
Member

potiuk commented Apr 5, 2023

@hussein-awala to avoid the UI rebase bug causing a problem, what steps did you execute/run to locally clean your branch when you faced the problem?

And is there a way to reuse the same PR when the problem occurs or do we need to open new PRs for the force pushes?

You need to have your branch rebased onto the apache/main and you need to push your branch with --force to your fork. That should be enough. See the command line instructiin in "how to rebase" section in CONTRIBUTING docs.

"sql_warehouse_name."
)
hook = self.hook
sql_result = hook.run(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not quite sure, but I feel the operator is a better choice here not sensor wdyt?

Copy link
Contributor Author

@harishkesavarao harishkesavarao Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review @pankajastro. This was reviewed extensively before via #30428 and @josh-fell, @o-nikolas and I agreed that we can keep the hook here because the operator isn't going to do anything more than what the hook does for this sensor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By design, a sensor should only wait for something. My concern here is we are running a query which will take the worker slot for the entire task execution time so there can be a problem when we run it in reschedule mode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also just curious how this is different than DatabricksSqlOperator

class DatabricksSqlOperator(SQLExecuteQueryOperator):

Copy link
Contributor Author

@harishkesavarao harishkesavarao Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By design, a sensor should only wait for something. My concern here is we are running a query which will take the worker slot for the entire task execution time so there can be a problem when we run it in reschedule mode.

@pankajastro Since this is an SQL sensor, running a SQL query to check/poke for existence of results is necessary. You are right about the sensor waiting for something in general, but this sensor doesn't wait indefinitely until it receives results, it immediately returns either a True or False based on whether the query returns any results at all. This is useful if you only want to know whether there are results but not want to know what they are, and take action based on it.

Copy link
Contributor Author

@harishkesavarao harishkesavarao Apr 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also just curious how this is different than DatabricksSqlOperator

class DatabricksSqlOperator(SQLExecuteQueryOperator):

In the context of Databricks, the SQL operator may not appear functionally different from the sensor in that both execute SQL queries, but the sensor can be used as an upstream dependency to check whether a query result contains data or not and then do something else with a downstream task, while you cannot do this with the operator. The sensor check returns just a True or False and not actual query results, while the operator just executes the query and returns the results back to the logger.

@harishkesavarao harishkesavarao force-pushed the db-sql-sensor branch 3 times, most recently from d8bb485 to 0fb389c Compare April 5, 2023 21:59
@harishkesavarao
Copy link
Contributor Author

@josh-fell @o-nikolas @eladkal requesting your reviews for the PR. I made all the changes you suggested over the past few days and we were almost close to merging when reviewing #30428. I had to close it due to the UI rebase bug, so this is just a copy of that PR.

@harishkesavarao harishkesavarao force-pushed the db-sql-sensor branch 2 times, most recently from f203f5b to 5c71377 Compare April 7, 2023 17:19
Copy link
Contributor

@alexott alexott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@harishkesavarao harishkesavarao force-pushed the db-sql-sensor branch 3 times, most recently from 364a47b to 9fba83c Compare April 10, 2023 16:49
@alexott
Copy link
Contributor

alexott commented Apr 11, 2023

@josh-fell @potiuk it looks like all comments were addressed

Copy link
Contributor

@o-nikolas o-nikolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sticking with this one and being gracious in taking all the feedback @harishkesavarao!

@o-nikolas o-nikolas merged commit 1e311cf into apache:main Apr 11, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 11, 2023

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants