Skip to content

Commit

Permalink
Merge branch 'master' into geoSpatialInterfaces1
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavbhole committed Mar 21, 2024
2 parents 5c2a995 + e769ec7 commit f827ea7
Show file tree
Hide file tree
Showing 265 changed files with 5,886 additions and 4,009 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/revised-its.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
matrix:
#jdk: [8, 11, 17]
jdk: [8]
it: [HighAvailability, MultiStageQuery, Catalog, BatchIndex, MultiStageQueryWithMM, InputSource, InputFormat]
it: [HighAvailability, MultiStageQuery, Catalog, BatchIndex, MultiStageQueryWithMM, InputSource, InputFormat, Security]
#indexer: [indexer, middleManager]
indexer: [middleManager]
uses: ./.github/workflows/reusable-revised-its.yml
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ env:
MVN: mvn -B
MAVEN_SKIP: -P skip-static-checks -Dweb.console.skip=true -Dmaven.javadoc.skip=true
MAVEN_SKIP_TESTS: -P skip-tests
MAVEN_OPTS: -Xmx3000m
MAVEN_OPTS: -Xmx8g

jobs:
static-checks:
Expand Down Expand Up @@ -144,6 +144,28 @@ jobs:
--levels ERROR \
--scope JavaInspectionsScope
openrewrite:
runs-on: ubuntu-latest
steps:
- name: checkout branch
uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '8'
cache: 'maven'

