question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add new connection type - Greenplum

See original GitHub issue

Greenplum DB is a popular open source relational DBMS[1].

I want to implement some database specific behaviour for a common class. It’s easy to check connection type for postgres, mysql or oracle. Now I use postgres connection type for Greenplum and cannot explicitly check type.

Airflow has PostgresHook based on psycopg2. As Greenplum supports PostgreSQL libpq API [2], PostgresHook could be reused for Greenplum.

As I see it’s enough to change 2 code line in the connectoin.py.

I’m not sure that it’s nice to reuse Hook. Please confirm or reject my idea.

Index: airflow/models/connection.py
===================================================================
--- airflow/models/connection.py  (revision 6416d898060706787861ff8ecbc4363152a35f45)
+++ airflow/models/connection.py  (date 1598717245079)
@@ -109,6 +109,7 @@
         ('grpc', 'GRPC Connection'),
         ('yandexcloud', 'Yandex Cloud'),
         ('spark', 'Spark'),
+        ('greenplum', 'Greenplum'),
     ]
 
     def __init__(
@@ -243,7 +244,7 @@
         elif self.conn_type == 'google_cloud_platform':
             from airflow.contrib.hooks.bigquery_hook import BigQueryHook
             return BigQueryHook(bigquery_conn_id=self.conn_id)
-        elif self.conn_type == 'postgres':
+        elif self.conn_type in ('postgres', 'greenplum'):
             from airflow.hooks.postgres_hook import PostgresHook
             return PostgresHook(postgres_conn_id=self.conn_id)
         elif self.conn_type == 'pig_cli':

  1. https://github.com/greenplum-db/gpdb
  2. https://gpdb.docs.pivotal.io/6-10/security-guide/topics/ports_and_protocols.html

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RosterIncommented, Dec 11, 2020

@mebelousov I think in that case you don’t need to duplicate code. you can inherit from PostgresHook and overwrite only the methods that are incomparable.

You hook can be:

class GreenplumHook(PostgresHook):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def _generate_insert_sql():
        pass
1reaction
turbaszekcommented, Sep 13, 2020

@mebelousov would you like to open a PR?

Read more comments on GitHub >

github_iconTop Results From Across the Web

dblink | Pivotal Greenplum Docs
Use the dblink_connect() function to create either an implicit or a named connection to another database. The connection string that you provide should...
Read more >
Greenplum Connections - Trifacta Documentation
Create Connection ​​ Name of the host. The port number of the Greenplum server. The default port value is 5432. The name of...
Read more >
Establish datasource connection to Pivotal Greenplum database
From Cognos Administration, create a new data source with JDBC type, and choose Pivotal Greenplum in the connection string page.
Read more >
Add a Greenplum database connection | ThoughtSpot Software
You can add a connection to a Greenplum database using ThoughtSpot DataFlow. Follow these steps: ... After you select the Greenplum Connection type,...
Read more >
Configure Pivotal Greenplum Bulk Connection for Writing Data
Select Greenplum ODBC as the Driver; · Select new database connection; · Select your DSN from the drop-down and enter a value for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found