Skip to content

Commit 6384cb1

Browse files
authored
chore(tesseract): Parse dependencies refactoring (#10131)
1 parent 35a163b commit 6384cb1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2276
-1287
lines changed

packages/cubejs-backend-native/src/node_export.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ use crate::stream::OnDrainHandler;
2121
use crate::tokio_runtime_node;
2222
use crate::transport::NodeBridgeTransport;
2323
use crate::utils::{batch_to_rows, NonDebugInRelease};
24-
use cubenativeutils::wrappers::neon::context::neon_guarded_funcion_call;
25-
use cubenativeutils::wrappers::neon::inner_types::NeonInnerTypes;
24+
use cubenativeutils::wrappers::neon::neon_guarded_funcion_call;
2625
use cubenativeutils::wrappers::NativeContextHolder;
2726
use cubesqlplanner::cube_bridge::base_query_options::NativeBaseQueryOptions;
2827
use cubesqlplanner::planner::base_query::BaseQuery;
@@ -617,8 +616,7 @@ pub fn reset_logger(mut cx: FunctionContext) -> JsResult<JsUndefined> {
617616
fn build_sql_and_params(cx: FunctionContext) -> JsResult<JsValue> {
618617
neon_guarded_funcion_call(
619618
cx,
620-
|context_holder: NativeContextHolder<_>,
621-
options: NativeBaseQueryOptions<NeonInnerTypes<FunctionContext<'static>>>| {
619+
|context_holder: NativeContextHolder<_>, options: NativeBaseQueryOptions<_>| {
622620
let base_query = BaseQuery::try_new(context_holder.clone(), Rc::new(options))?;
623621

624622
base_query.build_sql_and_params()

packages/cubejs-schema-compiler/src/adapter/BaseQuery.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ export class BaseQuery {
935935
timezone: this.options.timezone,
936936
joinGraph: this.joinGraph,
937937
cubeEvaluator: this.cubeEvaluator,
938+
securityContext: this.contextSymbols.securityContext,
938939
order,
939940
filters: this.options.filters,
940941
limit: this.options.limit ? this.options.limit.toString() : null,
@@ -995,6 +996,7 @@ export class BaseQuery {
995996
ungrouped: this.options.ungrouped,
996997
exportAnnotatedSql: false,
997998
preAggregationQuery: this.options.preAggregationQuery,
999+
securityContext: this.contextSymbols.securityContext,
9981000
cubestoreSupportMultistage: this.options.cubestoreSupportMultistage ?? getEnv('cubeStoreRollingWindowJoin'),
9991001
disableExternalPreAggregations: !!this.options.disableExternalPreAggregations,
10001002
};

packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,6 @@ export class CubeEvaluator extends CubeSymbols {
885885
});
886886
}
887887
}
888-
889888
return {
890889
allowNonStrictDateRangeMatch: aggregation.allowNonStrictDateRangeMatch,
891890
dimensions:

packages/cubejs-schema-compiler/test/integration/postgres/calc-groups.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ views:
447447
`);
448448

449449
if (getEnv('nativeSqlPlanner')) {
450-
it('basic cross join 1', async () => dbRunner.runQueryTest({
450+
it('basic cross join', async () => dbRunner.runQueryTest({
451451
dimensions: ['orders.currency'],
452452
timeDimensions: [
453453
{

packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts

Lines changed: 73 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,46 +2866,98 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL
28662866
console.log(query.buildSqlAndParams());
28672867

28682868
return dbRunner.testQuery(query.buildSqlAndParams()).then(res => {
2869-
console.log(JSON.stringify(res));
2870-
28712869
const expected = getEnv('nativeSqlPlanner') ?
2870+
28722871
[
2872+
{
2873+
vc__id: 1,
2874+
vc__created_at_day: '2017-01-02T00:00:00.000Z',
2875+
vc__visitor_checkins_count: null,
2876+
vc__visitor_checkins_rolling: 1
2877+
},
2878+
{
2879+
vc__id: 1,
2880+
vc__created_at_day: '2017-01-03T00:00:00.000Z',
2881+
vc__visitor_checkins_count: null,
2882+
vc__visitor_checkins_rolling: 1
2883+
},
2884+
{
2885+
vc__id: 1,
2886+
vc__created_at_day: '2017-01-04T00:00:00.000Z',
2887+
vc__visitor_checkins_count: null,
2888+
vc__visitor_checkins_rolling: 1
2889+
},
2890+
{
2891+
vc__id: 1,
2892+
vc__created_at_day: '2017-01-05T00:00:00.000Z',
2893+
vc__visitor_checkins_count: null,
2894+
vc__visitor_checkins_rolling: 1
2895+
},
2896+
{
2897+
vc__id: 1,
2898+
vc__created_at_day: '2017-01-06T00:00:00.000Z',
2899+
vc__visitor_checkins_count: null,
2900+
vc__visitor_checkins_rolling: 1
2901+
},
2902+
{
2903+
vc__id: 2,
2904+
vc__created_at_day: '2017-01-03T00:00:00.000Z',
2905+
vc__visitor_checkins_count: null,
2906+
vc__visitor_checkins_rolling: 1
2907+
},
2908+
{
2909+
vc__id: 2,
2910+
vc__created_at_day: '2017-01-04T00:00:00.000Z',
2911+
vc__visitor_checkins_count: null,
2912+
vc__visitor_checkins_rolling: 1
2913+
},
2914+
{
2915+
vc__id: 2,
2916+
vc__created_at_day: '2017-01-05T00:00:00.000Z',
2917+
vc__visitor_checkins_count: null,
2918+
vc__visitor_checkins_rolling: 1
2919+
},
2920+
{
2921+
vc__id: 2,
2922+
vc__created_at_day: '2017-01-06T00:00:00.000Z',
2923+
vc__visitor_checkins_count: null,
2924+
vc__visitor_checkins_rolling: 1
2925+
},
28732926
{
28742927
vc__id: 3,
28752928
vc__created_at_day: '2017-01-04T00:00:00.000Z',
28762929
vc__visitor_checkins_count: 1,
28772930
vc__visitor_checkins_rolling: 1
28782931
},
28792932
{
2880-
vc__created_at_day: '2017-01-05T00:00:00.000Z',
28812933
vc__id: 3,
2934+
vc__created_at_day: '2017-01-05T00:00:00.000Z',
28822935
vc__visitor_checkins_count: null,
2883-
vc__visitor_checkins_rolling: 1,
2936+
vc__visitor_checkins_rolling: 1
28842937
},
28852938
{
2886-
vc__created_at_day: '2017-01-06T00:00:00.000Z',
28872939
vc__id: 3,
2940+
vc__created_at_day: '2017-01-06T00:00:00.000Z',
28882941
vc__visitor_checkins_count: null,
2889-
vc__visitor_checkins_rolling: 1,
2942+
vc__visitor_checkins_rolling: 1
28902943
},
28912944
{
28922945
vc__id: 4,
28932946
vc__created_at_day: '2017-01-04T00:00:00.000Z',
28942947
vc__visitor_checkins_count: 1,
28952948
vc__visitor_checkins_rolling: 1
2896-
28972949
},
28982950
{
2899-
vc__created_at_day: '2017-01-05T00:00:00.000Z',
29002951
vc__id: 4,
2952+
vc__created_at_day: '2017-01-05T00:00:00.000Z',
29012953
vc__visitor_checkins_count: null,
2902-
vc__visitor_checkins_rolling: 1,
2954+
vc__visitor_checkins_rolling: 1
29032955
},
29042956
{
2905-
vc__created_at_day: '2017-01-06T00:00:00.000Z',
29062957
vc__id: 4,
2958+
vc__created_at_day: '2017-01-06T00:00:00.000Z',
29072959
vc__visitor_checkins_count: null,
2908-
vc__visitor_checkins_rolling: 1,
2960+
vc__visitor_checkins_rolling: 1
29092961
},
29102962
{
29112963
vc__id: 5,
@@ -2914,49 +2966,37 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL
29142966
vc__visitor_checkins_rolling: 1
29152967
},
29162968
{
2917-
vc__created_at_day: '2017-01-05T00:00:00.000Z',
29182969
vc__id: 5,
2970+
vc__created_at_day: '2017-01-05T00:00:00.000Z',
29192971
vc__visitor_checkins_count: null,
2920-
vc__visitor_checkins_rolling: 1,
2972+
vc__visitor_checkins_rolling: 1
29212973
},
29222974
{
2923-
vc__created_at_day: '2017-01-06T00:00:00.000Z',
29242975
vc__id: 5,
2976+
vc__created_at_day: '2017-01-06T00:00:00.000Z',
29252977
vc__visitor_checkins_count: null,
2926-
vc__visitor_checkins_rolling: 1,
2978+
vc__visitor_checkins_rolling: 1
29272979
},
29282980
{
29292981
vc__id: 6,
29302982
vc__created_at_day: '2017-01-05T00:00:00.000Z',
29312983
vc__visitor_checkins_count: 1,
29322984
vc__visitor_checkins_rolling: 1
29332985
},
2934-
29352986
{
2936-
vc__created_at_day: '2017-01-06T00:00:00.000Z',
29372987
vc__id: 6,
2988+
vc__created_at_day: '2017-01-06T00:00:00.000Z',
29382989
vc__visitor_checkins_count: null,
2939-
vc__visitor_checkins_rolling: 1,
2940-
},
2941-
{
2942-
vc__created_at_day: '2017-01-01T00:00:00.000Z',
2943-
vc__id: null,
2944-
vc__visitor_checkins_count: null,
2945-
vc__visitor_checkins_rolling: null,
2946-
},
2947-
{
2948-
vc__created_at_day: '2017-01-02T00:00:00.000Z',
2949-
vc__id: null,
2950-
vc__visitor_checkins_count: null,
2951-
vc__visitor_checkins_rolling: null,
2990+
vc__visitor_checkins_rolling: 1
29522991
},
29532992
{
2954-
vc__created_at_day: '2017-01-03T00:00:00.000Z',
29552993
vc__id: null,
2994+
vc__created_at_day: '2017-01-01T00:00:00.000Z',
29562995
vc__visitor_checkins_count: null,
2957-
vc__visitor_checkins_rolling: null,
2958-
},
2996+
vc__visitor_checkins_rolling: null
2997+
}
29592998
]
2999+
29603000
: [
29613001
{
29623002
vc__id: 3,

packages/cubejs-schema-compiler/test/integration/postgres/yaml-compiler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ cubes:
333333
);
334334
});
335335

336-
it('joins', async () => {
336+
it('joins 1', async () => {
337337
const { compiler, joinGraph, cubeEvaluator } = prepareYamlCompiler(`
338338
cubes:
339339
- name: orders

rust/cubenativeutils/src/wrappers/context.rs

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
use std::any::Any;
2+
13
use super::FunctionArgsDef;
24
use super::{inner_types::InnerTypes, object_handle::NativeObjectHandle};
5+
use crate::wrappers::serializer::NativeSerialize;
36
use crate::CubeError;
47

58
pub trait NativeContext<IT: InnerTypes>: Clone {
@@ -11,10 +14,39 @@ pub trait NativeContext<IT: InnerTypes>: Clone {
1114
fn empty_array(&self) -> Result<IT::Array, CubeError>;
1215
fn empty_struct(&self) -> Result<IT::Struct, CubeError>;
1316
fn to_string_fn(&self, result: String) -> Result<IT::Function, CubeError>;
17+
fn global(&self, name: &str) -> Result<NativeObjectHandle<IT>, CubeError>;
1418
fn make_function<In, Rt, F: FunctionArgsDef<IT::FunctionIT, In, Rt> + 'static>(
1519
&self,
1620
f: F,
1721
) -> Result<IT::Function, CubeError>;
22+
fn make_vararg_function<
23+
Rt: NativeSerialize<IT::FunctionIT>,
24+
F: Fn(
25+
NativeContextHolder<IT::FunctionIT>,
26+
Vec<NativeObjectHandle<IT::FunctionIT>>,
27+
) -> Result<Rt, CubeError>
28+
+ 'static,
29+
>(
30+
&self,
31+
f: F,
32+
) -> Result<IT::Function, CubeError>;
33+
fn make_proxy<
34+
Ret: NativeSerialize<IT::FunctionIT>,
35+
F: Fn(
36+
NativeContextHolder<IT::FunctionIT>,
37+
NativeObjectHandle<IT::FunctionIT>,
38+
String,
39+
) -> Result<Option<Ret>, CubeError>
40+
+ 'static,
41+
>(
42+
&self,
43+
target: Option<NativeObjectHandle<IT>>,
44+
get_fn: F,
45+
) -> Result<NativeObjectHandle<IT>, CubeError>;
46+
}
47+
48+
pub trait NativeContextHolderRef: 'static {
49+
fn as_any(&self) -> &dyn Any;
1850
}
1951

2052
#[derive(Clone)]
@@ -26,7 +58,7 @@ impl<IT: InnerTypes> NativeContextHolder<IT> {
2658
pub fn new(context: IT::Context) -> Self {
2759
Self { context }
2860
}
29-
pub fn context(&self) -> &impl NativeContext<IT> {
61+
pub fn context(&self) -> &IT::Context {
3062
&self.context
3163
}
3264
pub fn boolean(&self, v: bool) -> Result<IT::Boolean, CubeError> {
@@ -47,11 +79,62 @@ impl<IT: InnerTypes> NativeContextHolder<IT> {
4779
pub fn empty_array(&self) -> Result<IT::Array, CubeError> {
4880
self.context.empty_array()
4981
}
82+
pub fn global(&self, name: &str) -> Result<NativeObjectHandle<IT>, CubeError> {
83+
self.context.global(name)
84+
}
5085
pub fn empty_struct(&self) -> Result<IT::Struct, CubeError> {
5186
self.context.empty_struct()
5287
}
5388
#[allow(dead_code)]
5489
pub fn to_string_fn(&self, result: String) -> Result<IT::Function, CubeError> {
5590
self.context.to_string_fn(result)
5691
}
92+
93+
pub fn as_holder_ref(&self) -> &dyn NativeContextHolderRef {
94+
self
95+
}
96+
pub fn make_function<In, Rt, F: FunctionArgsDef<IT::FunctionIT, In, Rt> + 'static>(
97+
&self,
98+
f: F,
99+
) -> Result<IT::Function, CubeError> {
100+
self.context.make_function(f)
101+
}
102+
pub fn make_vararg_function<
103+
Rt: NativeSerialize<IT::FunctionIT>,
104+
F: Fn(
105+
NativeContextHolder<IT::FunctionIT>,
106+
Vec<NativeObjectHandle<IT::FunctionIT>>,
107+
) -> Result<Rt, CubeError>
108+
+ 'static,
109+
>(
110+
&self,
111+
f: F,
112+
) -> Result<IT::Function, CubeError> {
113+
self.context.make_vararg_function(f)
114+
}
115+
pub fn make_proxy<
116+
Ret: NativeSerialize<IT::FunctionIT>,
117+
F: Fn(
118+
NativeContextHolder<IT::FunctionIT>,
119+
NativeObjectHandle<IT::FunctionIT>,
120+
String,
121+
) -> Result<Option<Ret>, CubeError>
122+
+ 'static,
123+
>(
124+
&self,
125+
target: Option<NativeObjectHandle<IT>>,
126+
get_fn: F,
127+
) -> Result<NativeObjectHandle<IT>, CubeError> {
128+
self.context.make_proxy(target, get_fn)
129+
}
130+
}
131+
132+
impl<IT> NativeContextHolderRef for NativeContextHolder<IT>
133+
where
134+
IT: InnerTypes + 'static,
135+
NativeContextHolder<IT>: 'static,
136+
{
137+
fn as_any(&self) -> &dyn Any {
138+
self
139+
}
57140
}

rust/cubenativeutils/src/wrappers/functions_args_def.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::rc::Rc;
88

99
use super::inner_types::InnerTypes;
1010

11-
pub trait FunctionArgsDef<IT: InnerTypes, Input, Ret> {
11+
pub trait FunctionArgsDef<IT: InnerTypes, Input, Ret>: 'static {
1212
fn call_func(
1313
&self,
1414
context: NativeContextHolder<IT>,
@@ -47,7 +47,7 @@ macro_rules! impl_function_args_def {
4747
#[allow(non_snake_case)]
4848
impl<IT: InnerTypes, F, Ret, $($arg),*> FunctionArgsDef<IT, ($($arg,)*), Ret> for F
4949
where
50-
F: Fn(NativeContextHolder<IT>, $($arg),*) -> Result<Ret, CubeError>,
50+
F: Fn(NativeContextHolder<IT>, $($arg),*) -> Result<Ret, CubeError> + 'static,
5151
$($arg: NativeDeserialize<IT>,)*
5252
Ret: NativeSerialize<IT>,
5353
{

rust/cubenativeutils/src/wrappers/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ pub mod inner_types;
44
pub mod neon;
55
pub mod object;
66
pub mod object_handle;
7+
mod proxy;
78
pub mod serializer;
89

9-
pub use context::NativeContextHolder;
10+
pub use context::*;
1011
pub use functions_args_def::*;
11-
pub use object::{
12-
NativeArray, NativeBoolean, NativeFunction, NativeNumber, NativeString, NativeStruct,
13-
NativeType,
14-
};
12+
pub use object::*;
1513
pub use object_handle::NativeObjectHandle;
14+
pub use proxy::*;

0 commit comments

Comments
 (0)