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

Extract query ID from all kill_query procedure variations #425

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

willmostly
Copy link
Contributor

Description

Trino Gateway attempts to extract the query id from the body of queries using the runtime.kill_query procedure from the system catalog. This adds a test for this functionality.

Additional context and related issues

Release notes

( x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

@cla-bot cla-bot bot added the cla-signed label Jul 29, 2024
@willmostly willmostly force-pushed the will/test_extract_query_id_from_system_runtime_kill_query branch from 0f19b85 to 1ad0e45 Compare July 29, 2024 19:15
Copy link
Member

@mosabua mosabua left a comment

Choose a reason for hiding this comment

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

Looks fine .. I wish we would not have to mock around for stuff like that but a full integration test seems worse..

@willmostly willmostly force-pushed the will/test_extract_query_id_from_system_runtime_kill_query branch from 1ad0e45 to a8355b6 Compare August 30, 2024 21:42
@willmostly willmostly requested a review from ebyhr August 30, 2024 21:45
@willmostly willmostly force-pushed the will/test_extract_query_id_from_system_runtime_kill_query branch from a8355b6 to 83760bd Compare August 30, 2024 21:53
@willmostly willmostly force-pushed the will/test_extract_query_id_from_system_runtime_kill_query branch from 9a00f3e to 95e782a Compare September 3, 2024 19:40
@willmostly willmostly changed the title Test extraction of query ID from kill_query procedure Extract query ID from all kill_query procedure variations Sep 3, 2024
ebyhr
ebyhr previously requested changes Sep 4, 2024
Copy link
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

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

The regular expression is incorrect in some cases.

@willmostly willmostly force-pushed the will/test_extract_query_id_from_system_runtime_kill_query branch from 95e782a to c311199 Compare September 4, 2024 20:10
@mosabua
Copy link
Member

mosabua commented Sep 5, 2024

Needs a rebase now..

@willmostly willmostly force-pushed the will/test_extract_query_id_from_system_runtime_kill_query branch from c311199 to e9226b6 Compare September 9, 2024 19:29
{
assertThat(
extractQueryIdIfPresent(
prepareMockRequestWithBody("CALL system.runtime.kill_query(query_id => '20200416_160256_03078_6b4yt', message => 'If he dies, he dies')"),
Copy link
Member

Choose a reason for hiding this comment

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

Please add a test case with uppercase procedure name KILL_QUERY.

assertThat(extractQueryIdIfPresent(prepareMockRequestWithBody("call Kill_Query('20200416_160256_03078_6b4yt')"), ImmutableList.of()))
.isEqualTo("20200416_160256_03078_6b4yt");

assertThat(extractQueryIdIfPresent(prepareMockRequestWithBody("select * from postgres.query_logs.queries where sql LIKE '%kill_query(''20200416_160256%' "),
Copy link
Member

Choose a reason for hiding this comment

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

Uppercase select, from and where.

assertThat(extractQueryIdIfPresent(
prepareMockRequestWithBody("select * from postgres.query_logs.queries where sql LIKE 'CALL kill_query(_20200416_160256_03078_6b4yt_)' "),
ImmutableList.of()))
.isNull();
Copy link
Member

@ebyhr ebyhr Sep 16, 2024

Choose a reason for hiding this comment

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

Please add more test cases. e.g.

The procedure exists in a comment

// CALL kill_query('20200416_160256_03078_6b4yt', 'If he dies, he dies')
SELECT 1

Spaces exists

CALL kill_query ( '20200416_160256_03078_6b4yt',  'If he dies, he dies')

New lines exist

CALL kill_query(
'20200416_160256_03078_6b4yt',
'If he dies, he dies')

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

Successfully merging this pull request may close these issues.

3 participants