- name: maven install
run: |
echo 'Running Maven install...' &&
${MVN} clean install -q -ff -pl '!distribution' ${MAVEN_SKIP} ${MAVEN_SKIP_TESTS} -T1C &&
${MVN} install -q -ff -pl 'distribution' ${MAVEN_SKIP} ${MAVEN_SKIP_TESTS}
- name: rewrite:dryRun
run: |
${MVN} rewrite:dryRun ${MAVEN_SKIP}
web-checks:
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
| ⚙️ CodeQL Config | [![codeql-config](https://img.shields.io/github/actions/workflow/status/apache/druid/codeql-config.yml?branch=master&logo=github-actions&style=flat-square)](https://github.com/apache/druid/actions/workflows/codeql-config.yml) |
| 🔍 CodeQL | [![codeql](https://img.shields.io/github/actions/workflow/status/apache/druid/codeql.yml?branch=master&logo=github-actions&style=flat-square)](https://github.com/apache/druid/actions/workflows/codeql.yml) |
| 🕒 Cron Job ITS | [![cron-job-its](https://img.shields.io/github/actions/workflow/status/apache/druid/cron-job-its.yml?branch=master&logo=github-actions&style=flat-square)](https://github.com/apache/druid/actions/workflows/cron-job-its.yml) |
| 🏷️ Labeler | [![labeler](https://img.shields.io/github/actions/workflow/status/apache/druid/labeler.yml?branch=master&logo=github-actions&style=flat-square)](https://github.com/apache/druid/actions/workflows/labeler.yml) |
| 🏷️ Labeler | [![labeler](https://img.shields.io/github/actions/workflow/status/apache/druid/labeler.yml?logo=github-actions&style=flat-square)](https://github.com/apache/druid/actions/workflows/labeler.yml) |
| ♻️ Reusable Revised ITS | [![reusable-revised-its](https://img.shields.io/github/actions/workflow/status/apache/druid/reusable-revised-its.yml?branch=master&logo=github-actions&style=flat-square)](https://github.com/apache/druid/actions/workflows/reusable-revised-its.yml) |
| ♻️ Reusable Standard ITS | [![reusable-standard-its](https://img.shields.io/github/actions/workflow/status/apache/druid/reusable-standard-its.yml?branch=master&logo=github-actions&style=flat-square)](https://github.com/apache/druid/actions/workflows/reusable-standard-its.yml) |
| ♻️ Reusable Unit Tests | [![reusable-unit-tests](https://img.shields.io/github/actions/workflow/status/apache/druid/reusable-unit-tests.yml?branch=master&logo=github-actions&style=flat-square)](https://github.com/apache/druid/actions/workflows/reusable-unit-tests.yml) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,23 @@ public void benchIsOvershadowed(Blackhole blackhole)
blackhole.consume(timeline.isOvershadowed(segment.getInterval(), segment.getVersion(), segment));
}

@Benchmark
public void benchIsOvershadowedTotal(Blackhole blackhole)
{
blackhole.consume(isOvershadowedTotal());
}

private int isOvershadowedTotal()
{
int overshadowedCount = 0;
for (DataSegment segment : segments) {
if (timeline.isOvershadowed(segment.getInterval(), segment.getVersion(), segment)) {
overshadowedCount++;
}
}
return overshadowedCount;
}

@Benchmark
public void benchFindFullyOvershadowed(Blackhole blackhole)
{
Expand Down
28 changes: 16 additions & 12 deletions docs/api-reference/data-management-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,22 @@ Marks the state of a group of segments as unused, using an array of segment IDs
Pass the array of segment IDs or interval as a JSON object in the request body.

For the interval, specify the start and end times as ISO 8601 strings to identify segments inclusive of the start time and exclusive of the end time.
Druid only updates the segments completely contained within the specified interval; partially overlapping segments are not affected.
Optionally, specify an array of segment versions with interval. Druid updates only the segments completely contained
within the specified interval that match the optional list of versions; partially overlapping segments are not affected.

#### URL

<code class="postAPI">POST</code> <code>/druid/coordinator/v1/datasources/:datasource/markUnused</code>

#### Request body

The group of segments is sent as a JSON request payload that accepts one of the following properties:
The group of segments is sent as a JSON request payload that accepts the following properties:

|Property|Description|Example|
|----------|-------------|---------|
|`interval`|ISO 8601 segments interval.|`"2015-09-12T03:00:00.000Z/2015-09-12T05:00:00.000Z"`|
|`segmentIds`|Array of segment IDs.|`["segmentId1", "segmentId2"]`|
|Property|Description|Required|Example|
|----------|-------------|---------|---------|
|`interval`|ISO 8601 segments interval.|Yes, if `segmentIds` is not specified.|`"2015-09-12T03:00:00.000Z/2015-09-12T05:00:00.000Z"`|
|`segmentIds`|List of segment IDs.|Yes, if `interval` is not specified.|`["segmentId1", "segmentId2"]`|
|`versions`|List of segment versions. Must be provided with `interval`.|No.|`["2024-03-14T16:00:04.086Z", ""2024-03-12T16:00:04.086Z"]`|

#### Responses

Expand Down Expand Up @@ -306,20 +308,22 @@ Marks the state of a group of segments as used, using an array of segment IDs or
Pass the array of segment IDs or interval as a JSON object in the request body.

For the interval, specify the start and end times as ISO 8601 strings to identify segments inclusive of the start time and exclusive of the end time.
Druid only updates the segments completely contained within the specified interval; partially overlapping segments are not affected.
Optionally, specify an array of segment versions with interval. Druid updates only the segments completely contained
within the specified interval that match the optional list of versions; partially overlapping segments are not affected.

#### URL

<code class="postAPI">POST</code> <code>/druid/coordinator/v1/datasources/:datasource/markUsed</code>

#### Request body

The group of segments is sent as a JSON request payload that accepts one of the following properties:
The group of segments is sent as a JSON request payload that accepts the following properties:

|Property|Description|Example|
|----------|-------------|---------|
|`interval`| ISO 8601 segments interval.|`"2015-09-12T03:00:00.000Z/2015-09-12T05:00:00.000Z"`|
|`segmentIds`|Array of segment IDs.|`["segmentId1", "segmentId2"]`|
|Property|Description|Required|Example|
|----------|-------------|---------|---------|
|`interval`|ISO 8601 segments interval.|Yes, if `segmentIds` is not specified.|`"2015-09-12T03:00:00.000Z/2015-09-12T05:00:00.000Z"`|
|`segmentIds`|List of segment IDs.|Yes, if `interval` is not specified.|`["segmentId1", "segmentId2"]`|
|`versions`|List of segment versions. Must be provided with `interval`.|No.|`["2024-03-14T16:00:04.086Z", ""2024-03-12T16:00:04.086Z"]`|

#### Responses

Expand Down
133 changes: 133 additions & 0 deletions docs/tutorials/tutorial-append-data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
id: tutorial-append-data
title: Append data
sidebar_label: Append data
description: Learn how to append data to a datasource without changing the existing data in Apache Druid.
---

<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

This tutorial shows you how to use the Apache Druid SQL [INSERT](../multi-stage-query/reference.md#insert) function to append data to a [datasource](../design/storage.md) without changing the existing data.
The examples in the tutorial use the [multi-stage query (MSQ)](../multi-stage-query/index.md) task engine to executes SQL statements.

## Prerequisites

Before you follow the steps in this tutorial, download Druid as described in [Quickstart (local)](index.md) and have it running on your local machine. You don't need to load any data into the Druid cluster.

You should be familiar with data querying in Druid. If you haven't already, go through the [Query data](../tutorials/tutorial-query.md) tutorial first.

## Load sample data

Load a sample dataset using [INSERT](../multi-stage-query/reference.md#insert) and [EXTERN](../multi-stage-query/reference.md#extern-function) functions. The EXTERN function lets you read external data or write to an external location.

In the Druid [web console](../operations/web-console.md), go to the **Query** view and run the following query:

```sql
INSERT INTO "append_tutorial"
SELECT
TIME_PARSE("timestamp") AS "__time",
"animal",
"number"
FROM TABLE(
EXTERN(
'{"type":"inline","data":"{\"timestamp\":\"2024-01-01T07:01:35Z\",\"animal\":\"octopus\", \"number\":115}\n{\"timestamp\":\"2024-01-01T05:01:35Z\",\"animal\":\"mongoose\", \"number\":737}\n{\"timestamp\":\"2024-01-01T06:01:35Z\",\"animal\":\"snake\", \"number\":1234}\n{\"timestamp\":\"2024-01-01T01:01:35Z\",\"animal\":\"lion\", \"number\":300}\n{\"timestamp\":\"2024-01-02T07:01:35Z\",\"animal\":\"seahorse\", \"number\":115}\n{\"timestamp\":\"2024-01-02T05:01:35Z\",\"animal\":\"skunk\", \"number\":737}\n{\"timestamp\":\"2024-01-02T06:01:35Z\",\"animal\":\"iguana\", \"number\":1234}\n{\"timestamp\":\"2024-01-02T01:01:35Z\",\"animal\":\"opossum\", \"number\":300}"}',
'{"type":"json"}'
)
) EXTEND ("timestamp" VARCHAR, "animal" VARCHAR, "number" BIGINT)
PARTITIONED BY DAY
```

The resulting `append_tutorial` datasource contains records for eight animals over two days.
To view the results, open a new tab and run the following query:

```sql
SELECT * FROM "append_tutorial"
```

<details>
<summary> View the results</summary>

| `__time` | `animal` | `number`|
| -- | -- | -- |
| `2024-01-01T01:01:35.000Z`| `lion`| 300 |
| `2024-01-01T05:01:35.000Z`| `mongoose`| 737 |
| `2024-01-01T06:01:35.000Z`| `snake`| 1234 |
| `2024-01-01T07:01:35.000Z`| `octopus`| 115 |
| `2024-01-02T01:01:35.000Z`| `opossum`| 300 |
| `2024-01-02T05:01:35.000Z`| `skunk`| 737 |
| `2024-01-02T06:01:35.000Z`| `iguana`| 1234 |
| `2024-01-02T07:01:35.000Z`| `seahorse`| 115 |

</details>

## Append data

You can use the INSERT function to append data to the datasource without changing the existing data.
In a new tab, run the following query to ingest and append data to the `append_tutorial` datasource:

```sql
INSERT INTO "append_tutorial"
SELECT
TIME_PARSE("timestamp") AS "__time",
"animal",
"number"
FROM TABLE(
EXTERN(
'{"type":"inline","data":"{\"timestamp\":\"2024-01-03T01:09:35Z\",\"animal\":\"zebra\", \"number\":233}\n{\"timestamp\":\"2024-01-04T07:01:35Z\",\"animal\":\"bear\", \"number\":577}\n{\"timestamp\":\"2024-01-04T05:01:35Z\",\"animal\":\"falcon\", \"number\":848}\n{\"timestamp\":\"2024-01-04T06:01:35Z\",\"animal\":\"giraffe\", \"number\":113}\n{\"timestamp\":\"2024-01-04T01:01:35Z\",\"animal\":\"rhino\", \"number\":473}"}',
'{"type":"json"}'
)
) EXTEND ("timestamp" VARCHAR, "animal" VARCHAR, "number" BIGINT)
PARTITIONED BY DAY
```

Druid adds rows for the subsequent days after `seahorse`.
When the task completes, open a new tab and run the following query to view the results:

```sql
SELECT * FROM "append_tutorial"
```

<details>
<summary> View the results</summary>

| `__time` | `animal` | `number`|
| -- | -- | -- |
| `2024-01-01T01:01:35.000Z`| `lion`| 300 |
| `2024-01-01T05:01:35.000Z`| `mongoose`| 737 |
| `2024-01-01T06:01:35.000Z`| `snake`| 1234 |
| `2024-01-01T07:01:35.000Z`| `octopus`| 115 |
| `2024-01-02T01:01:35.000Z`| `opossum`| 300 |
| `2024-01-02T05:01:35.000Z`| `skunk`| 737 |
| `2024-01-02T06:01:35.000Z`| `iguana`| 1234 |
| `2024-01-02T07:01:35.000Z`| `seahorse`| 115 |
| `2024-01-03T01:09:35.000Z`| `zebra`| 233 |
| `2024-01-04T01:01:35.000Z`| `rhino`| 473 |
| `2024-01-04T05:01:35.000Z`| `falcon`| 848 |
| `2024-01-04T06:01:35.000Z`| `giraffe`| 113 |
| `2024-01-04T07:01:35.000Z`| `bear`| 577 |

</details>

## Learn more

See the following topics for more information:

* [SQL-based ingestion reference](../multi-stage-query/reference.md) for a reference on MSQ architecture.
* [SQL-based ingestion query examples](../multi-stage-query/examples.md) for example queries using the MSQ task engine.
Loading

0 comments on commit f827ea7

Please sign in to comment.