{
 "slug": "ifnull",
 "name": "IFNULL",
 "family": "logical",
 "signature": "IFNULL(expression, fallback)",
 "summary": "Replaces a null value with a fallback.",
 "traps": [
  {
   "summary": "Replacing IFNULL with amount changes the shown values or null handling.",
   "dataset": [
    {
     "label": "  cedar cedar  ",
     "quantity": 65,
     "amount": 12.8,
     "flag": true
    },
    {
     "label": "ORCHID-west",
     "quantity": 66,
     "amount": -7.6,
     "flag": false
    },
    {
     "label": "maple-east",
     "quantity": 67,
     "amount": 0,
     "flag": null
    },
    {
     "label": "willow north",
     "quantity": 68,
     "amount": 25.3,
     "flag": true
    },
    {
     "label": "birch-birch",
     "quantity": 69,
     "amount": 4.9,
     "flag": false
    },
    {
     "label": "pine/south",
     "quantity": 70,
     "amount": -1.2,
     "flag": null
    },
    {
     "label": "ash",
     "quantity": 71,
     "amount": 9,
     "flag": true
    },
    {
     "label": null,
     "quantity": null,
     "amount": null,
     "flag": null
    }
   ],
   "types": {
    "label": "string",
    "quantity": "integer",
    "amount": "float",
    "flag": "boolean"
   },
   "formula": "IFNULL([amount], 0)",
   "sql": "SELECT coalesce(amount,0) AS result FROM input",
   "naive_sql": "SELECT amount AS result FROM input",
   "engine": {
    "mode": "scalar"
   },
   "engine_rows": [
    [
     12.8
    ],
    [
     -7.6
    ],
    [
     0
    ],
    [
     25.3
    ],
    [
     4.9
    ],
    [
     -1.2
    ],
    [
     9
    ],
    [
     0
    ]
   ],
   "sql_rows": [
    [
     12.8
    ],
    [
     -7.6
    ],
    [
     0
    ],
    [
     25.3
    ],
    [
     4.9
    ],
    [
     -1.2
    ],
    [
     9
    ],
    [
     0
    ]
   ],
   "naive_sql_rows": [
    [
     12.8
    ],
    [
     -7.6
    ],
    [
     0
    ],
    [
     25.3
    ],
    [
     4.9
    ],
    [
     -1.2
    ],
    [
     9
    ],
    [
     null
    ]
   ]
  }
 ],
 "dialects": {
  "snowflake": {
   "sql": "SELECT coalesce(amount,0) AS result FROM input",
   "notes": "Equivalent spelling for the shown inputs. Dialect SQL is documented but has not been executed.",
   "sources": [
    "https://docs.snowflake.com/en/sql-reference/functions-string"
   ]
  },
  "bigquery": {
   "sql": "SELECT coalesce(amount,0) AS result FROM input",
   "notes": "Equivalent spelling for the shown inputs. Dialect SQL is documented but has not been executed.",
   "sources": [
    "https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/string_functions"
   ]
  }
 },
 "verified": true,
 "example": {
  "dataset": [
   {
    "label": "  cedar cedar  ",
    "quantity": 65,
    "amount": 12.8,
    "flag": true
   },
   {
    "label": "ORCHID-west",
    "quantity": 66,
    "amount": -7.6,
    "flag": false
   },
   {
    "label": "maple-east",
    "quantity": 67,
    "amount": 0,
    "flag": null
   },
   {
    "label": "willow north",
    "quantity": 68,
    "amount": 25.3,
    "flag": true
   },
   {
    "label": "birch-birch",
    "quantity": 69,
    "amount": 4.9,
    "flag": false
   },
   {
    "label": "pine/south",
    "quantity": 70,
    "amount": -1.2,
    "flag": null
   },
   {
    "label": "ash",
    "quantity": 71,
    "amount": 9,
    "flag": true
   },
   {
    "label": null,
    "quantity": null,
    "amount": null,
    "flag": null
   }
  ],
  "types": {
   "label": "string",
   "quantity": "integer",
   "amount": "float",
   "flag": "boolean"
  },
  "formula": "IFNULL([amount], 0)",
  "sql": "SELECT coalesce(amount,0) AS result FROM input",
  "engine_rows": [
   [
    12.8
   ],
   [
    -7.6
   ],
   [
    0
   ],
   [
    25.3
   ],
   [
    4.9
   ],
   [
    -1.2
   ],
   [
    9
   ],
   [
    0
   ]
  ]
 }
}