title: Bigquery Lag navigation function ignore nulls
body: <p>I have a table as below:</p>
  <pre><code>WITH
    table1 AS (
    SELECT
      TIMESTAMP '2016-10-18 2:51:45' AS ts,
      'AB4' AS packId,
      FALSE AS stat,
      'x' AS position
    UNION ALL
    SELECT
      TIMESTAMP '2016-10-18 2:54:11',
      'AB4',
      FALSE,
      'x'
    UNION ALL
    SELECT
      TIMESTAMP '2016-10-18 3:01:17',
      'AB4',
      FALSE,
      'x'
    UNION ALL
    SELECT
      TIMESTAMP '2016-10-18 3:05:42',
      'AB4',
      TRUE,
      NULL
    UNION ALL
    SELECT
      TIMESTAMP '2016-10-18 3:06:24',
      'AB4',
      FALSE,
      'x'
    UNION ALL
    SELECT
      TIMESTAMP '2016-10-18 3:06:36',
      'AB4',
      TRUE,
      'y'
    UNION ALL
    SELECT
      TIMESTAMP '2016-10-18 3:07:41',
      'AB4',
      FALSE,
      'x')
  SELECT
    ts,
    packId,
    stat,
    position,
    LAG(position) OVER prev_pos AS previous_position1,
    LAG(position,2) OVER prev_pos AS previous_position2
  FROM
    table1
  WINDOW
    prev_pos AS (
    PARTITION BY
      packId
    ORDER BY
      ts)
  </code></pre>
  <p>And results look like this:</p>
  <p><a href="https://i.stack.imgur.com/dG58X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dG58X.png" alt="enter image description here" /></a></p>
  <p>I would like to get previous value (from column position) which is not null , as shown in the result table, I want those null values be the previous non-null which is 'x' for both of them in this example.
  (There are thousands of rows with null positions so last non-null position
  for current row could be thousand rows before it  )</p>
  <p>In summary: how to ignore nulls for Lag in bigquery?</p>