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

chore(query): introduce meta Runtime #5294

Merged
merged 6 commits into from
May 11, 2022
Merged

Conversation

sundy-li
Copy link
Member

@sundy-li sundy-li commented May 11, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Summary about this PR

Changelog

  • Improvement

Related Issues

Related #5287

@vercel
Copy link

vercel bot commented May 11, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
databend ⬜️ Ignored (Inspect) May 11, 2022 at 7:45AM (UTC)

@mergify
Copy link
Contributor

mergify bot commented May 11, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@@ -424,6 +430,30 @@ impl QueryContext {
})?;
Ok(FunctionContext { tz })
}

pub fn block_on_meta<F>(&self, future: F) -> Result<F::Output>
where
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this function, show function can work well in Mac Osx.

I do not know whether this code is right or not. cc @drmingdrmer @dantengsky

Comment on lines +434 to +456
pub fn block_on_meta<F>(&self, future: F) -> Result<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
let rt = self.get_meta_runtime();
let (tx, rx): (
std::sync::mpsc::Sender<F::Output>,
std::sync::mpsc::Receiver<F::Output>,
) = std::sync::mpsc::channel();

rt.try_spawn(async move {
let res = future.await;
tx.send(res).unwrap();
})?;
match rx.recv() {
Ok(v) => Ok(v),
Err(cause) => Err(ErrorCode::LogicalError(format!(
"Logical error, receive error. {:?}",
cause
))),
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One concern: this method can not be called in a tokio-runtime, right? This method itself can not provide any guarantee on this. It's totally up to the caller.

Except this, everything else looks great to me:DDD

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can, because QueryNormalizer::normalize is inside tokio-runtime.

@sundy-li sundy-li marked this pull request as ready for review May 11, 2022 07:49
@sundy-li sundy-li requested a review from BohuTANG as a code owner May 11, 2022 07:49
@BohuTANG BohuTANG requested review from zhang2014 and removed request for BohuTANG May 11, 2022 08:10
@BohuTANG BohuTANG merged commit 3d3c514 into databendlabs:main May 11, 2022
@sundy-li
Copy link
Member Author

hmm, this approach may block the runtime, I revert it first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants