Skip to content
Snippets Groups Projects
Unverified Commit faee5986 authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Infer types for new date functions (#25694)

parent dc764aca
No related branches found
No related tags found
No related merge requests found
......@@ -363,12 +363,12 @@ export const MBQL_CLAUSES = {
},
"date-add": {
displayName: `dateAdd`,
type: "number",
type: "expression",
args: ["expression", "number", "string"],
},
"date-subtract": {
displayName: `dateSubtract`,
type: "number",
type: "expression",
args: ["expression", "number", "string"],
},
};
......
......@@ -12,6 +12,7 @@ export function infer(mbql, env) {
if (!Array.isArray(mbql)) {
return typeof mbql;
}
const op = mbql[0];
switch (op) {
case OP.Plus:
......@@ -32,16 +33,13 @@ export function infer(mbql, env) {
return MONOTYPE.Boolean;
}
if (op === "case") {
const clauses = mbql[1];
const first = clauses[0];
// TODO: type-checker must ensure the consistent types of all clauses.
return infer(first[1], env);
}
if (op === "coalesce") {
// TODO: type-checker must ensure the consistent types of all arguments
return infer(mbql[1], env);
switch (op) {
case "case":
return infer(mbql[1][0][1], env);
case "coalesce":
case "date-add":
case "date-subtract":
return infer(mbql[1], env);
}
const func = MBQL_CLAUSES[op];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment