Hi,
I was trying to replace the csv file in the cas server using python-swat interface. However, I encounter error with "Global Table cannot be replaced" when I run it.
Below is the code I used to upload the data. Anyone know the reason behind it? Thank you
conn.upload('abc.csv',casout=dict(name='trialupload2',caslib='public',promote = 'true',replace = 'true'))
TRIALUPLOAD2 table is in my cas server, and when I try to replace it, it resulted in the above error.
Try dropping the table first using the dropTable action
ERROR: Global tables cannot be replaced.
This is a valid error because "promote" and "replace" cannot be used together.
Hi @alexal,
If that is the case, then may I know is there any workaround for this? because I wish to overwrite the existing data in the CAS server. And if I set the promote to false, the data uploaded won't be visible to me anymore.
Upload the data to your session scope, then promote to the global scope (in a separate action).
May I know the proper way of promoting to global scope? Now that with
conn.read_csv('abc.csv',casout=dict(name='trialupload123',caslib='public',replace ='true'))
thiis command I am able to upload to the session scope.
But using when trying to promote to global scope using the below command it fails.
conn.read_csv('abc.csv',casout=dict(name='trialupload123',caslib='public',promote = 'true'))
Something like that:
load_csv = conn.read_csv('https://raw.githubusercontent.com/sassoftware/sas-viya-programming/master/data/cars.csv',casout=dict(name='CARS',caslib='CASUSER',replace ='true'))
promote_csv = conn.promote(load_csv,target='NEW_NAME_FOR_CARS_TABLE')
Thanks for the code. However, there is still one problem here. The error exists because the target table of the promotion already exists. Means that I couldn't overwrite the table of the same name in the CAS server.
ERROR: The target table trialupload432 of the promotion already exists. Please specify a different name.
thanks for the solution. However, the problem is that the table name in the global scope will be different everytime I upload the data. And in the SAS Studio I will have to access data from different tables every time.
Try dropping the table first using the dropTable action
Thanks. That will do the trick
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.