rule: RF04

test_pass_valid_identifier:
  pass_str: CREATE TABLE artist(artist_name TEXT)

test_fail_keyword_as_identifier_column:
  fail_str: CREATE TABLE artist(create TEXT)

test_fail_keyword_as_identifier_column_alias:
  fail_str: SELECT 1 as parameter

test_fail_keyword_as_identifier_table_alias:
  fail_str: SELECT x FROM tbl AS parameter

test_pass_valid_identifier_not_alias:
  # should pass on default config as not alias
  pass_str: SELECT parameter

test_fail_keyword_as_identifier_not_alias_all:
  fail_str: SELECT parameter
  configs:
    rules:
      references.keywords:
        unquoted_identifiers_policy: all

test_pass_valid_identifier_table_alias_column_alias_config:
  pass_str: SELECT x FROM tbl AS parameter
  configs:
    rules:
      references.keywords:
        unquoted_identifiers_policy: column_aliases

test_fail_keyword_as_identifier_column_alias_config:
  fail_str: SELECT x AS date FROM tbl AS parameter
  configs:
    rules:
      references.keywords:
        unquoted_identifiers_policy: column_aliases

test_pass_valid_quoted_identifier:
  pass_str: CREATE TABLE [artist]([artist_name] TEXT)
  configs:
    rules:
      references.keywords:
        quoted_identifiers_policy: aliases
    core:
      dialect: tsql

test_fail_keyword_as_quoted_identifier_column:
  fail_str: CREATE TABLE "artist"("create" TEXT)
  configs:
    rules:
      references.keywords:
        quoted_identifiers_policy: aliases

test_pass_keyword_as_quoted_identifier_column_none_policy:
  pass_str: CREATE TABLE "artist"("create" TEXT)
  configs:
    rules:
      references.keywords:
        quoted_identifiers_policy: none

test_fail_keyword_as_quoted_identifier_column_alias:
  fail_str: SELECT 1 as [parameter]
  configs:
    rules:
      references.keywords:
        quoted_identifiers_policy: aliases
    core:
      dialect: tsql

test_fail_keyword_as_quoted_identifier_table_alias:
  fail_str: SELECT [x] FROM [tbl] AS [parameter]
  configs:
    rules:
      references.keywords:
        quoted_identifiers_policy: aliases
    core:
      dialect: tsql

test_pass_valid_quoted_identifier_not_alias:
  # should pass on default config as not alias
  pass_str: SELECT [parameter]
  configs:
    rules:
      references.keywords:
        quoted_identifiers_policy: aliases
    core:
      dialect: tsql

test_fail_keyword_as_quoted_identifier_not_alias_all:
  fail_str: SELECT [parameter]
  configs:
    rules:
      references.keywords:
        quoted_identifiers_policy: all
    core:
      dialect: tsql

test_pass_valid_quoted_identifier_table_alias_column_alias_config:
  pass_str: SELECT [x] FROM [tbl] AS [parameter]
  configs:
    rules:
      references.keywords:
        quoted_identifiers_policy: column_aliases
    core:
      dialect: tsql

test_fail_keyword_as_quoted_identifier_column_alias_config:
  fail_str: SELECT [x] AS [date] FROM [tbl] AS [parameter]
  configs:
    rules:
      references.keywords:
        quoted_identifiers_policy: column_aliases
    core:
      dialect: tsql

test_pass_ignore_word1:
  pass_str: CREATE TABLE artist(create TEXT)
  configs:
    rules:
      references.keywords:
        ignore_words: create


test_pass_ignore_word2:
  pass_str: SELECT col1 AS date FROM table1
  configs:
    rules:
      references.keywords:
        ignore_words: date

test_pass_ignore_words_regex1:
  pass_str: CREATE TABLE artist(create TEXT)
  configs:
    rules:
      references.keywords:
        ignore_words_regex: ^cr


test_pass_ignore_words_regex2:
  pass_str: SELECT col1 AS date FROM table1
  configs:
    rules:
      references.keywords:
        ignore_words_regex: ^da

test_pass_one_character_identifier:
  pass_str: SELECT d.col1 FROM table1 d
  configs:
    core:
      dialect: snowflake

test_pass_bigquery:
  pass_str: SELECT stop from USERS
  configs:
    core:
      dialect: bigquery

test_pass_bigquery2:
  pass_str: SELECT `stop` from USERS
  configs:
    core:
      dialect: bigquery