@@ -15,7 +15,7 @@ |
||
15 | 15 | * @param string|DataType $type The type of field. This can either be "long", "float", "double" or "string" |
16 | 16 | * |
17 | 17 | */ |
18 | - public function __construct(string $metricName, string $outputName = '', string|DataType $type = DataType::LONG) |
|
18 | + public function __construct(string $metricName, string $outputName = '', string | DataType $type = DataType::LONG) |
|
19 | 19 | { |
20 | 20 | $this->type = is_string($type) ? DataType::from(strtolower($type)) : $type; |
21 | 21 | $this->metricName = $metricName; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | public function __construct( |
103 | 103 | DruidClient $client, |
104 | 104 | string $dataSource = '', |
105 | - string|Granularity $granularity = Granularity::ALL |
|
105 | + string | Granularity $granularity = Granularity::ALL |
|
106 | 106 | ) { |
107 | 107 | $this->client = $client; |
108 | 108 | $this->query = $this; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @return $this |
126 | 126 | * @see https://druid.apache.org/docs/latest/misc/math-expr.html |
127 | 127 | */ |
128 | - public function selectVirtual(string $expression, string $as, string|DataType $outputType = DataType::STRING): self |
|
128 | + public function selectVirtual(string $expression, string $as, string | DataType $outputType = DataType::STRING): self |
|
129 | 129 | { |
130 | 130 | $this->virtualColumn($expression, $as, $outputType); |
131 | 131 | $this->select($as, $as, null, $outputType); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @throws \Level23\Druid\Exceptions\QueryResponseException |
143 | 143 | * @throws \GuzzleHttp\Exception\GuzzleException |
144 | 144 | */ |
145 | - public function execute(array|QueryContext $context = []): QueryResponse |
|
145 | + public function execute(array | QueryContext $context = []): QueryResponse |
|
146 | 146 | { |
147 | 147 | $query = $this->getQuery($context); |
148 | 148 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return $this |
160 | 160 | */ |
161 | - public function granularity(string|Granularity $granularity): QueryBuilder |
|
161 | + public function granularity(string | Granularity $granularity): QueryBuilder |
|
162 | 162 | { |
163 | 163 | $this->granularity = is_string($granularity) ? Granularity::from(strtolower($granularity)) : $granularity; |
164 | 164 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @return string |
250 | 250 | * @throws \InvalidArgumentException if the JSON cannot be encoded. |
251 | 251 | */ |
252 | - public function toJson(array|QueryContext $context = []): string |
|
252 | + public function toJson(array | QueryContext $context = []): string |
|
253 | 253 | { |
254 | 254 | $query = $this->getQuery($context); |
255 | 255 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return array<string,array<mixed>|string|int> |
265 | 265 | */ |
266 | - public function toArray(array|QueryContext $context = []): array |
|
266 | + public function toArray(array | QueryContext $context = []): array |
|
267 | 267 | { |
268 | 268 | return $this->getQuery($context)->toArray(); |
269 | 269 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @throws \Level23\Druid\Exceptions\QueryResponseException |
278 | 278 | * @throws \GuzzleHttp\Exception\GuzzleException |
279 | 279 | */ |
280 | - public function timeseries(array|TimeSeriesQueryContext $context = []): TimeSeriesQueryResponse |
|
280 | + public function timeseries(array | TimeSeriesQueryContext $context = []): TimeSeriesQueryResponse |
|
281 | 281 | { |
282 | 282 | $query = $this->buildTimeSeriesQuery($context); |
283 | 283 | |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | * @throws \GuzzleHttp\Exception\GuzzleException |
307 | 307 | */ |
308 | 308 | public function scan( |
309 | - array|ScanQueryContext $context = [], |
|
309 | + array | ScanQueryContext $context = [], |
|
310 | 310 | ?int $rowBatchSize = null, |
311 | 311 | bool $legacy = false, |
312 | - string|ScanQueryResultFormat $resultFormat = ScanQueryResultFormat::NORMAL_LIST |
|
312 | + string | ScanQueryResultFormat $resultFormat = ScanQueryResultFormat::NORMAL_LIST |
|
313 | 313 | ): ScanQueryResponse { |
314 | 314 | $query = $this->buildScanQuery($context, $rowBatchSize, $legacy, $resultFormat); |
315 | 315 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @throws \Level23\Druid\Exceptions\QueryResponseException |
328 | 328 | * @throws \GuzzleHttp\Exception\GuzzleException |
329 | 329 | */ |
330 | - public function selectQuery(array|QueryContext $context = []): SelectQueryResponse |
|
330 | + public function selectQuery(array | QueryContext $context = []): SelectQueryResponse |
|
331 | 331 | { |
332 | 332 | $query = $this->buildSelectQuery($context); |
333 | 333 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @throws \Level23\Druid\Exceptions\QueryResponseException |
346 | 346 | * @throws \GuzzleHttp\Exception\GuzzleException |
347 | 347 | */ |
348 | - public function topN(array|TopNQueryContext $context = []): TopNQueryResponse |
|
348 | + public function topN(array | TopNQueryContext $context = []): TopNQueryResponse |
|
349 | 349 | { |
350 | 350 | $query = $this->buildTopNQuery($context); |
351 | 351 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @throws \Level23\Druid\Exceptions\QueryResponseException |
364 | 364 | * @throws \GuzzleHttp\Exception\GuzzleException |
365 | 365 | */ |
366 | - public function groupBy(array|GroupByV1QueryContext|GroupByV2QueryContext $context = []): GroupByQueryResponse |
|
366 | + public function groupBy(array | GroupByV1QueryContext | GroupByV2QueryContext $context = []): GroupByQueryResponse |
|
367 | 367 | { |
368 | 368 | $query = $this->buildGroupByQuery($context); |
369 | 369 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * @throws \Level23\Druid\Exceptions\QueryResponseException |
382 | 382 | * @throws \GuzzleHttp\Exception\GuzzleException |
383 | 383 | */ |
384 | - public function groupByV1(array|GroupByV1QueryContext|GroupByV2QueryContext $context = []): GroupByQueryResponse |
|
384 | + public function groupByV1(array | GroupByV1QueryContext | GroupByV2QueryContext $context = []): GroupByQueryResponse |
|
385 | 385 | { |
386 | 386 | $query = $this->buildGroupByQuery($context, 'v1'); |
387 | 387 | |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | * @throws \Level23\Druid\Exceptions\QueryResponseException |
402 | 402 | */ |
403 | 403 | public function search( |
404 | - array|QueryContext $context = [], |
|
405 | - string|SortingOrder $sortingOrder = SortingOrder::LEXICOGRAPHIC |
|
404 | + array | QueryContext $context = [], |
|
405 | + string | SortingOrder $sortingOrder = SortingOrder::LEXICOGRAPHIC |
|
406 | 406 | ): SearchQueryResponse { |
407 | 407 | $query = $this->buildSearchQuery($context, $sortingOrder); |
408 | 408 | |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | * @return \Level23\Druid\Queries\SearchQuery |
450 | 450 | */ |
451 | 451 | protected function buildSearchQuery( |
452 | - array|QueryContext $context = [], |
|
453 | - string|SortingOrder $sortingOrder = SortingOrder::LEXICOGRAPHIC |
|
452 | + array | QueryContext $context = [], |
|
453 | + string | SortingOrder $sortingOrder = SortingOrder::LEXICOGRAPHIC |
|
454 | 454 | ): SearchQuery { |
455 | 455 | if (count($this->intervals) == 0) { |
456 | 456 | throw new InvalidArgumentException('You have to specify at least one interval'); |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return \Level23\Druid\Queries\SelectQuery |
501 | 501 | */ |
502 | - protected function buildSelectQuery(array|QueryContext $context = []): SelectQuery |
|
502 | + protected function buildSelectQuery(array | QueryContext $context = []): SelectQuery |
|
503 | 503 | { |
504 | 504 | if (count($this->intervals) == 0) { |
505 | 505 | throw new InvalidArgumentException('You have to specify at least one interval'); |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | * @return \Level23\Druid\Queries\ScanQuery |
552 | 552 | */ |
553 | 553 | protected function buildScanQuery( |
554 | - array|QueryContext $context = [], |
|
554 | + array | QueryContext $context = [], |
|
555 | 555 | ?int $rowBatchSize = null, |
556 | 556 | bool $legacy = false, |
557 | - string|ScanQueryResultFormat $resultFormat = ScanQueryResultFormat::NORMAL_LIST |
|
557 | + string | ScanQueryResultFormat $resultFormat = ScanQueryResultFormat::NORMAL_LIST |
|
558 | 558 | ): ScanQuery { |
559 | 559 | if (count($this->intervals) == 0) { |
560 | 560 | throw new InvalidArgumentException('You have to specify at least one interval'); |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * |
633 | 633 | * @return TimeSeriesQuery |
634 | 634 | */ |
635 | - protected function buildTimeSeriesQuery(array|QueryContext $context = []): TimeSeriesQuery |
|
635 | + protected function buildTimeSeriesQuery(array | QueryContext $context = []): TimeSeriesQuery |
|
636 | 636 | { |
637 | 637 | if (count($this->intervals) == 0) { |
638 | 638 | throw new InvalidArgumentException('You have to specify at least one interval'); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @return TopNQuery |
702 | 702 | */ |
703 | - protected function buildTopNQuery(array|QueryContext $context = []): TopNQuery |
|
703 | + protected function buildTopNQuery(array | QueryContext $context = []): TopNQuery |
|
704 | 704 | { |
705 | 705 | if (count($this->intervals) == 0) { |
706 | 706 | throw new InvalidArgumentException('You have to specify at least one interval'); |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | * |
774 | 774 | * @return GroupByQuery |
775 | 775 | */ |
776 | - protected function buildGroupByQuery(array|QueryContext $context = [], string $type = 'v2'): GroupByQuery |
|
776 | + protected function buildGroupByQuery(array | QueryContext $context = [], string $type = 'v2'): GroupByQuery |
|
777 | 777 | { |
778 | 778 | if (count($this->intervals) == 0) { |
779 | 779 | throw new InvalidArgumentException('You have to specify at least one interval'); |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | * |
837 | 837 | * @return \Level23\Druid\Queries\QueryInterface |
838 | 838 | */ |
839 | - public function getQuery(array|QueryContext $context = []): QueryInterface |
|
839 | + public function getQuery(array | QueryContext $context = []): QueryInterface |
|
840 | 840 | { |
841 | 841 | // Check if this is a scan query. This is the preferred way to query when there are |
842 | 842 | // no aggregations done. |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return self |
31 | 31 | */ |
32 | - public function from(DataSourceInterface|string $dataSource): self |
|
32 | + public function from(DataSourceInterface | string $dataSource): self |
|
33 | 33 | { |
34 | 34 | return $this->dataSource($dataSource); |
35 | 35 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return self |
43 | 43 | */ |
44 | - public function dataSource(DataSourceInterface|string $dataSource): self |
|
44 | + public function dataSource(DataSourceInterface | string $dataSource): self |
|
45 | 45 | { |
46 | 46 | if (is_string($dataSource)) { |
47 | 47 | $this->dataSource = new TableDataSource($dataSource); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return self |
62 | 62 | */ |
63 | - public function join(DataSourceInterface|Closure|string $dataSourceOrClosure, string $as, string $condition, string|JoinType $joinType = JoinType::INNER): self |
|
63 | + public function join(DataSourceInterface | Closure | string $dataSourceOrClosure, string $as, string $condition, string | JoinType $joinType = JoinType::INNER): self |
|
64 | 64 | { |
65 | 65 | if ($this->dataSource instanceof TableDataSource && $this->dataSource->dataSourceName == '') { |
66 | 66 | throw new InvalidArgumentException('You first have to define your "from" dataSource before you can join!'); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | string $lookupName, |
99 | 99 | string $as, |
100 | 100 | string $condition, |
101 | - string|JoinType $joinType = JoinType::INNER |
|
101 | + string | JoinType $joinType = JoinType::INNER |
|
102 | 102 | ): self { |
103 | 103 | $lookupDataSource = new LookupDataSource($lookupName); |
104 | 104 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return self |
114 | 114 | */ |
115 | - public function leftJoin(DataSourceInterface|Closure|string $dataSourceOrClosure, string $as, string $condition): self |
|
115 | + public function leftJoin(DataSourceInterface | Closure | string $dataSourceOrClosure, string $as, string $condition): self |
|
116 | 116 | { |
117 | 117 | return $this->join($dataSourceOrClosure, $as, $condition, JoinType::LEFT); |
118 | 118 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return self |
126 | 126 | */ |
127 | - public function innerJoin(DataSourceInterface|Closure|string $dataSourceOrClosure, string $as, string $condition): self |
|
127 | + public function innerJoin(DataSourceInterface | Closure | string $dataSourceOrClosure, string $as, string $condition): self |
|
128 | 128 | { |
129 | 129 | return $this->join($dataSourceOrClosure, $as, $condition); |
130 | 130 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return $this |
161 | 161 | * @see https://druid.apache.org/docs/latest/querying/datasource.html#union |
162 | 162 | */ |
163 | - public function union(array|string $dataSources, bool $append = true): self |
|
163 | + public function union(array | string $dataSources, bool $append = true): self |
|
164 | 164 | { |
165 | 165 | $dataSources = (array)$dataSources; |
166 | 166 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return DataSourceInterface |
184 | 184 | * @throws InvalidArgumentException |
185 | 185 | */ |
186 | - protected function getDataSource(DataSourceInterface|Closure|string $dataSourceOrClosure): DataSourceInterface |
|
186 | + protected function getDataSource(DataSourceInterface | Closure | string $dataSourceOrClosure): DataSourceInterface |
|
187 | 187 | { |
188 | 188 | if ($dataSourceOrClosure instanceof DataSourceInterface) { |
189 | 189 | return $dataSourceOrClosure; |
@@ -12,5 +12,5 @@ |
||
12 | 12 | { |
13 | 13 | case SORTED_ARRAY = 'SORTED_ARRAY'; |
14 | 14 | case SORTED_SET = 'SORTED_SET'; |
15 | - case ARRAY = 'ARRAY'; |
|
15 | + case array = 'ARRAY'; |
|
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | * @throws \Exception |
85 | 85 | */ |
86 | 86 | public function timeBoundary( |
87 | - string|DataSourceInterface $dataSource, |
|
88 | - null|string|TimeBound $bound = TimeBound::BOTH, |
|
87 | + string | DataSourceInterface $dataSource, |
|
88 | + null | string | TimeBound $bound = TimeBound::BOTH, |
|
89 | 89 | \Closure $filterBuilder = null, |
90 | 90 | ContextInterface $context = null |
91 | - ): DateTime|array { |
|
91 | + ): DateTime | array { |
|
92 | 92 | |
93 | 93 | $query = [ |
94 | 94 | 'queryType' => 'timeBoundary', |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | */ |
301 | 301 | protected function getColumnsForInterval( |
302 | 302 | string $dataSource, |
303 | - DateTimeInterface|int|string $start, |
|
304 | - DateTimeInterface|int|string $stop = null |
|
303 | + DateTimeInterface | int | string $start, |
|
304 | + DateTimeInterface | int | string $stop = null |
|
305 | 305 | ): array { |
306 | 306 | $response = $this->client->query($dataSource) |
307 | 307 | ->interval($start, $stop) |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | */ |
343 | 343 | public function rowCount( |
344 | 344 | string $dataSource, |
345 | - DateTimeInterface|int|string $start, |
|
346 | - DateTimeInterface|int|string $stop = null |
|
345 | + DateTimeInterface | int | string $start, |
|
346 | + DateTimeInterface | int | string $stop = null |
|
347 | 347 | ): int { |
348 | 348 | $response = $this->client->query($dataSource) |
349 | 349 | ->interval($start, $stop) |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return \Level23\Druid\Queries\QueryBuilder |
94 | 94 | */ |
95 | - public function query(string $dataSource = '', string|Granularity $granularity = Granularity::ALL): QueryBuilder |
|
95 | + public function query(string $dataSource = '', string | Granularity $granularity = Granularity::ALL): QueryBuilder |
|
96 | 96 | { |
97 | 97 | return new QueryBuilder($this, $dataSource, $granularity); |
98 | 98 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | if (!is_array($row)) { |
338 | 338 | throw new InvalidArgumentException('We failed to parse response!'); |
339 | 339 | } |
340 | - } catch (InvalidArgumentException|JsonException $exception) { |
|
340 | + } catch (InvalidArgumentException | JsonException $exception) { |
|
341 | 341 | $this->log('We failed to decode druid response. '); |
342 | 342 | $this->log('Status code: ' . $response->getStatusCode()); |
343 | 343 | $this->log('Response body: ' . $contents); |
@@ -13,13 +13,13 @@ |
||
13 | 13 | |
14 | 14 | protected ?string $ordering; |
15 | 15 | |
16 | - protected DataType|string|null $outputType; |
|
16 | + protected DataType | string | null $outputType; |
|
17 | 17 | |
18 | 18 | public function __construct( |
19 | 19 | string $outputName, |
20 | 20 | string $expression, |
21 | 21 | ?string $ordering = null, |
22 | - DataType|string|null $outputType = null |
|
22 | + DataType | string | null $outputType = null |
|
23 | 23 | |
24 | 24 | ) { |
25 | 25 | $this->outputName = $outputName; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return $this |
119 | 119 | */ |
120 | - public function quantile(string $as, Closure|string $fieldOrClosure, float $fraction): self |
|
120 | + public function quantile(string $as, Closure | string $fieldOrClosure, float $fraction): self |
|
121 | 121 | { |
122 | 122 | $fields = $this->buildFields([$fieldOrClosure]); |
123 | 123 | if ($fields->count() != 1 || !$fields[0]) { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return $this |
154 | 154 | */ |
155 | - public function quantiles(string $as, Closure|string $fieldOrClosure, array $fractions): self |
|
155 | + public function quantiles(string $as, Closure | string $fieldOrClosure, array $fractions): self |
|
156 | 156 | { |
157 | 157 | $fields = $this->buildFields([$fieldOrClosure]); |
158 | 158 | if ($fields->count() != 1 || !$fields[0]) { |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function histogram( |
195 | 195 | string $as, |
196 | - Closure|string $fieldOrClosure, |
|
196 | + Closure | string $fieldOrClosure, |
|
197 | 197 | ?array $splitPoints = null, |
198 | 198 | ?int $numBins = null |
199 | 199 | ): self { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return $this |
233 | 233 | */ |
234 | - public function rank(string $as, Closure|string $fieldOrClosure, float|int $value): self |
|
234 | + public function rank(string $as, Closure | string $fieldOrClosure, float | int $value): self |
|
235 | 235 | { |
236 | 236 | $fields = $this->buildFields([$fieldOrClosure]); |
237 | 237 | if ($fields->count() != 1 || !$fields[0]) { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return $this |
270 | 270 | */ |
271 | - public function cdf(string $as, Closure|string $fieldOrClosure, array $splitPoints): self |
|
271 | + public function cdf(string $as, Closure | string $fieldOrClosure, array $splitPoints): self |
|
272 | 272 | { |
273 | 273 | $fields = $this->buildFields([$fieldOrClosure]); |
274 | 274 | if ($fields->count() != 1 || !$fields[0]) { |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @return $this |
303 | 303 | */ |
304 | - public function sketchSummary(string $as, Closure|string $fieldOrClosure): self |
|
304 | + public function sketchSummary(string $as, Closure | string $fieldOrClosure): self |
|
305 | 305 | { |
306 | 306 | $fields = $this->buildFields([$fieldOrClosure]); |
307 | 307 | if ($fields->count() != 1 || !$fields[0]) { |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return $this |
453 | 453 | */ |
454 | - public function constant(float|int $numericValue, string $as): self |
|
454 | + public function constant(float | int $numericValue, string $as): self |
|
455 | 455 | { |
456 | 456 | $this->postAggregations[] = new ConstantPostAggregator($as, $numericValue); |
457 | 457 | |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | string $as, |
631 | 631 | string $expression, |
632 | 632 | ?string $ordering = null, |
633 | - DataType|string|null $outputType = null |
|
633 | + DataType | string | null $outputType = null |
|
634 | 634 | ): self { |
635 | 635 | $this->postAggregations[] = new ExpressionPostAggregator( |
636 | 636 | $as, |