-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(tesseract): Fix rolling window with few time dimensions, filter_group in segments and member expressions #9673
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
Changes from 6 commits
12880ec
866e024
916b926
ed2c307
f0ccd15
44099a1
d787e45
14cc1e3
a206bff
c17bcbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,62 @@ | ||
| use super::member_sql::{MemberSql, NativeMemberSql}; | ||
| use super::struct_with_sql_member::{NativeStructWithSqlMember, StructWithSqlMember}; | ||
| use cubenativeutils::wrappers::serializer::{ | ||
| NativeDeserialize, NativeDeserializer, NativeSerialize, | ||
| }; | ||
| use cubenativeutils::wrappers::NativeArray; | ||
| use cubenativeutils::wrappers::{NativeContextHolder, NativeObjectHandle}; | ||
| use cubenativeutils::CubeError; | ||
| use serde::{Deserialize, Serialize}; | ||
| use std::any::Any; | ||
| use std::rc::Rc; | ||
|
|
||
| #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| pub struct ExpressionStructStatic { | ||
| #[serde(rename = "type")] | ||
| pub expression_type: String, | ||
| #[serde(rename = "sourceMeasure")] | ||
| pub source_measure: Option<String>, | ||
| #[serde(rename = "replaceAggregationType")] | ||
| pub replace_aggregation_type: Option<String>, | ||
| } | ||
|
|
||
| #[nativebridge::native_bridge(ExpressionStructStatic)] | ||
| pub trait ExpressionStruct { | ||
| #[nbridge(field, optional, vec)] | ||
| fn add_filters(&self) -> Result<Option<Vec<Rc<dyn StructWithSqlMember>>>, CubeError>; | ||
| } | ||
|
|
||
| pub enum MemberExpressionExpressionDef { | ||
| Sql(Rc<dyn MemberSql>), | ||
| Struct(Rc<dyn ExpressionStruct>), | ||
| } | ||
|
|
||
| impl<IT: InnerTypes> NativeDeserialize<IT> for MemberExpressionExpressionDef { | ||
| fn from_native(native_object: NativeObjectHandle<IT>) -> Result<Self, CubeError> { | ||
| match NativeMemberSql::from_native(native_object.clone()) { | ||
| Ok(sql) => Ok(Self::Sql(Rc::new(sql))), | ||
| Err(_) => match NativeExpressionStruct::from_native(native_object) { | ||
| Ok(expr) => Ok(Self::Struct(Rc::new(expr))), | ||
| Err(_) => Err(CubeError::user(format!( | ||
| "Member sql or expression struct expected for member expression expression field" | ||
| ))), | ||
| }, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Serialize, Deserialize, Debug, Clone)] | ||
| pub struct MemberExpressionDefinitionStatic { | ||
| #[serde(rename = "expressionName")] | ||
| pub expression_name: Option<String>, | ||
| pub name: Option<String>, | ||
| #[serde(rename = "cubeName")] | ||
| pub cube_name: Option<String>, | ||
| pub definition: Option<String>, | ||
| } | ||
|
|
||
| #[nativebridge::native_bridge(MemberExpressionDefinitionStatic)] | ||
| #[nativebridge::native_bridge(MemberExpressionDefinitionStatic, without_imports)] | ||
| pub trait MemberExpressionDefinition { | ||
| #[nbridge(field)] | ||
| fn expression(&self) -> Result<Rc<dyn MemberSql>, CubeError>; | ||
| fn expression(&self) -> Result<MemberExpressionExpressionDef, CubeError>; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,7 +1,8 @@ | ||||||
| use super::query_tools::QueryTools; | ||||||
| use super::sql_evaluator::{MeasureTimeShift, MemberExpressionSymbol, MemberSymbol, SqlCall}; | ||||||
| use super::sql_evaluator::{MeasureTimeShifts, MemberExpressionSymbol, MemberSymbol}; | ||||||
| use super::{evaluate_with_context, BaseMember, BaseMemberHelper, VisitorContext}; | ||||||
| use crate::cube_bridge::measure_definition::{MeasureDefinition, RollingWindow}; | ||||||
| use crate::cube_bridge::measure_definition::RollingWindow; | ||||||
| use crate::planner::sql_evaluator::MemberExpressionExpression; | ||||||
| use crate::planner::sql_templates::PlanSqlTemplates; | ||||||
| use cubenativeutils::CubeError; | ||||||
| use std::fmt::{Debug, Formatter}; | ||||||
|
|
@@ -11,7 +12,6 @@ pub struct BaseMeasure { | |||||
| measure: String, | ||||||
| query_tools: Rc<QueryTools>, | ||||||
| member_evaluator: Rc<MemberSymbol>, | ||||||
| definition: Option<Rc<dyn MeasureDefinition>>, | ||||||
| #[allow(dead_code)] | ||||||
| member_expression_definition: Option<String>, | ||||||
| cube_name: String, | ||||||
|
|
@@ -84,7 +84,6 @@ impl BaseMeasure { | |||||
| measure: s.full_name(), | ||||||
| query_tools: query_tools.clone(), | ||||||
| member_evaluator: evaluation_node.clone(), | ||||||
| definition: Some(s.definition().clone()), | ||||||
| member_expression_definition: None, | ||||||
| cube_name: s.cube_name().clone(), | ||||||
| name: s.name().clone(), | ||||||
|
|
@@ -101,7 +100,6 @@ impl BaseMeasure { | |||||
| measure: full_name, | ||||||
| query_tools: query_tools.clone(), | ||||||
| member_evaluator: evaluation_node, | ||||||
| definition: None, | ||||||
| cube_name, | ||||||
| name, | ||||||
| member_expression_definition, | ||||||
|
|
@@ -127,7 +125,7 @@ impl BaseMeasure { | |||||
| } | ||||||
|
|
||||||
| pub fn try_new_from_expression( | ||||||
| expression: Rc<SqlCall>, | ||||||
| expression: MemberExpressionExpression, | ||||||
| cube_name: String, | ||||||
| name: String, | ||||||
| member_expression_definition: Option<String>, | ||||||
|
|
@@ -138,6 +136,7 @@ impl BaseMeasure { | |||||
| name.clone(), | ||||||
| expression, | ||||||
| member_expression_definition.clone(), | ||||||
| query_tools.base_tools().clone(), | ||||||
| )?; | ||||||
| let full_name = member_expression_symbol.full_name(); | ||||||
| let member_evaluator = Rc::new(MemberSymbol::MemberExpression(member_expression_symbol)); | ||||||
|
|
@@ -146,28 +145,19 @@ impl BaseMeasure { | |||||
| measure: full_name, | ||||||
| query_tools, | ||||||
| member_evaluator, | ||||||
| definition: None, | ||||||
| cube_name, | ||||||
| name, | ||||||
| member_expression_definition, | ||||||
| default_alias, | ||||||
| })) | ||||||
| } | ||||||
|
|
||||||
| pub fn can_used_as_addictive_in_multplied(&self) -> Result<bool, CubeError> { | ||||||
| let measure_type = self.measure_type(); | ||||||
| let res = if measure_type == "countDistinct" || measure_type == "countDistinctApprox" { | ||||||
| true | ||||||
| } else if measure_type == "count" { | ||||||
| if let Some(definition) = &self.definition { | ||||||
| !definition.has_sql()? | ||||||
| } else { | ||||||
| false | ||||||
| } | ||||||
| pub fn can_used_as_addictive_in_multplied(&self) -> bool { | ||||||
|
||||||
| pub fn can_used_as_addictive_in_multplied(&self) -> bool { | |
| pub fn can_be_used_as_additive_in_multplied(&self) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Measures are not about drugs :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to rename this too:
| measure_symbol.can_used_as_addictive_in_multplied() | |
| measure_symbol.can_be_used_as_additive_in_multplied() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this to the upper scope and mark test(s) as skipped instead of making it pass while it does nothing?