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

[sc-26213] Lower max query text length limit to 100K #859

Merged

Conversation

usefulalgorithm
Copy link
Contributor

@usefulalgorithm usefulalgorithm commented May 7, 2024

🤔 Why?

The Snowflake crawler parses query logs from the QUERY_HISTORY view, whose query_text column is potentially truncated if the value is too long: https://docs.snowflake.com/en/sql-reference/account-usage/query_history

(The link says the limit is 100K characters, but in our Snowflake instance we can see a query is parsed that's longer than 100K:
截圖 2024-05-07 晚上7 39 04
)

From the lineage parser's perspective a truncated expression is an invalid expression. To make lineage parsing possible, just drop the sql queries that are longer than 100K characters long, since it's very likely to be a INSERT INTO expression.

🤓 What?

Lower max query text length limit to 100_000.

🧪 Tested?

  • Crawler run locally against metaphor's Snowflake instance.

☑️ Checks

  • My PR contains actual code changes, and I have updated the version number in pyproject.toml.

Copy link

github-actions bot commented May 7, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
18906 17752 94% 85% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
metaphor/snowflake/config.py 100% 🟢
metaphor/snowflake/extractor.py 85% 🟢
TOTAL 92% 🟢

updated for commit: 0a7957f by action🐍

Copy link

codecov bot commented May 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.89%. Comparing base (ec69369) to head (0a7957f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #859      +/-   ##
==========================================
+ Coverage   93.71%   93.89%   +0.18%     
==========================================
  Files         203      161      -42     
  Lines       19074    18906     -168     
==========================================
- Hits        17875    17752     -123     
+ Misses       1199     1154      -45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mars-lan
Copy link
Contributor

mars-lan commented May 7, 2024

I'm confused, the example you gave shows that a query_text of length 144k chars got truncated. Isn't that the correct expectation?

@usefulalgorithm
Copy link
Contributor Author

I'm confused, the example you gave shows that a query_text of length 144k chars got truncated. Isn't that the correct expectation?

ack I saw wrong, wait wait

@usefulalgorithm usefulalgorithm changed the title [sc-26213] Insert single row for VALUES clause for INSERT INTO expressions that are too long [sc-26213] Replace truncated VALUES clause for INSERT INTO expressions May 7, 2024
@usefulalgorithm
Copy link
Contributor Author

@mars-lan can you take another look? updated the pr description and some names in the logic

@usefulalgorithm usefulalgorithm enabled auto-merge (squash) May 7, 2024 16:55
@mars-lan
Copy link
Contributor

mars-lan commented May 7, 2024

@mars-lan can you take another look? updated the pr description and some names in the logic

Got it. In that case, let's just ignore queries longer than 100k w/o doing any regex magic?

@usefulalgorithm usefulalgorithm changed the title [sc-26213] Replace truncated VALUES clause for INSERT INTO expressions [sc-26213] Lower max query text length limit to 100K May 7, 2024
@usefulalgorithm usefulalgorithm requested a review from mars-lan May 8, 2024 10:51
Copy link
Contributor

@mars-lan mars-lan left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

pyproject.toml Outdated Show resolved Hide resolved
@usefulalgorithm usefulalgorithm requested a review from mars-lan May 8, 2024 14:49
@usefulalgorithm usefulalgorithm merged commit 7a89acd into main May 8, 2024
6 checks passed
@usefulalgorithm usefulalgorithm deleted the tsung-julii/sc-26213/truncate-insert-expression-values branch May 8, 2024 19:05
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