Skip to content

Commit 98cf9ae

Browse files
committed
Improve some code comments
1 parent f24b4f4 commit 98cf9ae

File tree

11 files changed

+17
-17
lines changed

11 files changed

+17
-17
lines changed

src/catalog/src/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4386,7 +4386,7 @@ pub static MZ_STATEMENT_LIFECYCLE_HISTORY: LazyLock<BuiltinSource> = LazyLock::n
43864386
is_retained_metrics_object: false,
43874387
// TODO[btv]: Maybe this should be public instead of
43884388
// `MONITOR_REDACTED`, but since that would be a backwards-compatible
4389-
// chagne, we probably don't need to worry about it now.
4389+
// change, we probably don't need to worry about it now.
43904390
access: vec![
43914391
SUPPORT_SELECT,
43924392
ANALYTICS_SELECT,
@@ -9125,7 +9125,7 @@ pub static MZ_EXPECTED_GROUP_SIZE_ADVICE: LazyLock<BuiltinView> = LazyLock::new(
91259125
-- such pattern, we look for how many levels can be eliminated without hitting a level
91269126
-- that actually substantially filters the input. The advice is constructed so that
91279127
-- setting the hint for the affected region will eliminate these redundant levels of
9128-
-- the hierachical rendering.
9128+
-- the hierarchical rendering.
91299129
--
91309130
-- A number of helper CTEs are used for the view definition. The first one, operators,
91319131
-- looks for operator names that comprise arrangements of inputs to each level of a

src/expr/src/linear.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,8 +1502,8 @@ pub fn memoize_expr(
15021502
// updated if they reference a column reference themselves.
15031503
if *col > input_arity {
15041504
if let MirScalarExpr::Column(col2, _) = memoized_parts[*col - input_arity] {
1505-
// We do _not_ propagate column names, since mis-associationg names and column
1506-
// references will be very confusing (and possibly bug inducing).
1505+
// We do _not_ propagate column names, since mis-associating names and column
1506+
// references will be very confusing (and possibly bug-inducing).
15071507
*col = col2;
15081508
}
15091509
}

src/expr/src/scalar/func.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,6 +2198,9 @@ fn range_difference<'a>(
21982198
propagates_nulls = true
21992199
)]
22002200
fn eq<'a>(a: Datum<'a>, b: Datum<'a>) -> Datum<'a> {
2201+
// SQL equality demands that if either input is null, then the result should be null. However,
2202+
// we don't need to handle this case here; it is handled when `BinaryFunc::eval` checks
2203+
// `propagates_nulls`.
22012204
Datum::from(a == b)
22022205
}
22032206

src/server-core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl ConnectionUuidHandle {
191191
*self.0.lock().expect("lock poisoned") = Some(conn_uuid);
192192
}
193193

194-
/// Returns a displayble that renders a possibly missing connection UUID.
194+
/// Returns a displayable that renders a possibly missing connection UUID.
195195
pub fn display(&self) -> impl fmt::Display {
196196
self.get().display_or("<unknown>")
197197
}

src/sql/src/func.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4956,6 +4956,7 @@ pub static OP_IMPLS: LazyLock<BTreeMap<&'static str, Func>> = LazyLock::new(|| {
49564956
// same type in planning. However, it's possible that we will perform
49574957
// equality on types not listed here (e.g. `Varchar`) due to decisions
49584958
// made in the optimizer.
4959+
// - Null inputs are handled by `BinaryFunc::eval` checking `propagates_nulls`.
49594960
"=" => Scalar {
49604961
params!(Numeric, Numeric) => BinaryFunc::Eq => Bool, 1752;
49614962
params!(Bool, Bool) => BinaryFunc::Eq => Bool, 91;

src/sql/src/plan/hir.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,7 @@ pub enum HirScalarExpr {
236236
/// Given `expr` with arity 1. If expr returns:
237237
/// * 0 rows, return NULL
238238
/// * 1 row, return the value of that row
239-
/// * >1 rows, the sql spec says we should throw an error but we can't
240-
/// (see <https://github.com/MaterializeInc/database-issues/issues/154>)
241-
/// so instead we return all the rows.
242-
/// If there are multiple `Select` expressions in a single SQL query, the result is that we take the product of all of them.
243-
/// This is counter to the spec, but is consistent with eg postgres' treatment of multiple set-returning-functions
244-
/// (see <https://tapoueh.org/blog/2017/10/set-returning-functions-and-postgresql-10/>).
239+
/// * >1 rows, we return an error
245240
Select(Box<HirRelationExpr>, NameMetadata),
246241
Windowing(WindowExpr, NameMetadata),
247242
}

src/transform/src/column_knowledge.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,6 @@ fn optimize(
783783
#[allow(deprecated)]
784784
expr.visit_mut_pre_post(
785785
&mut |e| {
786-
// We should not eagerly memoize `if` branches that might not be taken.
787-
// TODO: Memoize expressions in the intersection of `then` and `els`.
788786
if let MirScalarExpr::If { then, els, .. } = e {
789787
Some(vec![then, els])
790788
} else {

src/transform/src/dataflow.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ pub fn optimize_dataflow(
9999
transform_ctx.df_meta,
100100
)?;
101101

102+
// Warning: If you want to add a transform call here, consider it very carefully whether it
103+
// could accidentally invalidate information that we already derived above in
104+
// `optimize_dataflow_monotonic` or `prune_and_annotate_dataflow_index_imports`.
105+
102106
mz_repr::explain::trace_plan(dataflow);
103107

104108
Ok(())

src/transform/src/normalize_ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl crate::Transform for NormalizeOps {
4141
crate::canonicalization::TopKElision::action(expr);
4242
// (b) Fuse various like-kinded operators. Might enable further canonicalization.
4343
crate::fusion::Fusion::action(expr);
44-
// (c) Fuse join trees (might lift in-between Filters).
44+
// (c) Fuse join trees (might lift in-between MFPs).
4545
crate::fusion::join::Join::action(expr)?;
4646
// (d) Extract column references in Map as Project.
4747
crate::canonicalization::ProjectionExtraction::action(expr);

src/transform/src/typecheck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub enum TypeError<'a> {
7878
source: &'a MirRelationExpr,
7979
/// The column types we found (`sub` type)
8080
got: Vec<ColumnType>,
81-
/// The solumn types we expected (`sup` type)
81+
/// The column types we expected (`sup` type)
8282
expected: Vec<ColumnType>,
8383
/// The difference between these types
8484
diffs: Vec<RelationTypeDifference>,
@@ -460,7 +460,7 @@ impl Typecheck {
460460

461461
/// New non-transient global IDs will be treated as an error
462462
///
463-
/// Only turn this on after the context has been appropraitely populated by, e.g., an earlier run
463+
/// Only turn this on after the context has been appropriately populated by, e.g., an earlier run
464464
pub fn disallow_new_globals(mut self) -> Self {
465465
self.disallow_new_globals = true;
466466
self

0 commit comments

Comments
 (0)