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

[Feature] Add oracle to profile mapping #1189

Open
1 task done
slords opened this issue Sep 4, 2024 · 2 comments · May be fixed by #1190
Open
1 task done

[Feature] Add oracle to profile mapping #1189

slords opened this issue Sep 4, 2024 · 2 comments · May be fixed by #1190
Labels
area:profile Related to ProfileConfig, like Athena, BigQuery, Clickhouse, Spark, Trino, etc enhancement New feature or request triage-needed Items need to be reviewed / assigned to milestone

Comments

@slords
Copy link

slords commented Sep 4, 2024

Description

Oracle is a supported type in both airflow and cosmos. It would be nice to have the profile mapping implemented.

Use case/motivation

Map oracle from airflow to cosmos

Related issues

No response

Are you willing to submit a PR?

  • Yes, I am willing to submit a PR!
@slords slords added enhancement New feature or request triage-needed Items need to be reviewed / assigned to milestone labels Sep 4, 2024
@slords slords linked a pull request Sep 4, 2024 that will close this issue
2 tasks
Copy link

dosubot bot commented Sep 4, 2024

To add Oracle to the profile mapping in Cosmos, you can follow the structure of the existing profile mappings. Here are the steps you can take:

  1. Create the Oracle Profile Mapping Class:

    • Create a new directory for Oracle under cosmos/profiles/oracle/.
    • Implement the Oracle profile mapping class in a new file, e.g., cosmos/profiles/oracle/user_pass.py.

    Example implementation:

    from cosmos.profiles.base import BaseProfileMapping
    
    class OracleUserPasswordProfileMapping(BaseProfileMapping):
        @property
        def profile(self) -> dict:
            return {
                'type': 'oracle',
                'user': self.connection.login,
                'password': self.connection.password,
                'host': self.connection.host,
                'port': self.connection.port,
                'dbname': self.connection.schema,
            }
  2. Update the __init__.py File:

    • In cosmos/profiles/oracle/__init__.py, import the new profile mapping class.
    from .user_pass import OracleUserPasswordProfileMapping
    
    __all__ = ["OracleUserPasswordProfileMapping"]
  3. Register the Oracle Profile Mapping:

    • Add the Oracle profile mapping to the profile_mappings list in cosmos/profiles/__init__.py.
    from .oracle.user_pass import OracleUserPasswordProfileMapping
    
    profile_mappings: list[Type[BaseProfileMapping]] = [
        # ... other mappings ...
        OracleUserPasswordProfileMapping,
    ]
  4. Write Unit Tests:

    • Create unit tests for the Oracle profile mapping in a new file, e.g., tests/profiles/oracle/test_oracle_user_password.py.

    Example test:

    import unittest
    from cosmos.profiles.oracle.user_pass import OracleUserPasswordProfileMapping
    from airflow.models import Connection
    
    class TestOracleUserPasswordProfileMapping(unittest.TestCase):
        def test_profile_mapping(self):
            connection = Connection(
                conn_id='oracle_default',
                conn_type='oracle',
                host='localhost',
                login='user',
                password='password',
                schema='dbname',
                port=1521
            )
            mapping = OracleUserPasswordProfileMapping(connection)
            profile = mapping.profile
            self.assertEqual(profile['type'], 'oracle')
            self.assertEqual(profile['user'], 'user')
            self.assertEqual(profile['password'], 'password')
            self.assertEqual(profile['host'], 'localhost')
            self.assertEqual(profile['port'], 1521)
            self.assertEqual(profile['dbname'], 'dbname')
    
    if __name__ == '__main__':
        unittest.main()

By following these steps, you can implement and test the Oracle profile mapping in Cosmos.

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the area:profile Related to ProfileConfig, like Athena, BigQuery, Clickhouse, Spark, Trino, etc label Sep 4, 2024
Copy link

github-actions bot commented Nov 2, 2024

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Nov 2, 2024
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 9, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Nov 9, 2024
@tatiana tatiana reopened this Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:profile Related to ProfileConfig, like Athena, BigQuery, Clickhouse, Spark, Trino, etc enhancement New feature or request triage-needed Items need to be reviewed / assigned to milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants