Skip to content

Conversation

@RotRotAl
Copy link

@RotRotAl RotRotAl commented Sep 25, 2025

Allows to override the client tags that were set in the data source addition , via the the query editor.
Based on pr #309 by @laserninja that allows setting the client tags in the data source addition .

@cla-bot
Copy link

cla-bot bot commented Sep 25, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@RotRotAl
Copy link
Author

RotRotAl commented Oct 21, 2025

Cla was accepted waiting for #309 before i can publish this @laserninja @RoeyoOgen

clientTags := ctx.Value(trinoClientTagsKey)

if user != nil {
headers.Set("X-Trino-User", string(user.(*backend.User).Login))
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary?

Copy link
Author

Choose a reason for hiding this comment

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

nope, removed

src/e2e.test.ts Outdated
async function setupDataSourceWithAccessToken(page: Page) {
await page.getByTestId('data-testid Datasource HTTP settings url').fill('http://trino:8080');
await page.locator('div').filter({hasText: /^Impersonate logged in userAccess token$/}).getByLabel('Toggle switch').click();
await page.locator('#trino-settings-enable-impersonation').click({ force: true });
Copy link
Member

Choose a reason for hiding this comment

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

Why is force: true necessary?

README.md Outdated
* Raw SQL editor only, no query builder yet
* Macros
* Client tags support, used to identify resource groups.
* ```
Copy link
Member

Choose a reason for hiding this comment

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

What's this?

Copy link
Author

Choose a reason for hiding this comment

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

left overs from #309

}
if queryTags.ClientTags != "" {
contextWithTags = context.WithValue(contextWithTags, trinoClientTagsKey, queryTags.ClientTags)
fmt.Printf("Using client tag from query editor: %s\n", queryTags.ClientTags)
Copy link
Member

Choose a reason for hiding this comment

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

Remove this

Copy link
Author

Choose a reason for hiding this comment

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

done


if contextWithTags.Value(trinoClientTagsKey) == nil && settings.ClientTags != "" {
contextWithTags = context.WithValue(contextWithTags, trinoClientTagsKey, settings.ClientTags)
fmt.Printf("Using client tag from datasource settings: %s\n", settings.ClientTags)
Copy link
Member

Choose a reason for hiding this comment

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

Remove this

Copy link
Author

Choose a reason for hiding this comment

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

done

return ds.SQLDatasource.QueryData(ctx, req)
}

func (ds *SQLDatasourceWithTrinoUserContext) injectClientTags(contextWithTags context.Context, req *backend.QueryDataRequest, settings models.TrinoDatasourceSettings) context.Context {
Copy link
Member

Choose a reason for hiding this comment

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

You're not referencing ds anywhere, so this method doesn't need to be bound to it. Remove (ds *SQLDatasourceWithTrinoUserContext), and place it after injectAccessToken.

Copy link
Author

Choose a reason for hiding this comment

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

done

return args
}


Copy link
Member

Choose a reason for hiding this comment

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

Remove this extra line

Copy link
Author

Choose a reason for hiding this comment

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

done

return nil, fmt.Errorf("user can't be nil if impersonation is enabled")
}

Copy link
Member

Choose a reason for hiding this comment

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

Remove these spaces

Copy link
Author

Choose a reason for hiding this comment

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

done

@nineinchnick
Copy link
Member

Please squash all commits

@laserninja
Copy link
Contributor

@RotRotAl can you please create a PR with just your changes? We can get this approved #309 meanwhile

@RotRotAl
Copy link
Author

@laserninja sadly my code based on your changes, i will pull your changes after you finish the cr process

@cla-bot cla-bot bot added the cla-signed label Oct 28, 2025
@RotRotAl RotRotAl force-pushed the feature/ticketless-client-tags-in-query-editor branch 2 times, most recently from 904a534 to c699b9e Compare October 29, 2025 13:05
@RotRotAl RotRotAl requested a review from nineinchnick October 29, 2025 13:10
@RotRotAl
Copy link
Author

@nineinchnick done replying and fixing, thanks for the cr.

@RotRotAl RotRotAl force-pushed the feature/ticketless-client-tags-in-query-editor branch from 8bb3509 to 61c6a88 Compare October 29, 2025 13:25
@RotRotAl
Copy link
Author

RotRotAl commented Nov 2, 2025

Hi @nineinchnick stil needs second cr 🙏🏻

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

Development

Successfully merging this pull request may close these issues.

3 participants