Comments (5)
Hi @ahmedhamidibr !
Thanks for posting this issue and sorry for the late response.
Is this issue still relevant to you?
If so - one question - any chance your project overrides the source
macro?
from elementary.
Hi @haritamar,
Yes, indeed, my project overrides the source macro. It turns out that was the cause. After resetting back to the default source macro, it worked as expected. However, I remain interested in any workaround you might suggest to ensure the tests continue to work even when the source macro is overridden.
from elementary.
Hi @ahmedhamidibr ,
So the main issue is that for the schema_changes_from_baseline
test to work, Elementary needs to ontain a dbt Relation object which allows us to get the current columns of the table.
When you override the source
macro (or ref
for that matter), you have the ability to return a query string instead of a relation object - which works for many dbt use-cases but is problematic for Elementary's tests due to the reason above.
So there are two workarounds that can be done until we support this use case, depending on what exactly your overriding source
macro does:
- If it's possible to change your macro to return a dbt Relation object instead of a string (here's a dbt example for the ref macro, but a similar thing can be done for sources) then it should help solve the issue. This may be doable if your macro returns a database table (and not a select query).
- If on the other hand you actually return a query (e.g. if you're doing some filtering), then a possible (hacky) workaround would be to make the macro only return a Relation object when it's run from the context of the
schema_changes_from_baseline
test, e.g.:
{% set model_node = context.get("model") %}
{% if model_node and model_node.get("resource_type") == "test" and model_node["test_metadata"]["name"] == "schema_changes_from_baseline" %}
{% do return(builtins.source(source_name, table_name)) %}
{% endif %}
... do more complex logic that returns a query ...
from elementary.
@haritamar Thank you so much, this did the trick!
from elementary.
Glad to hear @ahmedhamidibr !
from elementary.
Related Issues (20)
- Understanding how elementary resolves dbt models with CI jobs
- Vulnerability (CVE-2022-42969) introduced by using 'retry' package HOT 2
- Lineage: Put exposures in a folder like models & sources HOT 2
- [BUG] Filtering in "Model duration" doesn't work HOT 1
- Issue on docs HOT 1
- Generated result query in report contains an invalid table HOT 2
- Exclude detection period from training period? HOT 3
- Macro 'dbt_macro__check_schema_exists' takes no keyword argument 'information_schema' Snowflake HOT 3
- Extend test description with anomaly_score and training_stddev HOT 4
- [FEATURE] - Add possibility to alert top n heaviest models from "Model Duration" HOT 1
- Cannot generate observability report HOT 6
- Add project name and environment to slack notification HOT 1
- elementary column anomalies tests fail on redshift with error 'Relation name is longer than 127 characters' HOT 1
- [BUG] Teams alerts spam 5x of the same failure with suppression set. HOT 5
- 0.15 / BigQuery EDR monitor fails HOT 3
- Temporary tables for volume and freshness tests are not properly cleaned on Athena HOT 5
- detection_period propery works wrong HOT 4
- Clicking on dbt tests link from dashboard redirects to tests page but with source freshness NOT excluded HOT 2
- --disable-samples should only hide the results of generic and singular tests, not graphs of freshness or volume tests
- Elementary model information_schema_columns fails with error: Unity Catalog is not enabled
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elementary.