Fedsql

Resolving the "BASE driver" connection error with PROC FEDSQL

Simon 16 vistas

The transition from SAS© 9.4 to SAS© Viya often comes with a learning curve regarding in-memory data management. A common confusion arises when transitioning from PROC SQL to PROC FEDSQL to interact with tables loaded in CAS libraries (CASLIBs).

If you have ever encountered the error "BASE driver, schema name... was not found", this article explains why it happens and how to fix your code.

Resolving the "BASE driver" connection error with PROC FEDSQL -

The Scenario

Imagine you are working in a SAS© Viya environment. You have defined a path-based CASLIB and loaded a table into memory.

Here is the typical configuration:

  1. Defining the CASLIB and Libref:

1caslib mycaslib path="/sas/staging/test" datasource=(srctype="path") libref=mycas;
2 

Loading Data In-Memory: You use PROC CASUTIL to load a table (e.g., test.sashdat) into the CAS server's memory.

1 
2PROC CASUTIL incaslib="mycaslib" outcaslib="mycaslib";
3 
4load casdata="test.sashdat" casout="test" replace;
5 
6RUN;
7 

So far, everything is working. The table is accessible in memory under the name mycas.test.

The Problem

To perform an aggregation (like a GROUP BY), you decide to use PROC FEDSQL, which is the standard SQL implementation for the CAS engine.

You attempt to run the following code:

1PROC FEDSQL;
2 CREATE TABLE mycas.counts AS
3 select FIELD, count(*) as N
4 from mycas.test
5 group BY FIELD;
6QUIT;

This is where the system returns the blocking error:

ERROR: Table "MYCAS.TEST" does not exist or cannot be accessed ERROR: BASE driver, schema name MYCAS was not found for this connection

The Explanation

The error does not stem from a library configuration issue or a missing file. It is due to the way PROC FEDSQL communicates with the CAS server.

Unlike a classic SAS© procedure that runs locally, PROC FEDSQL needs to explicitly know in which CAS session it should operate to access in-memory tables. If no session is referenced, the procedure attempts to find the table via the local engine (BASE driver), which does not know the "MYCAS" schema defined on the remote server.

The Solution

To fix this issue, you need to do two things:

  1. Ensure a CAS session is active.

  2. Tell PROC FEDSQL to use this session via the SESSREF option.

Here is the corrected code:

1/* 1. Start or reference a CAS session */
2cas mySession sessopts=(caslib=mycas timeout=3600 locale="en_US" metrics=true);
3 
4/* 2. Call PROC FEDSQL pointing to this session */
5PROC FEDSQL sessref=mySession;
6 CREATE TABLE mycas.counts AS
7 select FIELD, count(*) as N
8 from mycas.test
9 group BY FIELD;
10QUIT;

What to Remember

Adding the sessref=YourSessionName option is essential when you manipulate CAS tables directly with FedSQL. This creates the necessary bridge between your code and the data residing in memory on the Viya cluster.