Hi team, when I was trying to execute the followin...
# ingestion
n
Hi team, when I was trying to execute the following trino recipe for testing:
Copy code
source:
  type: trino
  config:
    # Coordinates
    host_port: xxxx
    database: xxxx

    # Credentials
    username: xxxx
    password: xxxx

sink:
  type: "file"
  config:
    filename: "./example_output_mces.json"
I was getting this error:
Copy code
DBAPIError: (trino.exceptions.FailedToObtainAddedPrepareHeader) 
[SQL: SELECT "table_name"
FROM "information_schema"."tables"
WHERE "table_schema" = ? and "table_type" != 'VIEW']
Can anybody help me with it?
m
Hi @nutritious-train-7865 , I will try to run it from my end but can you share the full stacktrace so I can see which part is throwing that exception?
Just checking into see if the user you are executing with user has access to the information_schema table?
n
Hi @miniature-tiger-96062 yes, the user has the information_schema table, and actually, the schema names have been sucessfully fetched from the information_schema table. I think the part that throw this exception is not able to find the
X-Trino-Added-Prepare
from the
response_headers
when the trino connector try to get the table names for a specific schema name
Copy code
File "/Users/houren.chen/datahub/datahub/datahub-python/lib/python3.9/site-packages/trino/dbapi.py", line 274, in _prepare_statement
    240  def _prepare_statement(self, operation, statement_name):
 (...)
    270  
    271          if constants.HEADER_ADDED_PREPARE in response_headers:
    272              return response_headers[constants.HEADER_ADDED_PREPARE]
    273  
--> 274      raise trino.exceptions.FailedToObtainAddedPrepareHeader
    ..................................................
     self = <trino.dbapi.Cursor object at 0x1357598b0>
     operation = 'SELECT "table_name"\nFROM "information_schema"."tables"\nWHERE "table_schema" = ? and "table_type" != \'VIEW\''
     statement_name = 'st_a786a843d14243d491ca1d09a90971c6'
     constants.HEADER_ADDED_PREPARE = 'X-Trino-Added-Prepare'
     response_headers = {'Date': 'Fri, 19 Nov 2021 05:39:52 GMT', 'Content-Type': 'application/json', 'Content-Length': '592', 'Connection': 'ke
                         ep-alive', 'Cache-Control': 'max-age=300'}
     trino.exceptions.FailedToObtainAddedPrepareHeader = <class 'trino.exceptions.FailedToObtainAddedPrepareHeader'>
d
@nutritious-train-7865 do you use Trino or Presto and which version?
n
@dazzling-judge-80093 I am using presto 330 now
d
Ahh, so it is not Trino but Presto, right?
b
Hey @dazzling-judge-80093, random question - how is the Hive connector different from Trino connector? We are actually using Presto that connects to Hive. Also from what Trino version does this connector support or is tested with?
h
@boundless-student-48844 trino datahub source has been developed and tested with trino server 361. In my understanding it should support latest versions as well, as trino source integration tests are written to fetch latest trino image during CI and they are working fine.
If you are using older version, it can be quickly tested for version support by updating trino integration tests with your trino version. I can help you with that, if you need any.
b
Cool thanks Mayuri, let us look into it. Btw what’s the benefit of using Trino connector over Hive connector for cases where Trino is using Hive metastore?
d
@boundless-student-48844 in this particular case based on the error message it seems Trino client expects a header which failed to get
X-Trino-Added-Prepare
from the server and my gut feeling this header is returned only by Trino servers and not by Presto ones.
b
yeah i think so. we are using 330 now but gonna upgrade to 350 only, let us see how to work around with the trino plugin
btw would you be able to shed some light on this question 😛
how is the Hive connector different from Trino connector?
We tried with hive plugin before and it worked. But i suspect the Hive plugin cannot ingest Presto/Trino views
n
@hundreds-photographer-13496 Thanks Mayuri, could you tell me how to update the trino integration tests with an older trino version?
h
@nutritious-train-7865 - you can change trinodb/trino to trinodb/trino:<your version> (e.g. trinodb/trino:359) in docker-compose.yml and re-run tests on your local setup . This guide is helpful for how to run tests. @boundless-student-48844 From what I understand version 350 was still presto so the trino source will definitely not work with version 350 or below. If you want to ingest from presto, you can either use • use sqlalchemy source with presto sqlalchemy dialect or • contribute to create presto source for datahub
thank you 1
b
Hey thanks Mayuri, I just looked into the code as well. Yeah we would need to use the presto dialect from pyhive (which uses sqlalchemy). We managed to import table metadata using the hive plugin, but as expected, the column info are not available for Presto views. We will surely contribute once we decide to work on the Presto plugin
n
Hi @hundreds-photographer-13496, I was trying to run the integration test for trino before I work on the presto plugin, but I ran into the below
TrinoExternalError
for the 
trino_hive_to_file
 part in the
test_trino.py
, could you advise me on it?
h
Hey @nutritious-train-7865, unfortunately I am unable to reproduce this error. Have you done any changes in your local setup ? just to confirm - are you following this guide here before running test ?- https://datahubproject.io/docs/metadata-ingestion/developing/
n
Yes, I am following this guide, actually all the other integration tests are passed except the trino one, but maybe let me try it out again since it’s likely only happens on my end
@hundreds-photographer-13496 The integration test for trino passed by increasing the memory for my docker desktop from 2GB to 4GB! The reason I try this is because I found that the docker clean up command always triggered and shut down the trino before all the sink wrote finished, thus raise the connection error in
test_trino.py
and failed the test. So I was thinking to increase the memory might work. Thanks a lot for your help!
🎉 1
s
e