Git Product home page Git Product logo

Comments (5)

ggam avatar ggam commented on September 18, 2024 1

Thanks to your comments I came to a safer workaround. Just ignore that especific exception:

{% macro oracle__drop_relation(relation) -%}
    {% call statement('drop_relation', auto_begin=False) -%}
    DECLARE
        dne_942    EXCEPTION;
        PRAGMA EXCEPTION_INIT(dne_942, -942);
        attempted_ddl_on_in_use_GTT EXCEPTION;
        pragma EXCEPTION_INIT(attempted_ddl_on_in_use_GTT, -14452);
        identifier_too_long  EXCEPTION;
        PRAGMA EXCEPTION_INIT(identifier_too_long, -972);
    BEGIN
        SAVEPOINT start_transaction;
        EXECUTE IMMEDIATE 'DROP {{ relation.type }} {{ relation }} cascade constraint';
        COMMIT;
    EXCEPTION
        WHEN attempted_ddl_on_in_use_GTT THEN
            NULL; -- if it its a global temporary table, leave it alone.
        WHEN dne_942 THEN
            NULL;
        WHEN identifier_too_long THEN
            NULL; -- object cannot actually exist anyway
    END;
    {%- endcall %}
{% endmacro %}

from dbt-oracle.

aosingh avatar aosingh commented on September 18, 2024

@ggam

For any ORA-00972: identifier is too long issue, if the database version is older than 12c there are 2 options:

{{ config(alias='sessions') }}
  • Have a macro override at dbt project level like we did in a similar issue

From Oracle 12c, identifiers can be 128 bytes long

I checked your macro override and I would be careful adding this check to a generic macro

{% if relation.type != "view" %}

The reason why we have <relation>__dbt_backup, is to handle the case if the dbt model was a previously a table. dbt renames the old relation to <relation>__dbt_backup and for that it drops any existing <relation>__dbt_backup to avoid ORA-00955: name is already used by an existing object

from dbt-oracle.

ggam avatar ggam commented on September 18, 2024

Hi @aosingh thanks for the quick response. I'm using alias for the longest names, but a "__dbt_backup" suffix is 12 characters long. That means I only have 18 characters to use in my user facing view names.

Since this is internal dbt and temporary stuff, I think it'd be correct to truncate the names from the left to 30 characters for old db versions. The rollback mechanism should prevent those objects to be persisted in case of error.

Regarding my hack:

{% if relation.type != "view" %}

Thanks for the word of caution. I'm aware it's a little clunky, but it should work until I have some time to dig deeper into the code.

from dbt-oracle.

aosingh avatar aosingh commented on September 18, 2024

@ggam

I discussed this internally, and as documented, the minimum supported Oracle Database version by dbt-oracle is 12c.

Starting with Oracle 12c, identifiers can be 128 bytes long and this should not be problem.

With Oracle 11g, let me know in case you encounter any ORA-00972: identifier is too long issues. I can help suggest a workaround probably by overriding the macro at project level.

from dbt-oracle.

ggam avatar ggam commented on September 18, 2024

from dbt-oracle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.