Skip to content

Commit

Permalink
S3x version2 merge to master branch (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin-Thakur authored Nov 17, 2023
1 parent f84cb92 commit 46f597a
Show file tree
Hide file tree
Showing 11 changed files with 554 additions and 54 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/vertica-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: [ '3.8','3.9' ,'3.10', '3.11']
services:
vertica:
image: vertica/vertica-ce:latest
Expand Down Expand Up @@ -45,13 +45,11 @@ jobs:
- name: Test Basic
run: python -m pytest tests/functional/adapter/test_basic.py
- name: Test Constraints
run: python -m pytest tests/functional/adapter/test_constraints.py
run: python -m pytest tests/functional/adapter/constraints/test_constraints.py
- name: Test Incremental
run: python -m pytest tests/functional/adapter/incremental/
- name: Test Concurrency
run: python -m pytest tests/functional/adapter/concurrency/
- name: Test ephemeral
run: python -m pytest tests/functional/adapter/ephemeral/
- name: Test Doc Generate
run: python -m pytest tests/functional/adapter/test_doc_gen.py
- name: Test Data Type Boolean
Expand All @@ -61,5 +59,6 @@ jobs:
- name: Test Data Type Int
run: python -m pytest tests/functional/adapter/utils/data_type/




24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
## Changelog
- This file provides a full account of all changes to dbt-vertica.
- "Breaking changes" listed under a version may require action from end users.

### 1.6.0

#### Features:
- Added support for [`dbt-core version 1.6.0`](https://github.com/dbt-labs/dbt-core/discussions/7958) according to DBT guidelines.
- new `clone` command
- Droped support for Python 3.7

#### Fixes:
- ensure support for revamped `dbt debug`
- new limit arg for `adapter.execute()`
- Added new functional tests and parameterize them by overriding fixtures:
- TestIncrementalConstraintsRollback
- TestTableContractSqlHeader
- TestIncrementalContractSqlHeader
- TestModelConstraintsRuntimeEnforcement
- TestConstraintQuotedColumn
- TestEquals
- TestMixedNullCompare
- TestNullCompare
- TestVerticaCloneNotPossible
- TestValidateSqlMethod


### 1.5.0
#### Features:
- Added support for [`dbt-core version 1.5.0`](https://github.com/dbt-labs/dbt-core/discussions/7213) according to DBT guidelines.
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.5.0"
version = "1.6.0"
13 changes: 8 additions & 5 deletions dbt/adapters/vertica/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,17 @@ def cancel(self, connection):
connection.handle.cancel()

@classmethod
def get_result_from_cursor(cls, cursor: Any) -> agate.Table:
def get_result_from_cursor(cls, cursor: Any, limit: Optional[int]) -> agate.Table:
data: List[Any] = []
column_names: List[str] = []

if cursor.description is not None:
column_names = [col[0] for col in cursor.description]
rows = cursor.fetchall()

if limit:
rows = cursor.fetchmany(limit)
else:
rows = cursor.fetchall()
# rows = cursor.fetchall()
# check result for every query if there are some queries with ; separator
while cursor.nextset():
check = cursor._message
Expand All @@ -206,13 +209,13 @@ def get_result_from_cursor(cls, cursor: Any) -> agate.Table:
return dbt.clients.agate_helper.table_from_data_flat(data, column_names)

def execute(
self, sql: str, auto_begin: bool = False, fetch: bool = False
self, sql: str, auto_begin: bool = False, fetch: bool = False, limit: Optional[int] = None
) -> Tuple[AdapterResponse, agate.Table]:
sql = self._add_query_comment(sql)
_, cursor = self.add_query(sql, auto_begin)
response = self.get_response(cursor)
if fetch:
table = self.get_result_from_cursor(cursor)
table = self.get_result_from_cursor(cursor,limit)
else:
table = dbt.clients.agate_helper.empty_table()
while cursor.nextset():
Expand Down
2 changes: 2 additions & 0 deletions dbt/adapters/vertica/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,5 @@ def get_incremental_strategy_macro(self, model_context, strategy: str):

# This returns a callable macro
return model_context[macro_name]
def debug_query(self) -> None:
self.execute("select 1 as id")
16 changes: 16 additions & 0 deletions dbt/include/vertica/macros/materializations/clone.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

{% macro vertica__can_clone_table() %}
{{ return(True) }}
{% endmacro %}


{% macro vertica__create_or_replace_clone(this_relation, defer_relation) %}


DROP TABLE IF EXISTS {{this_relation}};
create table
{{ this_relation }} as select * from
{{ defer_relation }}


{% endmacro %}
2 changes: 1 addition & 1 deletion example/demo_dbt_vmart/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: '1.0.0'
config-version: 2

# This setting configures which "profile" dbt uses for this project.
profile: 'vmart_project'
profile: vmart_project

# These configurations specify where dbt should look for different types of files.
# The `model-paths` config, for example, states that models in this project can be
Expand Down
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import sys
import re

# require python 3.7 or newer
if sys.version_info < (3, 7):
# require python 3.8 or newer
if sys.version_info < (3, 8):
print("Error: dbt does not support this version of Python.")
print("Please upgrade to Python 3.7 or higher.")
print("Please upgrade to Python 3.8 or higher.")
sys.exit(1)


Expand Down Expand Up @@ -78,7 +78,7 @@ def _get_dbt_core_version():


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

Expand Down Expand Up @@ -110,10 +110,10 @@ def _get_dbt_core_version():
]
},
install_requires=[
'dbt-core==1.5.0',
'dbt-core==1.6.0',
# "dbt-core~={}".format(dbt_core_version),
'vertica-python>=1.1.0',
'dbt-tests-adapter==1.5.0',
'dbt-tests-adapter==1.6.0',
'python-dotenv==0.21.1',
],
classifiers=[
Expand All @@ -127,5 +127,5 @@ def _get_dbt_core_version():
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: OS Independent"
],
python_requires=">=3.7.2",
python_requires=">=3.8.0",
)
Loading

0 comments on commit 46f597a

Please sign in to comment.