Skip to content

Commit 4e02acf

Browse files
authored
add snowflake partner identifier (#161)
1 parent 58c86b6 commit 4e02acf

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/platform/notebooks/deepnote/sqlIntegrationEnvironmentVariablesProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export class SqlIntegrationEnvironmentVariablesProvider implements ISqlIntegrati
105105
});
106106

107107
const { envVars: envVarList, errors } = getEnvironmentVariablesForIntegrations(projectIntegrationConfigs, {
108-
projectRootDirectory: ''
108+
projectRootDirectory: '',
109+
snowflakePartnerIdentifier: 'Deepnote_Workspaces'
109110
});
110111

111112
errors.forEach((error) => {

src/platform/notebooks/deepnote/sqlIntegrationEnvironmentVariablesProvider.unit.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,53 @@ suite('SqlIntegrationEnvironmentVariablesProvider', () => {
359359
const expectedEnvVarName = `SQL_${DATAFRAME_SQL_INTEGRATION_ID.toUpperCase().replace(/-/g, '_')}`;
360360
assert.ok(result[expectedEnvVarName], `Should have ${expectedEnvVarName} env var for DuckDB`);
361361
});
362+
363+
test('Snowflake integration includes partner identifier in URL as application parameter', async () => {
364+
const resource = Uri.file('/test/notebook.deepnote');
365+
const notebook = mock<NotebookDocument>();
366+
const snowflakeConfig: DatabaseIntegrationConfig = {
367+
id: 'my-snowflake',
368+
name: 'Snowflake DB',
369+
type: 'snowflake',
370+
metadata: {
371+
authMethod: 'password',
372+
accountName: 'test-account.us-east-1',
373+
warehouse: 'test_warehouse',
374+
database: 'test_db',
375+
role: 'test_role',
376+
username: 'test_user',
377+
password: 'test_pass'
378+
}
379+
};
380+
const project = createMockProject('project-123', [
381+
{ id: 'my-snowflake', name: 'Snowflake DB', type: 'snowflake' }
382+
]);
383+
384+
when(notebook.metadata).thenReturn({ deepnoteProjectId: 'project-123' });
385+
when(notebookEditorProvider.findAssociatedNotebookDocument(resource)).thenReturn(instance(notebook));
386+
when(notebookManager.getOriginalProject('project-123')).thenReturn(project);
387+
when(integrationStorage.getIntegrationConfig('my-snowflake')).thenResolve(snowflakeConfig);
388+
389+
const result = await provider.getEnvironmentVariables(resource);
390+
391+
const expectedEnvVarName = 'SQL_MY_SNOWFLAKE';
392+
assert.ok(result[expectedEnvVarName], `Should have ${expectedEnvVarName} env var`);
393+
394+
const envVarValue = result[expectedEnvVarName];
395+
assert.ok(typeof envVarValue === 'string', 'Env var value should be a string');
396+
assert.ok(envVarValue, 'Env var value should not be undefined');
397+
398+
// Parse and verify the structure
399+
const parsed = JSON.parse(envVarValue!);
400+
assert.ok(parsed.url, 'Should have url field');
401+
assert.ok(parsed.url.includes('snowflake://'), 'URL should be Snowflake connection string');
402+
403+
// Verify that the application parameter is set to the Snowflake partner identifier
404+
assert.ok(
405+
parsed.url.includes('application=Deepnote_Workspaces'),
406+
'URL should contain application=Deepnote_Workspaces parameter'
407+
);
408+
});
362409
});
363410
});
364411

0 commit comments

Comments
 (0)