Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing sqlglot's insert #2420

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open

Conversation

anuunchin
Copy link
Contributor

Description

Please check out #2399 where the motivation behind this PR is explained.

Here, we're just testing if an INSERT INTO statement created with the following steps works for different destinations:

  • Assume two tables have the same schema
  • Create a SELECT * FROM statement using an IbisRelation with something like:
    dataset = pipeline.dataset()
    select_relation_query = dataset.table("select_from_table").query()  
  • Make the target_table with:
    target_table = client.make_qualified_table_name("insert_into_table")
  • Make sqlglot create an INSERT INTO ... SELECT * FROM ... statement with something like:
    import sqlglot.expressions as sge
    query = sge.insert(
       expression=select_relation_query,
       into=target_table  
       dialect=dialect,
    ).sql()

    The source code of insert. Thanks to @zilto for pointing into this direction 🙏

Related Issues

Additional Context

Some destination don't really recognize double quotes ("") for identifiers, so there's a special handling in the test.

Copy link

netlify bot commented Mar 18, 2025

Deploy Preview for dlt-hub-docs ready!

Name Link
🔨 Latest commit 84085a5
🔍 Latest deploy log https://app.netlify.com/sites/dlt-hub-docs/deploys/67db0be5c576cc00085f1c0d
😎 Deploy Preview https://deploy-preview-2420--dlt-hub-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@anuunchin
Copy link
Contributor Author

Filesystem is being skipped as of now

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.

1 participant