#!/bin/bash
# Load 100 rows into inventory.products, script by Edward Stoever

#CREATE TABLE `extract_quarter_example` (
#  `claim_id` int(11) NOT NULL,
#  `claim_name` varchar(11) DEFAULT NULL,
#  `claim_closing_date` date DEFAULT NULL
#) ENGINE=Columnstore DEFAULT CHARSET=utf8mb3;

rm -f /tmp/example-extract_quarter_example.tsv
mariadb -ABNe 'truncate table example.extract_quarter_example;'

 i=0
 while [ $i -ne 25000 ]
do
  i=$(($i+1))

YY=$(shuf -i10-22 -n1)
MM=$(shuf -i1-12 -n1)
MM=$(echo $MM | awk '{printf("%02d", $1)}')
DD=$(shuf -i1-28 -n1)
DD=$(echo $DD | awk '{printf("%02d", $1)}')
CHANCE=$(shuf -i1-10 -n1)

if [ "$CHANCE" = "5" ]; then
  DATESTR=''
else
  DATESTR="20$YY-$MM-$DD"
fi

if (( $i % 100 == 0 )) 
  then echo $i; 
fi 

  echo -e $(($RANDOM*10000+$RANDOM))'\t'$(openssl rand -hex 12)'\t'"$DATESTR" >> /tmp/example-extract_quarter_example.tsv
done

# import the rows:
cpimport -s '\t' example extract_quarter_example /tmp/example-extract_quarter_example.tsv
