0
I’m calling an API that creates table in Hive. I’m developing an automated test script to make 30 requests and be able to create 30 tables in Hive. For this, I put a logic in which the tablename for each request is tableName 0, tableName 1 and so on (I did with range).
However, when I run the function, only the first table is inserted in the Hive (name_table_0) and returns status_code 200. The request of the others returns status_code 200 but the tables are not created in Hive.
Does anyone have suggestions to actually get other requests met and tables created?
def tests_requests_loops(table_sufix: str):
nome_tabela = f"nome_tabela_{table_sufix}"
body = {
"name_table": nome_tabela,
"schema_table": "{\"name\": \"Value\", \"type\": \"record\", \"namespace\": \"com.demo.producer.avro\", \"fields\": [{\"name\": \"id\", \"type\": \"int\"}, {\"name\": \"first_name\", \"type\": [\"null\", \"string\"]}",
"location":"hive-desenvolvimento"
}
print(body)
url = "https://api-dev-cloud/development/ingestion-events/configuracoes"
response = requests.request("POST", url, data=json.dumps(body), verify=False)
print(response)
for i in range(30):
tests_requests_loops(table_sufix=i)
Obs: has the parameters of headers but removed because it did not make much difference to the question.
The code seems correct. The first request also returns 200?
– Woss
That, the first also returns 200.
– Nakano
It should work. You can create a MOCK API to intercept requests and see if it’s sending everything correctly. If yes, the problem is not in your code.
– Woss
Thank you, Woss. I made some mocks, the code is correct. Hive was not accepting the same Location for the same requests, so I had to put this parameter in the range as well. Anyone who wants to make multiple requests to the same URL, this is a simple way but that solves the problem.
– Nakano