@@ -19,7 +19,7 @@ use std::{io::Cursor, time::Duration};
1919
2020use axum:: {
2121 body:: Body ,
22- extract:: { Json , Path , Query , State } ,
22+ extract:: { Json , OriginalUri , Path , Query , State } ,
2323 response:: { IntoResponse , Response } ,
2424 routing:: { get, post} ,
2525 Router ,
@@ -29,7 +29,7 @@ use datafusion_app::{observability::ObservabilityRequestDetails, ExecOptions, Ex
2929use http:: { HeaderValue , StatusCode } ;
3030use jiff:: Timestamp ;
3131use log:: error;
32- use serde:: Deserialize ;
32+ use serde:: { Deserialize , Serialize } ;
3333use tokio_stream:: StreamExt ;
3434use tower_http:: { timeout:: TimeoutLayer , trace:: TraceLayer } ;
3535use tracing:: info;
@@ -38,6 +38,7 @@ use crate::{config::HttpServerConfig, execution::AppExecution};
3838
3939#[ derive( Debug ) ]
4040struct ExecRequest {
41+ path : String ,
4142 sql : String ,
4243}
4344
@@ -83,17 +84,22 @@ struct PostSqlBody {
8384 flightsql : bool ,
8485}
8586
86- async fn post_sql_handler ( state : State < ExecutionState > , Json ( body) : Json < PostSqlBody > ) -> Response {
87+ async fn post_sql_handler (
88+ state : State < ExecutionState > ,
89+ OriginalUri ( uri) : OriginalUri ,
90+ Json ( body) : Json < PostSqlBody > ,
91+ ) -> Response {
8792 if body. flightsql && !cfg ! ( feature = "flightsql" ) {
8893 return (
8994 StatusCode :: BAD_REQUEST ,
9095 "FlightSQL is not enabled on this server" ,
9196 )
9297 . into_response ( ) ;
9398 }
94- let rt = state. execution . session_ctx ( ) . runtime_env ( ) ;
95- println ! ( "Runtime {rt:?}" ) ;
96- let req = ExecRequest { sql : body. sql } ;
99+ let req = ExecRequest {
100+ path : uri. path ( ) . to_string ( ) ,
101+ sql : body. sql . to_string ( ) ,
102+ } ;
97103 let opts = ExecOptions :: new ( Some ( state. config . result_limit ) , body. flightsql ) ;
98104 create_response ( & state, req, opts) . await
99105}
@@ -106,6 +112,7 @@ struct GetCatalogQueryParams {
106112
107113async fn get_catalog_handler (
108114 state : State < ExecutionState > ,
115+ OriginalUri ( uri) : OriginalUri ,
109116 Query ( query) : Query < GetCatalogQueryParams > ,
110117) -> Response {
111118 let opts = ExecOptions :: new ( None , query. flightsql ) ;
@@ -117,11 +124,14 @@ async fn get_catalog_handler(
117124 . into_response ( ) ;
118125 }
119126 let sql = "SHOW TABLES" . to_string ( ) ;
120- let req = ExecRequest { sql } ;
127+ let req = ExecRequest {
128+ path : uri. path ( ) . to_string ( ) ,
129+ sql,
130+ } ;
121131 create_response ( & state, req, opts) . await
122132}
123133
124- #[ derive( Deserialize ) ]
134+ #[ derive( Deserialize , Serialize ) ]
125135struct GetTablePathParams {
126136 catalog : String ,
127137 schema : String ,
@@ -136,19 +146,23 @@ struct GetTableQueryParams {
136146
137147async fn get_table_handler (
138148 state : State < ExecutionState > ,
139- Path ( params ) : Path < GetTablePathParams > ,
149+ Path ( path ) : Path < GetTablePathParams > ,
140150 Query ( query) : Query < GetTableQueryParams > ,
151+ OriginalUri ( uri) : OriginalUri ,
141152) -> Response {
142153 let GetTablePathParams {
143154 catalog,
144155 schema,
145156 table,
146- } = params ;
157+ } = path ;
147158 let sql = format ! (
148159 "SELECT * FROM \" {catalog}\" .\" {schema}\" .\" {table}\" LIMIT {}" ,
149160 state. config. result_limit
150161 ) ;
151- let req = ExecRequest { sql } ;
162+ let req = ExecRequest {
163+ path : uri. path ( ) . to_string ( ) ,
164+ sql,
165+ } ;
152166 let opts = ExecOptions :: new ( Some ( state. config . result_limit ) , query. flightsql ) ;
153167 create_response ( & state, req, opts) . await
154168}
@@ -247,6 +261,7 @@ async fn create_response(
247261 let ( res, details) = response_for_sql ( state, req. sql . clone ( ) , opts) . await ;
248262 let elapsed = Timestamp :: now ( ) - start;
249263 let req = ObservabilityRequestDetails {
264+ path : req. path ,
250265 sql : req. sql ,
251266 start_ms : start. as_millisecond ( ) ,
252267 duration_ms : elapsed. get_milliseconds ( ) ,
0 commit comments