tableau / hyper-api-samples

Sample code to get started with the Hyper API.
https://help.tableau.com/current/api/hyper_api/en-us/index.html
MIT License
134 stars 72 forks source link

Doesn't work with more than 2 tables? #72

Open chwalters opened 2 years ago

chwalters commented 2 years ago

The example works at first but then I tried to add a third table, and I get an error as below. Does anybody know if it is possible to upload a hyper file with more than 2 tables without a TDS?

`tableauserverclient.server.endpoint.exceptions.ServerResponseError:

400011: Bad Request
    There was a problem publishing the file 'Test.hyper'.`
jonas-eckhardt commented 2 years ago

@chwalters which example are you referring to?

I assume it's the publish multi-table one (https://github.com/tableau/hyper-api-samples/tree/main/Community-Supported/publish-multi-table-hyper)?

Did you properly set up constraints such that Tableau Server (2021.4+) can infer the data model from the hyper file? This is happening in line 63-65 in the example (https://github.com/tableau/hyper-api-samples/blob/bf2484c03518b44cbb6c6ee9e0f248f111be2434/Community-Supported/publish-multi-table-hyper/publish-multi-table-hyper.py#L63)

Cheers Jonas

chwalters commented 2 years ago

Sorry yes, it is the multi-table hyper example, sorry. Below is the way I added the 3rd table and constraints. Sorry about the formatting but it does all 'work' except the uploading (I can load the resulting .hyper in desktop, for example)

customer_emails_table = TableDefinition( table_name="CustomerEmails", columns=[ TableDefinition.Column(name="Email Address", type=SqlType.varchar(1024), nullability=NOT_NULLABLE), TableDefinition.Column(name="Customer ID", type=SqlType.text(), nullability=NOT_NULLABLE) ] )

connection.catalog.create_table(table_definition=customer_emails_table)

alter_statement = f'''ALTER TABLE {customer_emails_table.table_name} ADD ASSUMED FOREIGN KEY ("Customer ID") REFERENCES {customer_table.table_name} ( "Customer ID" )''' connection.execute_command(alter_statement)

email_data_to_insert = [ ["DK-13375", "test@abc.com"], ["DK-13375", "test@anotherdomain.com"], ["EB-13705", "blah@foobar.com"] ]

with Inserter(connection, customer_emails_table) as inserter: inserter.add_rows(rows=email_data_to_insert) inserter.execute()

jonas-eckhardt commented 2 years ago

Hmm.. we need to have a closer look at this. Can you please provide a complete & self-contained repo?

chwalters commented 2 years ago

Sure thing. I forked the repo and made the changes. I tested with my own config.json which I can't share for obvious reasons... https://github.com/chwalters/hyper-api-samples/commit/717bb0c05279ee50ed34985ad1780d87d31160f7

jonas-eckhardt commented 2 years ago

@chwalters are you experiencing this issue with Tableau Cloud (formally known as Tableau Online) or an on-prem server? If on-prem, what version?

I'll go ahead and report a defect for this for further investigation. We'll follow up with you in here.

chwalters commented 2 years ago

I'm using Tableau Cloud/Online, this is what the server reports:

{ "serverInfo": { "productVersion": { "value": "2022.2.0", "build": "20222.22.0722.0032" }, "prepConductorVersion": "2022.2.1", "restApiVersion": "3.16", "platform": "Linux", "serverSettings": { "oAuthEnabled": true, "sheetImageMaxAgeFloor": 1, "sheetImageMaxAgeCeiling": 240, "offlineInteractionSupportedPhase": 2 } } }

I'm also using 0.19 of Tableau Server Client lib in my local dev env. I appreciate any help or mitigation / alternative strategies for how best to upload multi-table Hyper files. Thank you for reporting/investigating!

chwalters commented 2 years ago

I guess I shouldn't have any expectations of a quick resolution but just wondering if anybody has been able to look into this?

vogelsgesang commented 2 years ago

We are still investigating this issue. Unfortunately, I am not aware of any progress we could share at this point

gleb-kalinin commented 2 years ago

Hello everyone, I'm stuck in this issue as well.

It probably might be something with setting Primary and Foreign keys: connection.execute_command( f'ALTER TABLE {customer_table.table_name} ADD ASSUMED PRIMARY KEY ("Customer ID")') connection.execute_command(f'''ALTER TABLE {orders_table.table_name} ADD ASSUMED FOREIGN KEY ("Customer ID") REFERENCES {customer_table.table_name} ( "Customer ID" )''')

As was mentioned above it works for 2 tables, but do you have any ideas how to extend it to 3 or more tables?

chwalters commented 2 years ago

Hello everyone, I'm stuck in this issue as well.

It probably might be something with setting Primary and Foreign keys: connection.execute_command( f'ALTER TABLE {customer_table.table_name} ADD ASSUMED PRIMARY KEY ("Customer ID")') connection.execute_command(f'''ALTER TABLE {orders_table.table_name} ADD ASSUMED FOREIGN KEY ("Customer ID") REFERENCES {customer_table.table_name} ( "Customer ID" )''')

As was mentioned above it works for 2 tables, but do you have any ideas how to extend it to 3 or more tables?

I think it is still being looked into by somebody at Tableau (hopefully! :-))

vogelsgesang commented 2 years ago

Yes, internally this is tracked as "Defect 1442219: Publishing a multi-table extract with three tables results in 400011: Bad Request" in our bug tracker (in case you have some account executive/representative at Tableau you might want to reach out to, use that reference number... will make it easier to tie things together on our own end...)

Unfortunately, the Hyper Update Rest API is owned by a sibling team of the team behind HyperAPI (which I am part of), and the HyperAPI team itself has only very limited possibilities to debug/fix this by themselves...