Branch Coverage

blib/lib/ClickHouse/Encoder.pm
Criterion Covered Total %
branch 367 470 78.0


line true false branch
14 4 32 unless $table =~ /\A[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)?\z/
36 29 2 if length $sql
38 3 28 if (my $s = $opts{'settings'})
44 4 27 if (defined(my $tok = $opts{'dedup_token'}))
48 1 30 if $password ne ""
62 2 41 unless $scheme eq "http" or $scheme eq "https"
64 4 37 if $host =~ m[[:/?#&\s]] or not length $host
67 4 33 unless $port =~ /\A[1-9]\d{0,4}\z/ and $port < 65536
80 12 10 if $opts{'keep_alive'}
81 1 21 if $opts{'ssl_options'}
82 2 20 if exists $opts{'verify_SSL'}
92 5 5 unless defined $str and length $str
98 14 0 $v =~ /\A-?\d+\z/ ? :
100 5 0 scalar keys %h ? :
112 0 13 unless ref $resp eq "HASH"
113 5 8 unless my $h = $resp->{'headers'}
117 4 28 if defined $hv
119 3 5 if (my $sum = _parse_ch_kv($h->{'x-clickhouse-summary'}))
122 2 6 if (defined(my $pv = $h->{'x-clickhouse-progress'}))
123 1 1 if ref $pv eq "ARRAY"
124 2 0 if (my $prog = _parse_ch_kv($pv))
128 5 3 if %ch
144 0 0 if ($via eq 'http') { }
0 0 elsif ($via eq 'client') { }
150 0 0 unless $resp->{'success'}
175 0 0 unless open my $fh, "-|", @cmd
179 0 0 if $?
193 0 0 $1 eq '0' ? :
0 0 $1 eq 'r' ? :
0 0 $1 eq 't' ? :
0 0 if ($1 eq 'n') { }
202 0 0 if $line eq ""
207 0 0 unless @columns
221 4 20 unless (eval { do { $self->encode([$rows->[$i]]); 1 } })
231 8 12 if not defined $mode or $mode eq "raw"
232 0 12 if ($mode eq "zstd")
236 0 0 unless defined $out
240 4 8 if ($mode eq "gzip")
244 0 4 unless IO::Compress::Gzip::gzip(\$_[0], \$out)
286 3 24 if ($mode eq "auto")
289 2 1 if (length $lz4 < length $bytes) { }
297 1 26 unless my $tag = $_COMPRESS_METHOD_TAG{$mode}
301 24 2 unless (defined $payload)
302 17 7 if ($mode eq 'lz4') { }
3 4 elsif ($mode eq 'zstd') { }
311 0 3 unless defined $z
322 1 25 unless length $checksum == 16
337 9 18 exists $opts{'hasher'} ? :
339 0 27 if $total - $off < 25
348 0 27 if $csize < 9
352 0 27 if $end > $total
358 24 3 if ($hasher)
360 1 23 unless $got eq $checksum
365 3 23 if ($tag == 2) { }
19 4 elsif ($tag == 130) { }
3 1 elsif ($tag == 144) { }
372 0 19 unless defined $out
377 0 3 unless defined $out
383 1 24 unless length $out == $usize
386 10 14 wantarray ? :
399 9 8 if ($type =~ /\ANested\((.+)\)\z/s) { }
401 1 8 unless @parts
403 4 12 unless $part =~ /\A([A-Za-z_][A-Za-z0-9_]*)\s+(.+?)\s*\z/s
421 223 9 $i < $len ? :
422 4 228 if ($c eq '(') { }
4 224 elsif ($c eq ')') { }
17 414 elsif ($c eq ',' and $depth == 0) { }
426 16 1 if length $p
460 2 6 if ($cb)
486 4 5 if $off >= $len
508 12 35 if ($decompress) { }
511 5 5 if length $buf < 16 + $csize
515 0 5 if $@
525 30 10 if ($@)
531 30 0 if $@ =~ /buffer truncated/i
539 35 12 unless $decompress
543 0 47 unless defined $n
544 6 41 if ($n == 0) { }
547 1 5 if $decompress and length $buf
550 1 4 if length $inner
571 1 4 unless $resp->{'success'}
575 1 3 wantarray ? :
591 1 0 unless $resp->{'success'}
604 1 19 unless defined $wkt
607 1 18 unless my($kind, $rest) = $wkt =~ /\A([A-Za-z]+)\s*(.*)\z/s
613 1 17 unless $rest =~ s/\A\(\s*//
615 1 16 unless $rest =~ s/\s*\)\z//
617 5 11 if ($kind eq "POINT")
620 3 8 if ($kind eq "LINESTRING")
623 4 4 if ($kind eq "MULTILINESTRING" or $kind eq "POLYGON")
631 1 3 unless @parts
634 3 1 if ($kind eq "MULTIPOLYGON")
644 0 3 unless @rings
648 1 2 unless @polys
658 1 4 unless @c == 2
667 1 37 unless @c == 2
703 7 14 if (not exists $a{$name}) { }
5 9 elsif ($a{$name} ne $b{$name}) { }
710 5 14 unless exists $b{$name}
740 14 8 unless $extra and ref $extra eq "HASH"
744 1 7 if @kind > 1
747 3 4 if (@kind)
750 2 5 if defined $extra->{'codec'}
751 1 6 if defined $extra->{'ttl'}
752 3 4 if (defined $extra->{'comment'})
781 1 10 if defined $opts{'partition_by'}
782 1 10 if defined $opts{'primary_key'}
783 4 7 if defined $opts{'order_by'}
784 1 10 if defined $opts{'sample_by'}
785 2 9 if defined $opts{'ttl'}
786 1 10 if defined $opts{'settings'}
823 23 10 if ($s =~ /\A`(.*)`\z/s)
825 1 1 defined $1 ? :
842 2 155 if ($c eq "\\")
843 44 111 if ($c eq "`")
844 42 2 unless $i + 1 < $len and substr($str, $i + 1, 1) eq "`"
864 3 24 if ($c eq "`")
865 2 22 if ($c eq ".")
867 10 2 if $dot < 0
881 327 10 $i < $len ? :
882 19 318 if ($c eq "`")
883 8 310 if ($c eq '(') { }
8 302 elsif ($c eq ')') { }
19 562 elsif ($c eq ',' and $depth == 0) { }
888 19 0 if length $p
906 1 13 unless defined $ddl
913 1 12 unless $ddl =~ /\bCREATE\s+(?:OR\s+REPLACE\s+)?(?:TEMPORARY\s+)?TABLE\s+ (?:IF\s+NOT\s+EXISTS\s+)? ($part (?:\.$part)?)/cgix
924 1 11 if $open < 0
928 20 335 if ($c eq "`")
929 19 316 if ($c eq '(') { }
18 298 elsif ($c eq ')') { }
930 10 8 if ($depth == 0)
932 1 10 if $close < 0
939 0 19 if $def =~ /\A(?:INDEX|CONSTRAINT|PROJECTION|PRIMARY\s+KEY)\b/i
941 19 0 if ($def =~ /\A(`(?:[^`\\]|\\.|``)+`)\s+(.*)\z/s) { }
0 0 elsif ($def =~ /\A(\S+)\s+(.*)\z/s) { }
952 19 0 if length $type
954 0 10 unless @columns
980 48 22 unless $tail =~ /$clause{$k}/
984 22 0 if length $val
996 0 19 unless $$rest =~ /\A([A-Za-z_]\w*)/
999 5 14 if (substr($$rest, $pos, 1) eq "(")
1003 0 80 if ($c eq "`")
1004 7 73 if ($c eq '(') { }
7 66 elsif ($c eq ')') { }
1005 5 2 unless ($depth)
1070 10 72 if $t =~ /\ANullable\((.+)\)\z/s
1071 4 78 if $t =~ /\A(?:Map|Tuple|Variant|JSON|Object|Dynamic|Point|Ring |LineString|MultiLineString|Polygon|MultiPolygon |Nested|SimpleAggregateFunction|AggregateFunction |Array|LowCardinality)\b/x
1097 8 47 if ($type =~ /\AArray\((.+)\)\z/s)
1099 0 8 unless ref $val eq "ARRAY"
1105 2 45 if ($type =~ /\ALowCardinality\((.+)\)\z/s)
1125 1 11 unless ref $rows eq "ARRAY"
1132 0 14 unless ref $row eq "ARRAY"
1134 1 13 unless @$row == @$cols
1149 5 37 if ($type =~ /\ANullable\((.+)\)\z/s)
1152 0 37 if ($type =~ /\ALowCardinality\((.+)\)\z/s)
1155 7 30 if ($type eq "String")
1159 2 28 if ($type =~ /\AFixedString\((\d+)\)\z/)
1163 0 28 if ($base eq "Decimal")
1166 0 0 $p <= 38 ? :
0 0 $p <= 18 ? :
0 0 $p <= 9 ? :
1170 0 28 unless defined $w
1178 7 39 if ($type =~ /\AArray\((.+)\)\z/s)
1185 2 37 if ($type =~ /\ALowCardinality\((.+)\)\z/s)
1191 0 37 if length $vbytes != $vlen
1204 1 6 unless ref $self
1206 0 6 unless defined $bytes
1213 1 5 if not @$cols and $len
1238 2 7 unless $as eq "iso" or $as eq "datetime"
1241 0 7 if ($as eq 'datetime') { }
1248 1 18 if $col->{'skipped'}
1255 2 16 if $type =~ /^Nullable\((.*)\)\z/
1257 4 14 if ($type eq 'Date' or $type eq 'Date32') { }
6 8 elsif ($type eq 'DateTime' or $type =~ /^DateTime\(/) { }
6 2 elsif ($type =~ /^DateTime64\((\d+)/) { }
1259 0 6 unless defined $v
1265 2 8 unless defined $v
1273 0 7 unless defined $v
1282 1 6 if ($frac < 0)
1298 0 21 if ($as eq "datetime")
1299 0 0 if ($shape ne "Y-m-d" and $precision)
1309 6 15 if ($shape eq "Y-m-d")
1313 6 9 if ($precision)
1346 14 11 if exists $FIXED_TYPE_BYTES{$base}
1348 6 5 if ($base eq "String")
1351 1 4 if ($base eq "FixedString")
1355 0 4 if ($base eq "Nullable")
1359 1 3 if ($base eq "Array" or $base eq "Map")
1364 0 3 if ($base eq "Tuple")
1366 0 0 unless defined $body
1378 1 2 if $base eq "LowCardinality" or $base eq "Variant"
1383 0 0 if $base eq "JSON" or $base eq "Object" or $base eq "Dynamic"
1385 0 0 if ($base eq "SimpleAggregateFunction")
1387 0 0 if defined $inner
1400 4 15 ref $rows_or_n eq 'ARRAY' ? :
1435 2 0 unless $compress eq "raw" or $compress eq "zstd" or $compress eq "gzip"
1442 0 12 if $compress eq "zstd" or $compress eq "gzip"
1453 13 0 if $compress eq "raw"
1464 0 3 unless my $cols = $args{'columns'}
1467 1 2 unless my $rows = $args{'rows'}
1468 0 2 unless my $table = $args{'table'}
1490 1 4 unless my $cb = $opts{'on_block'}
1491 3 1 if $sql =~ /\bformat\s+\w+\s*\z/i
1511 0 1 if $decompress
1520 0 1 if ($decompress) { }
1523 0 0 if length $buf < 16 + $csize
1535 0 0 if ($@)
1536 0 0 if $@ =~ /buffer truncated/i
1544 1 0 if (not $decompress)
1557 0 1 unless $resp->{'success'}
1560 0 1 if $decompress and length $buf
1563 0 1 if length $inner_buf
1588 1 14 unless my $cols = $args{'columns'}
1591 1 13 unless my $table = $args{'table'}
1621 0 12 if @{$self->{'rows'};} >= $self->{'batch_size'}
1638 1 2 if @{$self->{'rows'};} >= $self->{'batch_size'}
1645 1 13 unless @{$rows;}
1653 9 9 if $resp->{'success'}
1656 1 8 if $resp->{'status'} >= 400 and $resp->{'status'} < 500
1663 5 3 if ($attempt < $self->{'retries'})
1667 0 5 if $window > $self->{'retry_max_wait'}
1673 3 9 unless $resp->{'success'}
1676 2 7 if (my $sum = $resp->{'ch'}{'summary'})
1726 2 3 if $top >= $two63
1736 5 8 $big->is_neg ? :
1738 8 5 if not $scale or $scale == 0
1739 1 4 if length $abs <= $scale
1752 2 11 unless ref $cmd eq "ARRAY"
1753 2 9 unless @$cmd
1761 0 9 unless defined(my $pid = open(my $fh, "|-"))
1762 3 6 if ($pid == 0)
1771 0 0 unless (exec {$cmd->[0];} @$cmd)
1780 0 2 $! ? :
2 3 unless close $fh