Skip to content

fix: import only the tables that CREATE TABLE statements create - #1530

Open
ReguiguiMohamed wants to merge 1 commit into
datacontract:mainfrom
ReguiguiMohamed:fix/sql-import-create-schema
Open

fix: import only the tables that CREATE TABLE statements create#1530
ReguiguiMohamed wants to merge 1 commit into
datacontract:mainfrom
ReguiguiMohamed:fix/sql-import-create-schema

Conversation

@ReguiguiMohamed

@ReguiguiMohamed ReguiguiMohamed commented Aug 22, 2026

Copy link
Copy Markdown

datacontract import sql failed with AttributeError: 'NoneType' object has no attribute 'name' on any DDL file containing CREATE SCHEMA.

The importer collected every table node beneath a CREATE rather than the table each CREATE TABLE creates, and CREATE SCHEMA sales parses to a table node with no table name. It now reads the target of each CREATE TABLE, which also drops the empty schema objects CREATE DATABASE and CREATE VIEW produced, and the duplicates from their query sources.

Fixes #1529

  • Tests pass (uv run pytest)
  • Code formatted (uv run ruff check --fix && uv run ruff format)
  • Docs updated (if relevant)
  • CHANGELOG.md entry added

The four test_import_sql_* files pass. The full suite matches main, with one extra pass for the new test; the remaining failures are optional extras and Docker missing locally.

The SQL importer collected every table node under a CREATE statement, so a
CREATE SCHEMA reached the loop that reads a table name and raised
AttributeError: 'NoneType' object has no attribute 'name'. Any DDL file that
creates its schema before its tables failed to import.

It now reads the target of each CREATE TABLE. That also drops the empty
schema objects a CREATE DATABASE or CREATE VIEW produced, and the duplicates
their query sources produced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

datacontract import sql fails on a DDL file that contains CREATE SCHEMA

1 participant