Skip to content

Commit

Permalink
Add support for nopi table type (#37)
Browse files Browse the repository at this point in the history
* added support for nopi table type
  • Loading branch information
adamtwo authored Apr 29, 2022
1 parent a88cd89 commit 71ef3b7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ jobs:
./run.sh
cd $GITHUB_WORKSPACE/test/catalog/without_qvci
./run.sh
- name: Run nopi tests
run: |
sshpass -p root ssh -o StrictHostKeyChecking=no -p 4422 root@localhost "dbscontrol << EOF
M general 53=N
W
EOF
tpareset -y Disable PrimaryIndexDefault
"
$GITHUB_WORKSPACE/.github/workflows/scripts/verifyVantageIsRunning.sh
pytest test/nopi
- uses: actions/upload-artifact@v2
if: ${{ failure() || cancelled() }}
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Features

### Fixes
* The adapter now supports No Primary Index (NoPi) table types in metadata queries.

### Docs

Expand Down
10 changes: 6 additions & 4 deletions dbt/include/teradata/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ CURRENT_TIMESTAMP(6)
ColumnsV.DatabaseName AS table_schema,
ColumnsV.TableName AS table_name,
CASE WHEN TablesV.TableKind = 'T' THEN 'table'
WHEN TablesV.TableKind = 'O' THEN 'table'
WHEN TablesV.TableKind = 'V' THEN 'view'
ELSE TablesV.TableKind
END AS table_type,
Expand All @@ -160,7 +161,7 @@ CURRENT_TIMESTAMP(6)
ON ColumnsV.DatabaseName = TablesV.DatabaseName
AND ColumnsV.TableName = TablesV.TableName
WHERE
TablesV.TableKind IN ('T', 'V')
TablesV.TableKind IN ('T', 'V', 'O')
AND ColumnsV.DatabaseName = '{{ relation.schema }}' (NOT CASESPECIFIC)
AND ColumnsV.TableName = '{{ relation.identifier }}' (NOT CASESPECIFIC)
ORDER BY
Expand All @@ -179,12 +180,13 @@ CURRENT_TIMESTAMP(6)
TableName AS name,
DatabaseName AS "schema",
CASE WHEN TableKind = 'T' THEN 'table'
WHEN TableKind = 'V' THEN 'view'
ELSE TableKind
WHEN TableKind = 'O' THEN 'table'
WHEN TableKind = 'V' THEN 'view'
ELSE TableKind
END AS table_type
FROM {{ information_schema_name(schema_relation.schema) }}.TablesV
WHERE DatabaseName = '{{ schema_relation.schema }}' (NOT CASESPECIFIC)
AND TableKind IN ('T', 'V')
AND TableKind IN ('T', 'V', 'O')

{% endcall %}
{{ return(load_result('list_relations_without_caching').table) }}
Expand Down
7 changes: 4 additions & 3 deletions dbt/include/teradata/macros/catalog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
DatabaseName AS "table_schema",
TableName AS "table_name",
CASE WHEN TableKind = 'T' THEN 'table'
WHEN TableKind = 'V' THEN 'view'
ELSE TableKind
WHEN TableKind = 'O' THEN 'view'
WHEN TableKind = 'V' THEN 'view'
ELSE TableKind
END AS "table_type",
NULL AS "table_owner"

FROM {{ information_schema_name(schema) }}.tablesV

WHERE TableKind IN ('T', 'V')
WHERE TableKind IN ('T', 'V', 'O')

),

Expand Down
11 changes: 11 additions & 0 deletions test/nopi/nopi.dbtspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
target:
type: teradata
server: "{{ env_var('DBT_TERADATA_SERVER_NAME', 'localhost') }}"
username: "{{ env_var('DBT_TERADATA_USERNAME', 'dbc') }}"
password: "{{ env_var('DBT_TERADATA_PASSWORD', 'dbc') }}"
schema: "dbt_test_nopi_{{ var('_dbt_random_suffix') }}"
tmode: ANSI
log: "0"

sequences:
test_dbt_incremental: incremental

0 comments on commit 71ef3b7

Please sign in to comment.