From 48b5d0d2d36c34cea4df7aed70e0537cd854d62d Mon Sep 17 00:00:00 2001 From: Ben King <9087625+benfdking@users.noreply.github.com> Date: Sat, 29 Mar 2025 02:01:37 +0000 Subject: [PATCH] feat: adding postgres application name --- docs/integrations/engines/postgres.md | 25 +++++++++++++------------ sqlmesh/core/config/connection.py | 2 ++ tests/cli/test_cli.py | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docs/integrations/engines/postgres.md b/docs/integrations/engines/postgres.md index 5867c26494..b030965fd5 100644 --- a/docs/integrations/engines/postgres.md +++ b/docs/integrations/engines/postgres.md @@ -10,18 +10,19 @@ pip install "sqlmesh[postgres]" ### Connection options -| Option | Description | Type | Required | -|-------------------|---------------------------------------------------------------------------------|:------:|:--------:| -| `type` | Engine type name - must be `postgres` | string | Y | -| `host` | The hostname of the Postgres server | string | Y | -| `user` | The username to use for authentication with the Postgres server | string | Y | -| `password` | The password to use for authentication with the Postgres server | string | Y | -| `port` | The port number of the Postgres server | int | Y | -| `database` | The name of the database instance to connect to | string | Y | -| `keepalives_idle` | The number of seconds between each keepalive packet sent to the server. | int | N | -| `connect_timeout` | The number of seconds to wait for the connection to the server. (Default: `10`) | int | N | -| `role` | The role to use for authentication with the Postgres server | string | N | -| `sslmode` | The security of the connection to the Postgres server | string | N | +| Option | Description | Type | Required | +|--------------------|---------------------------------------------------------------------------------|:------:|:--------:| +| `type` | Engine type name - must be `postgres` | string | Y | +| `host` | The hostname of the Postgres server | string | Y | +| `user` | The username to use for authentication with the Postgres server | string | Y | +| `password` | The password to use for authentication with the Postgres server | string | Y | +| `port` | The port number of the Postgres server | int | Y | +| `database` | The name of the database instance to connect to | string | Y | +| `keepalives_idle` | The number of seconds between each keepalive packet sent to the server. | int | N | +| `connect_timeout` | The number of seconds to wait for the connection to the server. (Default: `10`) | int | N | +| `role` | The role to use for authentication with the Postgres server | string | N | +| `sslmode` | The security of the connection to the Postgres server | string | N | +| `application_name` | The name of the application to use for the connection | string | N | ## Airflow Scheduler **Engine Name:** `postgres` diff --git a/sqlmesh/core/config/connection.py b/sqlmesh/core/config/connection.py index 17c3904ce1..617d2bdb1f 100644 --- a/sqlmesh/core/config/connection.py +++ b/sqlmesh/core/config/connection.py @@ -1196,6 +1196,7 @@ class PostgresConnectionConfig(ConnectionConfig): connect_timeout: int = 10 role: t.Optional[str] = None sslmode: t.Optional[str] = None + application_name: t.Optional[str] = None concurrent_tasks: int = 4 register_comments: bool = True @@ -1214,6 +1215,7 @@ def _connection_kwargs_keys(self) -> t.Set[str]: "keepalives_idle", "connect_timeout", "sslmode", + "application_name", } @property diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index cf4860c979..72906d6470 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -1101,7 +1101,7 @@ def test_init_project_dialects(tmp_path): "bigquery": "# concurrent_tasks: 1\n # register_comments: True\n # pre_ping: False\n # pretty_sql: False\n # method: oauth\n # project: \n # execution_project: \n # quota_project: \n # location: \n # keyfile: \n # keyfile_json: \n # token: \n # refresh_token: \n # client_id: \n # client_secret: \n # token_uri: \n # scopes: \n # impersonated_service_account: \n # job_creation_timeout_seconds: \n # job_execution_timeout_seconds: \n # job_retries: 1\n # job_retry_deadline_seconds: \n # priority: \n # maximum_bytes_billed: ", "snowflake": "account: \n # concurrent_tasks: 4\n # register_comments: True\n # pre_ping: False\n # pretty_sql: False\n # user: \n # password: \n # warehouse: \n # database: \n # role: \n # authenticator: \n # token: \n # application: Tobiko_SQLMesh\n # private_key: \n # private_key_path: \n # private_key_passphrase: \n # session_parameters: ", "databricks": "# concurrent_tasks: 1\n # register_comments: True\n # pre_ping: False\n # pretty_sql: False\n # server_hostname: \n # http_path: \n # access_token: \n # auth_type: \n # oauth_client_id: \n # oauth_client_secret: \n # catalog: \n # http_headers: \n # session_configuration: \n # databricks_connect_server_hostname: \n # databricks_connect_access_token: \n # databricks_connect_cluster_id: \n # databricks_connect_use_serverless: False\n # force_databricks_connect: False\n # disable_databricks_connect: False\n # disable_spark_session: False", - "postgres": "host: \n user: \n password: \n port: \n database: \n # concurrent_tasks: 4\n # register_comments: True\n # pre_ping: True\n # pretty_sql: False\n # keepalives_idle: \n # connect_timeout: 10\n # role: \n # sslmode: ", + "postgres": "host: \n user: \n password: \n port: \n database: \n # concurrent_tasks: 4\n # register_comments: True\n # pre_ping: True\n # pretty_sql: False\n # keepalives_idle: \n # connect_timeout: 10\n # role: \n # sslmode: \n # application_name: ", } for dialect, expected_config in dialect_to_config.items():