Examples use generated data (datalines) or placeholders for connections to external sources (Hive).
1 Code Block
CASLIB Data
Explanation : This example shows the creation of a caslib to connect to a Hive server without using dynamic service discovery (ZooKeeper) or HDFS access. The `bulkload=false` option is specified because HDFS access is not configured. Replace `your_hive_server`, `your_username`, `your_password`, and `your_schema` with your own connection information.
Copied!
/* Connexion basique à Hive sans accès HDFS direct */
/* Les valeurs entre crochets angulaires (<>) doivent être remplacées par vos informations */
caslib hvcaslib_basic desc='Caslib Hadoop Basique'
dataSource=(srctype='hadoop',
server='your_hive_server',
username='your_username',
password='your_password',
schema='your_schema',
bulkload=false);
/* Charger et activer le caslib */
proc cas;
session casauto;
caslib _all_ assign;
run;
/* Afficher les informations sur le caslib */
proc cas;
session casauto;
caslib hvcaslib_basic info;
run;
quit;
1
/* Connexion basique à Hive sans accès HDFS direct */
2
/* Les valeurs entre crochets angulaires (<>) doivent être remplacées par vos informations */
Explanation : This example configures a Hadoop caslib that uses ZooKeeper for dynamic service discovery. It is ideal for HiveServer2 environments in high availability mode. The options `zooKeeperQuorum`, `zooKeeperNamespace`, and `zooKeeperPort` are used to specify ZooKeeper connection information. Be sure to replace the placeholders with the actual values for your environment, including the paths to the Hadoop jar and configuration directories, as well as ZooKeeper and authentication information.
Copied!
/* Connexion à Hive avec découverte de service dynamique via ZooKeeper */
/* Les valeurs entre crochets angulaires (<>) doivent être remplacées par vos informations */
caslib zoocaslib desc='Caslib ZooKeeper Hadoop'
dataSource=(srctype='hadoop',
username='your_username',
password='your_password',
dataTransferMode='serial',
hadoopJarPath='<Hadoop_jar_path_directory>',
hadoopConfigDir='<Hadoop_configuration_directory>',
zooKeeperQuorum="<node1.company.com>,<node2.company.com>,<node3.company.com>",
zooKeeperNamespace='hiveserver2',
zooKeeperPort=2181,
schema='your_schema');
/* Charger et activer le caslib */
proc cas;
session casauto;
caslib _all_ assign;
run;
/* Afficher les informations sur le caslib */
proc cas;
session casauto;
caslib zoocaslib info;
run;
quit;
1
/* Connexion à Hive avec découverte de service dynamique via ZooKeeper */
2
/* Les valeurs entre crochets angulaires (<>) doivent être remplacées par vos informations */
Explanation : This example illustrates connecting to a Hive server configured with Kerberos authentication. The options `krbAuthType`, `krbHostFQDN`, `krbRealm`, and `krbServiceName` are essential for passing Kerberos connection properties to the Simba driver. Replace placeholders such as `your_hive_server`, `your_schema`, `myhost.company.com`, and `example.com` with the appropriate values for your Kerberos environment.
Copied!
/* Connexion à Hive avec authentification Kerberos */
/* Les valeurs entre crochets angulaires (<>) doivent être remplacées par vos informations */
caslib hadoopkrb desc='Caslib Hadoop Kerberos'
dataSource=(srctype='hadoop',
server='your_hive_server',
schema='your_schema',
use_ssl=true,
krbAuthType=2,
krbHostFQDN='<myhost.company.com>',
krbRealm='<example.com>',
krbServiceName='hive',
bulkload=false);
/* Charger et activer le caslib */
proc cas;
session casauto;
caslib _all_ assign;
run;
/* Afficher les informations sur le caslib */
proc cas;
session casauto;
caslib hadoopkrb info;
run;
quit;
1
/* Connexion à Hive avec authentification Kerberos */
2
/* Les valeurs entre crochets angulaires (<>) doivent être remplacées par vos informations */
3
4
caslib hadoopkrb desc='Caslib Hadoop Kerberos'
5
dataSource=(srctype='hadoop',
6
server='your_hive_server',
7
schema='your_schema',
8
use_ssl=true,
9
krbAuthType=2,
10
krbHostFQDN='<myhost.company.com>',
11
krbRealm='<example.com>',
12
krbServiceName='hive',
13
bulkload=false);
14
15
/* Charger et activer le caslib */
16
PROC CAS;
17
SESSION casauto;
18
caslib _all_ assign;
19
RUN;
20
21
/* Afficher les informations sur le caslib */
22
PROC CAS;
23
SESSION casauto;
24
caslib hadoopkrb info;
25
RUN;
26
QUIT;
4 Code Block
PROC CASUTIL Data
Explanation : This example illustrates configuring a caslib for parallel data loading from Hive to CAS, then uses `PROC CASUTIL` to perform this loading. To make this example self-contained, a CAS table named `myHDdata` is first created to simulate the data that would normally be read from Hive. The options `dataTransferMode="parallel"`, `jobManagementURL`, `hadoopConfigDir`, and `bulkLoad=false` are crucial for enabling parallel loading. Replace placeholders such as `your_hive_server`, `your_schema`, `your_username`, `your_password`, `Livy_URL`, and `path-to-EP-config-files` with the specific values for your Hadoop/Hive installation.
Copied!
/* Création d'une table CAS de démonstration pour simuler une source Hive */
data casuser.myHDdata;
input id $ name $ value;
datalines;
1 Apple 10
2 Banana 20
3 Cherry 30
4 Date 40
;
run;
/* Connexion à Hive avec chargement parallèle activé */
/* Les valeurs entre crochets angulaires (<>) doivent être remplacées par vos informations */
caslib hvcaslib_parallel desc='Caslib Hadoop avec Chargement Parallèle'
dataSource=(srctype='hadoop',
server='your_hive_server',
schema='your_schema',
username='your_username',
password='your_password',
dataTransferMode="parallel",
jobManagementURL='<Livy_URL>',
hadoopConfigDir='<path-to-EP-config-files>',
bulkLoad=false);
/* Charger et activer le caslib */
proc cas;
session casauto;
caslib _all_ assign;
run;
/* Charger la table 'myHDdata' de Hive (simulée ici par la table CAS) dans CAS */
/* En pratique, 'myHDdata' serait une table existante dans Hive */
proc casutil;
list files incaslib="hvcaslib_parallel";
load casdata="myHDdata" incaslib="hvcaslib_parallel" outcaslib="casuser"
casout="HDdata_from_hvcaslib_parallel";
list tables incaslib="casuser";
contents casdata="HDdata_from_hvcaslib_parallel" incaslib="casuser";
run;
quit;
1
/* Création d'une table CAS de démonstration pour simuler une source Hive */
2
DATA casuser.myHDdata;
3
INPUT id $ name $ value;
4
DATALINES;
5
1 Apple 10
6
2 Banana 20
7
3 Cherry 30
8
4 Date 40
9
;
10
RUN;
11
12
/* Connexion à Hive avec chargement parallèle activé */
13
/* Les valeurs entre crochets angulaires (<>) doivent être remplacées par vos informations */
14
15
caslib hvcaslib_parallel desc='Caslib Hadoop avec Chargement Parallèle'
16
dataSource=(srctype='hadoop',
17
server='your_hive_server',
18
schema='your_schema',
19
username='your_username',
20
password='your_password',
21
dataTransferMode="parallel",
22
jobManagementURL='<Livy_URL>',
23
hadoopConfigDir='<path-to-EP-config-files>',
24
bulkLoad=false);
25
26
/* Charger et activer le caslib */
27
PROC CAS;
28
SESSION casauto;
29
caslib _all_ assign;
30
RUN;
31
32
/* Charger la table 'myHDdata' de Hive (simulée ici par la table CAS) dans CAS */
33
/* En pratique, 'myHDdata' serait une table existante dans Hive */
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.
« Before running a large parallel load, check your Livy URL and Hadoop configuration directories. A common cause of "Parallel Load Failure" is a mismatch between the Hadoop site-xml files on the CAS controller and those actually running on the Hadoop cluster nodes. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.