0

How do I iterate over all the rows in a table in Snowflake and pass it to a Python function without using pandas?

I have a Snowflake table with following columns: EmployeeID, EmployeeName, DirectReportID, DirectReportName, InDirectReportID, InDirectReportName. I have the tree structure ready using SQL recursive CTEs. I have tried CONNECT_BY but that doesn't give the depth of the table it goes from top to bottom (until EmployeeID instead of all people below a specific EmployeeID).I want to apply a Python DFS fn (that fn is also ready) to every row in my table. Is there a way I can achieve this using Python Stored Procedure in Snowflake? Is there a way to achieve tail recursion in this scenario?

2
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Commented Oct 16, 2022 at 18:17
  • Done. Edited and the first part is my question. Thank you :) Commented Oct 16, 2022 at 23:17

1 Answer 1

0

See Dealing with Parent-Child SQL Queries for an example of querying for descendants of a specific node in a recursive CTE.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, but I do not need a SQL Query. I want to connect my SQL table and pass it to a Python function for tail recursion so that I get the tree.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.