Alibaba Cloud Big Data ACP 認定学習ノート
1. ビッグデータ基盤
2. ビッグデータコンピューティングサービス Maxcompute
2.1 基礎知識
2.1.1 Maxcompute を購入し、サブユーザーを追加するプロジェクトを作成する
1. まず、自分のサービス領域で maxcompute を購入します。
2. プロジェクトを作成します
。 3. サブユーザーを追加し、その AccessKey を保存します
。 4. プロジェクトにユーザー権限を追加します。
2.1.2 ODPSの作成
1. ODPS を作成します。
2. テーブルを作成します。create table A (id bigint,name string);
3. このテーブルを表示します。desc A;
2.1.3 maxcompute のコマンドラインクライアント odpscmd のインストールと基本コマンド
1. Ali の公式 Web サイトでインストール パッケージをダウンロードし、解凍します
2. 加圧後に conf ディレクトリ内の唯一のファイルを開き、プロジェクトに従って関連情報を入力します:
3. ファイルを構成した後、cmd を開きますbin ディレクトリーをodpscmd.bat
開いて実行するには
Enter キーを押します。 4. quit;
odpscmd を終了するには Enter キーを
押します。 5. -f パラメーターはファイル内のコマンドを実行できます。odpscmd -f create.txt
6. -e パラメーターは SQL ステートメントを実行できます。odpscmd -e "select * from test_table;"
7. 別のプロジェクトにジャンプするuse 项目名;
ためにユーザー (ユーザーに複数のプロジェクトがある場合)。
2.2 データのアップロードとダウンロード
2.2.1 トンネルバッチオフライン処理
2.2.1.1 トンネルアップロード
1. 追加アップロードtunnel upload C:\Users\dz\Downloads\up.csv A;
drop table if exists A;#如果表存在删除
create table A(id int,name string);#创造表A,键是id和name
desc A;#查看表A
tunnel help;#查看tunel命令
tunnel upload C:\Users\dz\Downloads\up.csv A;#本地表up.csv内容追加上传到A表;
select * from A;#查看表A
truncate table A;#清理表A里的内容
2. パーティションテーブルのアップロード
まずパーティションテーブルを作成します
create table A(id int,name string) partitioned by (gender string);#按gender创造分区表
それから
tunnel upload C:\Users\dz\Downloads\up_p\up_1.csv A/gender='male' -acp=true;#上传本地表到此分区,没有此分区值则创建
select * from A where gender='male';查看分区值是此的分区表
read A;#查看分区表的所有分区
3. ファイルディレクトリのアップロード
tunnel upload C:\Users\dz\Downloads\DIR B;#将C:\Users\dz\Downloads\DIR下的所有文件上传到表B;
フォルダー内に異なる形式のテーブルがある場合: -dbr=true は、正しい形式のみが入力され、間違ったテーブルは破棄されることを意味します。
tunnel upload C:\Users\dz\Downloads\DIR B -dbr=true;#有格式错误的表格,抛弃此表格
4.パラメータスキャンスキャン
scan=true の場合、最初にデータをスキャンし、形式が正しい場合はデータをインポートします。scan
=false の場合、データをスキャンせずにデータを直接インポートします。scan
=only の場合、ローカル データのみをスキャンします。スキャン後にインポートしないでください
5. セパレータ
行区切り文字 - rd (デフォルト \r\n) および列区切り文字 - fd (,)
6. 1行目のヘッダー
CSV ファイルの最初の行ヘッダーを削除します: -h=true
2.2.1.2トンネルダウンロード
1. パーティションテーブルをダウンロードする
tunnel download A C:\Users\dz\Downloads\download\A_d.csv;#下载分区表的所有分区
tunnel download A\gender="male" C:\Users\dz\Downloads\download\A_d_male.csv;#下载分区表的指定分区
2. 指定したカラムをダウンロードします。
-ci=カラム番号 (0 から始まるシリアル番号)
-cn=カラム名
tunnel download B C:\Users\dz\Downloads\download\B_d_ci0.csv -ci=0;
tunnel download B C:\Users\dz\Downloads\download\B_d_cnname.csv -cn="name";
3. 代表的なヘッダーのダウンロード -h=true
tunnel download B C:\Users\dz\Downloads\download\B_d_h.csv -h=true;
4. 少数の情報のみをダウンロードできます。 -limit=num;
tunnel download B C:\Users\dz\Downloads\download\B_d_1.csv -limit=1 ;
2.2.2 javaSDK を使用してアップロードとダウンロードを開発する
1. まず、 Alibaba Cloud 公式 Web サイトからjavasdk をダウンロードし、Eclipse をインストールします。
2.2.3 データハブのリアルタイム処理チャネル
1. データハブ プロジェクトを作成します。
2. プロジェクトにトピックを書き込みます。
3. トピック内に接続同期タスクを作成します。
2.3maxcomputeSQL 開発の基本
2.3.1DDL
create table t_table01(id bigint,name string);#1.建表
desc t_table01;#2.看表
show create table t_table01;#3.查看建表语句
drop table t_table01;#4.删除表
select * from t_table01;#查看表
create table t_table01_p(id bigint,name string) partitioned by(class string);#1.创建分区表
desc t_table01_p;#2.查看分区表
create table AA as select * from A where gender="male";#使用as拿数据,不拿分区
create table AB like A;#使用like拿了表结构包括分区,不拿数据
alter table A set lifecycle 30;#1.设置分区表的生命周期是30天
alter table A disable lifecycle;#2.撤销分区表生命周期
select * from A where gender="male";#1.查看分区表,需要指定分区where
alter table A add if not exists partition(gender="unknown");#2.分区表增加分区gender=“unknown”
insert into A partition(gender="unknown") select 7,"someone";#3.指定分区unknow插入一条(7,someone)的数据
alter table A partition(gender="unknown") rename to partition(gender="trans");#4.将unknown分区名改为trans
alter table A merge partition(gender="male"),partition(gender="trans") overwrite partition(gender="unknow") purge;#5.将male和trans分区合并为unknow分区
alter table A rename to a_new;#6.修改表名A为a_new
alter table a_new add columns(desc string);#7.表加一列
create view v as select * from a_new;#1.创建视图
2.3.2DML
1. クエリ
list tables;#1.列出库内所有的表
select name,gender from aa;#2.查看aa表的name和gender两列
select name,gender from aa group by name,gender;#3.通过分组group by对这两列进行去重
select distinct name,gender from aa;#4.通过distinct对这两列进行去重
select * from aa limit 2;#5.查看aa表前两行
select * from (select * from aa where gender = 'female') a join (select * from aa where id = '21' and name = 'ki')b on a.id = b.id;#6.子查询
2.挿入
insert into aa values(10,'dz','female');#1.aa表插入一行数据
create table aa2 like aa;#2.做一个aa的备份表,拿结构不拿数据
insert into aa2 select * from aa;2.把aa的数据全追加到aa2
insert overwrite table aa2 select * from aa;2.把aa的数据全覆盖到aa2,aa2里原数据删掉了
3. パーティションテーブル
create table t_class_p (id int,name string)partitioned by(gender string);#1.创建分区表,gender分区
from aa insert into t_class_p partition(gender = '1') select id,name where id = 10 insert into t_class_p partition(gender = '2') select id,name where id = 11 insert into t_class_p partition(gender = '3') select id,name where id = 12;#2.多路输出,从aa表给分区表分别插入三个数据
set odps.sql.allow.fullscan =true;#3.设置分区表可以全局扫描
select * from t_class_p;#4.查询分区表所有内容
4. 支払う、結合する、補う、結合する
create table a1 as select * from aa where gender="female";#1.从aa表里分出gender为female的建表a1
create table a2 as select * from aa where gender="male";#2.从aa表里分出gender为male的建表a2
select id from a1 union all select id from a2;#3.a1表的id和a2表的id通过unio all求并集
select id from a1 union select id from a2;#4.使用union并集去重
select id from a1 intersect all select id from a2;#5.a1表的id和a2表的id通过intersect求交集
select id from a1 except all select id from a2;#6.使用except all求补集,在a1存在但在a2不存在
2.3.3 組み込み関数
1. 数学的演算と文字処理
select 0.5*10*20*sin(60/180*3.1415926);#1.sin三角函数
select ceil(3.1415926),floor(3.1415926),round(3.1415926),trunc(3.1415926),conv('3.1415926',10,2);#2.ceil向上取整,floor向下取整,round四舍五入,trunc截取,conv10进制转换2进制。
select rand();#3.随机值,可以给种子
select abs(-2);#4.abs取绝对值
select power(-2,5);#5.-2的5次方
select sqrt(16);#6.16的均方根
select length("dacadc中文");#7.字符串长度,每个中文1个字符
select length("dacadc中文");#8.字符串长度,每个中文3个字符
select char_matchcount('asdf','asbrgdgf');#9.字符串1里面有几个在字符串2里面出现
select is_encoding("测试","utf-8");#10.测试编码是否utf-8
select instr("sdsdvfg","s");#11第2个字符在第1个字符的哪一个位置第一次出现,以1开头计数
select substr("dasdf",2,3);#从第2个字符开始剪切,剪切长度为3
2. 日付処理とウィンドウ関数
select getdate();#1.查询系统日期
select datediff(datetime '2022-06-18 20:00:00',datetime '2022-06-15 19:00:00','dd');#2.查看两个时间相差几天
select unix_timestamp(datetime '2022-06-13 20:00:00');#3.时间转换成时间戳
select from_unixtime(1655121600);#4.时间戳转换成时间
3. 集計およびその他の機能
在这里插入代码片
2.4 UDF 開発の基礎
ユーザー定義関数
2.5 MR開発の基礎
MapReduce は、大規模なデータ セット (1 TB を超える) に対する並列操作のためのプログラミング モデルです。彼らの主なアイデアである「Map」と「Reduce」という概念は、関数型プログラミング言語から借用したものであり、ベクトル プログラミング言語から借用した機能も同様です。これにより、プログラマーは分散並列プログラミングを行わずに分散システム上でプログラムを実行することが非常に容易になります。現在のソフトウェア実装では、一連のキーと値のペアを新しい一連のキーと値のペアにマッピングする Map (マッピング) 関数を指定し、マッピングされたすべてのキーと値のペアが確実に一致するようにする同時 Reduce (リダクション) 関数を指定します。それぞれが同じキーのセットを共有します。
作成: 3 つの Java ファイルをマップ、リデュース、ドライブする
2.6 グラフ開発の基本
2.7 権限とセキュリティ
show grants;#1.查看此用户在此项目下的权限
3. ビッグデータ開発・ガバナンスプラットフォーム Dataworks
3.1 データ統合
1. まず新しいデータソースを作成します。ここではmysqlデータソースを構築します。
3.2 データ開発
3.3 タスクの運用と保守
3.4 データ管理
4. データ可視化分析プラットフォームQuick Bi
5.機械学習プラットフォームPAI
1. Alibaba Cloud pai を開きます。
2. ワークフローを作成して入力します。
3.赤ワインで分類されたデータセットをダウンロードし、データをワークスペースにインポートします。
操作については、https://blog.csdn.net/wyn_365/article/details/107284561 を参照してください。