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

Set resourceGroupQueryType as String not Optional #453

Open
JeongDaeKim opened this issue Aug 29, 2024 · 1 comment
Open

Set resourceGroupQueryType as String not Optional #453

JeongDaeKim opened this issue Aug 29, 2024 · 1 comment

Comments

@JeongDaeKim
Copy link
Contributor

resourceGroupQueryType = StatementUtils.getQueryType(statement).toString();

[StatementUtils.getQueryType returns Optional] (https://github.com/trinodb/trino/blob/c751cf5a500af61ff43b3ab0abd6d07b40cd7148/core/trino-main/src/main/java/io/trino/util/StatementUtils.java#L251), so resourceGroupQueryType will be Optional.toString not QueryType.toString, like Optional[...].

@Chaho12
Copy link
Member

Chaho12 commented Aug 29, 2024

@willmostly

if getQueryType(statement) returns an empty Optional, as calling toString() on an empty Optional would result in a NoSuchElementException.

What do you think of having a default string of UKNOWN if the optional is empty?

resourceGroupQueryType = StatementUtils.getQueryType(statement)
                                      .map(QueryType::toString)
                                      .orElse("UNKNOWN");

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

No branches or pull requests

2 participants