Skip to content

Commit 32d105e

Browse files
fix: flatten before detect (#1361)
This PR ensures the detect schema API used for detecting the schema of a given JSON file returns the exact, flattened schema as server would store the event.
1 parent 04078cf commit 32d105e

33 files changed

+114
-102
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ mod ui {
151151
.expect("has segemnts")
152152
.find(|v| v.starts_with('v'))
153153
.expect("version segement");
154-
println!("cargo:rustc-env=UI_VERSION={}", ui_version);
154+
println!("cargo:rustc-env=UI_VERSION={ui_version}");
155155
}
156156

157157
Ok(())

src/alerts/alerts_utils.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async fn execute_base_query(
8888
original_query: &str,
8989
) -> Result<DataFrame, AlertError> {
9090
let stream_name = query.first_table_name().ok_or_else(|| {
91-
AlertError::CustomError(format!("Table name not found in query- {}", original_query))
91+
AlertError::CustomError(format!("Table name not found in query- {original_query}"))
9292
})?;
9393

9494
let time_partition = PARSEABLE.get_stream(&stream_name)?.get_time_partition();
@@ -412,7 +412,7 @@ pub fn get_filter_string(where_clause: &Conditions) -> Result<String, String> {
412412
let value = match NumberOrString::from_string(value.to_owned()) {
413413
NumberOrString::Number(val) => format!("{val}"),
414414
NumberOrString::String(val) => {
415-
format!("'{}'", val)
415+
format!("'{val}'")
416416
}
417417
};
418418
format!("{} {}", condition.operator, value)
@@ -456,23 +456,23 @@ fn match_alert_operator(expr: &ConditionConfig) -> Expr {
456456
WhereConfigOperator::BeginsWith => Expr::BinaryExpr(BinaryExpr::new(
457457
Box::new(col(column)),
458458
Operator::RegexIMatch,
459-
Box::new(lit(format!("^{}", value))),
459+
Box::new(lit(format!("^{value}"))),
460460
)),
461461
WhereConfigOperator::EndsWith => Expr::BinaryExpr(BinaryExpr::new(
462462
Box::new(col(column)),
463463
Operator::RegexIMatch,
464-
Box::new(lit(format!("{}$", value))),
464+
Box::new(lit(format!("{value}$"))),
465465
)),
466466
WhereConfigOperator::DoesNotContain => col(column).not_ilike(lit(value)),
467467
WhereConfigOperator::DoesNotBeginWith => Expr::BinaryExpr(BinaryExpr::new(
468468
Box::new(col(column)),
469469
Operator::RegexNotIMatch,
470-
Box::new(lit(format!("^{}", value))),
470+
Box::new(lit(format!("^{value}"))),
471471
)),
472472
WhereConfigOperator::DoesNotEndWith => Expr::BinaryExpr(BinaryExpr::new(
473473
Box::new(col(column)),
474474
Operator::RegexNotIMatch,
475-
Box::new(lit(format!("{}$", value))),
475+
Box::new(lit(format!("{value}$"))),
476476
)),
477477
_ => unreachable!("value must not be null for operators other than `is null` and `is not null`. Should've been caught in validation")
478478
}

src/alerts/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ impl Conditions {
365365
format!("{} {}", expr2.column, expr2.operator)
366366
};
367367

368-
format!("[{} {op} {}]", expr1_msg, expr2_msg)
368+
format!("[{expr1_msg} {op} {expr2_msg}]")
369369
}
370370
},
371371
None => {

src/catalog/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,8 @@ pub fn partition_path(
459459
let lower = lower_bound.date_naive().format("%Y-%m-%d").to_string();
460460
let upper = upper_bound.date_naive().format("%Y-%m-%d").to_string();
461461
if lower == upper {
462-
RelativePathBuf::from_iter([stream, &format!("date={}", lower)])
462+
RelativePathBuf::from_iter([stream, &format!("date={lower}")])
463463
} else {
464-
RelativePathBuf::from_iter([stream, &format!("date={}:{}", lower, upper)])
464+
RelativePathBuf::from_iter([stream, &format!("date={lower}:{upper}")])
465465
}
466466
}

src/cli.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,7 @@ impl Options {
563563
} else {
564564
if endpoint.starts_with("http") {
565565
panic!(
566-
"Invalid value `{}`, please set the environment variable `{}` to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.",
567-
endpoint, env_var
566+
"Invalid value `{endpoint}`, please set the environment variable `{env_var}` to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.",
568567
);
569568
}
570569
endpoint.to_string()
@@ -579,15 +578,14 @@ impl Options {
579578

580579
if addr_parts.len() != 2 {
581580
panic!(
582-
"Invalid value `{}`, please set the environment variable to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.",
583-
endpoint
581+
"Invalid value `{endpoint}`, please set the environment variable to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details."
584582
);
585583
}
586584

587585
let hostname = self.resolve_env_var(addr_parts[0]);
588586
let port = self.resolve_env_var(addr_parts[1]);
589587

590-
self.build_url(&format!("{}:{}", hostname, port))
588+
self.build_url(&format!("{hostname}:{port}"))
591589
}
592590

593591
/// resolve the env var
@@ -597,15 +595,13 @@ impl Options {
597595
if let Some(env_var) = value.strip_prefix('$') {
598596
let resolved_value = env::var(env_var).unwrap_or_else(|_| {
599597
panic!(
600-
"The environment variable `{}` is not set. Please set it to a valid value. Refer to the documentation: https://logg.ing/env for more details.",
601-
env_var
598+
"The environment variable `{env_var}` is not set. Please set it to a valid value. Refer to the documentation: https://logg.ing/env for more details."
602599
);
603600
});
604601

605602
if resolved_value.starts_with("http") {
606603
panic!(
607-
"Invalid value `{}`, please set the environment variable `{}` to `<ip address / DNS>` without the scheme (e.g., 192.168.1.1 or example.com). Please refer to the documentation: https://logg.ing/env for more details.",
608-
resolved_value, env_var
604+
"Invalid value `{resolved_value}`, please set the environment variable `{env_var}` to `<ip address / DNS>` without the scheme (e.g., 192.168.1.1 or example.com). Please refer to the documentation: https://logg.ing/env for more details.",
609605
);
610606
}
611607

@@ -621,8 +617,7 @@ impl Options {
621617
.parse::<Url>()
622618
.unwrap_or_else(|err| {
623619
panic!(
624-
"{err}, failed to parse `{}` as Url. Please set the environment variable `P_ADDR` to `<ip address>:<port>` without the scheme (e.g., 192.168.1.1:8000). Please refer to the documentation: https://logg.ing/env for more details.",
625-
address
620+
"{err}, failed to parse `{address}` as Url. Please set the environment variable `P_ADDR` to `<ip address>:<port>` without the scheme (e.g., 192.168.1.1:8000). Please refer to the documentation: https://logg.ing/env for more details."
626621
);
627622
})
628623
}

src/connectors/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl FromStr for BadData {
9595
"drop" => Ok(BadData::Drop),
9696
"fail" => Ok(BadData::Fail),
9797
"dlt" => Ok(BadData::Dlt),
98-
_ => Err(format!("Invalid bad data policy: {}", s)),
98+
_ => Err(format!("Invalid bad data policy: {s}")),
9999
}
100100
}
101101
}

src/connectors/kafka/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ impl std::str::FromStr for SecurityProtocol {
827827
"SSL" => Ok(SecurityProtocol::Ssl),
828828
"SASL_SSL" => Ok(SecurityProtocol::SaslSsl),
829829
"SASL_PLAINTEXT" => Ok(SecurityProtocol::SaslPlaintext),
830-
_ => Err(format!("Invalid security protocol: {}", s)),
830+
_ => Err(format!("Invalid security protocol: {s}")),
831831
}
832832
}
833833
}
@@ -965,7 +965,7 @@ impl std::str::FromStr for SaslMechanism {
965965
"SCRAM-SHA-512" => Ok(SaslMechanism::ScramSha512),
966966
"GSSAPI" => Ok(SaslMechanism::Gssapi),
967967
"OAUTHBEARER" => Ok(SaslMechanism::OAuthBearer),
968-
_ => Err(format!("Invalid SASL mechanism: {}", s)),
968+
_ => Err(format!("Invalid SASL mechanism: {s}")),
969969
}
970970
}
971971
}
@@ -985,7 +985,7 @@ impl std::str::FromStr for Acks {
985985
"0" => Ok(Acks::None),
986986
"1" => Ok(Acks::Leader),
987987
"all" => Ok(Acks::All),
988-
_ => Err(format!("Invalid acks value: {}", s)),
988+
_ => Err(format!("Invalid acks value: {s}")),
989989
}
990990
}
991991
}

src/handlers/airplane.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl FlightService for AirServiceImpl {
253253

254254
let time = time.elapsed().as_secs_f64();
255255
QUERY_EXECUTE_TIME
256-
.with_label_values(&[&format!("flight-query-{}", stream_name)])
256+
.with_label_values(&[&format!("flight-query-{stream_name}")])
257257
.observe(time);
258258

259259
// Airplane takes off 🛫

src/handlers/http/cluster/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,13 +783,12 @@ pub async fn remove_node(node_url: Path<String>) -> Result<impl Responder, PostE
783783

784784
if removed_ingestor || removed_indexer || removed_querier || removed_prism {
785785
return Ok((
786-
format!("node {} removed successfully", domain_name),
786+
format!("node {domain_name} removed successfully"),
787787
StatusCode::OK,
788788
));
789789
}
790790
Err(PostError::Invalid(anyhow::anyhow!(
791-
"node {} not found",
792-
domain_name
791+
"node {domain_name} not found"
793792
)))
794793
}
795794

src/handlers/http/cluster/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,5 @@ pub fn to_url_string(str: String) -> String {
203203
return str;
204204
}
205205

206-
format!("http://{}/", str)
206+
format!("http://{str}/")
207207
}

0 commit comments

Comments
 (0)