Skip to content

Commit 51a708f

Browse files
committed
adw tpcds
1 parent 9fdbf3b commit 51a708f

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

optimizer/tpcds_etabs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Run the tpcds_makex.sql in your TPC-DS schema at it will spool a new script called tpcds_etabs.sql. This spooled script will create a bunch of external tables enabling you to load the TPC-DS files generated by dsdgen.
44

5+
I have also included tpcds_makex_adw.sql. It will create external tables in ADW to load from the object store.
6+
57
The example tpcds_etabs.sql script has been tested on TPC-DS v1.4. For other versions, just run tpcds_makex.sql to create a new tpcds_etabs.sql file. The whole workflow has been tested on v1.4 and v2.5.
68

79
If you leave the script unedited, you just create a symbolic link "/tmp/tpcdsload" pointing to the directory containing all of your dsdgen files.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
set serveroutput on
2+
set feedback off
3+
set echo off
4+
set termout off
5+
6+
spool tpcds_etabs.sql
7+
8+
declare
9+
sep char(1);
10+
datat user_tab_columns.data_type%type;
11+
begin
12+
dbms_output.put_line('create or replace directory tpcsd_load_dir as ''/tmp/tpcdsload'';');
13+
for tabl in (select table_name,lower(table_name) ltnam from user_tables where table_name not in (select table_name from user_external_tables) and substr(table_name,1,2) <> 'S_' order by 1)
14+
loop
15+
dbms_output.put_line('-------------------------------------------------------------------------------');
16+
dbms_output.put_line('drop table X_'||tabl.table_name||';');
17+
dbms_output.put_line('begin');
18+
dbms_output.put_line('dbms_cloud.create_external_table(''X_'||tabl.table_name||''', credential_name=>''DEF_CRED_NAME'',');
19+
dbms_output.put_line('file_uri_list =>''https://objectstorage.YOUR_REGION.oraclecloud.com/n/CONTAINER/b/BUCKET/o/'||tabl.ltnam||'.dat'',');
20+
dbms_output.put_line('format => json_object(''delimiter'' value ''|''),');
21+
dbms_output.put_line('column_list => ''');
22+
sep := ' ';
23+
for tabc in (select * from user_tab_columns where table_name = tabl.table_name order by column_id)
24+
loop
25+
datat := tabc.data_type;
26+
if (datat = 'CHAR' or datat = 'VARCHAR2')
27+
then
28+
datat := datat||'('||tabc.data_length||')';
29+
end if;
30+
if (datat = 'NUMBER')
31+
then
32+
if (tabc.data_precision is null)
33+
then
34+
datat := datat||'(38)';
35+
else
36+
datat := datat||'('||tabc.data_precision||','||tabc.data_scale||')';
37+
end if;
38+
end if;
39+
dbms_output.put_line(sep||tabc.column_name||' '||datat);
40+
sep := ',';
41+
end loop;
42+
dbms_output.put_line(''',');
43+
sep := ' ';
44+
dbms_output.put_line('field_list => ''');
45+
for tabc in (select * from user_tab_columns where table_name = tabl.table_name order by column_id)
46+
loop
47+
if (tabc.data_type = 'DATE')
48+
then
49+
dbms_output.put_line(sep||tabc.column_name||' date "YYYY-MM-DD"');
50+
else
51+
dbms_output.put_line(sep||tabc.column_name);
52+
end if;
53+
sep := ',';
54+
end loop;
55+
dbms_output.put_line('''');
56+
dbms_output.put_line(');');
57+
dbms_output.put_line('end;');
58+
dbms_output.put_line('/');
59+
end loop;
60+
end;
61+
/
62+
63+
spool off

0 commit comments

Comments
 (0)