Exemplo n.º 1
0
 def test_should_record_records_with_kerberos_auth(self):
     conn_url = ('presto://airflow@presto:7778/?'
                 'auth=kerberos&kerberos__service_name=HTTP&'
                 'verify=False&'
                 'protocol=https')
     with mock.patch.dict('os.environ',
                          AIRFLOW_CONN_PRESTO_DEFAULT=conn_url):
         hook = PrestoHook()
         sql = "SELECT name FROM tpch.sf1.customer ORDER BY custkey ASC LIMIT 3"
         records = hook.get_records(sql)
         assert [['Customer#000000001'], ['Customer#000000002'],
                 ['Customer#000000003']] == records
Exemplo n.º 2
0
    def execute(self, context: 'Context') -> None:
        presto = PrestoHook(presto_conn_id=self.presto_conn_id)
        self.log.info("Extracting data from Presto: %s", self.sql)
        results = presto.get_records(self.sql)

        mysql = MySqlHook(mysql_conn_id=self.mysql_conn_id)
        if self.mysql_preoperator:
            self.log.info("Running MySQL preoperator")
            self.log.info(self.mysql_preoperator)
            mysql.run(self.mysql_preoperator)

        self.log.info("Inserting rows into MySQL")
        mysql.insert_rows(table=self.mysql_table, rows=results)
Exemplo n.º 3
0
 def test_should_record_records(self):
     hook = PrestoHook()
     sql = "SELECT name FROM tpch.sf1.customer ORDER BY custkey ASC LIMIT 3"
     records = hook.get_records(sql)
     assert [['Customer#000000001'], ['Customer#000000002'],
             ['Customer#000000003']] == records