---
source: crates/squawk_parser/tests/tests.rs
input_file: crates/squawk_parser/tests/data/ok/create_materialized_view.sql
---
SOURCE_FILE
  COMMENT "-- simple"
  WHITESPACE "\n"
  CREATE_MATERIALIZED_VIEW
    CREATE_KW "create"
    WHITESPACE " "
    MATERIALIZED_KW "materialized"
    WHITESPACE " "
    VIEW_KW "view"
    WHITESPACE " "
    PATH
      PATH_SEGMENT
        NAME
          IDENT "t"
    WHITESPACE "\n  "
    AS_KW "as"
    WHITESPACE " "
    SELECT
      SELECT_CLAUSE
        SELECT_KW "select"
        WHITESPACE " "
        TARGET_LIST
          TARGET
            LITERAL
              INT_NUMBER "1"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- full"
  WHITESPACE "\n"
  CREATE_MATERIALIZED_VIEW
    CREATE_KW "create"
    WHITESPACE " "
    MATERIALIZED_KW "materialized"
    WHITESPACE " "
    VIEW_KW "view"
    WHITESPACE " "
    IF_NOT_EXISTS
      IF_KW "if"
      WHITESPACE " "
      NOT_KW "not"
      WHITESPACE " "
      EXISTS_KW "exists"
    WHITESPACE " "
    PATH
      PATH
        PATH_SEGMENT
          NAME_REF
            IDENT "foo"
      DOT "."
      PATH_SEGMENT
        NAME
          IDENT "bar"
    WHITESPACE "\n  "
    COLUMN_LIST
      L_PAREN "("
      COLUMN
        NAME
          IDENT "a"
      COMMA ","
      WHITESPACE " "
      COLUMN
        NAME
          IDENT "b"
      COMMA ","
      WHITESPACE " "
      COLUMN
        NAME
          IDENT "c"
      R_PAREN ")"
    WHITESPACE "\n  "
    USING_METHOD
      USING_KW "using"
      WHITESPACE " "
      NAME_REF
        IDENT "u"
    WHITESPACE "\n  "
    WITH_PARAMS
      WITH_KW "with"
      WHITESPACE " "
      ATTRIBUTE_LIST
        L_PAREN "("
        ATTRIBUTE_OPTION
          NAME
            IDENT "x"
          WHITESPACE " "
          EQ "="
          WHITESPACE " "
          ATTRIBUTE_VALUE
            LITERAL
              INT_NUMBER "10"
        COMMA ","
        WHITESPACE " "
        ATTRIBUTE_OPTION
          NAME
            IDENT "bar"
        COMMA ","
        WHITESPACE " "
        ATTRIBUTE_OPTION
          NAME
            IDENT "buzz"
          WHITESPACE " "
          EQ "="
          WHITESPACE " "
          ATTRIBUTE_VALUE
            LITERAL
              TRUE_KW "true"
        R_PAREN ")"
    WHITESPACE "\n  "
    TABLESPACE
      TABLESPACE_KW "tablespace"
      WHITESPACE " "
      NAME_REF
        IDENT "t"
    WHITESPACE "\n  "
    AS_KW "as"
    WHITESPACE " "
    SELECT
      SELECT_CLAUSE
        SELECT_KW "select"
        WHITESPACE " "
        TARGET_LIST
          TARGET
            LITERAL
              INT_NUMBER "1"
          COMMA ","
          WHITESPACE " "
          TARGET
            LITERAL
              INT_NUMBER "2"
          COMMA ","
          WHITESPACE " "
          TARGET
            LITERAL
              INT_NUMBER "3"
    WHITESPACE "\n  "
    WITH_NO_DATA
      WITH_KW "with"
      WHITESPACE " "
      NO_KW "no"
      WHITESPACE " "
      DATA_KW "data"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- table"
  WHITESPACE "\n"
  CREATE_MATERIALIZED_VIEW
    CREATE_KW "create"
    WHITESPACE " "
    MATERIALIZED_KW "materialized"
    WHITESPACE " "
    VIEW_KW "view"
    WHITESPACE " "
    PATH
      PATH_SEGMENT
        NAME
          IDENT "t"
    WHITESPACE "\n  "
    AS_KW "as"
    WHITESPACE " "
    TABLE
      TABLE_KW "table"
      WHITESPACE " "
      RELATION_NAME
        PATH
          PATH_SEGMENT
            NAME_REF
              IDENT "u"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- values"
  WHITESPACE "\n"
  CREATE_MATERIALIZED_VIEW
    CREATE_KW "create"
    WHITESPACE " "
    MATERIALIZED_KW "materialized"
    WHITESPACE " "
    VIEW_KW "view"
    WHITESPACE " "
    PATH
      PATH_SEGMENT
        NAME
          IDENT "t"
    WHITESPACE "\n  "
    AS_KW "as"
    WHITESPACE " "
    VALUES
      VALUES_KW "values"
      WHITESPACE " "
      ROW_LIST
        ROW
          L_PAREN "("
          LITERAL
            INT_NUMBER "1"
          R_PAREN ")"
        COMMA ","
        WHITESPACE " "
        ROW
          L_PAREN "("
          LITERAL
            INT_NUMBER "2"
          COMMA ","
          WHITESPACE " "
          LITERAL
            INT_NUMBER "2"
          R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n\n"
  COMMENT "-- https://github.com/sbdchd/squawk/issues/646"
  WHITESPACE "\n"
  CREATE_MATERIALIZED_VIEW
    CREATE_KW "CREATE"
    WHITESPACE " "
    MATERIALIZED_KW "MATERIALIZED"
    WHITESPACE " "
    VIEW_KW "VIEW"
    WHITESPACE " "
    PATH
      PATH
        PATH_SEGMENT
          NAME_REF
            IDENT "\"public\""
      DOT "."
      PATH_SEGMENT
        NAME
          IDENT "\"user_countries_view\""
    WHITESPACE " \n"
    AS_KW "AS"
    WHITESPACE " "
    PAREN_SELECT
      L_PAREN "("
      WHITESPACE "\n    "
      SELECT
        SELECT_CLAUSE
          SELECT_KW "select"
          WHITESPACE " "
          DISTINCT_CLAUSE
            DISTINCT_KW "distinct"
          WHITESPACE " "
          TARGET_LIST
            TARGET
              NAME_REF
                IDENT "\"client_id\""
            COMMA ","
            WHITESPACE " "
            TARGET
              BIN_EXPR
                NAME_REF
                  IDENT "\"address\""
                CUSTOM_OP
                  MINUS "-"
                  R_ANGLE ">"
                  R_ANGLE ">"
                LITERAL
                  STRING "'country'"
              WHITESPACE " "
              AS_NAME
                AS_KW "as"
                WHITESPACE " "
                NAME
                  IDENT "\"country\""
        WHITESPACE " \n    "
        FROM_CLAUSE
          FROM_KW "from"
          WHITESPACE " "
          FROM_ITEM
            NAME_REF
              IDENT "\"users\""
        WHITESPACE " "
        WHERE_CLAUSE
          WHERE_KW "where"
          WHITESPACE " "
          BIN_EXPR
            BIN_EXPR
              FIELD_EXPR
                NAME_REF
                  IDENT "\"users\""
                DOT "."
                NAME_REF
                  IDENT "\"address\""
              CUSTOM_OP
                MINUS "-"
                R_ANGLE ">"
                R_ANGLE ">"
              LITERAL
                STRING "'country'"
            WHITESPACE " "
            IS_NOT
              IS_KW "IS"
              WHITESPACE " "
              NOT_KW "NOT"
            WHITESPACE " "
            LITERAL
              NULL_KW "NULL"
      WHITESPACE "\n"
      R_PAREN ")"
  SEMICOLON ";"
  WHITESPACE "\n"
