File size: 1,657 Bytes
2eae90c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import sys

import polars as pl

scale_fac = int(sys.argv[1])

h_nation = """n_nationkey
n_name
n_regionkey
n_comment""".split(
    "\n"
)

h_region = """r_regionkey
r_name
r_comment""".split(
    "\n"
)

h_part = """p_partkey
p_name
p_mfgr
p_brand
p_type
p_size
p_container
p_retailprice
p_comment""".split(
    "\n"
)

h_supplier = """s_suppkey
s_name
s_address
s_nationkey
s_phone
s_acctbal
s_comment""".split(
    "\n"
)

h_partsupp = """ps_partkey
ps_suppkey
ps_availqty
ps_supplycost
ps_comment""".split(
    "\n"
)

h_customer = """c_custkey
c_name
c_address
c_nationkey
c_phone
c_acctbal
c_mktsegment
c_comment""".split(
    "\n"
)

h_orders = """o_orderkey
o_custkey
o_orderstatus
o_totalprice
o_orderdate
o_orderpriority
o_clerk
o_shippriority
o_comment""".split(
    "\n"
)

h_lineitem = """l_orderkey
l_partkey
l_suppkey
l_linenumber
l_quantity
l_extendedprice
l_discount
l_tax
l_returnflag
l_linestatus
l_shipdate
l_commitdate
l_receiptdate
l_shipinstruct
l_shipmode
comments""".split(
    "\n"
)

for name in [
    "nation",
    "region",
    "part",
    "supplier",
    "partsupp",
    "customer",
    "orders",
    "lineitem",
]:
    print("process table:", name)
    df = pl.read_csv(
        f"tables_scale_{scale_fac}/{name}.tbl",
        has_header=False,
        separator="|",
        try_parse_dates=True,
        new_columns=eval(f"h_{name}"),
    )
    print(df.shape)
    df = df.with_columns([pl.col(pl.Date).cast(pl.Datetime)])
    df.write_parquet(
        f"tables_scale_{scale_fac}/{name}.parquet",
        statistics=True,
        row_group_size=1024 * 512,
    )
    df.write_ipc(f"tables_scale_{scale_fac}/{name}.feather")