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

vdk-impala: Refactor query classifier for data lineage #1239

Merged
merged 4 commits into from
Oct 18, 2022

Conversation

kostoww
Copy link
Contributor

@kostoww kostoww commented Oct 13, 2022

Why?

Analysing the SQL query is not so trivial task, as there are number of variations of the DDL, DML and DDL with DML combinations. Current avoidance of single line comments does not work properly and skips queries that are eligible for lineage collection.

What?

Added sqlparse library in order to externalise comment-cleaning task, now it leaves us only with the query and there isn't any need to analyse whole query. What we do now is we check if query starts with blacklisted keyword, if so - query is not eligible for lineage. Although some keywords blacklisted might contain lineage data, like CREATE statement, when table is created from another with SELECT statement. In this case blacklisted word needs to be whitelisted in some conditions.

As sql statements are complex, we need to get which queries definitely has data lineage, instead of searching which query have for sure and for sure not data lineage. False positives queries for lineage, ie queries that does not have lineage information provided from the profile, but are marked as having one, will not break the logic at all, instead we optimize load on the impala server with a simple approach

How has this been tested?

Unit and integration tests, also with production-grade queries

What type of change are you making?

Bug-fixing

Signed-off-by: Plamen Kostov [email protected]

# Why?
Analysing the SQL query is not so trivial task, as there are number of variations of the DDL, DML and DDL with DML combinations. Current avoidance of single line comments does not work properly and skips queries that are eligible for lineage collection.

# What?
Added sqlparse library in order to externalise comment-cleaning task, now it leaves us only with the query and there isn't any need to analyse whole query. What we do now is we check if query starts with blacklisted keyword, if so - query is not eligible for lineage. Although some keywords blacklisted might contain lineage data, like CREATE statement, when table is created from another with SELECT statement. In this case blacklisted word needs to be whitelisted in some conditions.

As sql statements are complex, we need to get which queries definitely has data lineage, instead of searching which query have for sure and for sure not data lineage. False positives queries for lineage, ie queries that does not have lineage information provided from the profile, but are marked as having one, will not break the logic at all, instead we optimize load on the impala server with a simple approach

# How has this been tested?
Unit and integration tests, also with production-grade queries

# What type of change are you making?
Bug-fixing

Signed-off-by: Plamen Kostov <[email protected]>
Copy link
Contributor

@VladimirPetkov1 VladimirPetkov1 left a comment

Choose a reason for hiding this comment

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

You can add some docs in _does_query_have_linage method explaining why the method exists.
LGTM

# Why?
Analysing the SQL query is not so trivial task, as there are number of variations of the DDL, DML and DDL with DML combinations. Current avoidance of single line comments does not work properly and skips queries that are eligible for lineage collection.

# What?
Added sqlparse library in order to externalise comment-cleaning task, now it leaves us only with the query and there isn't any need to analyse whole query. What we do now is we check if query starts with blacklisted keyword, if so - query is not eligible for lineage. Although some keywords blacklisted might contain lineage data, like CREATE statement, when table is created from another with SELECT statement. In this case blacklisted word needs to be whitelisted in some conditions.

As sql statements are complex, we need to get which queries definitely has data lineage, instead of searching which query have for sure and for sure not data lineage. False positives queries for lineage, ie queries that does not have lineage information provided from the profile, but are marked as having one, will not break the logic at all, instead we optimize load on the impala server with a simple approach

# How has this been tested?
Unit and integration tests, also with production-grade queries

# What type of change are you making?
Bug-fixing

Signed-off-by: Plamen Kostov <[email protected]>
@kostoww kostoww force-pushed the topic/pkostov/impala-refactor-lineage-detecting branch from 672cedc to ce44501 Compare October 18, 2022 09:12
@kostoww kostoww enabled auto-merge (squash) October 18, 2022 09:13
@kostoww kostoww merged commit 5f74d78 into main Oct 18, 2022
@kostoww kostoww deleted the topic/pkostov/impala-refactor-lineage-detecting branch October 18, 2022 09:39
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.

4 participants