Skip to content
This repository was archived by the owner on Mar 13, 2020. It is now read-only.

Commit b889095

Browse files
authored
Merge pull request #16 from PageUpPeopleOrg/task/shave-that-yak
[OSC-1236] - Minor useful logic changes and yak shaves
2 parents 35a2a6f + 61aa4d8 commit b889095

34 files changed

+487
-359
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,33 @@ See `test_*.cmd` scripts for usage samples.
5252

5353
## Development
5454

55+
### Linting
56+
57+
Use autopep8 before pushing commits (include the "." for the folder)
58+
59+
`>>>autopep8 --in-place --aggressive --aggressive --recursive --max-line-length=120 .`
60+
61+
Use the following vscode settings by either:
62+
63+
- System wide: Ctrl+Shift+P, "open settings (json)"
64+
- For this project only: add the following to ./vscode/settings.json
65+
66+
```json
67+
{
68+
"python.pythonPath": (your python venv here),
69+
"files.trimFinalNewlines": true,
70+
"files.trimTrailingWhitespace": true,
71+
"files.insertFinalNewline": true,
72+
"files.eol": "\n",
73+
"editor.renderWhitespace": "all",
74+
"editor.tabCompletion": "on",
75+
"editor.trimAutoWhitespace": true,
76+
"editor.insertSpaces": true,
77+
"editor.rulers": [80, 120],
78+
"editor.formatOnSave": true
79+
}
80+
```
81+
5582
### Testing
5683

5784
#### Integration

__init__.py

Whitespace-only changes.

appveyor.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ environment:
77
PGPORT: 5432
88
PGHOST: "localhost"
99
DBNAME: relational_data_loader_integration_tests
10+
MSSQLSTR: "{'username': '','password': '','server_string': '(local)\\SQL2016'}"
1011
matrix:
1112
- PYTHON: "C:\\Python37-x64" #This needs to be a double slash
1213
PYTHON_VERSION: "3.7.x"
@@ -24,7 +25,6 @@ init:
2425
#- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
2526

2627
install:
27-
2828
#Setup Python
2929
- SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH% #Swap path to python to latest version (as per matrix above)
3030
- python --version
@@ -44,15 +44,27 @@ build_script:
4444
#Install the dependencies for rdl.
4545
- pip install -r requirements.txt
4646

47-
4847
test_script:
48+
# unit tests
49+
- test_run_unit_tests.cmd
50+
51+
# integration tests
4952
- test_full_refresh_from_csv.cmd
5053
- test_full_refresh_from_mssql.cmd
5154
- test_incremental_refresh_from_csv.cmd
5255
- test_incremental_refresh_from_mssql.cmd
56+
5357
- test_full_refresh_from_mssql.cmd
5458
- test_incremental_refresh_from_mssql.cmd
5559

60+
- sqlcmd -b -E -f 65001 -S "(local)\SQL2016" -d RelationalDataLoaderIntegrationTestSource -i .\integration_tests\mssql_source\source_database_setup\change_compound_pk.sql
61+
62+
- test_incremental_refresh_from_mssql.cmd
63+
64+
- sqlcmd -b -E -f 65001 -S "(local)\SQL2016" -d RelationalDataLoaderIntegrationTestSource -i .\integration_tests\mssql_source\source_database_setup\change_large_table.sql
65+
66+
- test_full_refresh_from_mssql.cmd
67+
5668
on_finish:
5769
#Enable this line to make the build pause after completion for RDP troubleshooting.
5870
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

integration_tests/csv_source/assertions/column_test_full_refresh_assertions.sql

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,36 @@ DROP TABLE IF EXISTS results;
44

55
CREATE TEMPORARY TABLE results AS
66
WITH
7-
expected(id, int_column_1, date_column_1, decimal_column_1, date_time_column_1, string_column_1, guid_column_1, big_int_column_1, bool_column_1)
8-
AS
9-
(
10-
SELECT 1, 111.0, '1976-12-01'::DATE, 12.1212, '1976-12-01 01:00:00.000000'::TIMESTAMP, 'A Basic String', '57bc8093-fe4c-477a-bbd7-fb5c02055a7e'::UUID,2147483647121212, True
7+
expected(id, int_column_1, date_column_1, decimal_column_1, date_time_column_1, string_column_1, guid_column_1, big_int_column_1, bool_column_1)
8+
AS
9+
(
10+
SELECT
11+
1, 111.0, '1976-12-01'::DATE,
12+
12.1212, '1976-12-01 01:00:00.000000'::TIMESTAMP,
13+
'A Basic String', '57bc8093-fe4c-477a-bbd7-fb5c02055a7e'::UUID,2147483647121212,
14+
True
1115
UNION ALL
12-
SELECT 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
13-
UNION ALL
14-
SELECT 3, 333.0, '2001-01-01', 33.333, NULL, 'This Text Has a Quote Before "Dave', NULL, NULL, True
15-
UNION ALL
16-
SELECT 4, NULL, NULL, NULL, NULL, 'ം ഃ അ ആ ഇ ഈ ഉ ഊ ഋ ഌ എ ഏ', 'aabc8093-fe4c-477a-bbd7-fb5c02055a7e', NULL, False
17-
UNION ALL
18-
SELECT 5, NULL, NULL, NULL, NULL, 'This row will be updated in the incremental review test', NULL, NULL, NULL
19-
),
16+
SELECT 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
17+
UNION ALL
18+
SELECT 3, 333.0, '2001-01-01', 33.333, NULL, 'This Text Has a Quote Before "Dave', NULL, NULL, True
19+
UNION ALL
20+
SELECT 4, NULL, NULL, NULL, NULL, 'ം ഃ അ ആ ഇ ഈ ഉ ഊ ഋ ഌ എ ഏ', 'aabc8093-fe4c-477a-bbd7-fb5c02055a7e', NULL, False
21+
UNION ALL
22+
SELECT 5, NULL, NULL, NULL, NULL, 'This row will be updated in the incremental review test', NULL, NULL, NULL
23+
),
2024

