-
error: 44 | .route("/api/sql/query", routing::post(router::query))
| ------------- ^^^^^^^^^^^^^ the trait `Handler<_, _, _>` is not implemented for fn item `fn(axum::extract::State<Arc<_>>, axum::Json<SQLQuery>) -> impl Future<Output = Result<impl IntoResponse, ApiErrResp>> {router::query::<_>}`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `Handler<T, S, B>`:
<Layered<L, H, T, S, B, B2> as Handler<T, S, B2>>
<MethodRouter<S, B> as Handler<(), S, B>> router : pub fn build_http_server<C: ServerContext>(
ctx: Arc<C>,
addr: &AddressConfig,
) -> Result<HttpServer> {
let route = Router::new()
.route("/", routing::get(router::root))
.route("/api/sql/query", routing::post(router::query))
.with_state(ctx);
Ok(ServerBuilder::default()
.addr(addr.http.parse()?)
.route(route)
.build())
} query function: pub async fn query<C: ServerContext>(ctx: Arc<C>, sql: &str) -> Result<String> {
let df_session = ctx.get_df_session()?;
df_session.query(sql).await
} In df_session.query: pub async fn query(&self, sql: &str) -> Result<String> {
let stmt = parse_statement(&self.session, sql).await?;
let plan = self.session.state().statement_to_plan(stmt).await?;
let options = SQLOptions::new();
options.verify_plan(&plan)?;
let df = self.session.execute_logical_plan(plan).await?;
Ok(arrow::util::pretty::pretty_format_batches(&df.collect().await?)?.to_string())
} |
Beta Was this translation helpful? Give feedback.
Answered by
jplatte
Sep 7, 2023
Replies: 1 comment 2 replies
-
That's so weird! If remove this code everything is fine |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please check Debugging type errors in the handler documentation. It looks like some part of that code you commented our in that screenshot makes the
async fn
's Future type!Send
.