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

Get Presto query's statement ID in JDBC driver #9425

Closed
liumingchao opened this issue Nov 28, 2017 · 1 comment
Closed

Get Presto query's statement ID in JDBC driver #9425

liumingchao opened this issue Nov 28, 2017 · 1 comment

Comments

@liumingchao
Copy link

liumingchao commented Nov 28, 2017

I'm developing a software with Presto JDBC, and would like to get query's session ID to cancel the statement later in another thread.

In MySQL, I can get the ID as in:

long id = statement.getConnection().unwrap(MySQLConnection.class).getId();
(statement is an object of java.sql.Statement)

How can I get Presto statement's unique session ID? I'm looking into Presto JDBC document and sources but can't find it.

Before the query and not in the resultset

Any ideas or suggestions would be appreciated so much.

@electrum
Copy link
Contributor

electrum commented Feb 13, 2018

Sorry for the late reply. There are two options. First is to get the query ID from the ResultSet:

resultSet.unwrap(PrestoResultSet.class).getQueryId();

However, this will only tell you the query ID after results are available, which might be a long time for big queries. The other way is to add a progress monitor to Statement:

statement.unwrap(PrestoStatement.class).setProgressMonitor(stats -> {
    stats.getQueryId();
});

The progress monitor is called many times during execution (with the latest stats each time). This callback happens inline, on the thread executing the query, so don't do anything slow or expensive here.

Note that Presto doesn't really have the concept of a session ID

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