21-
actual AS
22-
(
25+
actual
26+
AS
27+
(
2328
SELECT id, int_column_1, date_column_1, decimal_column_1, date_time_column_1, string_column_1, guid_column_1, big_int_column_1, bool_column_1
24-
FROM rdl_integration_tests.load_source_data
25-
)
29+
FROM rdl_integration_tests.load_source_data
30+
)
2631

27-
SELECT *
28-
FROM expected
29-
EXCEPT
30-
SELECT *
31-
FROM actual;
32+
SELECT *
33+
FROM expected
34+
EXCEPT
35+
SELECT *
36+
FROM actual;
3237

3338
DO $$
3439
BEGIN

integration_tests/csv_source/config/ColumnTest.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
32
"source_table": {
43
"name": "ColumnTest",
54
"schema": "dbo",
@@ -54,42 +53,37 @@
5453
"nullable": true
5554
}
5655
},
57-
{
56+
{
5857
"source_name": "StringColumn1",
5958
"destination": {
6059
"name": "string_column_1",
6160
"type": "string",
6261
"nullable": true
6362
}
6463
},
65-
{
64+
{
6665
"source_name": "GuidColumn1",
6766
"destination": {
6867
"name": "guid_column_1",
6968
"type": "guid",
7069
"nullable": true
7170
}
7271
},
73-
{
72+
{
7473
"source_name": "BigIntColumn1",
7574
"destination": {
7675
"name": "big_int_column_1",
7776
"type": "bigint",
7877
"nullable": true
7978
}
8079
},
81-
{
80+
{
8281
"source_name": "BoolColumn1",
8382
"destination": {
8483
"name": "bool_column_1",
8584
"type": "boolean",
8685
"nullable": true
8786
}
8887
}
89-
90-
91-
92-
93-
9488
]
9589
}

integration_tests/csv_source/full_refresh_data/ColumnTest.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ id,StringColumn1,IntColumn1,DecimalColumn1,DateColumn1,DateTimeColumn1,GuidColum
33
2,,,,,,,,
44
3,"This Text Has a Quote Before ""Dave", 333,33.333, 01-01-01,,,,1
55
4,"ം ഃ അ ആ ഇ ഈ ഉ ഊ ഋ ഌ എ ഏ",,,,,AABC8093-FE4C-477A-BBD7-FB5C02055A7E,,0
6-
5,"This row will be updated in the incremental review test",,
6+
5,"This row will be updated in the incremental review test",,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
id,StringColumn1,IntColumn1,DecimalColumn1,DateColumn1,DateTimeColumn1,GuidColumn1,BigIntColumn1,BoolColumn1
22
5,"This row WAS updated in the incremental review test",,,,,,,1
33
6,"A Basic String",111,12.1212,01-Dec-1976,01-dec-1976 1:00 am,57BC8093-FE4C-477A-BBD7-FB5C02055A7E,,0
4-
7,"Another Basic String",111,12.1212,01-Dec-1976,01-dec-1976 1:00 am,,,1
4+
7,"Another Basic String",111,12.1212,01-Dec-1976,01-dec-1976 1:00 am,,,1

integration_tests/mssql_source/assertions/large_table_test_full_refresh_assertions.sql

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
SET client_encoding TO 'UTF8';
2-
1+
SET client_encoding
2+
TO 'UTF8';
33

44
DO $$
5-
BEGIN
6-
IF (SELECT COUNT(*) FROM rdl_integration_tests.load_large_data ) = 1000000 THEN
5+
BEGIN
6+
IF ((SELECT COUNT(*)
7+
FROM rdl_integration_tests.load_large_data ) = 1000000)
8+
OR
9+
((SELECT COUNT(*)
10+
FROM rdl_integration_tests.load_large_data ) = 1000001) THEN
711
RAISE NOTICE '[LARGE MSSQL IMPORT TEST] PASS';
8-
ELSE
12+
ELSE
913
RAISE EXCEPTION '[LARGE MSSQL IMPORT TEST] FAIL: Did not find the required 1,000,000 rows.';
10-
END IF;
14+
END
15+
IF;
1116
END $$;
12-
13-

integration_tests/mssql_source/config/CompoundPkTest.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"source_table": {
33
"name": "CompoundPk",
44
"schema": "dbo",
5-
"primary_keys": ["Id1","Id2"]
5+
"primary_keys": ["Id1", "Id2"]
66
},
77
"target_schema": "rdl_integration_tests",
88
"stage_table": "stage_compound_pk",
@@ -21,7 +21,7 @@
2121
"primary_key": true
2222
}
2323
},
24-
{
24+
{
2525
"source_name": "Id2",
2626
"destination": {
2727
"name": "id_2",
@@ -30,6 +30,5 @@
3030
"primary_key": true
3131
}
3232
}
33-
3433
]
3534
}

integration_tests/mssql_source/config/LargeTableTest.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"nullable": true
4646
}
4747
},
48-
{
48+
{
4949
"source_name": "StringColumn1",
5050
"destination": {
5151
"name": "string_column_1",
@@ -69,15 +69,13 @@
6969
"nullable": true
7070
}
7171
},
72-
{
72+
{
7373
"source_name": "BoolColumn",
7474
"destination": {
7575
"name": "bool_column_1",
7676
"type": "boolean",
7777
"nullable": true
7878
}
7979
}
80-
81-
8280
]
8381
}

0 commit comments

Comments
 (0)