Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click cli main merge #6926

Merged
merged 157 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
a9c8bc0
f-string cleanup #6068 (#6082)
eve-johns Oct 17, 2022
35f7975
Updated string formatting on non-f-strings. (#6086)
luke-bassett Oct 17, 2022
ff2f1f4
Working solution serialization bug. (#5874)
VersusFacit Oct 18, 2022
a7670a3
Add unit tests for recent stringifier functors added to events librar…
VersusFacit Oct 20, 2022
53ae325
CT-1099: Migrate test 071_commented_yaml_regression_3568_tests (#6106)
peterallenwebb Oct 20, 2022
6c86094
Add 'michelleark' to changie's core_team list (#6084)
MichelleArk Oct 20, 2022
17b8266
convert 027 cycle test (#6094)
MichelleArk Oct 21, 2022
c285601
[BUGFIX] Force `tox` to update `pip` (fixes `psycopg2-binary @ 2.9.5`…
iknox-fa Oct 25, 2022
1916784
Ct 1167/030 statement tests conversion (#6109)
VersusFacit Oct 26, 2022
7b73264
switch out to use internal action for triage labels (#6120)
emmyoop Oct 27, 2022
77dfec7
more ergonomic profile name handling (#6157)
iknox-fa Oct 27, 2022
fc00239
point to correct workflow (#6161)
emmyoop Oct 27, 2022
8145eed
revert to community action (#6163)
emmyoop Oct 27, 2022
be4a91a
Convert messages to struct logs (#6064)
emmyoop Oct 31, 2022
a427484
converting 023_exit_codes_tests (#6105)
MichelleArk Nov 1, 2022
d23285b
Add new index.html and changelog yaml files from dbt-docs (#6112)
FishtownBuildBot Nov 2, 2022
8e28f59
Bump python from 3.10.7-slim-bullseye to 3.11.0-slim-bullseye in /doc…
dependabot[bot] Nov 2, 2022
c3ccbe3
add python version and upgrade action (#6204)
emmyoop Nov 3, 2022
cfad27f
add typing to DepsTask.run (#6192)
MichelleArk Nov 3, 2022
d0543c9
Updates lib to use new profile name functionality (#6202)
racheldaniel Nov 4, 2022
68d06d8
Combine various print result log events with different levels (#6174)
gshank Nov 4, 2022
6c76137
CT 1443 remove root path (#6172)
gshank Nov 4, 2022
930bd35
properly track hook running (#6059)
ChenyuLInx Nov 7, 2022
4e78618
Convert threading tests to pytest (#6226)
stu-k Nov 8, 2022
d5e9ce1
Convert color tests to pytest (#6230)
stu-k Nov 8, 2022
f022435
Convert postgres index tests (#6228)
stu-k Nov 8, 2022
73116fb
feature/favor-state-node (#5859)
josephberni Nov 9, 2022
9f280a8
Update colorama requirement from <0.4.6,>=0.3.9 to >=0.3.9,<0.4.7 in …
dependabot[bot] Nov 13, 2022
39c5c42
converting 044_test_run_operations (#6122)
MichelleArk Nov 14, 2022
66ac107
[CT-1262] Convert dbt_debug (#6125)
McKnight-42 Nov 14, 2022
eae9867
s/gitlab/github for flake8 precommit repo (#6252)
MichelleArk Nov 15, 2022
9297e4d
Update pathspec requirement from ~=0.9.0 to >=0.9,<0.11 in /core (#5917)
dependabot[bot] Nov 16, 2022
a235abd
Add new index.html and changelog yaml files from dbt-docs (#6265)
FishtownBuildBot Nov 16, 2022
9877648
Revert "Bump python from 3.10.7-slim-bullseye to 3.11.0-slim-bullseye…
leahwicz Nov 17, 2022
517576c
add back in conditional node length check (#6298)
emmyoop Nov 22, 2022
7d70664
CT 1537 fix event test and rename a couple of fields (#6293)
gshank Nov 22, 2022
bce0e7c
BaseContext: expose md5 function in context (#6247)
haritamar Nov 28, 2022
55db15a
Convert test 067. (#6305)
VersusFacit Nov 29, 2022
020f639
Update stale.yml (#6258)
leahwicz Nov 29, 2022
b344041
Add GHA workflow to build CLI API docs (#6187)
stu-k Nov 29, 2022
47c2edb
Ct 1518/convert 063 relation names tests (#6304)
VersusFacit Nov 29, 2022
c3be975
Ct 288/convert 070 incremental test (#6330)
VersusFacit Nov 29, 2022
b5d303f
Bump mashumaro[msgpack] from 3.0.4 to 3.1 in /core (#6108)
dependabot[bot] Nov 30, 2022
2289e45
Exposures support metrics (#6342)
MichelleArk Dec 1, 2022
481235a
clarify error log for number of allowed models in a Python file (#6251)
justbldwn Dec 1, 2022
1fbcaa4
reformatting of test after some spike investigation (#6314)
McKnight-42 Dec 1, 2022
85d0b5a
Reverting back to older ubuntu image (#6363)
leahwicz Dec 2, 2022
67a8138
[fix] Fix the partial parse write path (#6081)
z3z1ma Dec 2, 2022
ebfcf2a
Update `core/dbt/README.md` to match current (#6371)
dbeatty10 Dec 2, 2022
16f529e
CT 1477 enrich logging events with data similar to legacy logger (#6325)
gshank Dec 3, 2022
540c3b7
Prevent docs gen workflow on forks (#6390)
stu-k Dec 6, 2022
60f8005
CT-1405: Refactor event logging code (#6291)
peterallenwebb Dec 6, 2022
b9a35da
Fix intermittent database connection failure in Windows CI test (#6395)
dbeatty10 Dec 7, 2022
0721f2c
Bump mashumaro[msgpack] from 3.1.1 to 3.2 in /core (#6375)
dependabot[bot] Dec 7, 2022
1b6fed2
CT 1604 remove compiled classes (#6384)
gshank Dec 7, 2022
9c91f3a
Adjust tox passenv to be multiline (#6405)
jtcohen6 Dec 7, 2022
99f27de
Feature/dbt deps tarball (#4689)
timle2 Dec 7, 2022
bef6edb
Fix dbt.config.get default values (python-model) (#6317)
devmessias Dec 7, 2022
0544b08
Add support for Python 3.11 (#6326)
iknox-fa Dec 8, 2022
0fbbc89
Remove PR from most changelog kinds (#6374)
emmyoop Dec 12, 2022
83b1fee
Add aranke to core committers (#6431)
aranke Dec 12, 2022
8478262
Update docker README (#6423)
jaypeedevlin Dec 13, 2022
fafd5ed
CT 1644 node cleanup (#6427)
gshank Dec 13, 2022
3d54a83
[CT-1284] Change Python model default materialization to table (#6432)
aranke Dec 13, 2022
c00052c
Add Optional back on "database" field of HasRelationMetadata (#6439)
gshank Dec 13, 2022
05dc021
Bumping version to 1.4.0b1 and generate changelog (#6440)
github-actions[bot] Dec 14, 2022
5e4e917
CT-1685: Restore certain aspects of legacy logging behavior important…
peterallenwebb Dec 14, 2022
7e90e06
Paw/ct 1652 restore default logging (#6447)
peterallenwebb Dec 14, 2022
e8da84f
Feature/support incremental predicates (#5702)
dave-connors-3 Dec 14, 2022
df93858
Updating 1.4.0b1 changelog (#6450)
leahwicz Dec 15, 2022
b9bdb77
Fix dependency changelog kind (#6452)
emmyoop Dec 19, 2022
304797b
exception cleanup (#6347)
emmyoop Dec 20, 2022
1e35339
Fix typo in util.py (#6037)
eltociear Dec 20, 2022
c39ea80
add back validator_error_message (#6465)
emmyoop Dec 20, 2022
ce9d0af
[CT-1591] Don't parse empty Python files (#6433)
aranke Dec 20, 2022
9ecb6e5
Treat dense text blobs as binary for `git grep` (#6462)
dbeatty10 Dec 21, 2022
76fd12c
adding pre-commit install to make dev (#6417)
justbldwn Jan 3, 2023
6ef3fbb
Partial parsing bug with empty schema file - ensure None is not passe…
gshank Jan 3, 2023
8217ad4
Fix issue link for 5859 changelog entry (#6496)
jtcohen6 Jan 4, 2023
748a932
Update agate requirement from <1.6.4,>=1.6 to >=1.6,<1.7.1 in /core (…
dependabot[bot] Jan 4, 2023
d453964
CT 1551 partial parsing logging events (#6474)
gshank Jan 4, 2023
5453840
DBT_FAVOR_STATE_STATE -> DBT_FAVOR_STATE (#6392)
NiallRees Jan 4, 2023
9d6f961
🎨 add missing fstrings, convert format to fstring (#6243)
justbldwn Jan 5, 2023
9ef2366
Updating metric attributes renamed event (#6518)
callum-mcdata Jan 5, 2023
d43c070
Making Metric Timestamps Optional (#6402)
callum-mcdata Jan 5, 2023
94d6d19
[CT-1693] Port severity test to Pytest (#6537)
aranke Jan 6, 2023
d9a4ee1
CT 1549 reorg logging events to have two top level keys (#6553)
gshank Jan 9, 2023
02c2047
add deprecation decorator (#6540)
emmyoop Jan 9, 2023
ab3f8dc
Ct 1517/convert 060 persist docs (#6409)
VersusFacit Jan 9, 2023
34fa703
fix log msg format (#6557)
emmyoop Jan 9, 2023
294def2
Fix event level regression (#6556)
peterallenwebb Jan 9, 2023
2b0f659
[CT-1694] Deprecate event tracking tests (#6538)
aranke Jan 9, 2023
89cc89d
Fix changelog entry for 5989/6432 (#6560)
jtcohen6 Jan 10, 2023
9eb82c6
Remove duplicated changelog entry for 5521 (#6563)
dbeatty10 Jan 10, 2023
4d6352d
CT-1645: Bump mashumaro version to receive regression fix, and add un…
peterallenwebb Jan 10, 2023
b9fdfd9
Adds the meta field to node_info in logs (#6493)
tmastny Jan 10, 2023
b13b0e9
Re-factor list of YAML keys for hooks to late-render (#6435)
dbeatty10 Jan 10, 2023
0dbdece
Ct 1716 cleanup logging events (#6561)
gshank Jan 10, 2023
457ff3e
fixed minor typos (#6499)
nshuman1 Jan 10, 2023
5da6360
Adds buildable selection mode (#6366)
AGPapa Jan 10, 2023
0fc080d
add defer_to_manifest in before_run to fix faulty deferred docs gener…
mivanicova Jan 10, 2023
eb200b4
Rename exceptions (#6539)
emmyoop Jan 10, 2023
dd4b47d
Check length of escaped strings in the adapter test (#6567)
dbeatty10 Jan 11, 2023
7a61602
Add --warn-error-options (#6520)
MichelleArk Jan 11, 2023
86e8722
Call `update_event_status` earlier + rename an event (#6572)
jtcohen6 Jan 12, 2023
1c7c23a
convert 043_custom_alias_tests (#6590)
MichelleArk Jan 12, 2023
d74ae19
Bumping version to 1.5.0a1 and generate changelog (#6593)
github-actions[bot] Jan 12, 2023
2bfc691
finish message rename in types.proto (#6594)
emmyoop Jan 12, 2023
f789b25
convert adapter table materialization test (#6595)
ChenyuLInx Jan 13, 2023
7077c47
converting 022_test_timezones (#6588)
MichelleArk Jan 13, 2023
585e7c5
migrate ref override (#6600)
ChenyuLInx Jan 13, 2023
c40b488
convert 037_external_references (#6589)
MichelleArk Jan 13, 2023
20c95a4
convert 057_run_query_tests (#6607)
MichelleArk Jan 13, 2023
065ab2e
Reformat `tests/` (#6622)
jtcohen6 Jan 16, 2023
e1b5e68
Convert 068_partial_parsing_tests (#6614)
gshank Jan 17, 2023
89d111a
CT 1440 Fix code to emit ConnectionReused event (#6605)
gshank Jan 17, 2023
43e24c5
update gh action set-output variables (#6635)
davidbloss Jan 18, 2023
0a03355
update test matrix (#6604)
emmyoop Jan 18, 2023
066346f
convert 038_caching_tests (#6612)
jtcohen6 Jan 18, 2023
fa7c4d1
Respect quoting config in dbt-py models (#6620)
jtcohen6 Jan 19, 2023
b05582d
mv `on_schema_change` tests -> "adapter zone" (#6618)
jtcohen6 Jan 19, 2023
07a004b
convert 062_defer_state_tests (#6616)
jtcohen6 Jan 19, 2023
f841a7c
add backwards compatibility and default argument for `incremental_pre…
dave-connors-3 Jan 19, 2023
6954c4d
CT-1786: Port docs tests to pytest (#6608)
peterallenwebb Jan 19, 2023
9801eeb
Consolidate changie entries from #6620 (#6684)
jtcohen6 Jan 20, 2023
3aeab73
convert 069_build_tests (#6678)
MichelleArk Jan 20, 2023
a181cee
Improve error message for packages missing `dbt_project.yml` (#6685)
dbeatty10 Jan 20, 2023
93619a9
Ct 738/dbt debug log fix (#6541)
VersusFacit Jan 21, 2023
5c765bf
Cheeky performance improvement on big DAGs (#6694)
boxysean Jan 23, 2023
7b464b8
CT-1718: Add Note and Formatting event types (#6691)
peterallenwebb Jan 23, 2023
17014bf
add adapter_response for test (#6645)
aezomz Jan 24, 2023
e2ccf01
CT 1886 include adapter_response in NodeFinished log message (#6709)
gshank Jan 24, 2023
cbb9117
test_init conversion (#6610)
MichelleArk Jan 24, 2023
db99e2f
Event Clean-Up (#6716)
peterallenwebb Jan 25, 2023
da47b90
[CT-1630] Convert Column_types tests (#6690)
McKnight-42 Jan 25, 2023
a34521e
CT 1894 log partial parsing var changes and sort cli vars before hash…
gshank Jan 25, 2023
b0651b1
change `exposure_content` to `source_content` (#6739)
Mathyoub Jan 26, 2023
c65ba11
Ct 1827/064 column comments tests conversion (#6654)
VersusFacit Jan 26, 2023
c2c4757
Graph Analysis Optimization for Large Dags (#6720)
peterallenwebb Jan 26, 2023
3f96fad
Ct 1629/052 column quoting tests conversion (#6652)
VersusFacit Jan 26, 2023
82d9b2f
[CI/CD] Update release workflow and introduce workflow for nightly re…
alexander-smolyakov Jan 27, 2023
c653330
Adding nssalian to committers list (#6769)
nssalian Jan 27, 2023
a8abc49
[CT-1940] Stand-alone Python module for PostgresColumn (#6773)
nssalian Jan 28, 2023
92d1ef8
Update release workflow (#6778)
alexander-smolyakov Jan 30, 2023
d2f3cdd
[CT-1841] Convert custom target test to Pytest (#6765)
aranke Jan 30, 2023
622e5fd
fix contributor list generation (#6799)
emmyoop Jan 31, 2023
42b7caa
Ct 1827/064 column comments tests conversion (#6766)
VersusFacit Jan 31, 2023
1a6e4a0
Add clearer directions for custom test suite vars in Makefile. (#6764)
VersusFacit Jan 31, 2023
d9424cc
CT 2000 fix semver prerelease comparisons (#6838)
gshank Feb 2, 2023
2245d8d
update regex to match all iterations (#6839)
emmyoop Feb 2, 2023
b2ea2b8
move test_store_test_failures.py to adapter zone (#6816)
colin-rogers-dbt Feb 2, 2023
4c63b63
[CT-1959]: moving simple_seed tests to adapter zone (#6859)
nssalian Feb 7, 2023
ccb4fa2
CT-1917: Fix a regression in the behavior of the -q/--quiet cli param…
peterallenwebb Feb 7, 2023
df64511
Dynamically list all `.latest` branches for scheduled testing (#6682)
emmyoop Feb 8, 2023
3ad4037
add base class for merge exclude tests (#6700)
dave-connors-3 Feb 8, 2023
abbece8
1.4 regression: Check if status has node attribute (#6899)
emmyoop Feb 8, 2023
723142c
Merge main into feature/click-cli
aranke Feb 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230123-132814.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: add merge_exclude_columns adapter tests
time: 2023-01-23T13:28:14.808748-06:00
custom:
Author: dave-connors-3
Issue: "6699"
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230207-143544.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix regression of --quiet cli parameter behavior
time: 2023-02-07T14:35:44.160163-05:00
custom:
Author: peterallenwebb
Issue: "6749"
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230208-110551.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Ensure results from hooks contain nodes when processing them
time: 2023-02-08T11:05:51.952494-06:00
custom:
Author: emmyoop
Issue: "6796"
30 changes: 29 additions & 1 deletion .github/workflows/release-branch-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,33 @@ on:
permissions: read-all

jobs:
fetch-latest-branches:
runs-on: ubuntu-latest

outputs:
latest-branches: ${{ steps.get-latest-branches.outputs.repo-branches }}

steps:
- name: "Fetch dbt-core Latest Branches"
uses: dbt-labs/actions/fetch-repo-branches@v1.1.1
id: get-latest-branches
with:
repo_name: ${{ github.event.repository.name }}
organization: "dbt-labs"
pat: ${{ secrets.GITHUB_TOKEN }}
fetch_protected_branches_only: true
regex: "^1.[0-9]+.latest$"
perform_match_method: "match"
retries: 3

- name: "[ANNOTATION] ${{ github.event.repository.name }} - branches to test"
run: |
title="${{ github.event.repository.name }} - branches to test"
message="The workflow will run tests for the following branches of the ${{ github.event.repository.name }} repo: ${{ steps.get-latest-branches.outputs.repo-branches }}"
echo "::notice $title::$message"
kick-off-ci:
needs: [fetch-latest-branches]
name: Kick-off CI
runs-on: ubuntu-latest

Expand All @@ -39,7 +65,9 @@ jobs:
max-parallel: 1
fail-fast: false
matrix:
branch: [1.0.latest, 1.1.latest, 1.2.latest, 1.3.latest, 1.4.latest, main]
branch: ${{ fromJSON(needs.fetch-latest-branches.outputs.latest-branches) }}
include:
- branch: 'main'

steps:
- name: Call CI workflow for ${{ matrix.branch }} branch
Expand Down
16 changes: 16 additions & 0 deletions core/dbt/events/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,13 @@ message LogSeedResultMsg {

// Skipped Q017

message LogSeedResultMsg {
EventInfo info = 1;
LogSeedResult data = 2;
}

// Skipped Q017

// Q018
message LogFreshnessResult {
string status = 1;
Expand Down Expand Up @@ -1719,6 +1726,15 @@ message NothingToDo {
}

message NothingToDoMsg {
NodeInfo node_info = 1;
string resource_type = 2;
string schema = 3;
string node_name = 4;
int32 index = 5;
int32 total = 6;
}

message SkippingDetailsMsg {
EventInfo info = 1;
NothingToDo data = 2;
}
Expand Down
2 changes: 2 additions & 0 deletions core/dbt/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def get_dbt_config(project_dir, args=None, single_threaded=False):

profile_name = getattr(args, "profile", None)

profile_name = getattr(args, "profile", None)

runtime_args = RuntimeArgs(
project_dir=project_dir,
profiles_dir=profiles_dir,
Expand Down
13 changes: 13 additions & 0 deletions core/dbt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,19 @@ def parse_args(args, cls=DBTArgumentParser):
""",
)

warn_error_flag.add_argument(
"--warn-error-options",
default=None,
help="""
If dbt would normally warn, instead raise an exception based on
include/exclude configuration. Examples include --select that selects
nothing, deprecations, configurations with no associated models,
invalid test configurations, and missing sources/refs in tests.
This argument should be a YAML string, with keys 'include' or 'exclude'.
eg. '{"include": "all", "exclude": ["NoNodesForSelectionCriteria"]}'
""",
)

p.add_argument(
"--no-version-check",
dest="version_check",
Expand Down
Empty file added core/dbt/task/parse.py
Empty file.
2 changes: 1 addition & 1 deletion core/dbt/task/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def after_run(self, adapter, results):
database_schema_set: Set[Tuple[Optional[str], str]] = {
(r.node.database, r.node.schema)
for r in results
if r.node.is_relational
if (hasattr(r, "node") and r.node.is_relational)
and r.status not in (NodeStatus.Error, NodeStatus.Fail, NodeStatus.Skipped)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import pytest
from dbt.tests.util import run_dbt, check_relations_equal
from collections import namedtuple


models__merge_exclude_columns_sql = """
{{ config(
materialized = 'incremental',
unique_key = 'id',
incremental_strategy='merge',
merge_exclude_columns=['msg']
) }}
{% if not is_incremental() %}
-- data for first invocation of model
select 1 as id, 'hello' as msg, 'blue' as color
union all
select 2 as id, 'goodbye' as msg, 'red' as color
{% else %}
-- data for subsequent incremental update
select 1 as id, 'hey' as msg, 'blue' as color
union all
select 2 as id, 'yo' as msg, 'green' as color
union all
select 3 as id, 'anyway' as msg, 'purple' as color
{% endif %}
"""

seeds__expected_merge_exclude_columns_csv = """id,msg,color
1,hello,blue
2,goodbye,green
3,anyway,purple
"""

ResultHolder = namedtuple(
"ResultHolder",
[
"seed_count",
"model_count",
"seed_rows",
"inc_test_model_count",
"relation",
],
)


class BaseMergeExcludeColumns:
@pytest.fixture(scope="class")
def models(self):
return {"merge_exclude_columns.sql": models__merge_exclude_columns_sql}

@pytest.fixture(scope="class")
def seeds(self):
return {"expected_merge_exclude_columns.csv": seeds__expected_merge_exclude_columns_csv}

def update_incremental_model(self, incremental_model):
"""update incremental model after the seed table has been updated"""
model_result_set = run_dbt(["run", "--select", incremental_model])
return len(model_result_set)

def get_test_fields(self, project, seed, incremental_model, update_sql_file):

seed_count = len(run_dbt(["seed", "--select", seed, "--full-refresh"]))

model_count = len(run_dbt(["run", "--select", incremental_model, "--full-refresh"]))

relation = incremental_model
# update seed in anticipation of incremental model update
row_count_query = "select * from {}.{}".format(project.test_schema, seed)

seed_rows = len(project.run_sql(row_count_query, fetch="all"))

# propagate seed state to incremental model according to unique keys
inc_test_model_count = self.update_incremental_model(incremental_model=incremental_model)

return ResultHolder(seed_count, model_count, seed_rows, inc_test_model_count, relation)

def check_scenario_correctness(self, expected_fields, test_case_fields, project):
"""Invoke assertions to verify correct build functionality"""
# 1. test seed(s) should build afresh
assert expected_fields.seed_count == test_case_fields.seed_count
# 2. test model(s) should build afresh
assert expected_fields.model_count == test_case_fields.model_count
# 3. seeds should have intended row counts post update
assert expected_fields.seed_rows == test_case_fields.seed_rows
# 4. incremental test model(s) should be updated
assert expected_fields.inc_test_model_count == test_case_fields.inc_test_model_count
# 5. result table should match intended result set (itself a relation)
check_relations_equal(
project.adapter, [expected_fields.relation, test_case_fields.relation]
)

def test__merge_exclude_columns(self, project):
"""seed should match model after two incremental runs"""

expected_fields = ResultHolder(
seed_count=1,
model_count=1,
inc_test_model_count=1,
seed_rows=3,
relation="expected_merge_exclude_columns",
)

test_case_fields = self.get_test_fields(
project,
seed="expected_merge_exclude_columns",
incremental_model="merge_exclude_columns",
update_sql_file=None,
)
self.check_scenario_correctness(expected_fields, test_case_fields, project)
28 changes: 28 additions & 0 deletions tests/functional/hooks/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
macros_missing_column = """
{% macro export_table_check() %}
{% set table = 'test_column' %}
{% set query %}
SELECT column_name
FROM {{ref(table)}}
LIMIT 1
{% endset %}
{%- if flags.WHICH in ('run', 'build') -%}
{% set results = run_query(query) %}
{% if execute %}
{%- if results.rows -%}
{{ exceptions.raise_compiler_error("ON_RUN_START_CHECK_NOT_PASSED: Data already exported. DBT Run aborted.") }}
{% else -%}
{{ log("No data found in " ~ table ~ " for current day and runtime region. Proceeding...", true) }}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{% endmacro %}
"""

models__missing_column = """
select 1 as col
"""

macros__before_and_after = """
{% macro custom_run_hook(state, target, run_started_at, invocation_id) %}
Expand Down
24 changes: 24 additions & 0 deletions tests/functional/hooks/test_run_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
macros__before_and_after,
models__hooks,
seeds__example_seed_csv,
macros_missing_column,
models__missing_column,
)

from dbt.tests.util import (
Expand Down Expand Up @@ -141,3 +143,25 @@ def test_pre_and_post_seed_hooks(self, setUp, project, dbt_profile_target):
check_table_does_not_exist(project.adapter, "start_hook_order_test")
check_table_does_not_exist(project.adapter, "end_hook_order_test")
self.assert_used_schemas(project)


class TestAfterRunHooks(object):
@pytest.fixture(scope="class")
def macros(self):
return {"temp_macro.sql": macros_missing_column}

@pytest.fixture(scope="class")
def models(self):
return {"test_column.sql": models__missing_column}

@pytest.fixture(scope="class")
def project_config_update(self):
return {
# The create and drop table statements here validate that these hooks run
# in the same order that they are defined. Drop before create is an error.
# Also check that the table does not exist below.
"on-run-start": "- {{ export_table_check() }}"
}

def test_missing_column_pre_hook(self, project):
run_dbt(["run"], expect_pass=False)