Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type ConnectionOptions = {
readonly session?: Session;
readonly extraCredential?: ExtraCredential;
readonly ssl?: SecureContextOptions;
extraHeaders?: RequestHeaders;
};

export type QueryStage = {
Expand Down Expand Up @@ -192,6 +193,7 @@ class Client {
[TRINO_EXTRA_CREDENTIAL_HEADER]: encodeAsString(
options.extraCredential ?? {}
),
...(options.extraHeaders ?? {}),
};

if (options.auth && options.auth.type === 'basic') {
Expand Down
16 changes: 16 additions & 0 deletions tests/it/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ describe('trino', () => {
expect(info.query).toBe(singleCustomerQuery);
});

test.concurrent('client extra header propagation', async () => {
const source = 'new-client';
const trino = Trino.create({
catalog: 'tpcds',
schema: 'sf100000',
auth: new BasicAuth('test'),
extraHeaders: {'X-Trino-Source': source},
});

const query = await trino.query(singleCustomerQuery);
const qr = await query.next();

const info: any = await trino.queryInfo(qr.value.id);
expect(info.session.source).toBe(source);
});

test.concurrent('query request header propagation', async () => {
const trino = Trino.create({catalog: 'tpcds', auth: new BasicAuth('test')});
const query = await trino.query(useSchemaQuery);
Expand Down