-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove snipsync (#613) * add custom snippets element * Add pymssql dependency * Quote keyword in version table columns * Init ms sql (not working) * Partially working mssql * ms sql ci template init * Use pyodbc instead of pymssql * make database exception * ms sql escaping * Replace pymysql with pyodbc dependency * Fix binary+json escape, time type * autocommit mode * Include pyarrow * test_sql_client running * Add dbt map * try sql ci all OS * Run with x * Try install driver * Configure + detect odbc_driver, prefer v18 * skip dbt tests for now * no arrow * escape time * Temp table merge queries mssql compat * escape all version/state columns * Remove fs credentials * Fix double ; * Fix py 3.8 * Init ms sql docs * Forward query params * All load tests running * Convert to odbc dsn * Skip marker for filesystem pipeline test * Limit ms sql inserts to 1000 rows * Cleanup * Do NULLS FIRST sorting in python * Lint pq import * Fix athena tests * -x * disables index creation by default, updates docs * Revert "remove snipsync (#613)" This reverts commit 34dcc91. --------- Co-authored-by: David Scharf <[email protected]> Co-authored-by: Marcin Rudolf <[email protected]>
- Loading branch information
1 parent
82d8b9d
commit e8fecb7
Showing
27 changed files
with
4,162 additions
and
3,663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
|
||
name: test MS SQL | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
- devel | ||
workflow_dispatch: | ||
|
||
env: | ||
DESTINATION__MSSQL__CREDENTIALS: mssql://[email protected]:1433/dlt_ci | ||
DESTINATION__MSSQL__CREDENTIALS__PASSWORD: ${{ secrets.MSSQL_PASSWORD }} | ||
|
||
RUNTIME__SENTRY_DSN: https://[email protected]/4504819859914752 | ||
RUNTIME__LOG_LEVEL: ERROR | ||
|
||
ACTIVE_DESTINATIONS: "[\"mssql\"]" | ||
ALL_FILESYSTEM_DRIVERS: "[\"memory\"]" | ||
|
||
jobs: | ||
get_docs_changes: | ||
uses: ./.github/workflows/get_docs_changes.yml | ||
if: ${{ !github.event.pull_request.head.repo.fork }} | ||
|
||
run_loader: | ||
name: Tests MS SQL loader | ||
needs: get_docs_changes | ||
if: needs.get_docs_changes.outputs.changes_outside_docs == 'true' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-latest"] | ||
defaults: | ||
run: | ||
shell: bash | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
|
||
- name: Check out | ||
uses: actions/checkout@master | ||
|
||
- name: Install ODBC driver for SQL Server | ||
run: | | ||
sudo ACCEPT_EULA=Y apt-get install --yes msodbcsql18 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10.x" | ||
|
||
- name: Install Poetry | ||
uses: snok/[email protected] | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
installer-parallel: true | ||
|
||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-gcp | ||
|
||
- name: Install dependencies | ||
run: poetry install --no-interaction -E mssql -E s3 -E gs -E az | ||
|
||
- run: | | ||
poetry run pytest tests/load --ignore tests/load/pipeline/test_dbt_helper.py | ||
if: runner.os != 'Windows' | ||
name: Run tests Linux/MAC | ||
- run: | | ||
poetry run pytest tests/load --ignore tests/load/pipeline/test_dbt_helper.py | ||
if: runner.os == 'Windows' | ||
name: Run tests Windows | ||
shell: cmd | ||
matrix_job_required_check: | ||
name: MS SQL loader tests | ||
needs: run_loader | ||
runs-on: ubuntu-latest | ||
if: always() | ||
steps: | ||
- name: Check matrix job results | ||
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') | ||
run: | | ||
echo "One or more matrix job tests failed or were cancelled. You may need to re-run them." && exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# loader account setup | ||
|
||
1. Create new database `CREATE DATABASE dlt_data` | ||
2. Create new user, set password `CREATE USER loader WITH PASSWORD 'loader';` | ||
3. Set as database owner (we could set lower permission) `ALTER DATABASE dlt_data OWNER TO loader` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from typing import Type | ||
|
||
from dlt.common.schema.schema import Schema | ||
from dlt.common.configuration import with_config, known_sections | ||
from dlt.common.configuration.accessors import config | ||
from dlt.common.data_writers.escape import escape_postgres_identifier, escape_mssql_literal | ||
from dlt.common.destination import DestinationCapabilitiesContext | ||
from dlt.common.destination.reference import JobClientBase, DestinationClientConfiguration | ||
from dlt.common.arithmetics import DEFAULT_NUMERIC_PRECISION, DEFAULT_NUMERIC_SCALE | ||
from dlt.common.wei import EVM_DECIMAL_PRECISION | ||
|
||
from dlt.destinations.mssql.configuration import MsSqlClientConfiguration | ||
|
||
|
||
@with_config(spec=MsSqlClientConfiguration, sections=(known_sections.DESTINATION, "mssql",)) | ||
def _configure(config: MsSqlClientConfiguration = config.value) -> MsSqlClientConfiguration: | ||
return config | ||
|
||
|
||
def capabilities() -> DestinationCapabilitiesContext: | ||
caps = DestinationCapabilitiesContext() | ||
caps.preferred_loader_file_format = "insert_values" | ||
caps.supported_loader_file_formats = ["insert_values"] | ||
caps.preferred_staging_file_format = None | ||
caps.supported_staging_file_formats = [] | ||
caps.escape_identifier = escape_postgres_identifier | ||
caps.escape_literal = escape_mssql_literal | ||
caps.decimal_precision = (DEFAULT_NUMERIC_PRECISION, DEFAULT_NUMERIC_SCALE) | ||
caps.wei_precision = (DEFAULT_NUMERIC_PRECISION, 0) | ||
# https://learn.microsoft.com/en-us/sql/sql-server/maximum-capacity-specifications-for-sql-server?view=sql-server-ver16&redirectedfrom=MSDN | ||
caps.max_identifier_length = 128 | ||
caps.max_column_identifier_length = 128 | ||
caps.max_query_length = 4 * 1024 * 64 * 1024 | ||
caps.is_max_query_length_in_bytes = True | ||
caps.max_text_data_type_length = 2 ** 30 - 1 | ||
caps.is_max_text_data_type_length_in_bytes = False | ||
caps.supports_ddl_transactions = True | ||
caps.max_rows_per_insert = 1000 | ||
|
||
return caps | ||
|
||
|
||
def client(schema: Schema, initial_config: DestinationClientConfiguration = config.value) -> JobClientBase: | ||
# import client when creating instance so capabilities and config specs can be accessed without dependencies installed | ||
from dlt.destinations.mssql.mssql import MsSqlClient | ||
|
||
return MsSqlClient(schema, _configure(initial_config)) # type: ignore[arg-type] | ||
|
||
|
||
def spec() -> Type[DestinationClientConfiguration]: | ||
return MsSqlClientConfiguration |
Oops, something went wrong.