Skip to content

Commit

Permalink
Merge code to main branch for all fixes (#132)
Browse files Browse the repository at this point in the history
Co-authored-by: nrodriguezmicrofocus <[email protected]>
Co-authored-by: nrodriguezmicrofocus <[email protected]>
  • Loading branch information
3 people authored Jun 12, 2024
1 parent f0eca51 commit 6c766dd
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 27 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@



### 1.7.13

#### Fixes:
- Enable connection autocommit parameter(https://github.com/vertica/dbt-vertica/issues/128)
- Fixed- SQLParse with a high vulnerability(https://github.com/vertica/dbt-vertica/security/dependabot/1)
- Update collect_freshness(https://github.com/vertica/dbt-vertica/issues/129)
- Incremental strategy, On schema change- Add or remove columns from table(https://github.com/vertica/dbt-vertica/issues/122)

### 1.7.3

#### Features:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ your-profile:
backup_server_node: [list of backup hostnames or IPs]
retries: [1 or more]
threads: [1 or more]
autocommit: False
target: dev
```
Expand All @@ -81,6 +82,7 @@ your-profile:
| backup_server_node | List of hosts to connect to if the primary host specified in the connection (host, port) is unreachable. Each item in the list should be either a host string (using default port 5433) or a (host, port) tuple. A host can be a host name or an IP address. | No | none | ['123.123.123.123','www.abc.com',('123.123.123.124',5433)]
| retries | The retry times after an unsuccessful connection. | No | 2 | 3 |
| threads | The number of threads the dbt project will run on. | No | 1 | 3 |
| autocommit | Connection autocommit(True/False) | Yes | False | True |
| label | A session label to identify the connection. | No | An auto-generated label with format of: dbt_username | dbt_dbadmin |

For more information on Vertica’s connection properties please refer to [Vertica-Python](https://github.com/vertica/vertica-python#create-a-connection) Connection Properties.
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/vertica/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@



version = "1.7.3"
version = "1.7.13"
4 changes: 3 additions & 1 deletion dbt/adapters/vertica/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class verticaCredentials(Credentials):
port: int = 5433
timeout: int = 3600
oauth_access_token: str = ""
autocommit: Optional[bool]= False
withMaterialization: bool = False
ssl_env_cafile: Optional[str] = None
ssl_uri: Optional[str] = None
Expand Down Expand Up @@ -68,7 +69,7 @@ def unique_field(self):

def _connection_keys(self):
# return an iterator of keys to pretty-print in 'dbt debug'
return ('host','port','database','username','schema', 'connection_load_balance')
return ('host','port','database','username','schema', 'connection_load_balance', 'autocommit')

class verticaConnectionManager(SQLConnectionManager):
TYPE = 'vertica'
Expand All @@ -93,6 +94,7 @@ def open(cls, connection):
'session_label': f'dbt_{credentials.username}',
'retries': credentials.retries,
'oauth_access_token': credentials.oauth_access_token,
'autocommit': credentials.autocommit,
'backup_server_node':credentials.backup_server_node,

}
Expand Down
31 changes: 10 additions & 21 deletions dbt/include/vertica/macros/adapters/columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -175,29 +175,18 @@
{% if remove_columns is none %}
{% set remove_columns = [] %}
{% endif %}
{% for column in add_columns %}
{% set sql -%}
alter table {{ relation }}
add column {{ adapter.quote(column.name) }} {{ column.data_type }}
{%- endset -%}
{% do run_query(sql) %}
{% endfor %}
{% for column in remove_columns %}
{% set sql -%}
alter table {{ relation }}
drop column {{ adapter.quote(column.name) }} ;
{%- endset -%}

{% endfor %}
{% do log(sql) %}
{% do run_query(sql) %}


-- {% do run_query(sql) %}
{% set sql -%}
{% for column in add_columns %}
ALTER TABLE {{ relation }} ADD COLUMN IF NOT EXISTS {{ adapter.quote(column.name) }} {{ column.data_type }} ;
{% endfor %}
{% for column in remove_columns %}
ALTER TABLE {{ relation }} DROP COLUMN IF EXISTS {{ adapter.quote(column.name) }} ;
{% endfor %}
{%- endset -%}
{% do log(sql) %}
{% do run_query(sql) %}
{% endmacro %}



{#
No need to implement get_columns_in_query(). Syntax supported by default.
#}
2 changes: 1 addition & 1 deletion dbt/include/vertica/macros/adapters/freshness.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
where {{ filter }}
{% endif %}
{% endcall %}
{{ return(load_result('collect_freshness').table) }}
{{ return(load_result('collect_freshness')) }}
{%- endmacro %}
4 changes: 4 additions & 0 deletions dbt/include/vertica/profile_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ prompts:
hint: 'takes True or False'
type: 'bool'
default: True
autocommit:
hint: 'takes True or False'
type: 'bool'
default: False
retries:
hint: 'number of retries'
type: 'int'
Expand Down
2 changes: 2 additions & 0 deletions dbt/include/vertica/sample_profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ default:
schema: [dev_schema]
threads: [1 or more]
connection_load_balance: [True or False]
autocommit: [True or False]
retries: [2 or more]

prod:
Expand All @@ -24,5 +25,6 @@ default:
schema: [prod_schema]
threads: [1 or more]
connection_load_balance: [True or False]
autocommit: [True or False]
retries: [2 or more]
target: dev
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _get_dbt_core_version():


package_name = "dbt-vertica"
package_version = "1.7.3"
package_version = "1.7.13"
description = """Official vertica adapter plugin for dbt (data build tool)"""
dbt_core_version = _get_dbt_core_version()

Expand Down Expand Up @@ -111,10 +111,10 @@ def _get_dbt_core_version():
]
},
install_requires=[
'dbt-core==1.7.3',
'dbt-core==1.7.13',
# "dbt-core~={}".format(dbt_core_version),
'vertica-python>=1.1.0',
'dbt-tests-adapter==1.7.3',
'dbt-tests-adapter==1.7.13',
'python-dotenv==0.21.1',
],
classifiers=[
Expand Down

0 comments on commit 6c766dd

Please sign in to comment.