hyper-api-samples icon indicating copy to clipboard operation
hyper-api-samples copied to clipboard

Doesn't work with more than 2 tables?

Open chwalters opened this issue 3 years ago • 11 comments
trafficstars

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'.`

chwalters avatar Aug 01 '22 08:08 chwalters

@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

jonas-eckhardt avatar Aug 01 '22 09:08 jonas-eckhardt

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", "[email protected]"], ["DK-13375", "[email protected]"], ["EB-13705", "[email protected]"] ]

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

chwalters avatar Aug 01 '22 09:08 chwalters

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

jonas-eckhardt avatar Aug 01 '22 14:08 jonas-eckhardt

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

chwalters avatar Aug 01 '22 14:08 chwalters

@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.

jonas-eckhardt avatar Aug 02 '22 10:08 jonas-eckhardt

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 avatar Aug 02 '22 12:08 chwalters

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

chwalters avatar Aug 10 '22 09:08 chwalters

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

vogelsgesang avatar Aug 10 '22 17:08 vogelsgesang

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?

gleb-kalinin avatar Aug 16 '22 14:08 gleb-kalinin

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! :-))

chwalters avatar Aug 18 '22 09:08 chwalters

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...

vogelsgesang avatar Aug 18 '22 09:08 vogelsgesang