Published on :
Data Access CREATION_INTERNE

Example: Reading an ORC table from ADLS

This code is also available in: Deutsch Español Français
Awaiting validation
Access to ORC tables stored in Azure Data Lake Storage Gen2 (ADLS) is achieved via the LIBNAME statement. The 'DIRECTORIES_AS_DATA=YES' option is essential for reading Hive tables stored as directories. Azure storage account and application IDs are required for authentication. The example is designed to be executable in a SAS© Viya 4 environment, relying on the prior existence of an ORC table in ADLS, here an 'inventory' table. A SAS© data creation step is added to make the example self-contained in accordance with requirements, even if in the original scenario, this table is created via Hive.
Data Analysis

Type : CREATION_INTERNE


The example creates a temporary SAS 'inventory' table using a DATA step with 'datalines'. This table simulates the structure and data of an ORC Hive table to make the example self-contained.

1 Code Block
DATA STEP Data
Explanation :
This DATA step creates a temporary SAS dataset named 'inventory' with the same columns and data as the original Hive table. In a real scenario for reading from ADLS, this 'inventory' table should be converted to ORC format and uploaded to your Azure Data Lake Storage Gen2 account.
Copied!
1DATA work.inventory;
2 LENGTH descr $32;
3 FORMAT day YYYYMMDD10.;
4 INPUT item descr $ price day:YYMMDD10.;
5 DATALINES;
64600 incandescent A19 15.54 2019-10-17
71023 led A19 14.97 2019-10-17
81023 incandescent B10 5.49 2019-10-16
94219 incandescent E12 3.97 2019-10-15
10;
11RUN;
2 Code Block
LIBNAME / PROC PRINT
Explanation :
The LIBNAME statement assigns the 'mylib' libref to the ORC engine, pointing to a location in Azure. The 'storage_account_name', 'storage_application_id', and 'storage_file_system' options are used to configure the connection to the ADLS account. The 'directories_as_data=yes' option is crucial to allow access to Hive tables stored as directories. The PRINT procedure then displays the content of the ORC table 'mylib.inventory' read from ADLS. Replace 'myacct', 'b1fc955d5c-e0e2-45b3-a3cc-a1cf54120f', and 'myorcdata' with your own Azure storage account information. 'data/user' represents the path to the ORC file in ADLS.
Copied!
1LIBNAME mylib orc '/data/user'
2 storage_account_name = myacct
3 storage_application_id = 'b1fc955d5c-e0e2-45b3-a3cc-a1cf54120f'
4 storage_file_system = myorcdata
5 directories_as_data=yes
6 ;
7PROC PRINT DATA=mylib.inventory noobs;
8RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright © SAS Institute Inc. All Rights Reserved


Related Documentation : Data Access

Sujet / Mot-cléLien vers la ressource
DOC FedSQL en/sampleCode/FEDSQL9D66