Skip to content

Commit 17c6e3e

Browse files
register UDF in shared session context
1 parent 61c63dd commit 17c6e3e

4 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ use once_cell::sync::Lazy;
6868
pub use openid;
6969
use parseable::PARSEABLE;
7070
use reqwest::{Client, ClientBuilder};
71+
pub use {clap, tracing_actix_web, tracing_opentelemetry, tracing_subscriber};
7172
pub use {opentelemetry, opentelemetry_otlp, opentelemetry_proto, opentelemetry_sdk};
72-
pub use {tracing_actix_web, tracing_opentelemetry, tracing_subscriber, clap};
7373

7474
// It is very unlikely that panic will occur when dealing with locks.
7575
pub const LOCK_EXPECT: &str = "Thread shouldn't panic while holding a lock";

src/metastore/metastore_traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ pub trait Metastore: std::fmt::Debug + Send + Sync {
229229
stream_name: &str,
230230
get_base: bool,
231231
tenant_id: &Option<String>,
232-
is_migration: bool
232+
is_migration: bool,
233233
) -> Result<Bytes, MetastoreError>;
234234
async fn put_stream_json(
235235
&self,
@@ -247,7 +247,7 @@ pub trait Metastore: std::fmt::Debug + Send + Sync {
247247
stream_name: &str,
248248
mode: Option<Mode>,
249249
tenant_id: &Option<String>,
250-
is_migration: bool
250+
is_migration: bool,
251251
) -> Result<Vec<Bytes>, MetastoreError>;
252252

253253
/// Fetch manifests only for the explicitly requested date keys

src/metastore/metastores/object_store_metastore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ impl Metastore for ObjectStoreMetastore {
892892
stream_name: &str,
893893
mode: Option<Mode>,
894894
tenant_id: &Option<String>,
895-
_is_migration: bool
895+
_is_migration: bool,
896896
) -> Result<Vec<Bytes>, MetastoreError> {
897897
let root = tenant_id.as_deref().unwrap_or("");
898898
let path = RelativePathBuf::from_iter([root, stream_name, STREAM_ROOT_DIRECTORY]);

src/query/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use datafusion::execution::{
3232
};
3333
use datafusion::logical_expr::expr::Alias;
3434
use datafusion::logical_expr::{
35-
Aggregate, Explain, Filter, LogicalPlan, PlanType, Projection, ToStringifiedPlan,
35+
Aggregate, Explain, Filter, LogicalPlan, PlanType, Projection, ScalarUDF, ToStringifiedPlan,
3636
};
3737
use datafusion::physical_plan::stream::RecordBatchStreamAdapter;
3838
use datafusion::physical_plan::{
@@ -112,6 +112,13 @@ impl InMemorySessionContext {
112112
ctx.clone()
113113
}
114114

115+
pub fn register_udf(&self, udf: ScalarUDF) {
116+
self.session_context
117+
.write()
118+
.expect("SessionContext should be writeable")
119+
.register_udf(udf);
120+
}
121+
115122
pub fn add_schema(&self, tenant_id: &str) {
116123
self.session_context
117124
.write()

0 commit comments

Comments
 (0)