DockerでBeelineを起動し、CDWに接続

# 1) Dockerをインストール
https://hub.docker.com/

# 2) Dockerを起動
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/133516/9dbdc746-8282-479a-fa46-5638bb94ce36.png)


# 3) Beeline のコンテナー起動
docker run -it bde2020/hive /bin/bash


# 4) CDWのJDBC URIを取得

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/133516/616733ef-e34e-c2ec-9b04-dd89fd7da87f.png)

Data Warehouseに入る。
    【Virtual Warehouses】ー＞接続したいCDWのVirtual Warehouse選ぶ。
    右側の三点のメニューをクリックし、「Copy JDBC URL」をクリック。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/133516/75fffb9e-594e-aacf-a991-bc7f1a75d6e8.png)


![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/133516/fb4c73ea-7ff1-3e63-4d72-4146747347c3.png)


私の場合は下記URL:

```
jdbc:hive2://hs2-zzeng-iceberg-hive-vw.dw-******.******.cloudera.site/default;transportMode=http;httpPath=cliservice;socketTimeout=60;ssl=true;auth=browser;
```

これに基づいて、
Beeline コマンドを作る：

```
# beeline -n <csso_username> -p <password> -u "jdbc:hive2://hs2-zzeng-iceberg-hive-vw.dw-******.******.cloudera.site/default;transportMode=http;httpPath=cliservice;socketTimeout=60;ssl=true;auth=browser;"


```


# 5) 動作確認

```bash

[zzeng@zeng-mbp ~]$ docker run -it bde2020/hive /bin/bash
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Configuring core
 - Setting fs.defaultFS=hdfs://f79932f343d9:8020
Configuring hdfs
Configuring yarn
Configuring httpfs
Configuring kms
Configuring mapred
Configuring hive
Configuring for multihomed network
root@f79932f343d9:/opt#
root@f79932f343d9:/opt# beeline -n zzeng -p ******** -u "jdbc:hive2://hs2-zzeng-iceberg-hive-vw.dw-******.******.cloudera.site/default;transportMode=http;httpPath=cliservice;socketTimeout=60;ssl=true;auth=browser;"
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Connecting to jdbc:hive2://hs2-zzeng-iceberg-hive-vw.dw-se-sandboxx-aws.a465-9q4k.cloudera.site/default;transportMode=http;httpPath=cliservice;socketTimeout=60;ssl=true;auth=browser;
Connected to: Apache Hive (version 3.1.3000.2024.0.17.0-73)
Driver: Hive JDBC (version 2.3.2)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 2.3.2 by Apache Hive
0: jdbc:hive2://hs2-zzeng-iceberg-hive-vw.dw->
0: jdbc:hive2://hs2-zzeng-iceberg-hive-vw.dw-> show databases;
INFO  : Compiling command(queryId=hive_20240314095722_23905dc8-7ab9-4420-8a21-70d81a905995): show databases
INFO  : Semantic Analysis Completed (retrial = false)
INFO  : Created Hive schema: Schema(fieldSchemas:[FieldSchema(name:database_name, type:string, comment:from deserializer)], properties:null)
INFO  : Completed compiling command(queryId=hive_20240314095722_23905dc8-7ab9-4420-8a21-70d81a905995); Time taken: 0.012 seconds
INFO  : Executing command(queryId=hive_20240314095722_23905dc8-7ab9-4420-8a21-70d81a905995): show databases
INFO  : Starting task [Stage-0:DDL] in serial mode
INFO  : Completed executing command(queryId=hive_20240314095722_23905dc8-7ab9-4420-8a21-70d81a905995); Time taken: 0.009 seconds
INFO  : OK
+----------------------------+
|       database_name        |
+----------------------------+
| airlinedata                |
...
| zzeng_airlines_csv         |
| zzeng_airlines_ice         |
+----------------------------+
18 rows selected (1.67 seconds)
0: jdbc:hive2://hs2-zzeng-iceberg-hive-vw.dw->

```