|
1 | 1 | """
|
2 |
| -Copyright (c) 2022, Oracle and/or its affiliates. |
| 2 | +Copyright (c) 2024, Oracle and/or its affiliates. |
3 | 3 | Copyright (c) 2020, Vitor Avancini
|
4 | 4 |
|
5 | 5 | Licensed under the Apache License, Version 2.0 (the "License");
|
|
19 | 19 | from dataclasses import dataclass, field
|
20 | 20 |
|
21 | 21 | from dbt.adapters.base.relation import BaseRelation
|
| 22 | +from dbt.adapters.contracts.relation import ComponentName |
22 | 23 | from dbt.adapters.events.logging import AdapterLogger
|
23 | 24 | from dbt.adapters.relation_configs import (
|
24 | 25 | RelationConfigBase,
|
@@ -148,3 +149,19 @@ def materialized_view_config_changeset(
|
148 | 149 | return config_change_collection
|
149 | 150 |
|
150 | 151 | return None
|
| 152 | + |
| 153 | + def _is_exactish_match(self, field: ComponentName, value: str) -> bool: |
| 154 | + """ |
| 155 | +
|
| 156 | + The only purpose of _is_exactish_match is to detect matches that are |
| 157 | + approximate (case-insensitive and quote-stripped) but not exact, |
| 158 | + so that dbt can raise an exception saying a too-similar relation |
| 159 | + already exists in the cache |
| 160 | +
|
| 161 | + """ |
| 162 | + if self.dbt_created and self.quote_policy.get_part(field) is False: |
| 163 | + return self.path.get_lowered_part(field) == value.lower() |
| 164 | + elif self.quote_policy.get_part(field) is False: |
| 165 | + return self.path.get_lowered_part(field) == value.lower() |
| 166 | + else: |
| 167 | + return self.path.get_part(field) == value |
0 commit comments