@@ -13,22 +13,29 @@ sudo mariadb -e "DROP DATABASE IF EXISTS test"
1313sudo mariadb -e " CREATE DATABASE test"
1414sudo mariadb test < create.sql
1515
16- # Load via DuckDB's native vectorized CSV reader (12x faster than LOAD DATA LOCAL
16+ # Load via DuckDB's native vectorized parquet reader (faster than LOAD DATA LOCAL
1717# INFILE which routes every row through MariaDB's single-threaded write_row path).
18- # hits.tsv is tab-delimited with datetime strings in TIMESTAMP columns, matching
19- # the table schema — no type conversion needed.
2018#
2119# DuckDB glob expander requires read permission on all parent directories.
2220# /home/ubuntu is mode 751 (o+x only) so DuckDB can traverse but not list it,
2321# causing "No files found" errors. Hardlink to /var/lib/mysql/ (mysql-owned,
24- # mode 755) resolves this instantly without copying 70 GB.
25- HITS_LINK=/var/lib/mysql/hits_load.tsv
26- sudo ln " $( realpath hits.tsv) " " $HITS_LINK "
27- sudo chmod 644 " $HITS_LINK "
22+ # mode 755) resolves this instantly without copying 14 GB.
23+ HITS_LINK=/var/lib/mysql/hits.parquet
24+ if [ ! -f " $HITS_LINK " ]; then
25+ sudo ln " $( realpath hits.parquet) " " $HITS_LINK "
26+ sudo chmod 644 " $HITS_LINK "
27+ fi
2828# NULLSTR '\N' matches MySQL/MariaDB convention: only \N is NULL, empty fields → ''.
2929# Without this, DuckDB treats every empty TSV field as NULL → NOT NULL violations.
30- duck " COPY test.hits FROM '$HITS_LINK ' (FORMAT CSV, DELIMITER '\t', NULLSTR '\N')"
30+ # duck "COPY test.hits FROM '$HITS_LINK' (FORMAT CSV, DELIMITER '\t', NULLSTR '\N')"
31+ duck " INSERT INTO test.hits
32+ SELECT * REPLACE (
33+ make_date(EventDate) AS EventDate,
34+ epoch_ms(EventTime * 1000) AS EventTime,
35+ epoch_ms(ClientEventTime * 1000) AS ClientEventTime,
36+ epoch_ms(LocalEventTime * 1000) AS LocalEventTime)
37+ FROM read_parquet('$HITS_LINK ', binary_as_string=True);"
3138
32- sudo rm -f " $HITS_LINK "
33- rm -f hits.tsv
39+ # sudo rm -f "$HITS_LINK"
40+ # rm -f hits.parquet
3441sync
0 commit comments