Hi,
I try to get datatable content along with the column __ROW_ID__
by using the Python SDK together with a data_transformer:
df = onedata_api.datatables.get_content_as_pandas(name=datatable_name,
project_id=project_id,
data_transformers=[sql(f"SELECT *, \"__ROW_ID__\" FROM inputTable")])
Sadly the column __ROW_ID__
is not returned when using a data_transformer. When removing the data_transformer the column __ROW_ID__
is available in the resulting df.
Any ideas how I can add the __ROW_ID__
together with a data_transformer?
Thanks in advance!
ROW_IDs are only included in results that are considered “editable”. Editable means here, that every row in the result corresponds to exactly one row of the original data that is stored in the data table and that any change in the resulting table of the request can be mapped back the the original data and stored. This enables editing of data tables in the OD client or in Apps.
The outcome of a custom SQL (you call it “data_transformer”) is in general not editable according to the above definition. If you still want the row ID, then try to rename the column that contains it in the SQL (I am crossing my fingers in the hope that this works). The server allows requesters to require that the ROW_ID is always included in results, but I do not know whether the Python SDK reveals this.
2 Likes
Renaming did work. Thank you very much!
1 Like