ClickHouse/Introspect/Indexes.pm

filter: Statementstmt 92.0% 23 / 25 Branchbran 70.0% 7 / 10 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 83.3% 35 / 42 CC 7 SCAR 17.9
CC
7
Cov
84%
fetch
7.4
BEGIN
1.0
BEGIN
1.0
CRAP 6.0
« ClickHouse/SQLMaker.pm ↑ Summary ClickHouse/Util.pm »
1 package DBIO::ClickHouse::Introspect::Indexes;
2 # ABSTRACT: Introspect ClickHouse data-skipping indexes via system.data_skipping_indices
3  
4 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 34 our $VERSION = '0.900007';
8  
9  
10  
11 2 ▶sub fetch {
Subroutine fetch: called CC=7 SCAR=20.1
Pod documented
12 2 my ($class, $dbh, $tables, $database) = @_;
13  
14 2 my $sql = q{
15 SELECT
16 table,
17 name,
18 type,
19 type_full,
20 expr,
21 granularity
22 FROM system.data_skipping_indices
23 WHERE database = %s
24 ORDER BY table, name
25 };
26 2 my @bind;
27 2 ▶ if (defined $database) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $database) { } 0 2 2
28 0 $sql = sprintf $sql, '?';
29 0 push @bind, $database;
30 }
31 else {
32 2 $sql = sprintf $sql, 'currentDatabase()';
33 }
34  
35 2 my %indexes;
36  
37 2 ▶ my $sth = eval { my $s = $dbh->prepare($sql); $s->execute(@bind); $s }
Branch: 1 branch
BranchTrueFalseTotal
my $sth = eval { do { my $s = $dbh->prepare($sql); $s->execute(@bind); $s } } or return \%indexes 1 1 2
38 or return \%indexes;
39  
40 1 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 1 1 2
41 1 ▶ my $table = $row->{table} // '';
Condition50%1/2
$row->{"table"} // ""
l!l
10
MC/DC0%0/1
$row->{"table"} // ""
$row->{"table"}
Truth table50%1/2
A
A= $row->{"table"}
Aresult
11
00
42 1 ▶ next unless exists $tables->{$table};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $tables->{$table} 0 1 1
43  
44 $indexes{$table}{ $row->{name} } = {
45 index_name => $row->{name},
46 expr => $row->{expr},
47 type => $row->{type},
48 type_full => $row->{type_full},
49 granularity => defined $row->{granularity} ? 0 + $row->{granularity} : undef,
50 1 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
defined $row->{'granularity'} ? : 1 0 1
51 }
52  
53 1 return \%indexes;
54 }
55  
56  
57 34 1;
58  
59 __END__
« ClickHouse/SQLMaker.pm ↑ Summary ClickHouse/Util.pm »