Microsoft SQL Server
Microsoft SQL Server is a database server for storing and retrieving data.
User Impersonation
The Microsoft SQL Server username provided in the connection configuration is the default username when running queries. When queries are run against Microsoft SQL Server in Dremio, users use the privileges associated with the Microsoft SQL Server username and run queries under that username.
You can change this default in Dremio by enabling user impersonation in the Advanced Options, which allows users to run queries under their own usernames and restricts their access. For example, user_1 can run queries as user_1 rather than sqlsvr_svc. Before enabling user impersonation, some setup is required in Microsoft SQL Server to allow one user to impersonate another user. The username of the user in Dremio must be the same as their username in Microsoft SQL Server, and the user must be able to connect through the Microsoft SQL Server username.
To set up user impersonation, follow these steps:
-
Ensure the user's username in Microsoft SQL Server matches their username in Dremio. If the usernames do not match, modify one of the usernames or create a new user account with a matching username.
-
Run a GRANT IMPERSONATE command in Microsoft SQL Server to allow the user to connect through their Microsoft SQL Server username:
Example of granting impersonate privilege in Microsoft SQL ServerGRANT IMPERSONATE ON USER::testuser1 TO proxyuser;In this example, the user can log in as
testuser1in Dremio and in Microsoft SQL Server, and they can connect through theproxyuser. Theproxyuseris the Microsoft SQL Server username provided in the connection configuration. -
Log in to Dremio as a member of the ADMIN role.
-
Follow the steps for Configure Microsoft SQL Server as a Source using the Microsoft SQL Server username
proxyuserand enable User Impersonation in the Advanced Options. -
Grant privileges to the user.
Now that you have enabled user impersonation, a user who logs in to Dremio with their username can access Microsoft SQL Server according to their privileges. The user can also run queries against Microsoft SQL Server under their username.
Connect to Microsoft SQL Server
- In the Dremio console, click Add Data on the Home page.
- In the Add Data dialog, select Microsoft SQL Server.
- Configure the connection using the sections below, then click Save.
General
The General tab contains the required fields to create a Microsoft SQL Server connection.
Perform these steps in the General tab:
- In the General tab, for Name, enter a name for the connection. The name cannot include the following special characters:
/,:,[, or]. - For Host, enter the Microsoft SQL Server hostname.
- For Port, enter the Microsoft SQL Server port number. The default port is 1433.
- (Optional) For Database, enter the Microsoft SQL Server database name.
- (Optional) For Encrypt connection, enable encrypted connections to Microsoft SQL Server using SSL.
- For Authentication, Master Authentication is the default and the only option. Provide the username and password of a master database user with permissions to read required objects:
- For Username, enter your Microsoft SQL Server database username.
- For Password, enter your Microsoft SQL Server database password.
Advanced Options
Click Advanced Options in the sidebar. All advanced options are optional.
| Advanced Option | Description |
|---|---|
| Show only the initial database used for connecting | If selected, hides the other databases that the credential has access to. |
| Record fetch size | Number of records to fetch at once. Set to 0 (zero) to have Dremio 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 (s) | 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. |
| Query timeout (s) | The amount of time (in seconds) allowed to wait for the results of a query. If this time expires, the connection being used is returned to an idle state. |
| Enable user impersonation | Select the checkbox to allow users to run queries using their credentials rather than those of the user specified in the Authentication configuration. Some setup is required in Microsoft SQL Server to allow one user to impersonate another user. Read User Impersonation for more information. |
| Encryption | Verify Server Certificate is enabled. Add an SSL/TLS server certificate distinguished name in the text box. |
| Connection Properties | Custom key value pairs for the connection. 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. All Dataset Handling parameters are optional.
| Parameter | Description |
|---|---|
| Remove dataset definitions if underlying data is unavailable | By default, Dremio 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 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 Dremio needs for query planning such as information required for fields, types, shards, statistics, and locality. These are the parameters to fetch the dataset information. All Dataset Details parameters are optional.
Parameter Description Fetch mode You can choose to fetch only from queried datasets, which is set by default. Dremio updates details for previously queried objects. 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
This connection inherits privileges from Project settings. To grant specific users or roles additional privileges in this connection:
- Enter the username 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/ROLES table.
- For the users or roles in the USERS/ROLES table, toggle the checkmark for each privilege you want to grant on the Dremio source that is being created.
- Click Save after setting the configuration.
See Privileges for additional information about privileges.
Edit a Microsoft SQL Server Connection
- On the Open Catalog page, under Connections, right-click the connection and select Settings.
- Update the connection configuration as needed.
- Click Save.
Delete a Microsoft SQL Server Connection
- On the Open Catalog page, under Connections, right-click the connection and select Delete.
- Click Delete to confirm.
Predicate Pushdowns
Dremio offloads these operations to Microsoft SQL Server:
*, +, -, /, %
<, <=, <>, =, >, >=, !=
AND, NOT, OR, ||
ABS
ACOS
ADD_MONTHS
ASIN
ATAN
ATAN2
AVG
CAST
CEIL
CEILING
CHAR_LENGTH
CHARACTER_LENGTH
CONCAT
COS
COT
DATE_ADD
DATE_SUB
DATE_TRUNC_DAY
DATE_TRUNC_HOUR
DATE_TRUNC_MINUTE
DATE_TRUNC_MONTH
DATE_TRUNC_YEAR
DEGREES
E
EXP
EXTRACT_DAY
EXTRACT_DOW
EXTRACT_DOY
EXTRACT_HOUR
EXTRACT_MINUTE
EXTRACT_MONTH
EXTRACT_QUARTER
EXTRACT_SECOND
EXTRACT_WEEK
EXTRACT_YEAR
FLOOR
IS DISTINCT FROM
IS NOT DISTINCT FROM
IS NOT NULL
IS NULL
LAST_DAY
LCASE
LEFT
LENGTH
LIKE
LN
LOCATE
LOG
LOG10
LOWER
LPAD
LTRIM
MAX
MEDIAN
MIN
MOD
MONTH
PERCENT_CONT
PERCENT_DISC
PI
POSITION
POW
POWER
RADIANS
RAND
REPLACE
REVERSE
RIGHT
ROUND
RPAD
RTRIM
SIGN
SIN
SQRT
SUBSTR
SUBSTRING
SUM
TAN
TIMESTAMPADD_DAY
TIMESTAMPADD_HOUR
TIMESTAMPADD_MINUTE
TIMESTAMPADD_MONTH
TIMESTAMPADD_QUARTER
TIMESTAMPADD_SECOND
TIMESTAMPADD_YEAR
TIMESTAMPDIFF_DAY
TIMESTAMPDIFF_HOUR
TIMESTAMPDIFF_MINUTE
TIMESTAMPDIFF_MONTH
TIMESTAMPDIFF_QUARTER
TIMESTAMPDIFF_SECOND
TIMESTAMPDIFF_WEEK
TIMESTAMPDIFF_YEAR
TO_DATE
TRIM
TRUNC
TRUNCATE
UCASE
UPPER
YEAR
Since Microsoft SQL Server has no Boolean type, project operations that contain SQL expressions which evaluate to true or false (e.g., SELECT username, friends > 0), and filter operations that include Boolean literals in a filter (e.g., WHERE currentAccount = true) cannot be executed as pushdowns.
Data Type Map
Dremio supports SQL Server data types, as shown in the following table which provides the mappings from SQL Server to Dremio data types. If there are additional SQL Server types not listed in the table, then those types are not supported in Dremio.
| SQL Server Data Type | Dremio Type |
|---|---|
| BIGINT IDENTITY | BIGINT |
| BIGINT | BIGINT |
| BINARY | VARBINARY |
| BIT | BOOLEAN |
| CHAR | VARCHAR |
| DATE | DATE |
| DATETIME | TIMESTAMP |
| DATETIME2 | TIMESTAMP |
| DECIMAL | DECIMAL |
| DECIMAL() IDENTITY | DECIMAL |
| FLOAT | DOUBLE |
| IMAGE | VARBINARY |
| INT IDENTITY | INTEGER |
| INT | INTEGER |
| MONEY | DOUBLE |
| NCHAR | VARCHAR |
| NTEXT | VARCHAR |
| NUMERIC | DECIMAL |
| NUMERIC() IDENTITY | DECIMAL |
| NVARCHAR | VARCHAR |
| REAL | FLOAT |
| SMALLDATETIME | TIMESTAMP |
| SMALLINT IDENTITY | INTEGER |
| SMALLINT | INTEGER |
| SMALLMONEY | DOUBLE |
| SYSNAME | VARCHAR |
| TEXT | VARCHAR |
| TIME | TIME |
| TINYINT IDENTITY | INTEGER |
| TINYINT | INTEGER |
| UNIQUEIDENTIFIER | VARBINARY |
| VARBINARY | VARBINARY |
| VARCHAR | VARCHAR |