Skip to content

Conversation

@ClaireGz
Copy link
Contributor

@ClaireGz ClaireGz commented Feb 9, 2026

Problem
nao sync was not creating any .md files for Snowflake databases even when nao debug correctly detected multiple schemas (e.g. 4 schemas).
This was because:

  • Wrong API usage: The sync used conn.list_databases(), which returns databases, not schemas. For Snowflake, the connection is already scoped to a database, so we need to list schemas within that database.
  • Wrong attribute: The code used db_config.schema instead of db_config.schema_name (the actual field on SnowflakeConfig).

Solution

  • Schema discovery: When no schema is configured, we now get schemas by querying INFORMATION_SCHEMA.SCHEMATA (with fallbacks: raw SQL, then parsing from list_tables(), then list_databases()).
  • Table listing: We try list_tables(database=schema) first, then fall back to listing all tables and filtering by schema, handling both schema.table and database.schema.table formats.
  • Config: Use db_config.schema_name when a single schema is configured.

With these changes, nao sync creates the expected markdown files (columns, preview, description) for all schemas and tables in the Snowflake database.…schema

…schema

Co-authored-by: Cursor <cursoragent@cursor.com>
@ClaireGz ClaireGz changed the title Fix Snowflake sync: list schemas within database and list tables per … Fix Snowflake sync Feb 9, 2026
@ClaireGz ClaireGz added the bug Something isn't working label Feb 9, 2026
ClaireGz and others added 2 commits February 9, 2026 19:06
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@claude
Copy link

claude bot commented Feb 9, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@claude
Copy link

claude bot commented Feb 9, 2026

Code review

Found 2 CLAUDE.md compliance issues:

1. Excessive comments describing WHAT instead of WHY

Location: cli/nao_core/commands/sync/providers/databases/snowflake.py, lines 34-102

The new code contains numerous inline comments that describe what the code does rather than why, which violates CLAUDE.md's comment minimization rule:

Minimize comments — only comment complex or ambiguous logic with short JSDocs or python docstring; never describe function inputs/outputs

Examples of unnecessary comments:

  • Line 37: # Try to access INFORMATION_SCHEMA.SCHEMATA table - the code itself makes this obvious
  • Line 42: # Fallback: try using raw SQL if available - the try/except structure makes this clear
  • Lines 56-57: # Extract schema names from fully qualified table names... - the code logic is self-explanatory
  • Line 62: # Format: database.schema.table or schema.table - describing the format being parsed
  • Lines 79-80, 84, 86-87, 92, 96, 100: Similar descriptive comments

Recommendation: Remove these comments and let the code be self-documenting through descriptive variable/function names.

Reference:

nao/CLAUDE.md

Line 32 in 713b9d5

- **Minimize comments** — only comment complex or ambiguous logic with short JSDocs or python docstring; never describe function inputs/outputs


2. Single Responsibility Principle violation - Extract helper functions

Location: cli/nao_core/commands/sync/providers/databases/snowflake.py, lines 33-70 and 78-102

The schema discovery logic (lines 33-70) and table listing logic (lines 78-102) should be extracted into separate helper functions. These complex, deeply nested blocks violate CLAUDE.md's principles:

Follow SOLID principles — single responsibility
Write small, focused functions — each does one thing; extract early rather than inline

The schema discovery block has 4 levels of nested try/except handling multiple concerns:

  • Accessing INFORMATION_SCHEMA
  • Raw SQL fallback
  • Parsing table names to extract schemas
  • Default fallback behavior

Similarly, the table listing block (lines 78-102) combines table name parsing, schema matching, and filtering logic.

Recommendation: Extract to helper functions such as:

  • _discover_schemas(conn, db_config, db_name) -> list[str]
  • _list_schema_tables(conn, schema) -> list[str]
  • _parse_qualified_table_name(table_name) -> tuple

This would improve readability, testability, and adherence to single responsibility.

Reference:

nao/CLAUDE.md

Lines 28 to 30 in 713b9d5

- Follow **SOLID principles** — single responsibility, depend on abstractions
- Place **high-level functions first** in each file, then private/helper functions below
- Write **small, focused functions** — each does one thing; extract early rather than inline

@Bl3f
Copy link
Contributor

Bl3f commented Feb 10, 2026

Thank you, but closing this as it will be fixed by #166.

@Bl3f Bl3f closed this Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants