Skip to content

Support limit pushdown in Loki connector. #25876

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jeschkies
Copy link
Member

Description

This bumps the Loki client version to 0.0.5 and adds support for limit pushdown in the Loki connector for log queries.

Additional context and related issues

Closes #25875

Release notes

( ) 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.
(x) Release notes are required, with the following suggested text:

## Section
* Support limit pushdown. ({issue}`25875`)

@cla-bot cla-bot bot added the cla-signed label May 28, 2025
@github-actions github-actions bot added the loki Loki connector label May 28, 2025
@@ -51,7 +51,7 @@
<dependency>
<groupId>io.github.jeschkies</groupId>
<artifactId>loki-client</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
Copy link
Member

Choose a reason for hiding this comment

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

How does this bump relate to LIMIT pushdown?

Copy link
Member Author

Choose a reason for hiding this comment

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

The client did not support passing the limit as URL parameter. We need 0.0.5 to pass it.

{
LokiTableHandle lokiTableHandle = (LokiTableHandle) tableHandle;

// TODO: return Optional.empty() if query is a metric query
Copy link
Member

Choose a reason for hiding this comment

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

When do you handle this TODO comment? Follow-up or this PR?

))
LIMIT 1
""",
SELECT to_iso8601(timestamp), value FROM
Copy link
Member

Choose a reason for hiding this comment

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

Revert unrelated changes.

@@ -81,6 +82,42 @@ void testLogsQuery()
"VALUES ('line 1')");
}

@Test
void testLimitedLogsQuery()
Copy link
Member

Choose a reason for hiding this comment

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

Please verify LIMIT pushdown is exactly happened.

Copy link
Member Author

@jeschkies jeschkies May 28, 2025

Choose a reason for hiding this comment

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

I'm not sure this is possible other than inferring that it was passed down. We'd have to grab the Loki logs or mock the client. How do you verify it in other database connectors?

Copy link
Member

Choose a reason for hiding this comment

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

You can refer to tests using SUPPORTS_LIMIT_PUSHDOWN.

@ebyhr ebyhr added the needs-docs This pull request requires changes to the documentation label May 28, 2025
@ebyhr
Copy link
Member

ebyhr commented May 28, 2025

Push down limit to Loki connector.

https://trino.io/development/process.html#pull-request-and-commit-guidelines-

  • Do not end the subject line with a period.

@@ -49,7 +53,8 @@ public LokiRecordSet(LokiClient lokiClient, LokiSplit split, List<LokiColumnHand

// Execute the query
try {
this.result = lokiClient.rangeQuery(split.query(), split.start(), split.end(), split.step());
log.info("querying %s with limit %d", split.query(), split.limit());
Copy link
Member

Choose a reason for hiding this comment

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

Change to debug level and move before try.

Copy link

This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack.

@github-actions github-actions bot added the stale label Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed loki Loki connector needs-docs This pull request requires changes to the documentation stale
Development

Successfully merging this pull request may close these issues.

Propage limit to Loki connector
2 participants