Skip to content

Feat/import snowflake lineage addition - #1759

Open
dmaresma wants to merge 9 commits into
datacontract:mainfrom
dmaresma:feat/import_snowflake_lineage_addition
Open

dmaresma wants to merge 9 commits into
datacontract:mainfrom
dmaresma:feat/import_snowflake_lineage_addition

Conversation

@dmaresma

Copy link
Copy Markdown
Contributor

#1630 resolved

  • [ x] Tests pass (uv run pytest)
  • [ x] Code formatted (uv run ruff check --fix && uv run ruff format)
  • [ x] Docs updated (if relevant)
  • [ x] CHANGELOG.md entry added

@jschoedl jschoedl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi, thanks for the contribution!

snowflake_importer.py uses an EXECUTE IMMEDIATE script - can you replace this with plain queries from Python? The columns query already returns every table and column:

cur.execute_async(
    "SELECT * FROM TABLE(SNOWFLAKE.CORE.GET_LINEAGE(%s, 'COLUMN', 'UPSTREAM', 1))",
    (object_name,),
)

This would be easier to test and maintain. It would also allow for better error messages and reduce the risk for SQL injections (imagine e.g. a column named x\', $$COLUMN$$, $$UPSTREAM$$, 1)) UNION ALL SELECT … -- in line 253).

@dmaresma

Copy link
Copy Markdown
Contributor Author

I decide the keep the column cursor/loop of the lineage on the Snowflake side, to keep the snowflake query call as low as possible, for the SQL Injection a query template will enforce the control.
the snowflake GET_LINEAGE doesn't support yet dynamic parameters, we can't use a CROSS JOIN.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants