Fix for IS NOT NULL

This commit is contained in:
Matt Aitken
2025-12-20 17:42:48 +00:00
parent 5ee655e680
commit 449a3cbaf7
3 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -1233,7 +1233,7 @@ export class TSQLParseTreeConverter implements TSQLParserVisitor<any> {
return {
expression_type: "compare_operation",
left: this.visitAsExpr(ctx.columnExpr()),
right: { value: null } as Constant,
right: { expression_type: "constant", value: null } as Constant,
op: ctx.NOT() ? CompareOperationOp.NotEq : CompareOperationOp.Eq,
};
}
@@ -320,11 +320,23 @@ describe("ClickHousePrinter", () => {
expect(sql).toContain("isNull(");
});
it("should handle IS NOT NULL comparisons", () => {
it("should handle != NULL comparisons", () => {
const { sql } = printQuery("SELECT * FROM task_runs WHERE started_at != NULL");
expect(sql).toContain("isNotNull(");
});
it("should handle IS NULL syntax", () => {
const { sql } = printQuery("SELECT * FROM task_runs WHERE error IS NULL");
expect(sql).toContain("isNull(error)");
});
it("should handle IS NOT NULL syntax", () => {
const { sql } = printQuery("SELECT * FROM task_runs WHERE error IS NOT NULL");
expect(sql).toContain("isNotNull(error)");
});
});
describe("ORDER BY clauses", () => {
+3 -1
View File
@@ -238,7 +238,9 @@ export class ClickHousePrinter {
response = this.visitSampleExpr(node as SampleExpr);
break;
default:
throw new NotImplementedError(`Unknown expression type: ${nodeType}`);
throw new NotImplementedError(
`Unknown expression type: ${nodeType}. Node: ${JSON.stringify(node, null, 2).slice(0, 200)}`
);
}
this.indentLevel--;