Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Column.data_type does not take into account the data_length #29

Closed
1 task done
sandhein opened this issue Jul 7, 2022 · 2 comments
Closed
1 task done
Assignees
Labels
bug Something isn't working

Comments

@sandhein
Copy link

sandhein commented Jul 7, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When using column.data_type for columns of type varchar or numeric, the adapters just gives back the column_type, without the size / data_lengths. You can see this behaviour for example when using dbt_utils.union:

grafik

Thsi results in ORA-00906: missing left paranthesis

Expected Behavior

Return the data_lengths/size in parathesis:
grafik

This can be done by overiting the following methods:
`
@DataClass
class OracleColumn(Column):

def is_string(self):
    # in Oracle, 'varchar2' is also a string:
    if self.dtype.lower() in ['varchar2', 'char', 'varchar']:
        return True
    return super().is_string()

@classmethod
def string_type(cls, size: int) -> str:
    return "varchar2({})".format(size)

def is_numeric(self) -> bool:
    # in Oracle, 'number' is also a numeric:
    if self.dtype.lower() in ['number', 'float']:
        return True
    return super().is_numeric()

`

Steps To Reproduce

No response

Relevant log output using --debug flag enabled

No response

Environment

- OS: Windows
- Python: Python 3.8.10
- dbt: 1.1.1

What Oracle database version are you using dbt with?

19c

Additional Context

No response

@sandhein sandhein added the bug Something isn't working label Jul 7, 2022
@aosingh aosingh self-assigned this Jul 7, 2022
aosingh added a commit that referenced this issue Jul 8, 2022
1. Fixes Bug #29
2. Introduced new class OracleColumn which can be used to define logic specific to Oracle table column
3. Added an example model in dbt_adbs_test_project to reproduce the error and validate the fix
4. Added a project specific macro in dbt_adbs_test_project to translate the string datatype
@aosingh
Copy link
Member

aosingh commented Jul 10, 2022

Hi @sandhein

This is fixed now and we plan to release the fix in the upcoming dbt-oracle version 1.1.1. Meanwhile, you can test the fix using the release candidate. It can be installed using pip

pip install dbt-oracle==1.1.1rc1

Let me know if you have any questions

@aosingh
Copy link
Member

aosingh commented Jul 15, 2022

This is now fixed in dbt-oracle==1.1.1 Please test it and let me know if you face this issue.

@aosingh aosingh closed this as completed Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants