DROP DATABASE IF EXISTS no_results_bug;
CREATE DATABASE no_results_bug;

USE no_results_bug;

CREATE TABLE `avaya` (
`CallID` int(11) NOT NULL,
`callDate` datetime DEFAULT NULL,
`time` int(11) DEFAULT NULL,
`sec_dur` int(11) NOT NULL,
`cond_code` varchar(1) DEFAULT '',
`code_dial` varchar(4) DEFAULT '',
`code_used` varchar(4) DEFAULT '',
`dialed_num` varchar(23) DEFAULT '',
`calling_num` varchar(15) DEFAULT '',
`acct_code` varchar(15) DEFAULT '',
`auth_code` varchar(13) DEFAULT '',
`vdn` varchar(13) DEFAULT '',
`location_to` varchar(3) DEFAULT '',
`location_from` varchar(3) DEFAULT '',
`in_trk_code` varchar(4) DEFAULT '',
`frl` varchar(1) DEFAULT '',
`in_crt_id` varchar(3) DEFAULT '',
`out_crt_id` varchar(3) DEFAULT '',
`feat_flag` varchar(1) DEFAULT '',
`attd_console` varchar(2) DEFAULT '',
`node_num` varchar(2) DEFAULT '',
`ins` varchar(3) DEFAULT '',
`inx` varchar(3) DEFAULT '',
`ixc_code` varchar(3) DEFAULT '',
`bcc` varchar(1) DEFAULT '',
`ma_uui` varchar(1) DEFAULT '',
`res_flag` varchar(1) DEFAULT '',
`tsc_ct` varchar(4) DEFAULT '',
`packet_ct` varchar(4) DEFAULT '',
`tsc_flag` varchar(4) DEFAULT '',
`Hub_Site` varchar(5) DEFAULT '',
`Site_Code` varchar(5) DEFAULT '',
`Location_Code` varchar(55) DEFAULT '',
`Call_Type` varchar(25) DEFAULT '',
`Call_Direction` varchar(25) DEFAULT '',
`City` varchar(55) DEFAULT '',
`State` varchar(55) DEFAULT '',
`Country_Code` varchar(5) DEFAULT '',
`NPA` varchar(5) DEFAULT '',
`NXX` varchar(5) DEFAULT '',
`Tax` double(13,4) DEFAULT NULL,
`Cost` double(13,4) DEFAULT NULL,
`Call_Date` datetime DEFAULT NULL,
`Call_Time` time DEFAULT NULL,
`Incoming_Trunk` varchar(255) DEFAULT '',
`Outgoing_Trunk` varchar(255) DEFAULT '',
`Dialed_Digits` varchar(255) DEFAULT '',
`ANI_Digits` varchar(255) DEFAULT '',
`Call_Duration` int(11) DEFAULT NULL,
`Extension` varchar(255) DEFAULT '',
`Site_Timezone` varchar(15) DEFAULT ''
) ENGINE=Columnstore DEFAULT CHARSET=latin1;

select * from information_schema.columnstore_columns;

LOAD DATA LOCAL infile '423_cdr_avaya.txt' INTO TABLE `avaya`;

select * from information_schema.columnstore_extents;
SELECT COUNT(*) FROM `avaya` WHERE Site_Code='kch';

select * from information_schema.columnstore_extents;

LOAD DATA LOCAL infile '423_avaya.problem' INTO TABLE `avaya`;
--LOAD DATA LOCAL infile 'no-problem' INTO TABLE `avaya`;

select * from information_schema.columnstore_extents;

SELECT COUNT(*) FROM `avaya` WHERE Site_Code='kch';


