Compare two values for sorting with NULLS ordering support
(
&self,
a: &Value,
b: &Value,
nulls_first: bool,
)
| 6750 | |
| 6751 | /// Compare two values for sorting with NULLS ordering support |
| 6752 | fn compare_values( |
| 6753 | &self, |
| 6754 | a: &Value, |
| 6755 | b: &Value, |
| 6756 | nulls_first: bool, |
| 6757 | ) -> Option<std::cmp::Ordering> { |
| 6758 | use crate::storage::Value; |
| 6759 | use std::cmp::Ordering; |
| 6760 | |
| 6761 | match (a, b) { |
| 6762 | (Value::Number(a), Value::Number(b)) => { |
| 6763 | Some(a.partial_cmp(b).unwrap_or(Ordering::Equal)) |
| 6764 | } |
| 6765 | (Value::String(a), Value::String(b)) => Some(a.cmp(b)), |
| 6766 | (Value::Boolean(a), Value::Boolean(b)) => Some(a.cmp(b)), |
| 6767 | (Value::Null, Value::Null) => Some(Ordering::Equal), |
| 6768 | (Value::Null, _) => Some(if nulls_first { |
| 6769 | Ordering::Less |
| 6770 | } else { |
| 6771 | Ordering::Greater |
| 6772 | }), |
| 6773 | (_, Value::Null) => Some(if nulls_first { |
| 6774 | Ordering::Greater |
| 6775 | } else { |
| 6776 | Ordering::Less |
| 6777 | }), |
| 6778 | // For different types, convert to string for comparison |
| 6779 | _ => { |
| 6780 | let a_str = format!("{:?}", a); |
| 6781 | let b_str = format!("{:?}", b); |
| 6782 | Some(a_str.cmp(&b_str)) |
| 6783 | } |
| 6784 | } |
| 6785 | } |
| 6786 | |
| 6787 | /// Execute DISTINCT operation to remove duplicate rows |
| 6788 | fn execute_distinct(&self, input_rows: Vec<Row>) -> Result<Vec<Row>, ExecutionError> { |
no test coverage detected