Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 167 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub use self::{
Expression, FromItem, FromItemFunctionBuilder, FromItemJoinBuilder,
FromItemSubqueryBuilder, FromItemTableBuilder, Function, Identifier, JoinType,
PostgresType, SelectExpression, TableName, TableReference, UnaryExpression, UnaryOperator,
VariadicExpression, WhereExpression, WithExpression,
VariadicExpression, VariadicOperator, WhereExpression, WithExpression,
},
statement::{
Distinctness, InsertStatementBuilder, SelectStatement, Statement, WindowStatement,
Expand Down
2 changes: 2 additions & 0 deletions libs/@local/hashql/eval/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ insta = { workspace = true }
libtest-mimic = { workspace = true }
regex = { workspace = true }
similar-asserts = { workspace = true }
sqruff-lib = "0.37.3"
sqruff-lib-core = "0.37.3"
testcontainers = { workspace = true, features = ["reusable-containers"] }
testcontainers-modules = { workspace = true, features = ["postgres"] }

Expand Down
4 changes: 4 additions & 0 deletions libs/@local/hashql/eval/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
impl_trait_in_assoc_type,
try_blocks
)]
#![cfg_attr(test, feature(
// Library Features
iter_intersperse
))]

extern crate alloc;
pub mod context;
Expand Down
33 changes: 33 additions & 0 deletions libs/@local/hashql/eval/src/postgres/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ const GRAPH_READ_TERMINATOR: TerminalDiagnosticCategory = TerminalDiagnosticCate
name: "Nested Graph Reads Not Supported in SQL",
};

const AMBIGUOUS_INTEGER_TYPE: TerminalDiagnosticCategory = TerminalDiagnosticCategory {
id: "ambiguous-integer-type",
name: "Cannot Determine Integer Type for SQL Operator Selection",
};

const MISSING_ISLAND_GRAPH: TerminalDiagnosticCategory = TerminalDiagnosticCategory {
id: "missing-island-graph",
name: "Missing Island Graph for Body",
Expand Down Expand Up @@ -93,6 +98,13 @@ pub enum PostgresDiagnosticCategory {
ProjectedAssignment,
/// A nested graph read terminator reached the SQL backend.
GraphReadTerminator,
/// The operand type could not be classified as boolean or integer for SQL operator
/// selection.
///
/// Boolean and integer operations share a single MIR operator (e.g. `BitNot` covers both
/// logical `NOT` and bitwise `~`), but PostgreSQL requires distinct SQL operators. When the
/// operand type cannot be resolved, the compiler cannot select the correct SQL form.
AmbiguousIntegerType,
/// Island analysis did not produce an island graph for a filter body.
MissingIslandGraph,
}
Expand All @@ -117,6 +129,7 @@ impl DiagnosticCategory for PostgresDiagnosticCategory {
Self::FunctionPointerConstant => Some(&FUNCTION_POINTER_CONSTANT),
Self::ProjectedAssignment => Some(&PROJECTED_ASSIGNMENT),
Self::GraphReadTerminator => Some(&GRAPH_READ_TERMINATOR),
Self::AmbiguousIntegerType => Some(&AMBIGUOUS_INTEGER_TYPE),
Self::MissingIslandGraph => Some(&MISSING_ISLAND_GRAPH),
}
}
Expand Down Expand Up @@ -290,6 +303,26 @@ pub(super) fn graph_read_terminator(span: SpanId) -> EvalDiagnostic {
diagnostic
}

#[coverage(off)]
Comment thread Fixed
pub(super) fn ambiguous_integer_type(span: SpanId, operator: &str) -> EvalDiagnostic {
let mut diagnostic = Diagnostic::new(
category(PostgresDiagnosticCategory::AmbiguousIntegerType),
Severity::Bug,
)
.primary(Label::new(
span,
format!("cannot determine operand type for `{operator}`"),
));

diagnostic.add_message(Message::note(format!(
"the `{operator}` operator compiles to different SQL depending on whether the operand is \
a boolean or an integer, but the type could not be resolved; this indicates a \
compiler/type-checking bug or an unanticipated type (e.g. a union produced by GVN)"
)));

diagnostic
}

#[coverage(off)]
pub(super) fn missing_island_graph(span: SpanId) -> EvalDiagnostic {
let mut diagnostic = Diagnostic::new(
Expand Down
Loading
Loading