1
2////////////////////////////////////////////////////////////////////
3////////////////////////////////////////////////////////////////////
4// THIS FILE IS GENERATED BY gentpcecode.py, DO NOT EDIT MANUALLY //
5////////////////////////////////////////////////////////////////////
6////////////////////////////////////////////////////////////////////
7
8
9#include "tpce_generated.hpp"
10
11using namespace duckdb;
12using namespace std;
13
14namespace TPCE {
15struct tpce_append_information {
16 tpce_append_information(Connection &con, string schema, string table) :
17 appender(con, schema, table) {}
18
19 Appender appender;
20};
21
22static void append_value(tpce_append_information &info, int32_t value) {
23 info.appender.Append<int32_t>(value);
24}
25
26static void append_bigint(tpce_append_information &info, int64_t value) {
27 info.appender.Append<int64_t>(value);
28}
29
30static void append_string(tpce_append_information &info, const char *value) {
31 info.appender.Append<Value>(Value(value));
32}
33
34static void append_double(tpce_append_information &info, double value) {
35 info.appender.Append<double>(value);
36}
37
38static void append_bool(tpce_append_information &info, bool value) {
39 info.appender.Append<bool>(value);
40}
41
42static void append_timestamp(tpce_append_information &info, CDateTime time) {
43 info.appender.Append<int64_t>(0); // Timestamp::FromString(time.ToStr(1));
44}
45
46void append_char(tpce_append_information &info, char value) {
47 char val[2];
48 val[0] = value;
49 val[1] = '\0';
50 append_string(info, val);
51}
52
53template <typename T> class DuckDBBaseLoader : public CBaseLoader<T> {
54 protected:
55 tpce_append_information info;
56
57 public:
58 DuckDBBaseLoader(Connection &con, string schema, string table) :
59 info(con, schema, table) {
60 }
61
62 void FinishLoad() {
63
64 }
65};
66
67
68class DuckDBAccountPermissionLoad : public DuckDBBaseLoader<ACCOUNT_PERMISSION_ROW> {
69public:
70 DuckDBAccountPermissionLoad(Connection &con, string schema, string table) :
71 DuckDBBaseLoader(con, schema, table) {
72
73 }
74
75 void WriteNextRecord(const ACCOUNT_PERMISSION_ROW &next_record) {
76 info.appender.BeginRow();
77 append_bigint(info, next_record.AP_CA_ID);
78 append_string(info, next_record.AP_ACL);
79 append_string(info, next_record.AP_TAX_ID);
80 append_string(info, next_record.AP_L_NAME);
81 append_string(info, next_record.AP_F_NAME);
82 info.appender.EndRow();
83 }
84
85};
86class DuckDBAddressLoad : public DuckDBBaseLoader<ADDRESS_ROW> {
87public:
88 DuckDBAddressLoad(Connection &con, string schema, string table) :
89 DuckDBBaseLoader(con, schema, table) {
90
91 }
92
93 void WriteNextRecord(const ADDRESS_ROW &next_record) {
94 info.appender.BeginRow();
95 append_bigint(info, next_record.AD_ID);
96 append_string(info, next_record.AD_LINE1);
97 append_string(info, next_record.AD_LINE2);
98 append_string(info, next_record.AD_ZC_CODE);
99 append_string(info, next_record.AD_CTRY);
100 info.appender.EndRow();
101 }
102
103};
104class DuckDBBrokerLoad : public DuckDBBaseLoader<BROKER_ROW> {
105public:
106 DuckDBBrokerLoad(Connection &con, string schema, string table) :
107 DuckDBBaseLoader(con, schema, table) {
108
109 }
110
111 void WriteNextRecord(const BROKER_ROW &next_record) {
112 info.appender.BeginRow();
113 append_bigint(info, next_record.B_ID);
114 append_string(info, next_record.B_ST_ID);
115 append_string(info, next_record.B_NAME);
116 append_value(info, next_record.B_NUM_TRADES);
117 append_double(info, next_record.B_COMM_TOTAL);
118 info.appender.EndRow();
119 }
120
121};
122class DuckDBCashTransactionLoad : public DuckDBBaseLoader<CASH_TRANSACTION_ROW> {
123public:
124 DuckDBCashTransactionLoad(Connection &con, string schema, string table) :
125 DuckDBBaseLoader(con, schema, table) {
126
127 }
128
129 void WriteNextRecord(const CASH_TRANSACTION_ROW &next_record) {
130 info.appender.BeginRow();
131 append_bigint(info, next_record.CT_T_ID);
132 append_timestamp(info, next_record.CT_DTS);
133 append_double(info, next_record.CT_AMT);
134 append_string(info, next_record.CT_NAME);
135 info.appender.EndRow();
136 }
137
138};
139class DuckDBChargeLoad : public DuckDBBaseLoader<CHARGE_ROW> {
140public:
141 DuckDBChargeLoad(Connection &con, string schema, string table) :
142 DuckDBBaseLoader(con, schema, table) {
143
144 }
145
146 void WriteNextRecord(const CHARGE_ROW &next_record) {
147 info.appender.BeginRow();
148 append_string(info, next_record.CH_TT_ID);
149 append_value(info, next_record.CH_C_TIER);
150 append_double(info, next_record.CH_CHRG);
151 info.appender.EndRow();
152 }
153
154};
155class DuckDBCommissionRateLoad : public DuckDBBaseLoader<COMMISSION_RATE_ROW> {
156public:
157 DuckDBCommissionRateLoad(Connection &con, string schema, string table) :
158 DuckDBBaseLoader(con, schema, table) {
159
160 }
161
162 void WriteNextRecord(const COMMISSION_RATE_ROW &next_record) {
163 info.appender.BeginRow();
164 append_value(info, next_record.CR_C_TIER);
165 append_string(info, next_record.CR_TT_ID);
166 append_string(info, next_record.CR_EX_ID);
167 append_value(info, next_record.CR_FROM_QTY);
168 append_value(info, next_record.CR_TO_QTY);
169 append_double(info, next_record.CR_RATE);
170 info.appender.EndRow();
171 }
172
173};
174class DuckDBCompanyLoad : public DuckDBBaseLoader<COMPANY_ROW> {
175public:
176 DuckDBCompanyLoad(Connection &con, string schema, string table) :
177 DuckDBBaseLoader(con, schema, table) {
178
179 }
180
181 void WriteNextRecord(const COMPANY_ROW &next_record) {
182 info.appender.BeginRow();
183 append_bigint(info, next_record.CO_ID);
184 append_string(info, next_record.CO_ST_ID);
185 append_string(info, next_record.CO_NAME);
186 append_string(info, next_record.CO_IN_ID);
187 append_string(info, next_record.CO_SP_RATE);
188 append_string(info, next_record.CO_CEO);
189 append_bigint(info, next_record.CO_AD_ID);
190 append_string(info, next_record.CO_DESC);
191 append_timestamp(info, next_record.CO_OPEN_DATE);
192 info.appender.EndRow();
193 }
194
195};
196class DuckDBCompanyCompetitorLoad : public DuckDBBaseLoader<COMPANY_COMPETITOR_ROW> {
197public:
198 DuckDBCompanyCompetitorLoad(Connection &con, string schema, string table) :
199 DuckDBBaseLoader(con, schema, table) {
200
201 }
202
203 void WriteNextRecord(const COMPANY_COMPETITOR_ROW &next_record) {
204 info.appender.BeginRow();
205 append_bigint(info, next_record.CP_CO_ID);
206 append_bigint(info, next_record.CP_COMP_CO_ID);
207 append_string(info, next_record.CP_IN_ID);
208 info.appender.EndRow();
209 }
210
211};
212class DuckDBCustomerLoad : public DuckDBBaseLoader<CUSTOMER_ROW> {
213public:
214 DuckDBCustomerLoad(Connection &con, string schema, string table) :
215 DuckDBBaseLoader(con, schema, table) {
216
217 }
218
219 void WriteNextRecord(const CUSTOMER_ROW &next_record) {
220 info.appender.BeginRow();
221 append_bigint(info, next_record.C_ID);
222 append_string(info, next_record.C_TAX_ID);
223 append_string(info, next_record.C_ST_ID);
224 append_string(info, next_record.C_L_NAME);
225 append_string(info, next_record.C_F_NAME);
226 append_string(info, next_record.C_M_NAME);
227 append_char(info, next_record.C_GNDR);
228 append_char(info, next_record.C_TIER);
229 append_timestamp(info, next_record.C_DOB);
230 append_bigint(info, next_record.C_AD_ID);
231 append_string(info, next_record.C_CTRY_1);
232 append_string(info, next_record.C_AREA_1);
233 append_string(info, next_record.C_LOCAL_1);
234 append_string(info, next_record.C_EXT_1);
235 append_string(info, next_record.C_CTRY_2);
236 append_string(info, next_record.C_AREA_2);
237 append_string(info, next_record.C_LOCAL_2);
238 append_string(info, next_record.C_EXT_2);
239 append_string(info, next_record.C_CTRY_3);
240 append_string(info, next_record.C_AREA_3);
241 append_string(info, next_record.C_LOCAL_3);
242 append_string(info, next_record.C_EXT_3);
243 append_string(info, next_record.C_EMAIL_1);
244 append_string(info, next_record.C_EMAIL_2);
245 info.appender.EndRow();
246 }
247
248};
249class DuckDBCustomerAccountLoad : public DuckDBBaseLoader<CUSTOMER_ACCOUNT_ROW> {
250public:
251 DuckDBCustomerAccountLoad(Connection &con, string schema, string table) :
252 DuckDBBaseLoader(con, schema, table) {
253
254 }
255
256 void WriteNextRecord(const CUSTOMER_ACCOUNT_ROW &next_record) {
257 info.appender.BeginRow();
258 append_bigint(info, next_record.CA_ID);
259 append_bigint(info, next_record.CA_B_ID);
260 append_bigint(info, next_record.CA_C_ID);
261 append_string(info, next_record.CA_NAME);
262 append_char(info, next_record.CA_TAX_ST);
263 append_double(info, next_record.CA_BAL);
264 info.appender.EndRow();
265 }
266
267};
268class DuckDBCustomerTaxrateLoad : public DuckDBBaseLoader<CUSTOMER_TAXRATE_ROW> {
269public:
270 DuckDBCustomerTaxrateLoad(Connection &con, string schema, string table) :
271 DuckDBBaseLoader(con, schema, table) {
272
273 }
274
275 void WriteNextRecord(const CUSTOMER_TAXRATE_ROW &next_record) {
276 info.appender.BeginRow();
277 append_string(info, next_record.CX_TX_ID);
278 append_bigint(info, next_record.CX_C_ID);
279 info.appender.EndRow();
280 }
281
282};
283class DuckDBDailyMarketLoad : public DuckDBBaseLoader<DAILY_MARKET_ROW> {
284public:
285 DuckDBDailyMarketLoad(Connection &con, string schema, string table) :
286 DuckDBBaseLoader(con, schema, table) {
287
288 }
289
290 void WriteNextRecord(const DAILY_MARKET_ROW &next_record) {
291 info.appender.BeginRow();
292 append_timestamp(info, next_record.DM_DATE);
293 append_string(info, next_record.DM_S_SYMB);
294 append_double(info, next_record.DM_CLOSE);
295 append_double(info, next_record.DM_HIGH);
296 append_double(info, next_record.DM_LOW);
297 append_bigint(info, next_record.DM_VOL);
298 info.appender.EndRow();
299 }
300
301};
302class DuckDBExchangeLoad : public DuckDBBaseLoader<EXCHANGE_ROW> {
303public:
304 DuckDBExchangeLoad(Connection &con, string schema, string table) :
305 DuckDBBaseLoader(con, schema, table) {
306
307 }
308
309 void WriteNextRecord(const EXCHANGE_ROW &next_record) {
310 info.appender.BeginRow();
311 append_string(info, next_record.EX_ID);
312 append_string(info, next_record.EX_NAME);
313 append_value(info, next_record.EX_NUM_SYMB);
314 append_value(info, next_record.EX_OPEN);
315 append_value(info, next_record.EX_CLOSE);
316 append_string(info, next_record.EX_DESC);
317 append_bigint(info, next_record.EX_AD_ID);
318 info.appender.EndRow();
319 }
320
321};
322class DuckDBFinancialLoad : public DuckDBBaseLoader<FINANCIAL_ROW> {
323public:
324 DuckDBFinancialLoad(Connection &con, string schema, string table) :
325 DuckDBBaseLoader(con, schema, table) {
326
327 }
328
329 void WriteNextRecord(const FINANCIAL_ROW &next_record) {
330 info.appender.BeginRow();
331 append_bigint(info, next_record.FI_CO_ID);
332 append_value(info, next_record.FI_YEAR);
333 append_value(info, next_record.FI_QTR);
334 append_timestamp(info, next_record.FI_QTR_START_DATE);
335 append_double(info, next_record.FI_REVENUE);
336 append_double(info, next_record.FI_NET_EARN);
337 append_double(info, next_record.FI_BASIC_EPS);
338 append_double(info, next_record.FI_DILUT_EPS);
339 append_double(info, next_record.FI_MARGIN);
340 append_double(info, next_record.FI_INVENTORY);
341 append_double(info, next_record.FI_ASSETS);
342 append_double(info, next_record.FI_LIABILITY);
343 append_bigint(info, next_record.FI_OUT_BASIC);
344 append_bigint(info, next_record.FI_OUT_DILUT);
345 info.appender.EndRow();
346 }
347
348};
349class DuckDBHoldingLoad : public DuckDBBaseLoader<HOLDING_ROW> {
350public:
351 DuckDBHoldingLoad(Connection &con, string schema, string table) :
352 DuckDBBaseLoader(con, schema, table) {
353
354 }
355
356 void WriteNextRecord(const HOLDING_ROW &next_record) {
357 info.appender.BeginRow();
358 append_bigint(info, next_record.H_T_ID);
359 append_bigint(info, next_record.H_CA_ID);
360 append_string(info, next_record.H_S_SYMB);
361 append_timestamp(info, next_record.H_DTS);
362 append_double(info, next_record.H_PRICE);
363 append_value(info, next_record.H_QTY);
364 info.appender.EndRow();
365 }
366
367};
368class DuckDBHoldingHistoryLoad : public DuckDBBaseLoader<HOLDING_HISTORY_ROW> {
369public:
370 DuckDBHoldingHistoryLoad(Connection &con, string schema, string table) :
371 DuckDBBaseLoader(con, schema, table) {
372
373 }
374
375 void WriteNextRecord(const HOLDING_HISTORY_ROW &next_record) {
376 info.appender.BeginRow();
377 append_bigint(info, next_record.HH_H_T_ID);
378 append_bigint(info, next_record.HH_T_ID);
379 append_value(info, next_record.HH_BEFORE_QTY);
380 append_value(info, next_record.HH_AFTER_QTY);
381 info.appender.EndRow();
382 }
383
384};
385class DuckDBHoldingSummaryLoad : public DuckDBBaseLoader<HOLDING_SUMMARY_ROW> {
386public:
387 DuckDBHoldingSummaryLoad(Connection &con, string schema, string table) :
388 DuckDBBaseLoader(con, schema, table) {
389
390 }
391
392 void WriteNextRecord(const HOLDING_SUMMARY_ROW &next_record) {
393 info.appender.BeginRow();
394 append_bigint(info, next_record.HS_CA_ID);
395 append_string(info, next_record.HS_S_SYMB);
396 append_value(info, next_record.HS_QTY);
397 info.appender.EndRow();
398 }
399
400};
401class DuckDBIndustryLoad : public DuckDBBaseLoader<INDUSTRY_ROW> {
402public:
403 DuckDBIndustryLoad(Connection &con, string schema, string table) :
404 DuckDBBaseLoader(con, schema, table) {
405
406 }
407
408 void WriteNextRecord(const INDUSTRY_ROW &next_record) {
409 info.appender.BeginRow();
410 append_string(info, next_record.IN_ID);
411 append_string(info, next_record.IN_NAME);
412 append_string(info, next_record.IN_SC_ID);
413 info.appender.EndRow();
414 }
415
416};
417class DuckDBLastTradeLoad : public DuckDBBaseLoader<LAST_TRADE_ROW> {
418public:
419 DuckDBLastTradeLoad(Connection &con, string schema, string table) :
420 DuckDBBaseLoader(con, schema, table) {
421
422 }
423
424 void WriteNextRecord(const LAST_TRADE_ROW &next_record) {
425 info.appender.BeginRow();
426 append_string(info, next_record.LT_S_SYMB);
427 append_timestamp(info, next_record.LT_DTS);
428 append_double(info, next_record.LT_PRICE);
429 append_double(info, next_record.LT_OPEN_PRICE);
430 append_bigint(info, next_record.LT_VOL);
431 info.appender.EndRow();
432 }
433
434};
435class DuckDBNewsItemLoad : public DuckDBBaseLoader<NEWS_ITEM_ROW> {
436public:
437 DuckDBNewsItemLoad(Connection &con, string schema, string table) :
438 DuckDBBaseLoader(con, schema, table) {
439
440 }
441
442 void WriteNextRecord(const NEWS_ITEM_ROW &next_record) {
443 info.appender.BeginRow();
444 append_bigint(info, next_record.NI_ID);
445 append_string(info, next_record.NI_HEADLINE);
446 append_string(info, next_record.NI_SUMMARY);
447 append_string(info, next_record.NI_ITEM);
448 append_timestamp(info, next_record.NI_DTS);
449 append_string(info, next_record.NI_SOURCE);
450 append_string(info, next_record.NI_AUTHOR);
451 info.appender.EndRow();
452 }
453
454};
455class DuckDBNewsXRefLoad : public DuckDBBaseLoader<NEWS_XREF_ROW> {
456public:
457 DuckDBNewsXRefLoad(Connection &con, string schema, string table) :
458 DuckDBBaseLoader(con, schema, table) {
459
460 }
461
462 void WriteNextRecord(const NEWS_XREF_ROW &next_record) {
463 info.appender.BeginRow();
464 append_bigint(info, next_record.NX_NI_ID);
465 append_bigint(info, next_record.NX_CO_ID);
466 info.appender.EndRow();
467 }
468
469};
470class DuckDBSectorLoad : public DuckDBBaseLoader<SECTOR_ROW> {
471public:
472 DuckDBSectorLoad(Connection &con, string schema, string table) :
473 DuckDBBaseLoader(con, schema, table) {
474
475 }
476
477 void WriteNextRecord(const SECTOR_ROW &next_record) {
478 info.appender.BeginRow();
479 append_string(info, next_record.SC_ID);
480 append_string(info, next_record.SC_NAME);
481 info.appender.EndRow();
482 }
483
484};
485class DuckDBSecurityLoad : public DuckDBBaseLoader<SECURITY_ROW> {
486public:
487 DuckDBSecurityLoad(Connection &con, string schema, string table) :
488 DuckDBBaseLoader(con, schema, table) {
489
490 }
491
492 void WriteNextRecord(const SECURITY_ROW &next_record) {
493 info.appender.BeginRow();
494 append_string(info, next_record.S_SYMB);
495 append_string(info, next_record.S_ISSUE);
496 append_string(info, next_record.S_ST_ID);
497 append_string(info, next_record.S_NAME);
498 append_string(info, next_record.S_EX_ID);
499 append_bigint(info, next_record.S_CO_ID);
500 append_bigint(info, next_record.S_NUM_OUT);
501 append_timestamp(info, next_record.S_START_DATE);
502 append_timestamp(info, next_record.S_EXCH_DATE);
503 append_double(info, next_record.S_PE);
504 append_double(info, next_record.S_52WK_HIGH);
505 append_timestamp(info, next_record.S_52WK_HIGH_DATE);
506 append_double(info, next_record.S_52WK_LOW);
507 append_timestamp(info, next_record.S_52WK_LOW_DATE);
508 append_double(info, next_record.S_DIVIDEND);
509 append_double(info, next_record.S_YIELD);
510 info.appender.EndRow();
511 }
512
513};
514class DuckDBSettlementLoad : public DuckDBBaseLoader<SETTLEMENT_ROW> {
515public:
516 DuckDBSettlementLoad(Connection &con, string schema, string table) :
517 DuckDBBaseLoader(con, schema, table) {
518
519 }
520
521 void WriteNextRecord(const SETTLEMENT_ROW &next_record) {
522 info.appender.BeginRow();
523 append_bigint(info, next_record.SE_T_ID);
524 append_string(info, next_record.SE_CASH_TYPE);
525 append_timestamp(info, next_record.SE_CASH_DUE_DATE);
526 append_double(info, next_record.SE_AMT);
527 info.appender.EndRow();
528 }
529
530};
531class DuckDBStatusTypeLoad : public DuckDBBaseLoader<STATUS_TYPE_ROW> {
532public:
533 DuckDBStatusTypeLoad(Connection &con, string schema, string table) :
534 DuckDBBaseLoader(con, schema, table) {
535
536 }
537
538 void WriteNextRecord(const STATUS_TYPE_ROW &next_record) {
539 info.appender.BeginRow();
540 append_string(info, next_record.ST_ID);
541 append_string(info, next_record.ST_NAME);
542 info.appender.EndRow();
543 }
544
545};
546class DuckDBTaxRateLoad : public DuckDBBaseLoader<TAX_RATE_ROW> {
547public:
548 DuckDBTaxRateLoad(Connection &con, string schema, string table) :
549 DuckDBBaseLoader(con, schema, table) {
550
551 }
552
553 void WriteNextRecord(const TAX_RATE_ROW &next_record) {
554 info.appender.BeginRow();
555 append_string(info, next_record.TX_ID);
556 append_string(info, next_record.TX_NAME);
557 append_double(info, next_record.TX_RATE);
558 info.appender.EndRow();
559 }
560
561};
562class DuckDBTradeLoad : public DuckDBBaseLoader<TRADE_ROW> {
563public:
564 DuckDBTradeLoad(Connection &con, string schema, string table) :
565 DuckDBBaseLoader(con, schema, table) {
566
567 }
568
569 void WriteNextRecord(const TRADE_ROW &next_record) {
570 info.appender.BeginRow();
571 append_bigint(info, next_record.T_ID);
572 append_timestamp(info, next_record.T_DTS);
573 append_string(info, next_record.T_ST_ID);
574 append_string(info, next_record.T_TT_ID);
575 append_bool(info, next_record.T_IS_CASH);
576 append_string(info, next_record.T_S_SYMB);
577 append_value(info, next_record.T_QTY);
578 append_double(info, next_record.T_BID_PRICE);
579 append_bigint(info, next_record.T_CA_ID);
580 append_string(info, next_record.T_EXEC_NAME);
581 append_double(info, next_record.T_TRADE_PRICE);
582 append_double(info, next_record.T_CHRG);
583 append_double(info, next_record.T_COMM);
584 append_double(info, next_record.T_TAX);
585 append_bool(info, next_record.T_LIFO);
586 info.appender.EndRow();
587 }
588
589};
590class DuckDBTradeHistoryLoad : public DuckDBBaseLoader<TRADE_HISTORY_ROW> {
591public:
592 DuckDBTradeHistoryLoad(Connection &con, string schema, string table) :
593 DuckDBBaseLoader(con, schema, table) {
594
595 }
596
597 void WriteNextRecord(const TRADE_HISTORY_ROW &next_record) {
598 info.appender.BeginRow();
599 append_bigint(info, next_record.TH_T_ID);
600 append_timestamp(info, next_record.TH_DTS);
601 append_string(info, next_record.TH_ST_ID);
602 info.appender.EndRow();
603 }
604
605};
606class DuckDBTradeRequestLoad : public DuckDBBaseLoader<TRADE_REQUEST_ROW> {
607public:
608 DuckDBTradeRequestLoad(Connection &con, string schema, string table) :
609 DuckDBBaseLoader(con, schema, table) {
610
611 }
612
613 void WriteNextRecord(const TRADE_REQUEST_ROW &next_record) {
614 info.appender.BeginRow();
615 append_bigint(info, next_record.TR_T_ID);
616 append_string(info, next_record.TR_TT_ID);
617 append_string(info, next_record.TR_S_SYMB);
618 append_value(info, next_record.TR_QTY);
619 append_double(info, next_record.TR_BID_PRICE);
620 append_bigint(info, next_record.TR_B_ID);
621 info.appender.EndRow();
622 }
623
624};
625class DuckDBTradeTypeLoad : public DuckDBBaseLoader<TRADE_TYPE_ROW> {
626public:
627 DuckDBTradeTypeLoad(Connection &con, string schema, string table) :
628 DuckDBBaseLoader(con, schema, table) {
629
630 }
631
632 void WriteNextRecord(const TRADE_TYPE_ROW &next_record) {
633 info.appender.BeginRow();
634 append_string(info, next_record.TT_ID);
635 append_string(info, next_record.TT_NAME);
636 append_bool(info, next_record.TT_IS_SELL);
637 append_bool(info, next_record.TT_IS_MRKT);
638 info.appender.EndRow();
639 }
640
641};
642class DuckDBWatchItemLoad : public DuckDBBaseLoader<WATCH_ITEM_ROW> {
643public:
644 DuckDBWatchItemLoad(Connection &con, string schema, string table) :
645 DuckDBBaseLoader(con, schema, table) {
646
647 }
648
649 void WriteNextRecord(const WATCH_ITEM_ROW &next_record) {
650 info.appender.BeginRow();
651 append_bigint(info, next_record.WI_WL_ID);
652 append_string(info, next_record.WI_S_SYMB);
653 info.appender.EndRow();
654 }
655
656};
657class DuckDBWatchListLoad : public DuckDBBaseLoader<WATCH_LIST_ROW> {
658public:
659 DuckDBWatchListLoad(Connection &con, string schema, string table) :
660 DuckDBBaseLoader(con, schema, table) {
661
662 }
663
664 void WriteNextRecord(const WATCH_LIST_ROW &next_record) {
665 info.appender.BeginRow();
666 append_bigint(info, next_record.WL_ID);
667 append_bigint(info, next_record.WL_C_ID);
668 info.appender.EndRow();
669 }
670
671};
672class DuckDBZipCodeLoad : public DuckDBBaseLoader<ZIP_CODE_ROW> {
673public:
674 DuckDBZipCodeLoad(Connection &con, string schema, string table) :
675 DuckDBBaseLoader(con, schema, table) {
676
677 }
678
679 void WriteNextRecord(const ZIP_CODE_ROW &next_record) {
680 info.appender.BeginRow();
681 append_string(info, next_record.ZC_CODE);
682 append_string(info, next_record.ZC_TOWN);
683 append_string(info, next_record.ZC_DIV);
684 info.appender.EndRow();
685 }
686
687};
688CBaseLoader<ACCOUNT_PERMISSION_ROW> *
689DuckDBLoaderFactory::CreateAccountPermissionLoader() {
690 return new DuckDBAccountPermissionLoad(con, schema, "account_permission" + suffix);
691}
692
693CBaseLoader<ADDRESS_ROW> *
694DuckDBLoaderFactory::CreateAddressLoader() {
695 return new DuckDBAddressLoad(con, schema, "address" + suffix);
696}
697
698CBaseLoader<BROKER_ROW> *
699DuckDBLoaderFactory::CreateBrokerLoader() {
700 return new DuckDBBrokerLoad(con, schema, "broker" + suffix);
701}
702
703CBaseLoader<CASH_TRANSACTION_ROW> *
704DuckDBLoaderFactory::CreateCashTransactionLoader() {
705 return new DuckDBCashTransactionLoad(con, schema, "cash_transaction" + suffix);
706}
707
708CBaseLoader<CHARGE_ROW> *
709DuckDBLoaderFactory::CreateChargeLoader() {
710 return new DuckDBChargeLoad(con, schema, "charge" + suffix);
711}
712
713CBaseLoader<COMMISSION_RATE_ROW> *
714DuckDBLoaderFactory::CreateCommissionRateLoader() {
715 return new DuckDBCommissionRateLoad(con, schema, "commission_rate" + suffix);
716}
717
718CBaseLoader<COMPANY_ROW> *
719DuckDBLoaderFactory::CreateCompanyLoader() {
720 return new DuckDBCompanyLoad(con, schema, "company" + suffix);
721}
722
723CBaseLoader<COMPANY_COMPETITOR_ROW> *
724DuckDBLoaderFactory::CreateCompanyCompetitorLoader() {
725 return new DuckDBCompanyCompetitorLoad(con, schema, "company_competitor" + suffix);
726}
727
728CBaseLoader<CUSTOMER_ROW> *
729DuckDBLoaderFactory::CreateCustomerLoader() {
730 return new DuckDBCustomerLoad(con, schema, "customer" + suffix);
731}
732
733CBaseLoader<CUSTOMER_ACCOUNT_ROW> *
734DuckDBLoaderFactory::CreateCustomerAccountLoader() {
735 return new DuckDBCustomerAccountLoad(con, schema, "customer_account" + suffix);
736}
737
738CBaseLoader<CUSTOMER_TAXRATE_ROW> *
739DuckDBLoaderFactory::CreateCustomerTaxrateLoader() {
740 return new DuckDBCustomerTaxrateLoad(con, schema, "customer_taxrate" + suffix);
741}
742
743CBaseLoader<DAILY_MARKET_ROW> *
744DuckDBLoaderFactory::CreateDailyMarketLoader() {
745 return new DuckDBDailyMarketLoad(con, schema, "daily_market" + suffix);
746}
747
748CBaseLoader<EXCHANGE_ROW> *
749DuckDBLoaderFactory::CreateExchangeLoader() {
750 return new DuckDBExchangeLoad(con, schema, "exchange" + suffix);
751}
752
753CBaseLoader<FINANCIAL_ROW> *
754DuckDBLoaderFactory::CreateFinancialLoader() {
755 return new DuckDBFinancialLoad(con, schema, "financial" + suffix);
756}
757
758CBaseLoader<HOLDING_ROW> *
759DuckDBLoaderFactory::CreateHoldingLoader() {
760 return new DuckDBHoldingLoad(con, schema, "holding" + suffix);
761}
762
763CBaseLoader<HOLDING_HISTORY_ROW> *
764DuckDBLoaderFactory::CreateHoldingHistoryLoader() {
765 return new DuckDBHoldingHistoryLoad(con, schema, "holding_history" + suffix);
766}
767
768CBaseLoader<HOLDING_SUMMARY_ROW> *
769DuckDBLoaderFactory::CreateHoldingSummaryLoader() {
770 return new DuckDBHoldingSummaryLoad(con, schema, "holding_summary" + suffix);
771}
772
773CBaseLoader<INDUSTRY_ROW> *
774DuckDBLoaderFactory::CreateIndustryLoader() {
775 return new DuckDBIndustryLoad(con, schema, "industry" + suffix);
776}
777
778CBaseLoader<LAST_TRADE_ROW> *
779DuckDBLoaderFactory::CreateLastTradeLoader() {
780 return new DuckDBLastTradeLoad(con, schema, "last_trade" + suffix);
781}
782
783CBaseLoader<NEWS_ITEM_ROW> *
784DuckDBLoaderFactory::CreateNewsItemLoader() {
785 return new DuckDBNewsItemLoad(con, schema, "news_item" + suffix);
786}
787
788CBaseLoader<NEWS_XREF_ROW> *
789DuckDBLoaderFactory::CreateNewsXRefLoader() {
790 return new DuckDBNewsXRefLoad(con, schema, "news_xref" + suffix);
791}
792
793CBaseLoader<SECTOR_ROW> *
794DuckDBLoaderFactory::CreateSectorLoader() {
795 return new DuckDBSectorLoad(con, schema, "sector" + suffix);
796}
797
798CBaseLoader<SECURITY_ROW> *
799DuckDBLoaderFactory::CreateSecurityLoader() {
800 return new DuckDBSecurityLoad(con, schema, "security" + suffix);
801}
802
803CBaseLoader<SETTLEMENT_ROW> *
804DuckDBLoaderFactory::CreateSettlementLoader() {
805 return new DuckDBSettlementLoad(con, schema, "settlement" + suffix);
806}
807
808CBaseLoader<STATUS_TYPE_ROW> *
809DuckDBLoaderFactory::CreateStatusTypeLoader() {
810 return new DuckDBStatusTypeLoad(con, schema, "status_type" + suffix);
811}
812
813CBaseLoader<TAX_RATE_ROW> *
814DuckDBLoaderFactory::CreateTaxRateLoader() {
815 return new DuckDBTaxRateLoad(con, schema, "tax_rate" + suffix);
816}
817
818CBaseLoader<TRADE_ROW> *
819DuckDBLoaderFactory::CreateTradeLoader() {
820 return new DuckDBTradeLoad(con, schema, "trade" + suffix);
821}
822
823CBaseLoader<TRADE_HISTORY_ROW> *
824DuckDBLoaderFactory::CreateTradeHistoryLoader() {
825 return new DuckDBTradeHistoryLoad(con, schema, "trade_history" + suffix);
826}
827
828CBaseLoader<TRADE_REQUEST_ROW> *
829DuckDBLoaderFactory::CreateTradeRequestLoader() {
830 return new DuckDBTradeRequestLoad(con, schema, "trade_request" + suffix);
831}
832
833CBaseLoader<TRADE_TYPE_ROW> *
834DuckDBLoaderFactory::CreateTradeTypeLoader() {
835 return new DuckDBTradeTypeLoad(con, schema, "trade_type" + suffix);
836}
837
838CBaseLoader<WATCH_ITEM_ROW> *
839DuckDBLoaderFactory::CreateWatchItemLoader() {
840 return new DuckDBWatchItemLoad(con, schema, "watch_item" + suffix);
841}
842
843CBaseLoader<WATCH_LIST_ROW> *
844DuckDBLoaderFactory::CreateWatchListLoader() {
845 return new DuckDBWatchListLoad(con, schema, "watch_list" + suffix);
846}
847
848CBaseLoader<ZIP_CODE_ROW> *
849DuckDBLoaderFactory::CreateZipCodeLoader() {
850 return new DuckDBZipCodeLoad(con, schema, "zip_code" + suffix);
851}
852
853static string AccountPermissionSchema(string schema, string suffix) {
854 return "CREATE TABLE " + schema + ".account_permission" + suffix + " ("
855 "ap_ca_id BIGINT,"
856 "ap_acl VARCHAR,"
857 "ap_tax_id VARCHAR,"
858 "ap_l_name VARCHAR,"
859 "ap_f_name VARCHAR)";
860}
861
862static string AddressSchema(string schema, string suffix) {
863 return "CREATE TABLE " + schema + ".address" + suffix + " ("
864 "ad_id BIGINT,"
865 "ad_line1 VARCHAR,"
866 "ad_line2 VARCHAR,"
867 "ad_zc_code VARCHAR,"
868 "ad_ctry VARCHAR)";
869}
870
871static string BrokerSchema(string schema, string suffix) {
872 return "CREATE TABLE " + schema + ".broker" + suffix + " ("
873 "b_id BIGINT,"
874 "b_st_id VARCHAR,"
875 "b_name VARCHAR,"
876 "b_num_trades INTEGER,"
877 "b_comm_total DECIMAL)";
878}
879
880static string CashTransactionSchema(string schema, string suffix) {
881 return "CREATE TABLE " + schema + ".cash_transaction" + suffix + " ("
882 "ct_t_id BIGINT,"
883 "ct_dts TIMESTAMP,"
884 "ct_amt DECIMAL,"
885 "ct_name VARCHAR)";
886}
887
888static string ChargeSchema(string schema, string suffix) {
889 return "CREATE TABLE " + schema + ".charge" + suffix + " ("
890 "ch_tt_id VARCHAR,"
891 "ch_c_tier INTEGER,"
892 "ch_chrg DECIMAL)";
893}
894
895static string CommissionRateSchema(string schema, string suffix) {
896 return "CREATE TABLE " + schema + ".commission_rate" + suffix + " ("
897 "cr_c_tier INTEGER,"
898 "cr_tt_id VARCHAR,"
899 "cr_ex_id VARCHAR,"
900 "cr_from_qty INTEGER,"
901 "cr_to_qty INTEGER,"
902 "cr_rate DECIMAL)";
903}
904
905static string CompanySchema(string schema, string suffix) {
906 return "CREATE TABLE " + schema + ".company" + suffix + " ("
907 "co_id BIGINT,"
908 "co_st_id VARCHAR,"
909 "co_name VARCHAR,"
910 "co_in_id VARCHAR,"
911 "co_sp_rate VARCHAR,"
912 "co_ceo VARCHAR,"
913 "co_ad_id BIGINT,"
914 "co_desc VARCHAR,"
915 "co_open_date TIMESTAMP)";
916}
917
918static string CompanyCompetitorSchema(string schema, string suffix) {
919 return "CREATE TABLE " + schema + ".company_competitor" + suffix + " ("
920 "cp_co_id BIGINT,"
921 "cp_comp_co_id BIGINT,"
922 "cp_in_id VARCHAR)";
923}
924
925static string CustomerSchema(string schema, string suffix) {
926 return "CREATE TABLE " + schema + ".customer" + suffix + " ("
927 "c_id BIGINT,"
928 "c_tax_id VARCHAR,"
929 "c_st_id VARCHAR,"
930 "c_l_name VARCHAR,"
931 "c_f_name VARCHAR,"
932 "c_m_name VARCHAR,"
933 "c_gndr VARCHAR,"
934 "c_tier VARCHAR,"
935 "c_dob TIMESTAMP,"
936 "c_ad_id BIGINT,"
937 "c_ctry_1 VARCHAR,"
938 "c_area_1 VARCHAR,"
939 "c_local_1 VARCHAR,"
940 "c_ext_1 VARCHAR,"
941 "c_ctry_2 VARCHAR,"
942 "c_area_2 VARCHAR,"
943 "c_local_2 VARCHAR,"
944 "c_ext_2 VARCHAR,"
945 "c_ctry_3 VARCHAR,"
946 "c_area_3 VARCHAR,"
947 "c_local_3 VARCHAR,"
948 "c_ext_3 VARCHAR,"
949 "c_email_1 VARCHAR,"
950 "c_email_2 VARCHAR)";
951}
952
953static string CustomerAccountSchema(string schema, string suffix) {
954 return "CREATE TABLE " + schema + ".customer_account" + suffix + " ("
955 "ca_id BIGINT,"
956 "ca_b_id BIGINT,"
957 "ca_c_id BIGINT,"
958 "ca_name VARCHAR,"
959 "ca_tax_st VARCHAR,"
960 "ca_bal DECIMAL)";
961}
962
963static string CustomerTaxrateSchema(string schema, string suffix) {
964 return "CREATE TABLE " + schema + ".customer_taxrate" + suffix + " ("
965 "cx_tx_id VARCHAR,"
966 "cx_c_id BIGINT)";
967}
968
969static string DailyMarketSchema(string schema, string suffix) {
970 return "CREATE TABLE " + schema + ".daily_market" + suffix + " ("
971 "dm_date TIMESTAMP,"
972 "dm_s_symb VARCHAR,"
973 "dm_close DECIMAL,"
974 "dm_high DECIMAL,"
975 "dm_low DECIMAL,"
976 "dm_vol BIGINT)";
977}
978
979static string ExchangeSchema(string schema, string suffix) {
980 return "CREATE TABLE " + schema + ".exchange" + suffix + " ("
981 "ex_id VARCHAR,"
982 "ex_name VARCHAR,"
983 "ex_num_symb INTEGER,"
984 "ex_open INTEGER,"
985 "ex_close INTEGER,"
986 "ex_desc VARCHAR,"
987 "ex_ad_id BIGINT)";
988}
989
990static string FinancialSchema(string schema, string suffix) {
991 return "CREATE TABLE " + schema + ".financial" + suffix + " ("
992 "fi_co_id BIGINT,"
993 "fi_year INTEGER,"
994 "fi_qtr INTEGER,"
995 "fi_qtr_start_date TIMESTAMP,"
996 "fi_revenue DECIMAL,"
997 "fi_net_earn DECIMAL,"
998 "fi_basic_eps DECIMAL,"
999 "fi_dilut_eps DECIMAL,"
1000 "fi_margin DECIMAL,"
1001 "fi_inventory DECIMAL,"
1002 "fi_assets DECIMAL,"
1003 "fi_liability DECIMAL,"
1004 "fi_out_basic BIGINT,"
1005 "fi_out_dilut BIGINT)";
1006}
1007
1008static string HoldingSchema(string schema, string suffix) {
1009 return "CREATE TABLE " + schema + ".holding" + suffix + " ("
1010 "h_t_id BIGINT,"
1011 "h_ca_id BIGINT,"
1012 "h_s_symb VARCHAR,"
1013 "h_dts TIMESTAMP,"
1014 "h_price DECIMAL,"
1015 "h_qty INTEGER)";
1016}
1017
1018static string HoldingHistorySchema(string schema, string suffix) {
1019 return "CREATE TABLE " + schema + ".holding_history" + suffix + " ("
1020 "hh_h_t_id BIGINT,"
1021 "hh_t_id BIGINT,"
1022 "hh_before_qty INTEGER,"
1023 "hh_after_qty INTEGER)";
1024}
1025
1026static string HoldingSummarySchema(string schema, string suffix) {
1027 return "CREATE TABLE " + schema + ".holding_summary" + suffix + " ("
1028 "hs_ca_id BIGINT,"
1029 "hs_s_symb VARCHAR,"
1030 "hs_qty INTEGER)";
1031}
1032
1033static string IndustrySchema(string schema, string suffix) {
1034 return "CREATE TABLE " + schema + ".industry" + suffix + " ("
1035 "in_id VARCHAR,"
1036 "in_name VARCHAR,"
1037 "in_sc_id VARCHAR)";
1038}
1039
1040static string LastTradeSchema(string schema, string suffix) {
1041 return "CREATE TABLE " + schema + ".last_trade" + suffix + " ("
1042 "lt_s_symb VARCHAR,"
1043 "lt_dts TIMESTAMP,"
1044 "lt_price DECIMAL,"
1045 "lt_open_price DECIMAL,"
1046 "lt_vol BIGINT)";
1047}
1048
1049static string NewsItemSchema(string schema, string suffix) {
1050 return "CREATE TABLE " + schema + ".news_item" + suffix + " ("
1051 "ni_id BIGINT,"
1052 "ni_headline VARCHAR,"
1053 "ni_summary VARCHAR,"
1054 "ni_item VARCHAR,"
1055 "ni_dts TIMESTAMP,"
1056 "ni_source VARCHAR,"
1057 "ni_author VARCHAR)";
1058}
1059
1060static string NewsXrefSchema(string schema, string suffix) {
1061 return "CREATE TABLE " + schema + ".news_xref" + suffix + " ("
1062 "nx_ni_id BIGINT,"
1063 "nx_co_id BIGINT)";
1064}
1065
1066static string SectorSchema(string schema, string suffix) {
1067 return "CREATE TABLE " + schema + ".sector" + suffix + " ("
1068 "sc_id VARCHAR,"
1069 "sc_name VARCHAR)";
1070}
1071
1072static string SecuritySchema(string schema, string suffix) {
1073 return "CREATE TABLE " + schema + ".security" + suffix + " ("
1074 "s_symb VARCHAR,"
1075 "s_issue VARCHAR,"
1076 "s_st_id VARCHAR,"
1077 "s_name VARCHAR,"
1078 "s_ex_id VARCHAR,"
1079 "s_co_id BIGINT,"
1080 "s_num_out BIGINT,"
1081 "s_start_date TIMESTAMP,"
1082 "s_exch_date TIMESTAMP,"
1083 "s_pe DECIMAL,"
1084 "s_52wk_high DECIMAL,"
1085 "s_52wk_high_date TIMESTAMP,"
1086 "s_52wk_low DECIMAL,"
1087 "s_52wk_low_date TIMESTAMP,"
1088 "s_dividend DECIMAL,"
1089 "s_yield DECIMAL)";
1090}
1091
1092static string SettlementSchema(string schema, string suffix) {
1093 return "CREATE TABLE " + schema + ".settlement" + suffix + " ("
1094 "se_t_id BIGINT,"
1095 "se_cash_type VARCHAR,"
1096 "se_cash_due_date TIMESTAMP,"
1097 "se_amt DECIMAL)";
1098}
1099
1100static string StatusTypeSchema(string schema, string suffix) {
1101 return "CREATE TABLE " + schema + ".status_type" + suffix + " ("
1102 "st_id VARCHAR,"
1103 "st_name VARCHAR)";
1104}
1105
1106static string TaxRateSchema(string schema, string suffix) {
1107 return "CREATE TABLE " + schema + ".tax_rate" + suffix + " ("
1108 "tx_id VARCHAR,"
1109 "tx_name VARCHAR,"
1110 "tx_rate DECIMAL)";
1111}
1112
1113static string TradeSchema(string schema, string suffix) {
1114 return "CREATE TABLE " + schema + ".trade" + suffix + " ("
1115 "t_id BIGINT,"
1116 "t_dts TIMESTAMP,"
1117 "t_st_id VARCHAR,"
1118 "t_tt_id VARCHAR,"
1119 "t_is_cash BOOLEAN,"
1120 "t_s_symb VARCHAR,"
1121 "t_qty INTEGER,"
1122 "t_bid_price DECIMAL,"
1123 "t_ca_id BIGINT,"
1124 "t_exec_name VARCHAR,"
1125 "t_trade_price DECIMAL,"
1126 "t_chrg DECIMAL,"
1127 "t_comm DECIMAL,"
1128 "t_tax DECIMAL,"
1129 "t_lifo BOOLEAN)";
1130}
1131
1132static string TradeHistorySchema(string schema, string suffix) {
1133 return "CREATE TABLE " + schema + ".trade_history" + suffix + " ("
1134 "th_t_id BIGINT,"
1135 "th_dts TIMESTAMP,"
1136 "th_st_id VARCHAR)";
1137}
1138
1139static string TradeRequestSchema(string schema, string suffix) {
1140 return "CREATE TABLE " + schema + ".trade_request" + suffix + " ("
1141 "tr_t_id BIGINT,"
1142 "tr_tt_id VARCHAR,"
1143 "tr_s_symb VARCHAR,"
1144 "tr_qty INTEGER,"
1145 "tr_bid_price DECIMAL,"
1146 "tr_b_id BIGINT)";
1147}
1148
1149static string TradeTypeSchema(string schema, string suffix) {
1150 return "CREATE TABLE " + schema + ".trade_type" + suffix + " ("
1151 "tt_id VARCHAR,"
1152 "tt_name VARCHAR,"
1153 "tt_is_sell BOOLEAN,"
1154 "tt_is_mrkt BOOLEAN)";
1155}
1156
1157static string WatchItemSchema(string schema, string suffix) {
1158 return "CREATE TABLE " + schema + ".watch_item" + suffix + " ("
1159 "wi_wl_id BIGINT,"
1160 "wi_s_symb VARCHAR)";
1161}
1162
1163static string WatchListSchema(string schema, string suffix) {
1164 return "CREATE TABLE " + schema + ".watch_list" + suffix + " ("
1165 "wl_id BIGINT,"
1166 "wl_c_id BIGINT)";
1167}
1168
1169static string ZipCodeSchema(string schema, string suffix) {
1170 return "CREATE TABLE " + schema + ".zip_code" + suffix + " ("
1171 "zc_code VARCHAR,"
1172 "zc_town VARCHAR,"
1173 "zc_div VARCHAR)";
1174}
1175
1176void CreateTPCESchema(duckdb::DuckDB &db, duckdb::Connection &con, std::string &schema, std::string &suffix) {
1177 con.Query(AccountPermissionSchema(schema, suffix));
1178 con.Query(AddressSchema(schema, suffix));
1179 con.Query(BrokerSchema(schema, suffix));
1180 con.Query(CashTransactionSchema(schema, suffix));
1181 con.Query(ChargeSchema(schema, suffix));
1182 con.Query(CommissionRateSchema(schema, suffix));
1183 con.Query(CompanySchema(schema, suffix));
1184 con.Query(CompanyCompetitorSchema(schema, suffix));
1185 con.Query(CustomerSchema(schema, suffix));
1186 con.Query(CustomerAccountSchema(schema, suffix));
1187 con.Query(CustomerTaxrateSchema(schema, suffix));
1188 con.Query(DailyMarketSchema(schema, suffix));
1189 con.Query(ExchangeSchema(schema, suffix));
1190 con.Query(FinancialSchema(schema, suffix));
1191 con.Query(HoldingSchema(schema, suffix));
1192 con.Query(HoldingHistorySchema(schema, suffix));
1193 con.Query(HoldingSummarySchema(schema, suffix));
1194 con.Query(IndustrySchema(schema, suffix));
1195 con.Query(LastTradeSchema(schema, suffix));
1196 con.Query(NewsItemSchema(schema, suffix));
1197 con.Query(NewsXrefSchema(schema, suffix));
1198 con.Query(SectorSchema(schema, suffix));
1199 con.Query(SecuritySchema(schema, suffix));
1200 con.Query(SettlementSchema(schema, suffix));
1201 con.Query(StatusTypeSchema(schema, suffix));
1202 con.Query(TaxRateSchema(schema, suffix));
1203 con.Query(TradeSchema(schema, suffix));
1204 con.Query(TradeHistorySchema(schema, suffix));
1205 con.Query(TradeRequestSchema(schema, suffix));
1206 con.Query(TradeTypeSchema(schema, suffix));
1207 con.Query(WatchItemSchema(schema, suffix));
1208 con.Query(WatchListSchema(schema, suffix));
1209 con.Query(ZipCodeSchema(schema, suffix));
1210}
1211
1212} /* namespace TPCE */
1213