Skip to main content
Solved

Retreiving a list of RAW table columns and their datatype through the Python SDK

  • 30 May 2024
  • 2 replies
  • 17 views

Hi

For a use case I am working on I need to retrieve information about the raw tables in our environment. What I need to do is that i need to retrieve the name of each of the  columns and the datatypes of the columns for every single raw table we have in our environment. I have looked through the python SDK docs, but have not been able to find out how to do this. I noticed that it is possible to do a preview of a transformation through the SDK and get a schema out this way, however this feels a bit too “hacky” and is also very time consuming and inefficient. Does anyone have any idea of how I can get what I need?

Thanks

Sebastian

2 replies

Userlevel 1
Badge +2

Hi Sebastian,

 

Raw does not have a fixed schema. Therefore it is impossible to get data type of the raw table. but I have tried using python inbuilt function and in there I was able to get only int,string and None data types.  I don think it will helpful for you requirement but I will share my sample code and output:

my_table_list = client.raw.rows.list("Maneshka-New","assets")
for x in my_table_list:
for y in x.columns:
print(type(x.columns[y]))


Output:
 

 

Thanks! This is very helpful and may help me in my use case

Reply