使用hybriddb pg的外部表輸出資料到oss時,一般會輸出成多個檔案(檔案個數一般與節點數個數一致)。如何輸出為乙個檔案呢?步驟如下:
1)建立示例表:
create table test(
a1 char(30),
a2 char(30),
a3 varchar(255),
a4 varchar(255)
2)插入資料:
insert into test values('******x','yyyyy','zzzzz','wwwww');3)建立外部表寫表,按源資料表的結構建立外部表。注意:insert into test select * from test;
insert into test select * from test;
insert into test select * from test;
insert into test select * from test;
insert into test select * from test;
insert into test select * from test;
相對於本地源表的表結構,需要新增乙個臨時字段,例如dummy_col,最好作為第乙個字段。
新增output_generator_col=false
file_name_generator_col=dummy_col這兩個選項。file_name_generator_col這個引數指定a.中新增的字段。
create writable external table test_oss_write(
dummy_col text,
a1 text,
a2 text,
a3 text,
a4 text
)location('oss:
dir=oncall_test/
id=xx
key=xx
bucket=osshuadong2
oss_connect_timeout=60
oss_dns_cache_timeout=300
output_generator_col=false
file_name_generator_col=dummy_col
') format 'csv' ( delimiter ',')
distributed by (dummy_col)
;
4) 將test資料寫入到oss中。這裡為了避開我們的一些limitation,寫成了如下形式,將a1-a4和表test換成使用者的字段和表名即可。
set rds_write_oss_file_by_distribution_column=on;
explain insert into test_oss_write select x, a1, a2, a3, a4 from (select row_number() over (partition by dummy_col||dummy_col) as rn, dummy_col||dummy_col as x, a1, a2, a3, a4 from (select y as dummy_col, a1, a2, a3, a4 from test, (values(1)) as q1(y)) as q2 ) as q3;
JS中如何輸出空格
js中如何輸出空格 在寫js 的時候,大家可以會發現這樣現象 document.write 1 2 3 結果 1 2 3 無論在輸出的內容中什麼位置有多少個空格,顯示的結果好像只有乙個空格。這是因為瀏覽器顯示機制,對手動敲入的空格,將連續多個空格顯示成1個空格。解決方法 1.使用輸出html標籤 來...
JS中如何輸出空格
在寫js時會有這種情況發生 無論在輸出的內容中什麼位置有多少個空格,顯示的結果中只有乙個空格。這是因為瀏覽器顯示機制,對手動敲入的空格,將連續多個空格顯示成1個空格。輸入 document.write 1 2 3 輸出 1 2 3解決方案 1.使用輸出html標籤來解決 document.write...
JS中如何輸出空格
在寫js 的時候,大家可以會發現這樣現象 document.write 1 2 3 結果 1 2 3 無論在輸出的內容中什麼位置有多少個空格,顯示的結果好像只有乙個空格。這是因為瀏覽器顯示機制,對手動敲入的空格,將連續多個空格顯示成1個空格。解決方法 1.使用輸出html標籤 來解決 documen...