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

How to get older data from a table with a self terminating query? #13

Open
d-thomson opened this issue Jun 3, 2019 · 2 comments
Open

Comments

@d-thomson
Copy link
Contributor

Hi Mario,

Thank you for the new release of the driver, I am now able to connect to a KSQL instance. I am able to query metadata (SHOW STREAMS; SHOW TABLES; etc.) however I am having trouble finding a way to query old data from a table where the query wont hang.

The code snippet I'm using:

// query: SELECT * FROM USERS_ORIGINAL LIMIT 3
//rs.beforeFirst(); // <<NOT SUPPORTED  

while (rs.next()) { // << "HANGS" HERE
	for (int colInd = 1; colInd <= rsMetaData.getColumnCount(); colInd++){
		String val = rs.getString(colInd);
                System.out.print(val);
                System.out.print("\t");
	}
	System.out.println();
}

The issue seems to be that the pointer for a table is always at the latest position, so when I run the query the driver seems to hang because there is no data coming in. I see that there is a way to set the offset to the earliest position using the following command

SET 'auto.offset.reset' = 'earliest';

but this doesn't seem to be supported by the driver. Do you know if there is a way to set this globally for the KSQL instance or if there's a way to specify this in the query itself?

Much appreciated.
Daniel

@mmolimar
Copy link
Owner

mmolimar commented Jun 4, 2019

You can set properties in the driver setting the flag properties=true and adding the properties you like. Besides that, you can also configure the timeout property to end the query if the data is not coming.

@d-thomson
Copy link
Contributor Author

d-thomson commented Jun 4, 2019

Thanks for that. I was able to get the timeout working however still having some difficulty working with setting properties. Using the following URL:

jdbc:ksql://<ksql-host>:<port>?timeout=1000&propteries=true&auto.offset.reset=earliest

doesn't seem to set that property for the request. I was able to set this property globally in the KSQL config with the form auto.offset.reset=earliest and in the KSQL shell using SET 'auto.offset.reset' = 'earliest'; however via the JDBC URL it doesn't seem to set. Trying to add quotes, or using SET cant pass the regex check.

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