-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathcast_binary.sql
More file actions
52 lines (34 loc) · 1.49 KB
/
cast_binary.sql
File metadata and controls
52 lines (34 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Copyright (c) Business Thinking Ltd. 2019-2026
* This software includes code developed by the AutomateDV (f.k.a dbtvault) Team at Business Thinking Ltd. Trading as Datavault
*/
{%- macro cast_binary(column_str, alias=none, quote=true) -%}
{{ return(adapter.dispatch('cast_binary', 'automate_dv')(column_str=column_str, alias=alias, quote=quote)) }}
{%- endmacro -%}
{%- macro default__cast_binary(column_str, alias=none, quote=true) -%}
{%- if quote -%}
CAST('{{ column_str }}' AS {{ automate_dv.type_binary() }})
{%- else -%}
CAST({{ column_str }} AS {{ automate_dv.type_binary() }})
{%- endif -%}
{%- if alias %} AS {{ alias }} {%- endif -%}
{%- endmacro -%}
{%- macro sqlserver__cast_binary(column_str, alias=none, quote=true) -%}
{%- if quote -%}
CONVERT({{ automate_dv.type_binary() }}, '{{ column_str }}', 2)
{%- else -%}
CONVERT({{ automate_dv.type_binary() }}, {{ column_str }}, 2)
{%- endif -%}
{% if alias %} AS {{ alias }} {%- endif %}
{%- endmacro -%}
{%- macro bigquery__cast_binary(column_str, alias=none, quote=true) -%}
{{ automate_dv.default__cast_binary(column_str=column_str, alias=alias, quote=quote) }}
{%- endmacro -%}
{%- macro redshift__cast_binary(column_str, alias=none, quote=true) -%}
{%- if quote -%}
'{{ column_str }}'
{%- else -%}
CAST({{ column_str }} AS {{ automate_dv.type_binary() }})
{%- endif -%}
{%- if alias %} AS {{ alias }} {%- endif -%}
{%- endmacro -%}