PostgreSQL
PostgreSQL is an open source object-relational database management system that is known for its reliability and performance, and this topic describes how to configure a PostgreSQL database as a Dremio Sonar source.
Prerequisites
Ensure that you have the following details before configuring PostgreSQL as a source:
- Database name
- Hostname or IP address
- Port
Dremio PostgreSQL Configuration
Perform these steps to configure PostgreSQL:
In the Datasets UI, you can see a truncated list of Sources at the bottom-left of the page. Click + Add Source.
Alternatively, click Databases. The page displays all database sources. Click the Add database button at the top-right of that page.
In the Add Data Source dialog, click PostgreSQL.
The following section describes the source configuration tabs.
General
The General tab contains the required fields to create a PostgreSQL source.
Perform these steps in the General tab:
- In the General tab, for Name, enter a name.
- For Host, enter the PostgreSQL host name.
- For Port, enter the PostgreSQL port number. The default port is 5432.
- For Database, enter the PostgreSQL database name.
- (Optional) For Encrypt connection, enable encrypted connections to PostgreSQL using SSL. You can modify the encryption validation mode under Advanced Options.
- For Authentication, you must choose one of the following authentication options:
- Master Authentication, this is the default option. Provide the username and password of a master database user with permissions to read required objects:
- For Username, enter your PostgreSQL database username.
- For Password, enter your PostgreSQL database password.
- For Secret Resource Url, provide the username and the Secret Resource URL that allows fetching the credentials, username and password, and the connection details from the AWS Secrets Manager:
- For Username, enter your PostgreSQL database username.
- For Secret Resource Url, enter the secret resource URL.
Advanced Options
Click Advanced Options in the sidebar.
note:
All advanced options are optional.
Advanced Option | Description |
---|---|
Record fetch size | Number of records to fetch at once. Set to 0 (zero) to have Sonar automatically decide. The default record fetch size is 200. |
Maximum Idle Connections | The total number of connections allowed to be idle at a given time. The default maximum idle connections is 8. |
Connection Idle Time | The amount of time (in seconds) allowed for a connection to remain idle before the connection is terminated. The default connection idle time is 60 seconds. |
Encryption Validation Mode | When encryption is enabled, set the validation mode as one of the following:
|
Connection Properties | Custom key value pairs for the connection relevant to the source. To add a connection property, click Add property and add the property name and value. |
Reflection Refresh
The Reflection Refresh tab in the sidebar allows you to set time intervals for reflections to refresh or expire.
Metadata
You can configure settings to refresh metadata and handle datasets. Click Metadata in the sidebar.
You can configure Dataset Handling and Metadata Refresh parameters.
Dataset Handling
These are the Dataset Handling parameters.
note:
All Dataset Handling parameters are optional.
Parameter | Description |
---|---|
Remove dataset definitions if underlying data is unavailable | By default, Sonar removes dataset definitions if underlying data is unavailable. Useful when files are temporarily deleted and added back in the same location with new sets of files. |
Metadata Refresh
These are the Metadata Refresh parameters:
Dataset Discovery: The refresh interval for fetching top-level source object names such as databases and tables. Set the time interval using this parameter.
Parameter Description (Optional) Fetch every You can choose to set the frequency to fetch object names in minutes, hours, days, or weeks. The default frequency to fetch object names is 1 hour. Dataset Details: The metadata that Sonar needs for query planning such as information required for fields, types, shards, statistics, and locality. These are the parameters to fetch the dataset information.
note:
All Dataset Details parameters are optional.
Parameter | Description |
---|---|
Fetch mode | You can choose to fetch only from queried datasets that are set by default. Sonar updates details for previously queried objects in a source. Fetching from all datasets is deprecated. |
Fetch every | You can choose to set the frequency to fetch dataset details in minutes, hours, days, or weeks. The default frequency to fetch dataset details is 1 hour. |
Expire after | You can choose to set the expiry time of dataset details in minutes, hours, days, or weeks. The default expiry time of dataset details is 3 hours. |
Privileges
You can grant privileges to specific users or roles.
- (Optional) For Privileges, enter the user name or role name that you want to grant access to and click the Add to Privileges button. The added user or role is displayed in the Users table.
- (Optional) For the users or roles in the Users table, toggle the green checkmark for each privilege you want to grant to the PostgreSQL source that is being created.
Click Save after setting the configuration.
Editing a PostgreSQL Source
To edit a PostgreSQL source:
- In the Datasets UI, click Databases. A list of databases is displayed.
- Under the Actions column, click the Settings (gear) icon for the source you want to edit. From the list of actions, click Edit Details.
- In the Edit Source dialog, you cannot edit the name. Editing other parameters is optional.
- Click Save.
Removing a PostgreSQL Source
To remove a PostgreSQL source, perform these steps:
- In the Datasets UI, click Databases. A list of sources is displayed.
- Under the Actions column, click the Settings (gear) icon for the source that you want to remove.
- From the list of actions, click Remove Source. Confirm that you want to remove the source.
warning:
Removing a source causes all downstream views dependent on objects in this source to break.
Predicate Pushdowns
Dremio offloads these operations to Postgres.
Operators | Operators | Operators | Operators |
---|---|---|---|
*, +, -, /, % | DATE_TRUNC_HOUR | IS DISTINCT FROM | REVERSE |
<, <=, <>, =, >, >=, != | DATE_TRUNC_MINUTE | IS NOT DISTINCT FROM | RIGHT |
AND, NOT, OR, || | DATE_TRUNC_MONTH | IS NOT NULL | ROUND |
ABS | DATE_TRUNC_QUARTER | IS NULL | RPAD |
ACOS | DATE_TRUNC_SECOND | LCASE | RTRIM |
ASIN | DATE_TRUNC_WEEK | LEFT | SIGN |
ATAN | DATE_TRUNC_YEAR | LENGTH | SIN |
ATAN2 | DEGREES | LIKE | SQRT |
AVG | E | LN | STDDEV |
CAST | EXP | LOCATE | STDDEV_POP |
CBRT | EXTRACT_CENTURY | LOG | STDDEV_SAMP |
CEIL | EXTRACT_DAY | LOG10 | SUBSTR |
CEILING | EXTRACT_DECADE | LOWER | SUBSTRING |
CHAR_LENGTH | EXTRACT_DOW | LPAD | SUM |
CHARACTER_LENGTH | EXTRACT_DOY | LTRIM | TAN |
CONCAT | EXTRACT_EPOCH | MAX | TO_CHAR |
COS | EXTRACT_HOUR | MIN | TO_DATE |
COT | EXTRACT_MILLENNIUM | MOD | TRIM |
COVAR_POP | EXTRACT_MINUTE | PI | TRUNC |
COVAR_SAMP | EXTRACT_MONTH | POSITION | TRUNCATE |
DATE_ADD | EXTRACT_QUARTER | POW | UCASE |
DATE_SUB | EXTRACT_SECOND | POWER | UPPER |
DATE_TRUNC_CENTURY | EXTRACT_WEEK | RADIANS | VAR_POP |
DATE_TRUNC_DAY | EXTRACT_YEAR | REGEXP_LIKE | VAR_SAMP |
DATE_TRUNC_DECADE | FLOOR | REPLACE |