Skip to content

Commit

Permalink
throw Err for WindowFrameUnits::Groups
Browse files Browse the repository at this point in the history
  • Loading branch information
huaxingao committed Sep 23, 2024
1 parent 2de7593 commit 78f18f6
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions native/core/src/execution/datafusion/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1696,28 +1696,40 @@ impl PhysicalPlanner {
WindowFrameUnits::Rows => {
WindowFrameBound::Preceding(ScalarValue::UInt64(None))
}
WindowFrameUnits::Range | WindowFrameUnits::Groups => {
WindowFrameUnits::Range => {
WindowFrameBound::Preceding(ScalarValue::Int64(None))
}
WindowFrameUnits::Groups => {
return Err(ExecutionError::GeneralError(format!(
"WindowFrameUnits::Groups is not supported."
)))
}
},
LowerFrameBoundStruct::Preceding(offset) => {
let offset_value = offset.offset.abs();
match units {
WindowFrameUnits::Rows => WindowFrameBound::Preceding(ScalarValue::UInt64(
Some(offset_value as u64),
)),
WindowFrameUnits::Range | WindowFrameUnits::Groups => {
WindowFrameUnits::Range => {
WindowFrameBound::Preceding(ScalarValue::Int64(Some(offset_value)))
},
WindowFrameUnits::Groups => {
return Err(ExecutionError::GeneralError(format!(
"WindowFrameUnits::Groups is not supported."
)))
}
}
}
LowerFrameBoundStruct::CurrentRow(_) => WindowFrameBound::CurrentRow,
},
None => match units {
WindowFrameUnits::Rows => WindowFrameBound::Preceding(ScalarValue::UInt64(None)),
WindowFrameUnits::Range | WindowFrameUnits::Groups => {
WindowFrameBound::Preceding(ScalarValue::Int64(None))
}
WindowFrameUnits::Range => WindowFrameBound::Preceding(ScalarValue::Int64(None)),
WindowFrameUnits::Groups =>
return Err(ExecutionError::GeneralError(format!(
"WindowFrameUnits::Groups is not supported."
)))
},
};

Expand All @@ -1731,25 +1743,37 @@ impl PhysicalPlanner {
WindowFrameUnits::Rows => {
WindowFrameBound::Following(ScalarValue::UInt64(None))
}
WindowFrameUnits::Range | WindowFrameUnits::Groups => {
WindowFrameUnits::Range => {
WindowFrameBound::Following(ScalarValue::Int64(None))
}
WindowFrameUnits::Groups => {
return Err(ExecutionError::GeneralError(format!(
"WindowFrameUnits::Groups is not supported."
)))
}
},
UpperFrameBoundStruct::Following(offset) => match units {
WindowFrameUnits::Rows => {
WindowFrameBound::Following(ScalarValue::UInt64(Some(offset.offset as u64)))
}
WindowFrameUnits::Range | WindowFrameUnits::Groups => {
WindowFrameUnits::Range => {
WindowFrameBound::Following(ScalarValue::Int64(Some(offset.offset)))
}
WindowFrameUnits::Groups => {
return Err(ExecutionError::GeneralError(format!(
"WindowFrameUnits::Groups is not supported."
)))
}
},
UpperFrameBoundStruct::CurrentRow(_) => WindowFrameBound::CurrentRow,
},
None => match units {
WindowFrameUnits::Rows => WindowFrameBound::Following(ScalarValue::UInt64(None)),
WindowFrameUnits::Range | WindowFrameUnits::Groups => {
WindowFrameBound::Following(ScalarValue::Int64(None))
}
WindowFrameUnits::Range => WindowFrameBound::Following(ScalarValue::Int64(None)),
WindowFrameUnits::Groups =>
return Err(ExecutionError::GeneralError(format!(
"WindowFrameUnits::Groups is not supported."
)))
},
};

Expand Down

0 comments on commit 78f18f6

Please sign in to comment.