BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Zhteh
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

Try dropping the table first using the dropTable action

View solution in original post

10 REPLIES 10
alexal
SAS Employee

@Zhteh,

ERROR: Global tables cannot be replaced.

 

This is a valid error because "promote" and "replace" cannot be used together.

Zhteh
Calcite | Level 5

 

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. 

alexal
SAS Employee

@Zhteh,

 

Upload the data to your session scope, then promote to the global scope (in a separate action).

Zhteh
Calcite | Level 5

@alexal

 

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'))

alexal
SAS Employee

@Zhteh,

 

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')
Zhteh
Calcite | Level 5

@alexal

 

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.
alexal
SAS Employee

@Zhteh,

 

That's correct. You have to choose a new name like I showed above.

Zhteh
Calcite | Level 5

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. 

BrunoMueller
SAS Super FREQ

Try dropping the table first using the dropTable action

Zhteh
Calcite | Level 5

@BrunoMueller

Thanks. That will do the trick 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Discussion stats
  • 10 replies
  • 10071 views
  • 1 like
  • 3 in conversation