@@ -30,11 +30,15 @@ def __init__(
3030 jinja_macros : JinjaMacroRegistry ,
3131 jinja_globals : t .Optional [t .Dict [str , t .Any ]] = None ,
3232 project_dialect : t .Optional [str ] = None ,
33+ quote_policy : t .Optional [Policy ] = None ,
3334 ):
35+ from dbt .adapters .base .relation import Policy
36+
3437 self .jinja_macros = jinja_macros
3538 self .jinja_globals = jinja_globals .copy () if jinja_globals else {}
3639 self .jinja_globals ["adapter" ] = self
3740 self .project_dialect = project_dialect
41+ self .quote_policy = quote_policy or Policy ()
3842
3943 @abc .abstractmethod
4044 def get_relation (self , database : str , schema : str , identifier : str ) -> t .Optional [BaseRelation ]:
@@ -95,6 +99,10 @@ def quote(self, identifier: str) -> str:
9599 """Returns a quoted identifier."""
96100 return exp .to_column (identifier ).sql (dialect = self .project_dialect , identify = True )
97101
102+ def quote_as_configured (self , value : str , component_type : str ) -> str :
103+ """Returns the value quoted according to the quote policy."""
104+ return self .quote (value ) if getattr (self .quote_policy , component_type , False ) else value
105+
98106 def dispatch (self , name : str , package : t .Optional [str ] = None ) -> t .Callable :
99107 """Returns a dialect-specific version of a macro with the given name."""
100108 target_type = self .jinja_globals ["target" ]["type" ]
@@ -216,20 +224,19 @@ def __init__(
216224 ):
217225 from dbt .adapters .base import BaseRelation
218226 from dbt .adapters .base .column import Column
219- from dbt .adapters .base .relation import Policy
220227
221228 super ().__init__ (
222229 jinja_macros ,
223230 jinja_globals = jinja_globals ,
224231 project_dialect = project_dialect or engine_adapter .dialect ,
232+ quote_policy = quote_policy ,
225233 )
226234
227235 table_mapping = table_mapping or {}
228236
229237 self .engine_adapter = engine_adapter
230238 self .relation_type = relation_type or BaseRelation
231239 self .column_type = column_type or Column
232- self .quote_policy = quote_policy or Policy ()
233240 self .table_mapping = {
234241 ** to_table_mapping ((snapshots or {}).values (), deployability_index ),
235242 ** table_mapping ,
0 commit comments