Skip to content
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

[GIE MetaData] Support MetaData for IR Algebra/Physical Operators #2480

Merged
merged 13 commits into from
Mar 10, 2023

Conversation

BingqingLyu
Copy link
Collaborator

@BingqingLyu BingqingLyu commented Mar 2, 2023

What do these changes do?

  • Add DataType for Algebra Operators, Expressions, and Variables in Proto
  • Provide FFI for setting MetaData for Algebra Operators, Expressions, Variables in IR-Core
  • Pass MetaData from Algebra Operators to Physical Operators
  • Fix related CIs

Related issue number

#2417

@BingqingLyu BingqingLyu marked this pull request as draft March 2, 2023 02:46
@BingqingLyu BingqingLyu marked this pull request as ready for review March 6, 2023 02:11
@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2023

Codecov Report

Merging #2480 (4196e85) into main (a012a92) will decrease coverage by 32.76%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2480       +/-   ##
===========================================
- Coverage   72.62%   39.87%   -32.76%     
===========================================
  Files          88       88               
  Lines        9816     9816               
===========================================
- Hits         7129     3914     -3215     
- Misses       2687     5902     +3215     

see 47 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf5d75e...4196e85. Read the comment docs.

expr.operators.get(0)
if let Some(common_pb::ExprOpr {
item: Some(common_pb::expr_opr::Item::Var(var)), ..
}) = expr.operators.get(0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use first() instead of get(0)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -209,6 +209,15 @@ impl Plan {
self
}

// Notice that this is used to set the meta_data of the **Last Appended OP**
pub fn with_meta_data(&mut self, meta_data: Option<Vec<pb::physical_opr::MetaData>>) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Vec requires Option? Empty Vec stands for None?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

pub fn with_meta_data(&mut self, meta_data: Option<Vec<pb::physical_opr::MetaData>>) {
if let Some(op) = self.plan.last_mut() {
if let Some(meta_data) = meta_data {
op.op_meta = meta_data;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably meta_data is a better name than op_meta.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -41,6 +47,8 @@ message Project {
// An indicator to tell the runtime whether the projected value is appending to or replacing
// existing relation.
bool is_append = 2;
// The datatype of output results
repeated MetaData op_meta = 3;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we donot use map<alias, IrDataType> for MetaData? As before, think meta_data is a better name than op_meta

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have renamed as meta_data. repeated MetaData here is defined in consist with, e.g., repeated ExprAlias in Project.

@@ -153,6 +153,7 @@ impl From<IrError> for FfiResult {
IrError::InvalidPattern(s) => FfiResult::new(ResultCode::Others, s),
IrError::InvalidExtendPattern(err) => FfiResult::new(ResultCode::Others, err.to_string()),
IrError::PbEncodeError(err) => FfiResult::new(ResultCode::Others, err.to_string()),
IrError::PbDecodeError(err) => FfiResult::new(ResultCode::Others, err.to_string()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Other error is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modifed as ResultCode::ParsePbError here.

@@ -800,6 +848,29 @@ fn set_predicate(ptr: *const c_void, cstr_predicate: *const c_char, opt: InnerOp
}
}

/// To set an operator's predicate from a pb predicate pointer
fn set_predicate_with_pb(ptr: *const c_void, ptr_predicate_pb: FfiPbPointer, opt: InnerOpt) -> FfiResult {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is set_predicate_pb, rather than set_predicate_with_pb. Same apply to a few following functions. Also comment this function: In the following functions, we can set expression directly from a pb pointer, which is parsed by the compiler instead of ffi function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -895,6 +966,13 @@ mod params {
set_predicate(ptr_params, cstr_pred, InnerOpt::Params)
}

#[no_mangle]
pub extern "C" fn set_params_predicate_with_pb(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same set_params_predicate_pb

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

/// To add a mapping for the project operator, which maps a pb pointer to represent an
/// expression, and a `NameOrId` parameter that represents an alias.
#[no_mangle]
pub extern "C" fn add_project_expr_alias_with_pb(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add_project_expr_pb_alias

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

self.plan.unfold(unfold.into()).with_meta_data(
meta_data
.map(|meta| vec![meta.into()])
.unwrap_or(vec![]),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use unwrap_or_default()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@longbinlai longbinlai merged commit 4f5bbeb into alibaba:main Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants