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

Cannot not extract queryId exactly in code, is that a bug? #135

Open
BruceKellan opened this issue Feb 23, 2021 · 4 comments
Open

Cannot not extract queryId exactly in code, is that a bug? #135

BruceKellan opened this issue Feb 23, 2021 · 4 comments

Comments

@BruceKellan
Copy link

Hi, thanks for your repo, it give me a lot of inspiration.
But I found a bug, this is code segment:

protected String extractQueryIdIfPresent(HttpServletRequest request) {

It use a overload method extractQueryIdIfPresent(path, queryParams), and the test case TestQueryIdCachingProxyHandler test extractQueryIdIfPresent(path, queryParams).

But if the request url is "/ui/query.html?20200416_160256_03078_6b4yt", path will be "/ui/query.html" and queryParams will be "20200416_160256_03078_6b4yt", in this case, we cannot not extract queryId exactly and get null

Logic is not the same as test case.

String queryId = QueryIdCachingProxyHandler.extractQueryIdIfPresent(path, null);

I think it's a bug, isn't it?

@amitds1997
Copy link
Contributor

Sorry, if I misunderstood your question, why can we not extract the queryId?

/ui/query.html?20200416_160256_03078_6b4yt satisfies the query Id pattern and should be extractable.

private static final Pattern QUERY_ID_PATTERN = Pattern.compile(".*[/=?](\\d+_\\d+_\\d+_\\w+).*");

This is used when a Trino UI path is passed to the gateway.

@BruceKellan
Copy link
Author

BruceKellan commented Feb 23, 2021

Hi, amitds1997, thanks for your reply.
My question is that the variable path is request.getRequestURI()


So the variable path will be /ui/query.html without 20200416_160256_03078_6b4yt, the variable queryParams will be 20200416_160256_03078_6b4yt in this case.

So regexp cannot extract queryId because path is /ui/query.html.

The above is my understanding. I reproduce it in my code.

If there is a problem with my understanding, please tell me.

By the way, my prestosql version is 348, /ui/query.html?20200416_160256_03078_6b4yt is my PrestoSQL UI path。

@BruceKellan
Copy link
Author

I have looked at other fork repo, such as rongfengliang's presto-gateway,
In his repo, he use the queryParams to be queryId in the same place.

https://github.com/rongfengliang/presto-gateway/blob/7be1c438868b059b375e3af91e40ab2a061988ca/gateway/src/main/java/com/lyft/data/gateway/handler/QueryIdCachingProxyHandler.java#L201

You can have a see.

@amitds1997
Copy link
Contributor

amitds1997 commented Feb 23, 2021

Yes, that seems to be a bug.

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

No branches or pull requests

2 participants