Skip to content

Commit 6bb7afc

Browse files
author
Devdutt Shenoi
authored
Merge branch 'main' into main
2 parents 592d3a1 + 7d9b9ab commit 6bb7afc

File tree

9 files changed

+372
-54
lines changed

9 files changed

+372
-54
lines changed

CONTRIBUTING.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
### Contributing
2+
3+
This document outlines how you can contribute to Parseable.
4+
5+
Thank you for considering to contribute to Parseable. The goal of this document is to provide everything you need to start your contribution. We encourage all contributions, including but not limited to:
6+
- Code patches, bug fixes.
7+
- Tutorials or blog posts.
8+
- Improving the documentation.
9+
- Submitting [bug reports](https://github.com/parseablehq/parseable/issues/new).
10+
11+
### Prerequisites
12+
13+
- Your PR has an associated issue. Find an [existing issue](https://github.com/parseablehq/parseable/issues) or open a new issue.
14+
- You've discussed the with [Parseable community](https://logg.ing/community).
15+
- You're familiar with GitHub Pull Requests(PR) workflow.
16+
- You've read the [Parseable documentation](https://www.parseable.com/docs).
17+
18+
### Contribution workflow
19+
20+
- Fork the [Parseable repository](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) in your own GitHub account.
21+
- [Create a new branch](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-and-deleting-branches-within-your-repository).
22+
- Review the Development Workflow section that describes the steps to maintain the repository.
23+
- Make your changes on your branch.
24+
- Submit the branch as a Pull Request pointing to the main branch of the Parseable repository. A maintainer should comment and/or review your Pull Request within a few hours.
25+
- You’ll be asked to review & sign the [Parseable Contributor License Agreement (CLA)](https://github.com/parseablehq/.github/blob/main/CLA.md) on the GitHub PR. Please ensure that you review the document. Once you’re ready, please sign the CLA by adding a comment I have read the CLA Document and I hereby sign the CLA in your Pull Request.
26+
- Please ensure that the commits in your Pull Request are made by the same GitHub user (which was used to create the PR and add the comment).
27+
28+
### Development workflow
29+
30+
We recommend Linux or macOS as the development platform for Parseable.
31+
32+
#### Setup and run Parseable
33+
34+
Parseable needs Rust 1.77.1 or above. Use the below command to build and run Parseable binary with local mode.
35+
36+
```sh
37+
cargo run --release local-store
38+
```
39+
40+
We recommend using the --release flag to test the full performance of Parseable.
41+
42+
#### Running Tests
43+
44+
```sh
45+
cargo test
46+
```
47+
48+
This command will be triggered to each PR as a requirement for merging it.
49+
50+
If you get a "Too many open files" error you might want to increase the open file limit using this command:
51+
52+
```sh
53+
ulimit -Sn 3000
54+
```
55+
56+
If you get a OpenSSL related error while building Parseable, you might need to install the dependencies using this command:
57+
58+
```sh
59+
sudo apt install build-essential
60+
sudo apt-get install libssl-dev
61+
sudo apt-get install pkg-config
62+
```
63+
64+
### Git Guidelines
65+
66+
- The PR title should be accurate and descriptive of the changes.
67+
- The draft PRs are recommended when you want to show that you are working on something and make your work visible. Convert your PR as a draft if your changes are a work in progress. Maintainers will review the PR once you mark your PR as ready for review.
68+
- The branch related to the PR must be up-to-date with main before merging. We use Bors to automatically enforce this requirement without the PR author having to rebase manually.

Cargo.lock

Lines changed: 2 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cross.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[target.aarch64-unknown-linux-gnu]
2+
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu@sha256:1e2a0291f92a4372cbc22d8994e735473045383f1ce7fa44a16c234ba00187f4"
3+
4+
[target.x86_64-unknown-linux-gnu]
5+
image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu@sha256:bf05360bb9d6d4947eed60532ac7a0d7e8fae8f214e9abb801d5941c8fe4918d"

src/alerts/alerts_utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use tracing::trace;
3131

3232
use crate::{
3333
alerts::AggregateCondition,
34+
parseable::PARSEABLE,
3435
query::{TableScanVisitor, QUERY_SESSION},
3536
rbac::{
3637
map::SessionKey,
@@ -137,8 +138,9 @@ async fn execute_base_query(
137138
AlertError::CustomError(format!("Table name not found in query- {}", original_query))
138139
})?;
139140

141+
let time_partition = PARSEABLE.get_stream(&stream_name)?.get_time_partition();
140142
query
141-
.get_dataframe(stream_name)
143+
.get_dataframe(time_partition.as_ref())
142144
.await
143145
.map_err(|err| AlertError::CustomError(err.to_string()))
144146
}

src/alerts/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use ulid::Ulid;
3737
pub mod alerts_utils;
3838
pub mod target;
3939

40-
use crate::parseable::PARSEABLE;
40+
use crate::parseable::{StreamNotFound, PARSEABLE};
4141
use crate::query::{TableScanVisitor, QUERY_SESSION};
4242
use crate::rbac::map::SessionKey;
4343
use crate::storage;
@@ -514,17 +514,16 @@ impl AlertConfig {
514514

515515
// for now proceed in a similar fashion as we do in query
516516
// TODO: in case of multiple table query does the selection of time partition make a difference? (especially when the tables don't have overlapping data)
517-
let stream_name = if let Some(stream_name) = query.first_table_name() {
518-
stream_name
519-
} else {
517+
let Some(stream_name) = query.first_table_name() else {
520518
return Err(AlertError::CustomError(format!(
521519
"Table name not found in query- {}",
522520
self.query
523521
)));
524522
};
525523

524+
let time_partition = PARSEABLE.get_stream(&stream_name)?.get_time_partition();
526525
let base_df = query
527-
.get_dataframe(stream_name)
526+
.get_dataframe(time_partition.as_ref())
528527
.await
529528
.map_err(|err| AlertError::CustomError(err.to_string()))?;
530529

@@ -704,6 +703,8 @@ pub enum AlertError {
704703
CustomError(String),
705704
#[error("Invalid State Change: {0}")]
706705
InvalidStateChange(String),
706+
#[error("{0}")]
707+
StreamNotFound(#[from] StreamNotFound),
707708
}
708709

709710
impl actix_web::ResponseError for AlertError {
@@ -717,6 +718,7 @@ impl actix_web::ResponseError for AlertError {
717718
Self::DatafusionError(_) => StatusCode::INTERNAL_SERVER_ERROR,
718719
Self::CustomError(_) => StatusCode::BAD_REQUEST,
719720
Self::InvalidStateChange(_) => StatusCode::BAD_REQUEST,
721+
Self::StreamNotFound(_) => StatusCode::NOT_FOUND,
720722
}
721723
}
722724

src/handlers/airplane.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::handlers::http::query::{into_query, update_schema_when_distributed};
3838
use crate::handlers::livetail::cross_origin_config;
3939
use crate::metrics::QUERY_EXECUTE_TIME;
4040
use crate::parseable::PARSEABLE;
41-
use crate::query::{TableScanVisitor, QUERY_SESSION};
41+
use crate::query::{execute, TableScanVisitor, QUERY_SESSION};
4242
use crate::utils::arrow::flight::{
4343
append_temporary_events, get_query_from_ticket, into_flight_data, run_do_get_rpc,
4444
send_to_ingester,
@@ -216,13 +216,9 @@ impl FlightService for AirServiceImpl {
216216
})?;
217217
let time = Instant::now();
218218

219-
let stream_name_clone = stream_name.clone();
220-
let (records, _) =
221-
match tokio::task::spawn_blocking(move || query.execute(stream_name_clone)).await {
222-
Ok(Ok((records, fields))) => (records, fields),
223-
Ok(Err(e)) => return Err(Status::internal(e.to_string())),
224-
Err(err) => return Err(Status::internal(err.to_string())),
225-
};
219+
let (records, _) = execute(query, &stream_name)
220+
.await
221+
.map_err(|err| Status::internal(err.to_string()))?;
226222

227223
/*
228224
* INFO: No returning the schema with the data.

src/handlers/http/query.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use actix_web::http::header::ContentType;
2020
use actix_web::web::{self, Json};
2121
use actix_web::{FromRequest, HttpRequest, HttpResponse, Responder};
22-
use arrow_array::RecordBatch;
2322
use chrono::{DateTime, Utc};
2423
use datafusion::common::tree_node::TreeNode;
2524
use datafusion::error::DataFusionError;
@@ -38,9 +37,9 @@ use crate::handlers::http::fetch_schema;
3837

3938
use crate::metrics::QUERY_EXECUTE_TIME;
4039
use crate::option::Mode;
41-
use crate::parseable::PARSEABLE;
40+
use crate::parseable::{StreamNotFound, PARSEABLE};
4241
use crate::query::error::ExecuteError;
43-
use crate::query::{CountsRequest, CountsResponse, Query as LogicalQuery};
42+
use crate::query::{execute, CountsRequest, CountsResponse, Query as LogicalQuery};
4443
use crate::query::{TableScanVisitor, QUERY_SESSION};
4544
use crate::rbac::Users;
4645
use crate::response::QueryResponse;
@@ -129,7 +128,8 @@ pub async fn query(req: HttpRequest, query_request: Query) -> Result<HttpRespons
129128

130129
return Ok(HttpResponse::Ok().json(response));
131130
}
132-
let (records, fields) = execute_query(query, table_name.clone()).await?;
131+
132+
let (records, fields) = execute(query, &table_name).await?;
133133

134134
let response = QueryResponse {
135135
records,
@@ -148,17 +148,6 @@ pub async fn query(req: HttpRequest, query_request: Query) -> Result<HttpRespons
148148
Ok(response)
149149
}
150150

151-
async fn execute_query(
152-
query: LogicalQuery,
153-
stream_name: String,
154-
) -> Result<(Vec<RecordBatch>, Vec<String>), QueryError> {
155-
match tokio::task::spawn_blocking(move || query.execute(stream_name)).await {
156-
Ok(Ok(result)) => Ok(result),
157-
Ok(Err(e)) => Err(QueryError::Execute(e)),
158-
Err(e) => Err(QueryError::Anyhow(anyhow::Error::msg(e.to_string()))),
159-
}
160-
}
161-
162151
pub async fn get_counts(
163152
req: HttpRequest,
164153
counts_request: Json<CountsRequest>,
@@ -330,6 +319,8 @@ Description: {0}"#
330319
ActixError(#[from] actix_web::Error),
331320
#[error("Error: {0}")]
332321
Anyhow(#[from] anyhow::Error),
322+
#[error("Error: {0}")]
323+
StreamNotFound(#[from] StreamNotFound),
333324
}
334325

335326
impl actix_web::ResponseError for QueryError {

0 commit comments

Comments
 (0)