Skip to content

Commit

Permalink
Merge "Fix check_sql_modules on Windows" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasika Navarange authored and Gerrit Code Review committed Nov 13, 2023
2 parents 35bf102 + e228d33 commit fcaab14
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python/generators/sql_processing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from enum import Enum
import re
import os
from typing import Dict, List

NAME = r'[a-zA-Z_\d\{\}]+'
Expand Down Expand Up @@ -177,12 +178,16 @@ def check_banned_create_table_as(sql: str, filename: str,
errors = []
for _, matches in match_pattern(CREATE_TABLE_AS_PATTERN, sql).items():
name = matches[0]
if filename not in allowlist:
# Normalize paths before checking presence in the allowlist so it will
# work on Windows for the Chrome stdlib presubmit.
allowlist_normpath = dict(
(os.path.normpath(path), tables) for path, tables in allowlist.items())
if os.path.normpath(filename) not in allowlist_normpath:
errors.append(f"CREATE TABLE '{name}' is deprecated."
"Use CREATE PERFETTO TABLE instead.\n"
f"Offending file: {filename}\n")
continue
if name not in allowlist[filename]:
if name not in allowlist_normpath[os.path.normpath(filename)]:
errors.append(
f"Table '{name}' uses CREATE TABLE which is deprecated "
"and this table is not allowlisted. Use CREATE PERFETTO TABLE.\n"
Expand Down

0 comments on commit fcaab14

Please sign in to comment.