Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ClickHouse native client to read database tables #7016

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions oximeter/db/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,9 +1437,34 @@ impl Client {
if replicated {
sql.push_str(" AND engine = 'ReplicatedMergeTree'");
}
self.execute_with_body(sql).await.map(|(_summary, body)| {
body.lines().map(ToString::to_string).collect()
})
bnaecker marked this conversation as resolved.
Show resolved Hide resolved
let col = self
.execute_with_block(&sql)
.await
.and_then(|result| {
result.data.ok_or_else(|| {
Error::Database(String::from(
"Query for database tables should have returned \
a data block, but none was found",
))
})
})?
.columns
.swap_remove("name")
.ok_or_else(|| {
Error::Database(String::from(
"Query for database tables should have returned \
a column with name 'names', but none was found",
))
})?;
let ValueArray::String(names) = col.values else {
return Err(Error::Database(format!(
"Query for database tables should have returned \
an array of string table names, but the column \
has type: '{}'",
col.data_type,
)));
};
Ok(names)
}
}

Expand Down
Loading